How to publish a pose in quaternion?
I have all the values for point(x, y, z)
and quaternion (w, qx, qy, qz)
. Do I just make a dict and publish it as a Pose topic?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
I have all the values for point(x, y, z)
and quaternion (w, qx, qy, qz)
. Do I just make a dict and publish it as a Pose topic?
You need to create a publisher and publish a geometry_msgs/Pose message.
#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Pose
def publisher():
pub = rospy.Publisher('pose', Pose, queue_size=1)
rospy.init_node('pose_publisher', anonymous=True)
rate = rospy.Rate(2) # Hz
while not rospy.is_shutdown():
p = Pose()
p.position.x = 0.5
p.position.y = -0.1
p.position.z = 1.0
# Make sure the quaternion is valid and normalized
p.orientation.x = 0.0
p.orientation.y = 0.0
p.orientation.z = 0.0
p.orientation.w = 1.0
pub.publish(p)
rate.sleep()
if __name__ == '__main__':
try:
publisher()
except rospy:
pass
To add: see rospy/Overview/Messages for some other styles of msg initialisation in rospy
.
Asked: 2019-02-27 03:42:03 -0600
Seen: 7,061 times
Last updated: Dec 08 '20
Retrieving pose of an object from an image or bag file
Default 2D pose estimate when navigating
Should i be able to set the current pose for amcl?
Which 6D pose estimation package works best and will be supported?
How to programatically set the 2D pose on a map ?
How to set the dimensions of the initial pose array
quaternions orientation representation