ros2_control - rolling
Loading...
Searching...
No Matches
data_structures.hpp
1// Copyright 2024 PAL Robotics S.L.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
17#ifndef JOINT_LIMITS__DATA_STRUCTURES_HPP_
18#define JOINT_LIMITS__DATA_STRUCTURES_HPP_
19
20#include <limits>
21#include <memory>
22#include <optional>
23#include <string>
24
25#define DEFINE_LIMIT_STRUCT(LimitType) \
26 struct LimitType \
27 { \
28 LimitType(double minimum_value, double maximum_value) \
29 : lower_limit(minimum_value), upper_limit(maximum_value) \
30 { \
31 } \
32 double lower_limit = -std::numeric_limits<double>::infinity(); \
33 double upper_limit = std::numeric_limits<double>::infinity(); \
34 };
35
36namespace joint_limits
37{
38
39DEFINE_LIMIT_STRUCT(PositionLimits);
40DEFINE_LIMIT_STRUCT(VelocityLimits);
41DEFINE_LIMIT_STRUCT(EffortLimits);
42DEFINE_LIMIT_STRUCT(AccelerationLimits);
43
45{
46 std::string joint_name;
47 std::optional<double> position = std::nullopt;
48 std::optional<double> velocity = std::nullopt;
49 std::optional<double> effort = std::nullopt;
50 std::optional<double> acceleration = std::nullopt;
51 std::optional<double> jerk = std::nullopt;
52
53 bool has_data() const
54 {
55 return has_position() || has_velocity() || has_effort() || has_acceleration() || has_jerk();
56 }
57
58 bool has_position() const { return position.has_value(); }
59
60 bool has_velocity() const { return velocity.has_value(); }
61
62 bool has_effort() const { return effort.has_value(); }
63
64 bool has_acceleration() const { return acceleration.has_value(); }
65
66 bool has_jerk() const { return jerk.has_value(); }
67};
68
70{
71 std::string joint_name;
74 JointControlInterfacesData prev_command;
76
77 bool has_actual_data() const { return actual.has_data(); }
78
79 bool has_command_data() const { return command.has_data(); }
80};
81
82} // namespace joint_limits
83#endif // JOINT_LIMITS__DATA_STRUCTURES_HPP_
Definition data_structures.hpp:37
Definition data_structures.hpp:45
Definition data_structures.hpp:70