Error when trying to move the robot via python script
Hello guys, I wrote a little python script to test moving the robot around in Gazebo, in which the robot just rotates around it z axis 5s clockwise and after that 5s counter clockwise in an while loop.
When i started my python script via rosrun move_pepper move_pepper.py i got following error:
pub = rospy.publisher('/pepper/cmd_vel', Twist, queue_size=1) AttributeError: 'module' object has no attribute 'publisher'
I dont really know what this means and i followed a tutorial in which very thing is the same
Here is my script code
#! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
from time import sleep
rospy.init_node('movep')
pub = rospy.publisher('/pepper/cmd_vel', Twist, queue_size=1)
rotate_right = True
while not rospy.is_shutdown(): msg = Twist() msg.angular.z = 0.1 if rotate_right else -0.1
pub.publish(msg)
rotate_right = not rotate_right
sleep(5)
what do i need to do to get it running?
i also dont know why it didnt properly show my code here, just the first and the last 3 lines
This has to do with indentation of the text. Try to indent with 5 times 'space'