How can I publish Twist messages to /gazebo node(amcl_demo.launch)
Hello! I'm runnning TurtleBot on rviz, and I want to publish Twist messages to the "/gazebo" node in order to control robot's velocity.
I wrote a publisher as below but it didn't work.
How can I solve this ploblem? Could you tell me please?
my code↓↓
#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
def callback(data):
pub=rospy.Publisher("/gazebo",Twist,queue_size=10)
vel_msg=Twist()
print(data.linear.x,data.angular.z)
vel_msg.linear.x=0
vel_msg.angular.z=0
pub.publish(vel_msg)
def main():
rospy.init_node("GetVelocity")
sub=rospy.Subscriber("/mobile_base/commands/velocity",Twist,callback)
rospy.spin()
if __name__== "__main__":
try:
main()
except rospy.ROSInterruptException:
pass
rqt_graph Image↓↓(while running "amcl_demo.launch"&"rviz"&"turtlebot_world.launch"&"above code")
rqt_graph(red arrow in this picture shows what I want to do)
can you post the whole rqt_graph?
Yes, sure. Here you are! all nodes