Services_quiz feedback

Hello,
I am stuck in completing services_quiz, The below-attached image is the reference for my quiz. Could anyone please help me where I am going wrong.

It is hard to say without seeing your execution. I’m guessing your squares were either not big enough, or you did not move enough.

Hi @rekhagouda27,

We have checked your package. There were some errors there. For instance, in the main part of the code:

rospy.init_node('service_server')
my_pub=rospy.Publisher('/cmd_vel',Twist,queue_size=1)
move_square=Twist

The message twist message is defined wrong, it has to be:

move_square=Twist()

Also, when you call the service the robot just starts on rotating in the Z-axis, but it is asked to perform a square.

Please look into any other bugs you might have and also ensure that the robot actually performs the specified task as said before submitting again.

If you need further clarifications, please let us know.

Hello, I did edit my code and tried again, i still get the same errror… Below code is my logic

size=2*float(request.side)

n=int(request.repetitions)

if((size>=1.0) and (size<2.0)): 

     for i in range(0,(2*n)):

           move_square.linear.x=0.2

           my_pub.publish(move_square) 

           rate.sleep()  

     for i in range(1,(2*n)):

           move_square.angular.z=-0.2

           my_pub.publish(move_square) 

           rate.sleep()      

elif(size>=2.0):

     

     for i in range(0,(n)):

        move_square.linear.x=0.2

        my_pub.publish(move_square) 

        rate.sleep() 

     

     for i in range(0,(n)):

      move_square.angular.z=-0.1

      my_pub.publish(move_square) 

      rate.sleep()

Please let me know where i am going wrong

Yes, in the second for loop, it has to be (0, 2*n)…

Hi @rekhagouda27,
Did you test and run your code before submitting it to the quiz? Did the robot actually move in a square motion as requested? I cannot see how your code would achieve that. To move in a square you have to do the following for EACH square:

move straight for some time -> stop -> turn for some time -> stop ->
move straight for some time -> stop -> turn for some time -> stop ->
move straight for some time -> stop -> turn for some time -> stop ->
move straight for some time -> stop -> turn for some time -> stop ->

what you seem to be doing for the WHOLE sequence, not just each square is the following:
move forward for some time -> turn while still moving forward

that’s it. To stop moving straight, you have to set

move_square.linear.x=0.0

and then publish it.

you are right. when i tried adding the move_square.linear.x=0.0

that is move_square.linear.x=0.2
move_square.angular.z=0

     move_square.angular.z=-0.2
     move_square.linear.x=0

then, robot does not move at all

I am trying with this logic

That looks better. But you know that you can launch your code without the quiz right? Test and refine it until it works, only then submit it.

1 Like

In the Client_server program,

#!/usr/bin/env python

import rospy

import rospkg

from services_quiz.srv import BB8CustomServiceMessage,BB8CustomServiceMessageRequest

rospy.init_node(‘service_client’)

rospy.wait_for_service(’/move_bb8_in_square_custom’)

move_bb8_in_square_custom_service_client=rospy.ServiceProxy(‘move_bb8_in_square_custom’,BB8CustomServiceMessage)

move_bb8_in_square_custom_object=BB8CustomServiceMessageRequest()

move_bb8_in_square_custom_object.side=1.0

move_bb8_in_square_custom_object.repetitions=1

rospy.loginfo(“Doing service call”)

result=move_bb8_in_square_custom_service_client(move_bb8_in_square_custom_object)

rospy.loginfo(str(result))

rospy.loginfo(“End of Service call”)

Do i need to mention the cases ? because my program works fine, when i launch the client_server program , My program runs only for the iteration i mention either Small sized circle. If i want to run the Bigger sized circle, I must change my values and then run.

I want to submit my assignment, just if i get confirmation on this. Can anyone please guide me with this

Can i please get a response?

Hi @rekhagouda27,

Here is a hint, from the instructions in the quiz:

Create a new service client that calls the service /move_bb8_in_square_custom , and makes BB-8 move in a small square twice and in a bigger square once . It will be called bb8_move_custom_service_client.py . The small square has to be of, at least, 1 sqm . The big square has to be of, at least, 2 sqm .

Before submitting the quiz, I suggest you review the instruction again and ensure that your quiz package is working as expected and that everything has been named as specified.

Thanks a lot for your reply.

1 Like