I have a ROS node which manipulates a serial frame, the frame contains ultrasonic measurements, I have to extract this measurement and publish it as sensor_msgs/Range Message
, and I am using the following code:
ros::Rate loop_rate(5);
while(ros::ok()){
ros::spinOnce();
if(ser.available())//serial::Serial ser;
{
std::string stringRange = ser.read(ser.available());
//ROS_INFO_STREAM("Read: " << result.data);
sonar_msg.range = ::atof(stringRange.c_str());
sonar_msg.header.stamp = ros::Time::now();
pub_sonar.publish(&sonar_msg);
}
loop_rate.sleep();
}
When I try to build using catkin, the terminal fails and give me an error message:
error: request for member ‘serialize’ in ‘t’, which is of pointer type
‘boost::call_traits<sensor_msgs::Range_<std::allocator<void>>*>::param_type
{aka sensor_msgs::Range_<std::allocator<void>>* const}’
(maybe you meant to use ‘->’ ?)
t.serialize(stream.getData(), 0);
I thing the problem in converting to float data.
How can I solve this?