0
$\begingroup$

Rosanswers logo

Hello guys,

I'm trying to get all the information of a particular message from a python script.

I'm using rospy.get_published_topics() to get the list of all the topics available, then, I select one of them and I want to be able to see all the information of this message (just like a rosmsg show in fact) from my python script.

Do you have clue on how to proceed, I tried to find the appropriate function in rospy but couldn't manage to get it.

Thank you so much in advance


Originally posted by benboy on ROS Answers with karma: 1 on 2019-03-25

Post score: 0


Original comments

Comment by mgruhler on 2019-03-25:
You do mean rostopic info, not rosmsg info, as was the original title, correct? I adapted the title to reflect this (as rosmsg actually has no info verb). if this is incorrect, please revert it...

Comment by mgruhler on 2019-03-25:
or do you mean to do a rosmsg show? The longer I look at you question the more I'm confused about those two possibilities :-)

Comment by benboy on 2019-03-25:
I meant rosmsg show, thank you for trying to clarify the thing

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

What about using the rosmsg API directly?

Is the following what you are looking for?

In [6]: import rosmsg

In [7]: print(rosmsg.get_msg_text("sensor_msgs/LaserScan", raw=True))
# Single scan from a planar laser range-finder
#
# If you have another ranging device with different behavior (e.g. a sonar
# array), please find or create a different message, since applications
# will make fairly laser-specific assumptions about this data

Header header            # timestamp in the header is the acquisition time of 
                         # the first ray in the scan.
                         #
                         # in frame frame_id, angles are measured around 
                         # the positive Z axis (counterclockwise, if Z is up)
                         # with zero angle being forward along the x axis
                         
float32 angle_min        # start angle of the scan [rad]
float32 angle_max        # end angle of the scan [rad]
float32 angle_increment  # angular distance between measurements [rad]

float32 time_increment   # time between measurements [seconds] - if your scanner
                         # is moving, this will be used in interpolating position
                         # of 3d points
float32 scan_time        # time between scans [seconds]

float32 range_min        # minimum range value [m]
float32 range_max        # maximum range value [m]

float32[] ranges         # range data [m] (Note: values < range_min or > range_max should be discarded)
float32[] intensities    # intensity data [device-specific units].  If your
                         # device does not provide intensities, please leave
                         # the array empty.

Originally posted by mgruhler with karma: 12390 on 2019-03-25

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by benboy on 2019-03-25:
Thank you so much @mgruhler it works perfectly for what I wanted to do, thanks again !

Comment by mgruhler on 2019-03-26:
happy to see this working. @benboy If you feel this is correct, could you also check the tick-mark net to the answer to mark it as solved? Thanks.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.