Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
types.hpp
1 // Copyright (c) 2022 Samsung R&D Institute Russia
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 
15 #ifndef NAV2_COLLISION_MONITOR__TYPES_HPP_
16 #define NAV2_COLLISION_MONITOR__TYPES_HPP_
17 
18 #include <string>
19 
20 namespace nav2_collision_monitor
21 {
22 
24 struct Velocity
25 {
26  double x; // x-component of linear velocity
27  double y; // y-component of linear velocity
28  double tw; // z-component of angular twist
29 
30  inline bool operator<(const Velocity & second) const
31  {
32  const double first_vel = x * x + y * y + tw * tw;
33  const double second_vel = second.x * second.x + second.y * second.y + second.tw * second.tw;
34  // This comparison includes rotations in place, where linear velocities are equal to zero
35  return first_vel < second_vel;
36  }
37 
38  inline Velocity operator*(const double & mul) const
39  {
40  return {x * mul, y * mul, tw * mul};
41  }
42 
43  inline bool isZero() const
44  {
45  return x == 0.0 && y == 0.0 && tw == 0.0;
46  }
47 };
48 
50 struct Point
51 {
52  double x; // x-coordinate of point
53  double y; // y-coordinate of point
54 };
55 
57 struct Pose
58 {
59  double x; // x-coordinate of pose
60  double y; // y-coordinate of pose
61  double theta; // rotation angle of pose
62 };
63 
65 enum ActionType
66 {
67  DO_NOTHING = 0, // No action
68  STOP = 1, // Stop the robot
69  SLOWDOWN = 2, // Slowdown in percentage from current operating speed
70  APPROACH = 3, // Keep constant time interval before collision
71  LIMIT = 4 // Limit absolute velocity from current operating speed
72 };
73 
75 struct Action
76 {
77  ActionType action_type;
78  Velocity req_vel;
79  std::string polygon_name;
80 };
81 
82 } // namespace nav2_collision_monitor
83 
84 #endif // NAV2_COLLISION_MONITOR__TYPES_HPP_
Action for robot.
Definition: types.hpp:76
Velocity for 2D model of motion.
Definition: types.hpp:25