ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Usarsim sends string data

asked 2011-07-18 19:28:05 -0500

Sara gravatar image

I am trying to implement robot exploration by ROS-Usarsim, the sensor data comes from the Usarsim as a variable length string, How can I receive these data as a double so I can use it for building my map.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2011-07-18 20:05:25 -0500

makokal gravatar image

updated 2011-07-18 20:07:46 -0500

If its just a mater of converting a std::string to a double, it doesn't get easier than using boost::lexical_cast as follows

#include <boost/lexical_cast.hpp>
...
std::string str; // keep the string here
double result = boost::lexical_cast<double>(str);

have fun

edit flag offensive delete link more

Comments

Thanks Mak,
Sara gravatar image Sara  ( 2011-07-19 18:26:09 -0500 )edit
The problem is that the string coming from usarsim is about 600 character length. Some of them are text and the other are sensor readings.does your solution above solve the problem?
Sara gravatar image Sara  ( 2011-07-19 18:51:46 -0500 )edit
The problem is that the string coming from usarsim is about 600 character length. Some of them are text and the other are sensor readings.does your solution above solve the problem?
Sara gravatar image Sara  ( 2011-07-19 18:51:46 -0500 )edit
when I do the solution above I get this message: message_traits.h:121:34: error: request for member ‘__getMD5Sum’ in ‘m’, which is of non-class type ‘const double’ Please advise
Sara gravatar image Sara  ( 2011-07-19 19:11:47 -0500 )edit
This is a sample of the string coming from usarsim: data: STA{Time 154829.4375} {FrontSteer 0} {RearSteer 0} {Battery 99999}data: SEN {Type RangeScanner} {Name lms200} {Resolution 0.1744} {FOV 3.1414} {Range 6.76,6.87,7.20,5.31,6.22,7.41,7.59,7.00,6.68,6.58,6.68,7.00,7.59,8.59,10.23,13 - Sara (5 min
Sara gravatar image Sara  ( 2011-07-19 19:12:03 -0500 )edit
1
You will need to parse that data. There is nothing ROS specific to that.
dornhege gravatar image dornhege  ( 2011-07-19 21:20:44 -0500 )edit
You need to parse this data out of the custom USARSIM format. This would be better asked in a USARSIM forum.
tfoote gravatar image tfoote  ( 2011-07-22 12:49:21 -0500 )edit

Hello, Sara, did you manage to correctly process the sensor data and build a map of the environment by using the makokal code.......

RB gravatar image RB  ( 2013-11-02 20:44:20 -0500 )edit

Question Tools

Stats

Asked: 2011-07-18 19:28:05 -0500

Seen: 319 times

Last updated: Jul 19 '11