ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Error when trying to move the robot via python script

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

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

edit retag flag offensive close merge delete

Comments

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 -0600 )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 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

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

RobertZickler gravatar image

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

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

Like described here: http://wiki.ros.org/rospy/Overview/Pu...

Robert

edit flag offensive delete link more

Comments

Thank you very much that was the culprit

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

Question Tools

1 follower

Stats

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

Seen: 425 times

Last updated: Oct 20 '20