# ROS Services Quiz

**URL:** <https://get-help.theconstruct.ai/t/ros-services-quiz/4108>\
**Category:** ROS Basics In 5 Days (Python)\
**Tags:** services\_quiz\
**Created:** [June 18, 2020, 10:34pm UTC](https://get-help.theconstruct.ai/t/ros-services-quiz/4108 "2020-06-18T22:34:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonyli19970130](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/tonyli19970130/32/10_2.png) [@tonyli19970130](https://get-help.theconstruct.ai/u/tonyli19970130)\
**Post date:** [June 18, 2020, 10:34pm UTC](https://get-help.theconstruct.ai/t/ros-services-quiz/4108/1 "2020-06-18T22:34:46Z")

</div>

Hello All, I am not sure how to implement the side request to my Move\_BB8 function. I am thinking of that the side = move\_square.linear.x \* move time (displacement = velocity \* time). But I am not positive toward my thought. Here is my code shown below without the implementation of side. Appreciate anyone who could help me out!

def Move\_BB8(request) :

```
#repeat the robot movement for request.repetitions times

i = 0

while i < request.repetitions :

    #move the robot in square

    j = 0

    while j < 4: #(j=0,1,2,3)

        move_square.linear.x = 0.2 #go straight 

        rate.sleep()

        move_square.linear.x = 0.0 #stop to attenuate the inertia effect

        rate.sleep()

        move_square.angular.z = 0.1 #make a turn 

        rate.sleep()

        move_square.angular.z = 0.0 #stop to attenuate the inertia effect

        rate.sleep()

        my_pub.publish(move_square)

        rate.sleep()

        j+=1

    i+=1

rospy.loginfo("Finished service move_bb8_in_square_custom")

response = BB8CustomServiceMessageResponse()

response.success = True

return response
```

---

<div class="post-metadata">

**Author:** ![simon.steinmann91](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/simon.steinmann91/32/324_2.png) [@simon.steinmann91](https://get-help.theconstruct.ai/u/simon.steinmann91)\
**Post date:** [June 19, 2020, 12:23pm UTC](https://get-help.theconstruct.ai/t/ros-services-quiz/4108/2 "2020-06-19T12:23:31Z")

</div>

Hi @tonyli19970130,  
Dont forget to publish the move\_square each time you change it. Also using rate.sleep seems kinda weird in this instant, as you are not really dealing with a continuous loop. Rather use fixed values.  
rospy.sleep(1) for example. Then you can simply change the length of the square by waiting longer after publishing the forward move command.

---

<div class="post-metadata">

**Author:** ![tonyli19970130](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/tonyli19970130/32/10_2.png) [@tonyli19970130](https://get-help.theconstruct.ai/u/tonyli19970130)\
**Post date:** [June 20, 2020, 12:18am UTC](https://get-help.theconstruct.ai/t/ros-services-quiz/4108/3 "2020-06-20T00:18:34Z")

</div>

Hi Simon, Thanks for the correction and now the robot moves perfectly fine. But when I do the quiz evaluation, it said that I did not have my services\_quiz pkg compiled as shown below. I wonder if you could give me some hints on this error further. Appreciate for your time.

 ![1](https://get-help.robotigniteacademy.com/uploads/default/original/2X/9/9bf314d25201f991f96010a5d6e8e3f5c53e94af.png)

---

<div class="post-metadata">

**Author:** ![simon.steinmann91](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/simon.steinmann91/32/324_2.png) [@simon.steinmann91](https://get-help.theconstruct.ai/u/simon.steinmann91)\
**Post date:** [June 20, 2020, 5:10pm UTC](https://get-help.theconstruct.ai/t/ros-services-quiz/4108/4 "2020-06-20T17:10:47Z")

</div>

It is hard to say. Double and triple check your spelling and naming of packages. @bayodesegun perhaps you can take a look.

---

<div class="post-metadata">

**Author:** ![tonyli19970130](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/tonyli19970130/32/10_2.png) [@tonyli19970130](https://get-help.theconstruct.ai/u/tonyli19970130)\
**Post date:** [June 20, 2020, 8:37pm UTC](https://get-help.theconstruct.ai/t/ros-services-quiz/4108/5 "2020-06-20T20:37:44Z")

</div>

I forgot to include the BB8CustomServiceMessage.srv in the services\_quiz package and have it complied. Now I got 10 for the quiz. Appreciate all the help!
