Ask Your Question

Error when trying to move the robot via python script

asked 2020-10-20 08:12:04 -0500

Qilos gravatar image

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 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


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


rotate_right = not rotate_right


what do i need to do to get it running?

edit retag flag offensive close merge delete


i also dont know why it didnt properly show my code here, just the first and the last 3 lines

Qilos gravatar image Qilos  ( 2020-10-20 09:18:04 -0500 )edit

This has to do with indentation of the text. Try to indent with 5 times 'space'

RobertZickler gravatar image RobertZickler  ( 2020-10-20 09:47:23 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-10-20 09:43:20 -0500

updated 2020-10-20 09:46:30 -0500

You have to write rospy.Publisher(...). With a capital P

Like described here:


edit flag offensive delete link more


Thank you very much that was the culprit

Qilos gravatar image Qilos  ( 2020-10-20 10:48:11 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-10-20 08:12:04 -0500

Seen: 181 times

Last updated: Oct 20 '20