how can i subscribe gazebo to /tf and /tf_static rostopics

asked 2019-07-22 10:24:54 -0600

microbot gravatar image

Hello,

I have been trying to run ros custom control plugin on robot in gazebo. In order to do that in one terminal i am launching the robot spawnned in the world in gazebo along with its controller manager, robot_state_publisher and pid controllers and in another terminal i am exporting ros_master_uri of the previous one and trying to run the control plugin using rosrun. When i do that , the plugin is displaying the necessary questions and taking the inputs from the user and when it has to call the talker/publisher to publish the joint angles, I can not see any change in the robot in gazebo. I believe that the talker is not publishing the joint configuration. I tried to change different transmission and interfaces but could not get it worked. Can anyone please help me with pointing out the problem or your diagnosis inorder to get it worked. Thank you. Here is the code for the talker,

def talker(jointname , position):
pub1 = rospy.Publisher('joint_states', JointState, queue_size = 10)
rospy.init_node('joint_state_publisher', anonymous=True)
rate = rospy.Rate(10)
while not rospy.is_shutdown():
    robot_configuration = JointState()
    robot_configuration.header = Header()
    robot_configuration.header.stamp = rospy.Time.now()
    robot_configuration.name = [jointname]
    robot_configuration.position = [position]
    robot_configuration.velocity = [2]
    robot_configuration.effort = [10]
    pub1.publish(robot_configuration)
rate.sleep()

I believe the error is caused because of the topic /tf, /tf_static, they are supposed to get join configuration from robot_State_publisher and then calculate the link positions using forward kinematics and publish them to gazebo. When i checked `rostopic info /tf

I see following ,

Type: tf2_msgs/TFMessage

 Publishers: 
 * /spider/rob_st_pub (http://Microbot:42951/)

 Subscribers: None

can anyone help me how to fix this

edit retag flag offensive close merge delete