mrr_utils.h
Go to the documentation of this file.
1 #ifndef POINT_H
2 #define POINT_H
3 
4 #include <eigen3/Eigen/Dense>
6 #include <geometry_msgs/Pose.h>
7 #include <ros/ros.h>
8 
9 namespace multi_robot_router
10 {
11 
12 
13 inline geometry_msgs::Pose& copy(const Eigen::Vector3d &src, geometry_msgs::Pose &des){
14  double cy = cos ( src[2] * 0.5 );
15  double sy = sin ( src[2] * 0.5 );
16 
17  des.position.x = src[0], des.position.y = src[1], des.position.z = 0;
18  des.orientation.w = cy;
19  des.orientation.x = 0.;
20  des.orientation.y = 0.;
21  des.orientation.z = sy;
22  return des;
23 }
24 inline geometry_msgs::Pose copy(const Eigen::Vector3d &src){
25  geometry_msgs::Pose des;
26  return copy(src,des);
27 }
28 
29 inline Eigen::Vector3d& copy(const geometry_msgs::Pose &src, Eigen::Vector3d &des){
30  double siny = +2.0 * ( src.orientation.w * src.orientation.z + src.orientation.x * src.orientation.y );
31  double cosy = +1.0 - 2.0 * ( src.orientation.y * src.orientation.y + src.orientation.z * src.orientation.z );
32  double yaw = atan2 ( siny, cosy );
33  des = Eigen::Vector3d (src.position.x, src.position.y, yaw );
34  return des;
35 }
36 inline Eigen::Vector3d copy(const geometry_msgs::Pose &src){
37  Eigen::Vector3d des;
38  return copy(src,des);
39 }
40 
41 //Checkpoint used in a Route
43 {
44  public:
45  struct Precondition
46  {
47  int32_t robotId;
48  int32_t stepCondition;
49  };
50 
51  uint32_t segId;
52  Eigen::Vector3d start;
53  Eigen::Vector3d end;
54  std::vector<Precondition> preconditions;
55 
60  {
61  segId = _v.getSegment().getSegmentId();
62 
64  {
65  Eigen::Vector2d s = _v.getSegment().getStart();
66  start[0] = s[0];
67  start[1] = s[1];
68  start[2] = atan2(end[1] - start[1], end[0] - start[0]);
69 
70  Eigen::Vector2d e = _v.getSegment().getEnd();
71  end[0] = e[0];
72  end[1] = e[1];
73  end[2] = atan2(end[1] - start[1], end[0] - start[0]);
74  }
75  else
76  {
77  Eigen::Vector2d s = _v.getSegment().getEnd();
78  start[0] = s[0];
79  start[1] = s[1];
80  start[2] = atan2(start[1] - end[1], start[0] - end[0]);
81 
82  Eigen::Vector2d e = _v.getSegment().getStart();
83  end[0] = e[0];
84  end[1] = e[1];
85  end[2] = atan2(start[1] - end[1], start[0] - end[0]);
86  }
87  }
88  Checkpoint() : segId(-1)
89  {
90  }
91 
96  {
97  bool updatedPc = false;
98 
99  for (Checkpoint::Precondition &pc : preconditions)
100  {
101  if (pc.robotId == n_pc.robotId)
102  {
103  pc.stepCondition = std::max(pc.stepCondition, n_pc.stepCondition);
104  updatedPc = true;
105  break;
106  }
107  }
108 
109  if (!updatedPc)
110  {
111  preconditions.push_back(n_pc);
112  }
113  }
114 
118  void updatePreconditions(const std::vector<Precondition> &n_pcs)
119  {
120  for (const Checkpoint::Precondition &n_pc : n_pcs)
121  {
122  bool updatedPc = false;
123 
124  for (Checkpoint::Precondition &pc : preconditions)
125  {
126  if (pc.robotId == n_pc.robotId)
127  {
128  pc.stepCondition = std::max(pc.stepCondition, n_pc.stepCondition);
129  updatedPc = true;
130  break;
131  }
132  }
133 
134  if (!updatedPc)
135  {
136  preconditions.push_back(n_pc);
137  }
138  }
139  }
140 };
141 } // namespace multi_robot_router
142 #endif
uint32_t getSegmentId() const
Definition: srr_utils.cpp:60
Checkpoint(const RouteVertex &_v)
constructor to assign Checkpoint from a Route Vertex used in route candidates
Definition: mrr_utils.h:59
std::vector< Precondition > preconditions
Definition: mrr_utils.h:54
XmlRpcServer s
void updatePreconditions(const std::vector< Precondition > &n_pcs)
adds or updates multiple preconditions of the checkpoint
Definition: mrr_utils.h:118
void updatePreconditions(const Precondition &n_pc)
adds or updates a precondition of the checkpoint
Definition: mrr_utils.h:95
const Eigen::Vector2d & getEnd() const
Definition: srr_utils.cpp:45
const Segment & getSegment() const
Definition: srr_utils.cpp:151
const Eigen::Vector2d & getStart() const
Definition: srr_utils.cpp:64
geometry_msgs::Pose & copy(const Eigen::Vector3d &src, geometry_msgs::Pose &des)
Definition: mrr_utils.h:13


tuw_multi_robot_router
Author(s): Benjamin Binder
autogenerated on Mon Jun 10 2019 15:42:49