I'm trying to publish some angular velocity to one of my drone rotor However the moment I publish, my rotor teleports to origin, and this is not only for this model, doesn't matter what model or what link I choose the moment I publish that particular link teleports to origin and comes back when stop publishing,

Here's the code I'm using to publish the state,

#!/usr/bin/env python3

import rospy
from gazebo_msgs.msg import LinkState
from geometry_msgs.msg import Twist, Pose

def set_link_state():
    rospy.init_node('rotate_drone_rotor', anonymous=True)
    pub = rospy.Publisher('/gazebo/set_link_state', LinkState, queue_size=10)

    rate = rospy.Rate(10)  # Publish at 10 Hz

    link_state_msg = LinkState()
    link_state_msg.link_name = 'iris::rotor_0'  # Adjust this to match the exact name of your rotor link

    # Set the pose to avoid teleporting to the origin
    link_state_msg.pose = Pose()  # Defaults to (0,0,0) position and (0,0,0,1) orientation
    # Set only angular velocity
    link_state_msg.twist = Twist()
    link_state_msg.twist.linear.x = 0.0
    link_state_msg.twist.linear.y = 0.0
    link_state_msg.twist.linear.z = 0.0
    link_state_msg.twist.angular.x = 0.0
    link_state_msg.twist.angular.y = 0.0  # Angular velocity in radians per second
    link_state_msg.twist.angular.z = 0.01

    rospy.loginfo("Publishing to /gazebo/set_link_state")

    while not rospy.is_shutdown():

if __name__ == '__main__':
    except rospy.ROSInterruptException:
  • $\begingroup$ Are you publishing tf between the joints of your drone? $\endgroup$
    – Sriram
    Commented Jun 25 at 5:10


Your Answer

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

Browse other questions tagged or ask your own question.