turtle in turtlebot_gazebo is not moving
Hi I'm new in ROS, and I have a problem with turtlebot_gazebo.
Here I got the code which I would like to use to move the robot.
import rospy
from geometry_msgs.msg import Twist
cmd_vel_pub = rospy.Publisher('cmd_vel', Twist, queue_size=1)
rospy.init_node('red_light_green_light')
red_light_twist = Twist()
green_light_twist = Twist()
green_light_twist.linear.x =5
driving_forward = False
light_change_time = rospy.Time.now()
rate = rospy.Rate(10)
while not rospy.is_shutdown():
if driving_forward:
cmd_vel_pub.publish(green_light_twist)
else:
cmd_vel_pub.publish(red_light_twist)
if light_change_time > rospy.Time.now():
driving_forward = not driving_forward
light_change_time = rospy.Time.now() + rospy.Duration(3)
rate.sleep()
This is the code from 'Programming robots with ROS' book.
Then in new terminal I use that command
./red_light_green_light.py cmd_vel:=cmd_vel_mux/input/teleop
and again in new terminal I'm running the code
rosrun wanderbot red_light_green_light.py
after that in the previous terminal i got this
shutdown request: new node registered with the same name
Traceback (most recent call last):
File "./red_light_green_light.py", line 25, in <module>
rate.sleep()
File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/timer.py", line 99, in
sleep
sleep(self._remaining(curr_time))
File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/timer.py", line 157, in
sleep
raise rospy.exceptions.ROSInterruptException("ROS shutdown request")
rospy.exceptions.ROSInterruptException: ROS shutdown request
The turtle in gazebo is not moving. Could someone give some advice? I would be really grateful.