Ask Your Question
0

how to publish laser data after manipulation?

asked 2012-02-27 04:07:05 -0500

liquidmonkey gravatar image

updated 2012-02-27 07:31:14 -0500

kwc gravatar image

am using a sick laser to get some data, i then remove some of the data but do it as a std::vector. but i'm unable to publish those points to ros. is there a vector to sensor_msgs conversion that needs to be done?

thanks for any help...

edit retag flag offensive close merge delete

Comments

1

Could you post a simple chunk of code showing what you are attempting to do? (e.g. your subscribe, modify, publish portion).

Eric Perko gravatar image Eric Perko  ( 2012-02-27 04:10:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2012-02-27 10:37:30 -0500

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-02-27 04:07:05 -0500

Seen: 280 times

Last updated: Feb 27 '12