I have a question about the exercise 3.2 of the 'Unit 3: Services in ROS' of the course 'ROS Basic in 5 days'.

In the first part of the exercises we need to create a Service Server that accepts an Empty service message and activates the circle movement. This service could be called /move_bb8_in_circle. And after that, we need to check that the robot moves because in the next step we have to create a client that executes this service.

But my problem is that my BB-8 doesn't move and I don't know what I need to add.

That is my launch file 'start_bb8_move_in_circle_service_server.launch':

   node pkg="unit_3_services"

And this is my service 'bb8_move_in_circle_servi""ce_server.py':

#! /usr/bin/env python

import rospy
from std_srvs.srv import Empty, EmptyResponse

def my_callback(request):
   print "bb8_service has been called"
   return EmptyResponse()

move_bb8_in_circle = rospy.Service('/move_bb8_in_circle', Empty, my_callback)

asked 04 Mar, 09:44

sanmool%40etsiamn.upv.es's gravatar image

accept rate: 50%

You have to make use of the message topics /cmd_vel to move the robot like you did in the previous unit. Import Twist from geometry_msgs, create an object of that type, assign the the appropriate speed values and in the callback function of the service publish the /cmd_vel message. See the following code:

#! /usr/bin/env python

import rospy
from std_srvs.srv import Empty, EmptyResponse
from geometry_msgs.msg import Twist

def my_callback(request):
    print "service bb8 move in circle has been called."

    vel = Twist()
    vel.linear.x = 0.2
    vel.linear.y = 0.5
    vel.angular.z = 0.0
    print vel
    return EmptyResponse()

pub = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
my_service = rospy.Service('/move_bb8_in_circle', Empty, my_callback)
print "Service bb8 started."
rospy.spin()  # maintain the service open.

Hope this will help you.

permanent link

answered 06 Mar, 12:45

joseecm%40gmail.com's gravatar image

accept rate: 20%

Oh, really thanks. Now I need to do that the robot moves in circles but that is easy.

Thanks for all!

(07 Mar, 08:32) sanmool@etsi...
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 04 Mar, 09:44

question was seen: 195 times

last updated: 07 Mar, 08:32

Related questions

powered by OSQA