Nav2 Navigation Stack - rolling  main
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 #include <vector>
20 
21 namespace nav2_collision_monitor
22 {
23 
25 struct Velocity
26 {
27  double x; // x-component of linear velocity
28  double y; // y-component of linear velocity
29  double tw; // z-component of angular twist
30 
31  inline bool operator<(const Velocity & second) const
32  {
33  const double first_vel = x * x + y * y + tw * tw;
34  const double second_vel = second.x * second.x + second.y * second.y + second.tw * second.tw;
35  // This comparison includes rotations in place, where linear velocities are equal to zero
36  return first_vel < second_vel;
37  }
38 
39  inline Velocity operator*(const double & mul) const
40  {
41  return {x * mul, y * mul, tw * mul};
42  }
43 
44  inline bool isZero() const
45  {
46  return x == 0.0 && y == 0.0 && tw == 0.0;
47  }
48 };
49 
51 struct Point
52 {
53  double x; // x-coordinate of point
54  double y; // y-coordinate of point
55  double z = 0.0; // z-coordinate of point (0 for inherently-2D sources)
56  std::string source = ""; // name of the data source
57 };
58 
60 struct Pose
61 {
62  double x; // x-coordinate of pose
63  double y; // y-coordinate of pose
64  double theta; // rotation angle of pose
65 };
66 
68 enum ActionType
69 {
70  DO_NOTHING = 0, // No action
71  STOP = 1, // Stop the robot
72  SLOWDOWN = 2, // Slowdown in percentage from current operating speed
73  APPROACH = 3, // Keep constant time interval before collision
74  LIMIT = 4 // Limit absolute velocity from current operating speed
75 };
76 
78 struct Action
79 {
80  ActionType action_type;
81  Velocity req_vel;
82  std::string polygon_name;
83  std::vector<Point> triggering_points;
84 };
85 
86 } // namespace nav2_collision_monitor
87 
88 #endif // NAV2_COLLISION_MONITOR__TYPES_HPP_
Action for robot.
Definition: types.hpp:79
Point with 2D collision-check coordinates and optional z from the source.
Definition: types.hpp:52
Velocity for 2D model of motion.
Definition: types.hpp:26