Hi Morgan,<br>Okay -- say I wanted to read in just the range values from sicklms -- how can I just grab those? When I use rostopic echo /scan, the ranges show up as a list within brackets - is there a way I can pick out data from a topic my node is subscribing to? Sorry if I'm being a bit dense -- I'm not well versed on handling data types in C++.<br>
Best,<br>Rishi<br><br clear="all">Rishi Bedi<br><a href="mailto:rbedi100@gmail.com">rbedi100@gmail.com</a><br>
<br><br><div class="gmail_quote">On Thu, Jul 15, 2010 at 3:00 PM, Morgan Quigley <span dir="ltr"><<a href="mailto:mquigley@cs.stanford.edu">mquigley@cs.stanford.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Rishi,<br>
<br>
Since there are such a wide variety of data types in the system that<br>
would need different useful string representations, the auto-generated<br>
message types don't create a string-generation function. You'll need<br>
to assemble a string yourself using stringstream or whatever.<br>
<br>
Cheers,<br>
Morgan<br>
<div><div></div><div class="h5"><br>
<br>
On Thu, Jul 15, 2010 at 11:55 AM, Rishi Bedi <<a href="mailto:rbedi100@gmail.com">rbedi100@gmail.com</a>> wrote:<br>
> Hi,<br>
> I'm trying to write a node that subscribes to the "/scan" topic, which is<br>
> published by sicktoolbox_wrapper. I tried to modify some of the code given<br>
> in the "Writing a Simple Publisher/Subscriber" tutorial:<br>
><br>
> #include <ros/ros.h><br>
> #include <std_msgs/String.h><br>
> #include <sensor_msgs/LaserScan.h><br>
><br>
> void scanCallback (const sensor_msgs::LaserScan::ConstPtr& scan_msg)<br>
><br>
> {<br>
>   ROS_INFO("Received [%s]", scan_msg);<br>
> }<br>
><br>
> int main(int argc, char** argv)<br>
> {<br>
>   ros::init(argc, argv, "listener");<br>
>   ros::NodeHandle n;<br>
>   ros::Subscriber scan_sub = n.subscribe("scan", 100, scanCallback);<br>
>   ros::spin();<br>
> }<br>
><br>
> The part where I think I'm getting tripped up is line 8 (the ROS_INFO<br>
> command) -- how do I handle the unique data type LaserScan that<br>
> sicktoolbox_wrapper uses to publish the scan data? I want to print the range<br>
> values out, preferably as one long string -- what is the best way to convert<br>
> the LaserScan type data into a string (or array)?<br>
><br>
> Thanks a lot --<br>
> Rishi<br>
><br>
> Rishi Bedi<br>
> <a href="mailto:rbedi100@gmail.com">rbedi100@gmail.com</a><br>
><br>
</div></div>> _______________________________________________<br>
> ros-users mailing list<br>
> <a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
> <a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
><br>
><br>
_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
</blockquote></div><br>