ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You can directly assign a std::vector<float>
to the float32[] ranges
field of the LaserScan
message:
sensor_msgs::LaserScan filtered_scan_msg;
std::vector<float> filtered_ranges;
// fill out vector here...
filtered_scan_msg.ranges = filtered_ranges;
Keep in mind that there are a lot of other fileds of the LaserScan
message that need to be correclty set - angle_min
, angle_max
, angle_increment
, etc.
For a working C++ example, you can look at laser_scan_splitter.cpp
in laser_scan_splitter.