Skip to content

Instantly share code, notes, and snippets.

@okalachev
Last active July 28, 2022 00:11
Show Gist options
  • Save okalachev/2c9b4e88b982de7f77f3a1bd7af54cbd to your computer and use it in GitHub Desktop.
Save okalachev/2c9b4e88b982de7f77f3a1bd7af54cbd to your computer and use it in GitHub Desktop.
Publish groundtruth pose in Clover simulator
#!/usr/bin/env python3
import rospy
from geometry_msgs.msg import PoseStamped
from gazebo_msgs.msg import LinkStates, ModelStates
rospy.init_node('groundtruth_pose')
pose_pub = rospy.Publisher('groundtruth', PoseStamped, queue_size=1)
# uncomment to loop groundtruth pose to vision pose input:
# pose_pub = rospy.Publisher('mavros/vision_pose/pose', PoseStamped, queue_size=1)
pose_msg = PoseStamped()
pose_msg.header.frame_id = 'map'
def link_states_callback(msg):
try:
index = msg.name.index('clover::base_link')
except ValueError:
return
pose_msg.pose = msg.pose[index]
pose_msg.header.stamp = rospy.Time.now()
pose_pub.publish(pose_msg)
rospy.Subscriber('gazebo/link_states', LinkStates, link_states_callback)
rospy.spin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment