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