ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
vehiclebasemeasurementwriter.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 // * Jonas Rieck
13 // ********************************************************************************
14 
15 
18 #include <std_msgs/Float32.h>
19 #include <std_msgs/Float32MultiArray.h>
20 
21 namespace adore
22 {
23 namespace if_ROS
24 {
49 class VehicleBaseMeasurementWriter : public adore::mad::AWriter<adore::fun::VehicleBaseMeasurement>
50 {
51 private:
52  ros::Publisher steering_angle_pub_;
53  ros::Publisher wheel_speed_pub_;
54  ros::Publisher yawrate_esp_pub_;
55  ros::Publisher ax_esp_pub_;
56  ros::Publisher ay_esp_pub_;
57 
58 public:
59  VehicleBaseMeasurementWriter(ros::NodeHandle* n, const std::string steering_topic,
60  const std::string wheel_speed_topic, const std::string yawrate_esp_topic,
61  const std::string ax_esp_topic, const std::string ay_esp_topic, int qsize)
62  {
63  steering_angle_pub_ = n->advertise<std_msgs::Float32>(steering_topic, qsize);
64  wheel_speed_pub_ = n->advertise<std_msgs::Float32MultiArray>(wheel_speed_topic, qsize);
65  yawrate_esp_pub_ = n->advertise<std_msgs::Float32>(yawrate_esp_topic, qsize);
66  ax_esp_pub_ = n->advertise<std_msgs::Float32>(ax_esp_topic, qsize);
67  ay_esp_pub_ = n->advertise<std_msgs::Float32>(ay_esp_topic, qsize);
68  }
70  virtual bool canWriteMore() const override
71  {
72  return true;
73  }
75  virtual void write(const adore::fun::VehicleBaseMeasurement& value) override
76  {
77  std_msgs::Float32 steering_msg;
78  steering_msg.data = value.getSteeringAngle();
79  steering_angle_pub_.publish(steering_msg);
80 
81  std_msgs::Float32MultiArray wheel_msg;
82  wheel_msg.data.insert(wheel_msg.data.end(),value.getWheelSpeeds().begin(),value.getWheelSpeeds().end());
83  wheel_speed_pub_.publish(wheel_msg);
84 
85  std_msgs::Float32 yaw_msg;
86  yaw_msg.data = value.getYawRate();
87  yawrate_esp_pub_.publish(yaw_msg);
88 
89  std_msgs::Float32 ax_msg;
90  ax_msg.data = value.getEspAx();
91  ax_esp_pub_.publish(ax_msg);
92 
93  std_msgs::Float32 ay_msg;
94  ay_msg.data = value.getEspAy();
95  ay_esp_pub_.publish(ay_msg);
96  }
97 };
98 } // namespace if_ROS
99 } // namespace adore
Definition: vehiclebasemeasurement.h:24
float getEspAx() const
Definition: vehiclebasemeasurement.h:43
float getEspAy() const
Definition: vehiclebasemeasurement.h:46
float getYawRate() const
Definition: vehiclebasemeasurement.h:40
const std::vector< float > & getWheelSpeeds() const
Definition: vehiclebasemeasurement.h:37
float getSteeringAngle() const
Definition: vehiclebasemeasurement.h:34
Definition: vehiclebasemeasurementwriter.h:50
virtual void write(const adore::fun::VehicleBaseMeasurement &value) override
write sends out data value
Definition: vehiclebasemeasurementwriter.h:75
VehicleBaseMeasurementWriter(ros::NodeHandle *n, const std::string steering_topic, const std::string wheel_speed_topic, const std::string yawrate_esp_topic, const std::string ax_esp_topic, const std::string ay_esp_topic, int qsize)
Definition: vehiclebasemeasurementwriter.h:59
ros::Publisher ay_esp_pub_
Definition: vehiclebasemeasurementwriter.h:56
ros::Publisher yawrate_esp_pub_
Definition: vehiclebasemeasurementwriter.h:54
virtual bool canWriteMore() const override
canWriteMore indicates whether more data can be written
Definition: vehiclebasemeasurementwriter.h:70
ros::Publisher steering_angle_pub_
Definition: vehiclebasemeasurementwriter.h:52
ros::Publisher wheel_speed_pub_
Definition: vehiclebasemeasurementwriter.h:53
ros::Publisher ax_esp_pub_
Definition: vehiclebasemeasurementwriter.h:55
Definition: com_patterns.h:97
Definition: areaofeffectconverter.h:20