Services_quiz_gradebot error

I don’t get any error in my Program and BB8 also move like in a square path ( not a perfect square but something similar). I can successfully launch my server.launch and client.launch and eveyrthing work fine. But I don’t know why Gradebot shows unable to launch services_quiz client. Can anyone help me any suggestions would be highly Appreciated.

Below is my bb8_move_custom_service_client.py

# scrubbed

And this is my bb8_move_custom_service_server.py

# scrubbed

My launch files are as follows:

call_bb8_move_in_square_custom_service_server.launch

<launch>
   <node
    pkg="services_quiz"
    type="bb8_move_custom_service_client.py"
    name="move_square" 
    output="screen"
  />
</launch>

start_bb8_move_custom_service_server.launch

<launch>
   <node
    pkg     ="services_quiz"
    type    ="bb8_move_custom_service_server.py"
    name    ="move_sqaure" 
    output  ="screen"
  />
</launch>

@bayodesegun @albertoezquerro . Could you please give me your valuable comment on this query. Thank you very much for your time.

Hi @balajigunasekeran22 ,

I want to tell this to you in a very clear way possible.
If you post incomplete codes and photographs instead of screenshots, it really frustrates us.
It frustrates people like me who are willing to help you. Imagine how it would frustrate the admins who are constantly dealing with the same issues from every new person like you!

Next time onwards, PLEASE, post the complete code and actual screenshot taken by pressing the “Print Screen” button on your keyboard.

Now to your problem:
Did you actually do what the error said?
Have you named your program and launch files as per instructions?

Regards,
Girish

Hi @girishkumar.kannan

I have updated the post as you mentioned in your previous comment. And I also did check my file names too for your reference I have mentioned the exact file names That I use in my package. Thank you for fast response.

  • Balaji
1 Like

Hi @balajigunasekeran22 ,

Your service server launch file has a lot of spaces. Improperly formatted launch files throw a lot of errors. I have faced similar issues before.

Try to fix the launch file formatting and run your package again. That should solve the problem.

Let me know if this did not solve the problem.

Regards,
Girish

EDIT: Just realized something, your server and client node names are same. So one of your programs will not work properly. Change the node name of the server to “move_square_server” and for the client, “move_square_client”. You will have to do the corresponding changes in the launch files too, in the name parameter.

Hi @girishkumar.kannan ,

I tried as you mentioned and still I face the same error in gradebot. Now I am clueless

start_bb8_move_custom_service_server.launch

<launch>
   <node
    pkg="services_quiz"
    type="bb8_move_custom_service_server.py"
    name="move_sqaure_server" 
    output="screen"
  />
</launch>

call_bb8_move_in_square_custom_service_server.launch

<launch>
   <node
    pkg="services_quiz"
    type="bb8_move_custom_service_client.py"
    name="move_square_client" 
    output="screen"
  />
</launch>

Hi @balajigunasekeran22 ,

Ok. I see that you have made the changes.

Did you try running the service server and service client on your terminal before submitting to the gradebot?
Did your service server and service client work without any issues?

Also, if they work fine on the terminal, could you share the terminal output screenshots of the server and the client working?
This way we can be certain that the gradebot has some issue and not your program.

Regards,
Girish

Hi @girishkumar.kannan ,

Here are the screenshots of service_server and the service_client in terminal.

server running in Terminal I pressed Cntrl + C after client file was launched successfully completed

client running in terminal

Hi @balajigunasekeran22 ,

Both your pictures are the same. Please re-upload the correct images.

Regards,
Girish

Pardon @girishkumar.kannan. I did update the correct images now please do reference in previous images. Thank you

Hi @balajigunasekeran22 ,

The above two images that you have posted (even after re-uploading) are still the same.

I immediately knew they were wrong images just by looking at them.

  1. You cannot run the Server and the Client in the same terminal.
  2. Also, you are running the same command on both the images that you have posted.

I think you have not understood my previous post correctly, so here is what I want you to do.

  1. Launch your service server and let it run in Webshell/Terminal 1.
  2. Wait for 10 seconds so that the service server is up and running.
  3. Launch your service client and let it run in Webshell/Terminal 2.
  4. Wait for 10 seconds so that the service client completes its routine.
  5. DO NOT PRESS CTRL+C ON ANY TERMINAL.
  6. Got to Webshell/Terminal 1 and take a screenshot - save it as service_server.png
  7. Got to Webshell/Terminal 2 and take a screenshot - save it as service_client.png
  8. Finally, post these two images as a new reply. DO NOT EDIT the previous post.

I hope I am clear this time.

Regards,
Girish

client

Server

Now its the server and client images

Regards,
Balaji

Hi @balajigunasekeran22 ,

I see that your service server and client has worked well.
Although, your service server seems to print "Stop message sent" for every step of movement. (This is because of your program, you have copy-pasted print statements for stop(), move_straight() and rotate()).

So, at this point, with the assumption that your file names are correct and you do not have any other mistakes, I would say that the gradebot has some problem.

Now I guess The Construct team can help you out.

Regards,
Girish

@bayodesegun @constructrosteaching Can you please help me with my issue ???

I’ll have a look later today. It’s likely to be one simple thing missing.

Thank you @girishkumar.kannan and @bayodesegun for your help. Looking to hearing from you.

The problem is that your code is not doing what the quiz asked it to do, so it is exiting earlier than it should:

  • 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 launch that starts it will be called call_bb8_move_in_square_custom_service_server.launch.

Your code must make the BB8 move three times: twice for the small square and once for the big square. I checked that your code is making the robot move one small square only.

Please fix that and your code should pass. You are already more than halfway done!

Hi @bayodesegun ,

As from your last reply I have adjust my client_server.py to make the robot move three time (Twice for small square and once for the big one).

But still i get the error that robot did not perform expected movements like in the image below.

So can I use time calculation to make the robot to move equally on all sides or is there any other method ??

That can still happen if it’s not moving the correct distance. Each side of the small square must be the length of one side of the square in the simulation, while that of the big square must be twice that.

You need to make the robot move these distances (or more) within the 3-minute deadline, neither too fast nor too slow.

I tried to correct my program as per your feedback. Can you please have a look at my modified code and give your feedback because I only have one last try to submit my assignment. My robot is moving in square path for twice in Small square and once in Big square. I would like to know whether my timing is correct or not

custom_service_client.py

#! /usr/bin/env python

import rospy
from rospy import Duration
from services_quiz.srv import BB8CustomServiceMessage, BB8CustomServiceMessageRequest

#from geometry_msgs.msg import Twist

rospy.init_node('move_square_client')
rospy.wait_for_service('/move_bb8_in_square_custom')
custom_client = rospy.ServiceProxy(
    '/move_bb8_in_square_custom', BB8CustomServiceMessage)

start_time = rospy.Time.now()

for i in range(2):
    custom_client_object = BB8CustomServiceMessageRequest()
    custom_client_object.side = 1.0
    custom_client_object.repetitions = 1
    result = custom_client(custom_client_object)
    rospy.loginfo('small square Completed')

# Update time
end_time = rospy.Time.now()
duration = end_time - start_time
duration_sec = duration.to_sec()
#duration_sec = duration.to_sec()
print("Completed 2 small squares in ",  duration_sec)

# check time
if duration_sec <= 120:
    print(" Completed small square in ", duration)


custom_client_object = BB8CustomServiceMessageRequest()
custom_client_object.side = 2.0
custom_client_object.repetitions = 1
result = custom_client(custom_client_object)
rospy.loginfo('Big square Completed')
print("Service_server is called")

# Update time
end_time = rospy.Time.now()
duration = (end_time - start_time).to_sec()
print("Completed Big squares in ",  duration)


custom_service_server.py


#!/usr/bin/env python
from math import pi
import rospy
from services_quiz.srv import BB8CustomServiceMessage, BB8CustomServiceMessageResponse
from geometry_msgs.msg import Twist
pi = 3.14159


def stop():
    # define the above mentioned function and send the twist messages here
    move.linear.x = 0.0
    move.angular.z = 0.0
    pub.publish(move)
    if not rospy.is_shutdown():
        rospy.loginfo("Stop")
    else:
        rospy.logerr("Failed to stop")
    # print('-X-')


def move_straight(side):
    move.linear.x = 0.30 * side
    move.angular.z = 0.0
    pub.publish(move)
    if not rospy.is_shutdown():
        rospy.loginfo("Moving straight")
    else:
        rospy.logerr("Failed to move straight")
    # print('->')


def rotate(angle):
    move.linear.x = 0.0
    move.angular.z = 1.0
    time = abs(angle / 1.0)
    pub.publish(move)
    if not rospy.is_shutdown():
        rospy.loginfo(" Rotating")
    else:
        rospy.logerr("Failed to rotate")
    rospy.sleep(time)
    # print('->')


def callback(req):
    side = req.side
    response = BB8CustomServiceMessageResponse()
    for i in range(req.repetitions):
        for j in range(4):
            move_straight(side)
            rospy.sleep(2)
            stop()
            rospy.sleep(2)
            rotate(pi/2)
            stop()
            rospy.sleep(2)
            pub.publish(move)
    response.success = True
    return response


if __name__ == "__main__":
    rospy.init_node('move_square_server')
    rospy.loginfo('service service started')
    shan_service = rospy.Service(
        '/move_bb8_in_square_custom', BB8CustomServiceMessage, callback)
    pub = rospy.Publisher('/cmd_vel', Twist, queue_size=10)
    move = Twist()
    rospy.spin()

@girishkumar.kannan @bayodesegun