Publish radar ros message repeated detected objects.
Hi, I have a radar sensor to detect vehicles in front of the car. each detected object has its data in the form of
struct
{
int32 ObjectID;
float32 distance;
float32 velocity;
float32 zimuth ;
float32 elevation;
} Radar_Point
I want to push this radar data using a standard ROS message I found the message
radar_msgs/msg/RadarScan.msg
std_msgs/Header header
radar_msgs/RadarReturn[] returns
and
radar_msgs/msg/RadarReturn.msg
# All variables below are relative to the radar's frame of reference.
# This message is not meant to be used alone but as part of a stamped or array message.
float32 range # Distance (m) from the sensor to the detected return.
float32 azimuth # Angle (in radians) in the azimuth plane between the sensor and the detected return.
# Positive angles are anticlockwise from the sensor and negative angles clockwise from the sensor as per REP-0103.
float32 elevation # Angle (in radians) in the elevation plane between the sensor and the detected return.
# Negative angles are below the sensor. For 2D radar, this will be 0.
float32 doppler_velocity # The doppler speeds (m/s) of the return.
float32 amplitude # The amplitude of the of the return (dB)
I find it difficult to map the radar sensor data to the radar ros message before I can publish it.
radar_msgs::RadarScan msgRadarScan;
ros::init(argc, argv, "conti_radar"); ros::NodeHandle n; ros::Publisher publisher_contiradar = n.advertise <radar_msgs::radarscan>("/conti_radar", 100);
void handledata( const double & simTime, const unsigned int & simFrame, std::vector<Radar_Point> & item, bool isExtended )
{
for (auto i = item.begin(); i != item.end(); ++i)
{
msgRadarScan.header.stamp.sec = simTime;
msgRadarScan.header.stamp.nsec = (simTime - msgRadarScan.header.stamp.sec)*1000000000;
msgRadarScan.header.frame_id = "base_link";
msgRadarScan.returns.range = item[i].distance;
msgRadarScan.returns.velocity = item[i].doppler_velocity;
msgRadarScan.returns.zimuth = item[i].azimuth;
msgRadarScan.returns.elevation = item[i].elevation;
msgRadarScan.returns.push_back();
}
}
publisher_contiradar.publish(msgRadarScan);
I try to implement in this way because For the radar sensor data, I have a number of detected objects. So I am thinking about adding a newly detected object to an array or vector?. Certainly, my code is wrong with many errors I just want to give you an idea about my idea. Can anyone help me to review the message conversion part? there must be a better way to publish Radar data to the ROS server. Please give me some suggestion
I don't believe anyone can help you, unless you clarify what "many errors" actually means.
Hi gvdhoorn I will specify more details about the errors. Thanks for pointing it out.