ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
cooperativeuserspredictionconverter.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2017-2020 German Aerospace Center (DLR).
3  * Eclipse ADORe, Automated Driving Open Research https://eclipse.org/adore
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License 2.0 which is available at
7  * http://www.eclipse.org/legal/epl-2.0.
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  * Reza Dariani - initial API and implementation
13  ********************************************************************************/
14 
15 #pragma once
16 #include <adore/env/afactory.h>
17 #include <adore_if_ros_msg/CooperativePlanningSet.h>
19 
20 namespace adore
21 {
22  namespace if_ROS
23  {
28  {
29  public:
30 
31  template<typename Tmsg>//adore_if_ros_msg::CooperativePlanningSet
33  {
34  list->clear();
36  for(int i=0; i<msg->data.size(); i++)
37  {
38  cup.setId(msg->data[i].id);
39  cup.setLanePosition(msg->data[i].lane_position);
40  cup.setTargetAutomationLevel(msg->data[i].target_automation_level);
41  cup.setToletatedDistanceAhead(msg->data[i].tolerated_distance_ahead);
42  cup.setToletatedDistanceBehind(msg->data[i].tolerated_distance_behind);
43  cup.setVehicleLength (msg->data[i].vehicle_length);
44  cup.setVehicleWidth (msg->data[i].vehicle_width);
45  for(int j=0; j<msg->data[i].prediction.size(); j++)
46  {
47  cup.currentTrajectory.x.push_back(msg->data[i].prediction[j].x);
48  cup.currentTrajectory.y.push_back(msg->data[i].prediction[j].y);
49  cup.currentTrajectory.v.push_back(msg->data[i].prediction[j].v);
50  cup.currentTrajectory.psi.push_back(msg->data[i].prediction[j].psi);
51  cup.currentTrajectory.t0.push_back(msg->data[i].prediction[j].t0);
52  cup.currentTrajectory.t1.push_back(msg->data[i].prediction[j].t1);
53  }
54  list->push_back(cup);
55  cup.clear();
56  }
57 
58  }
59  template<typename Tmsg>//adore_if_ros_msg::CooperativePlanning
61  {
62  user->clear();
63  user->setId(msg->id);
64  user->setLanePosition(msg->lane_position);
65  user->setTargetAutomationLevel(msg->target_automation_level);
66  user->setToletatedDistanceAhead(msg->tolerated_distance_ahead);
67  user->setToletatedDistanceBehind(msg->tolerated_distance_behind);
68  user->setVehicleWidth(msg->vehicle_width);
69  user->setVehicleLength(msg->vehicle_length);
70  for(int i=0; i<msg->prediction.size(); i++)
71  {
72  user->currentTrajectory.x.push_back(msg->prediction[i].x);
73  user->currentTrajectory.y.push_back(msg->prediction[i].y);
74  user->currentTrajectory.v.push_back(msg->prediction[i].v);
75  user->currentTrajectory.psi.push_back(msg->prediction[i].psi);
76  user->currentTrajectory.t0.push_back(msg->prediction[i].t0);
77  user->currentTrajectory.t1.push_back(msg->prediction[i].t1);
78 
79 
80  }
81 
82  }
83 
84  adore_if_ros_msg::CooperativePlanningSet operator()(const adore::env::CooperativeUsersList& list)
85  {
86  //std::cout<<"\nwrite p_info to msg";
87  adore_if_ros_msg::CooperativePlanningSet msg;
88  adore_if_ros_msg::CooperativePlanning cp;
89  adore_if_ros_msg::CooperativeUser cu;
90  for(int i=0; i<list.size(); i++)
91  {
92  cp.id = list[i].id;
93  cp.lane_position = list[i].lane_position;
94  cp.target_automation_level = list[i].target_automation_level;
95  cp.tolerated_distance_ahead = list[i].toletated_distance_ahead;
96  cp.tolerated_distance_behind = list[i].toletated_distance_behind;
97  cp.vehicle_length = list[i].vehicleLength;
98  cp.vehicle_width = list[i].vehicleWidth;
99  for(int j=0; j<list[i].currentTrajectory.x.size(); j++)
100  {
101  cu.x = list[i].currentTrajectory.x[j];
102  cu.y = list[i].currentTrajectory.y[j];
103  cu.v = list[i].currentTrajectory.v[j];
104  cu.psi = list[i].currentTrajectory.psi[j];
105  cu.t0 = list[i].currentTrajectory.t0[j];
106  cu.t1 = list[i].currentTrajectory.t1[j];
107  cp.prediction.push_back(cu);
108  }
109  msg.data.push_back(cp);
110  cp.prediction.clear();
111  }
112  return msg;
113  }
114 
115  adore_if_ros_msg::CooperativePlanning operator()(const adore::env::CooperativeUserPrediction& user)
116  {
117  adore_if_ros_msg::CooperativePlanning msg;
118 
119  msg.id = user.id;
120  msg.lane_position = user.lane_position;
121  msg.target_automation_level = user.target_automation_level;
122  msg.tolerated_distance_ahead = user.toletated_distance_ahead;
123  msg.tolerated_distance_behind = user.toletated_distance_behind;
124  msg.vehicle_length = user.vehicleLength;
125  msg.vehicle_width = user.vehicleWidth;
126  adore_if_ros_msg::CooperativeUser cu;
127  for(int i=0; i<user.currentTrajectory.x.size();i++)
128  {
129  cu.x = user.currentTrajectory.x[i];
130  cu.y = user.currentTrajectory.y[i];
131  cu.v = user.currentTrajectory.v[i];
132  cu.psi = user.currentTrajectory.psi[i];
133  cu.t0 = user.currentTrajectory.t0[i];
134  cu.t1 = user.currentTrajectory.t1[i];
135  msg.prediction.push_back(cu);
136  }
137  return msg;
138 
139 
140 
141 
142 
143  }
144 
145  };
146 
147 
148 
149 
150  }
151 }
std::vector< CooperativeUserPrediction > CooperativeUsersList
Definition: cooperativeusersprediction.h:70
Definition: areaofeffectconverter.h:20
Definition: cooperativeusersprediction.h:24
std::vector< double > v
Definition: cooperativeusersprediction.h:39
struct adore::env::CooperativeUserPrediction::@0 currentTrajectory
void setTargetAutomationLevel(unsigned int target_automation_level)
Definition: cooperativeusersprediction.h:47
void setLanePosition(int lane_position)
Definition: cooperativeusersprediction.h:46
void setVehicleWidth(double vehicleWidth)
Definition: cooperativeusersprediction.h:51
int lane_position
Definition: cooperativeusersprediction.h:31
std::vector< double > psi
Definition: cooperativeusersprediction.h:42
double toletated_distance_behind
Definition: cooperativeusersprediction.h:28
double vehicleLength
Definition: cooperativeusersprediction.h:32
std::vector< double > t1
Definition: cooperativeusersprediction.h:41
unsigned int target_automation_level
Definition: cooperativeusersprediction.h:30
int id
Definition: cooperativeusersprediction.h:27
double toletated_distance_ahead
Definition: cooperativeusersprediction.h:29
double vehicleWidth
Definition: cooperativeusersprediction.h:33
void clear()
Definition: cooperativeusersprediction.h:52
void setId(int id)
Definition: cooperativeusersprediction.h:45
void setToletatedDistanceBehind(double toletated_distance_behind)
Definition: cooperativeusersprediction.h:48
void setToletatedDistanceAhead(double toletated_distance_ahead)
Definition: cooperativeusersprediction.h:49
std::vector< double > t0
Definition: cooperativeusersprediction.h:40
void setVehicleLength(double vehicleLength)
Definition: cooperativeusersprediction.h:50
std::vector< double > x
Definition: cooperativeusersprediction.h:37
std::vector< double > y
Definition: cooperativeusersprediction.h:38
Definition: cooperativeuserspredictionconverter.h:28
adore_if_ros_msg::CooperativePlanning operator()(const adore::env::CooperativeUserPrediction &user)
Definition: cooperativeuserspredictionconverter.h:115
void operator()(Tmsg msg, adore::env::CooperativeUserPrediction *user)
Definition: cooperativeuserspredictionconverter.h:60
adore_if_ros_msg::CooperativePlanningSet operator()(const adore::env::CooperativeUsersList &list)
Definition: cooperativeuserspredictionconverter.h:84
void operator()(Tmsg msg, adore::env::CooperativeUsersList *list)
Definition: cooperativeuserspredictionconverter.h:32