Closed wegunterjr closed 4 years ago
It's not clear what the type of rvr_pose
is, but I assume it is not a dictionary, so very likely, the serialization is failing. Make sure you pass a dictionary in there and it will work.
Ah..It is Pose from ROS, did I setup the Message right? With the two parts?https://docs.ros.org/melodic/api/geometry_msgs/html/msg/Pose.html
# A representation of pose in free space, composed of position and orientation.
Point position
Quaternion orientation
ROS messages need to be converted to dictionaries to be sent via the rosbridge
, the easiest way to do that is using the yaml
module, so, in your case, you the following should work:
import yaml
rvr_pose = Pose()
rvr_pose.position.x = locator_X
rvr_pose.position.y = locator_Y
rvr_pose.orientation.z = imu_Yaw
rvr_pose_topic = roslibpy.Topic(client, '/rvr_pose', 'geometry_msgs/Pose')
rvr_pose_serialized = dict(yaml.load(str(rvr_pose)))
rvr_pose_topic.publish(roslibpy.Message(rvr_pose_serialized))
NOTE: In your code, you use rvr_pose
as a Pose instance, and rvr_Pose
as a topic instance, that's not a very good idea, because they look almost the same, except the casing. In my example, I have renamed them to rvr_pose
and rvr_pose_topic
respectively.
WOOHOO!!!! That worked!
Great 👍
this should be added to the docs. thank you.
I am publishing data to a rosbridge, and seem to be just fine with 'std_msgs/String', and 'std_msgs/Float32, but when i try to do 'geometry_messages/Pose' which has orientation and position, I see the topic being published, but there is no data.
rvr_Pose = roslibpy.Topic(client, '/rvr_pose', 'geometry_msgs/Pose')
Thoughts?