I have submitted the Services Quiz. I failed to pass the condition: BB8 did not move enough. Can anyone explain what this means and what I can do to rectify it?
Hello @somikdhar327 ,
It sounds like the square performed by the robot is not big enough. Try making the robot perform a bigger square (bigger radius).
I have been trying but it is still showing the same.
Here is my server code:
#! /usr/bin/env python
import rospy
from services_quiz.srv import BB8CustomServiceMessage, BB8CustomServiceMessageResponse
from geometry_msgs.msg import Twist
pub = None
def my_callback(request):
move_square = Twist()
move_square.linear.x = 0
move_square.angular.z = 0
distance = request.side
repeat = request.repetitions
wait_time = distance
while repeat > 0:
j=0
while j < 4:
move_square.linear.x = 0.2
move_square.angular.z = 0
pub.publish(move_square)
rospy.sleep(wait_time)
move_square.linear.x = 0
move_square.angular.z = 0
pub.publish(move_square)
rospy.sleep(1)
move_square.linear.x = 0
move_square.angular.z = 1.57
pub.publish(move_square)
rospy.sleep(1)
move_square.linear.x = 0
move_square.angular.z = 0
pub.publish(move_square)
rospy.sleep(0.5)
j += 1
#make_square(distance)
repeat -= 1
my_response = BB8CustomServiceMessageResponse()
my_response.success = True
return my_response
def main():
global pub
rospy.init_node('service_move_bb8_in_square_custom_server')
my_service = rospy.Service('/move_bb8_in_square_custom', BB8CustomServiceMessage , my_callback) # create the Service called move_bb8_in_circle with the defined callback
pub = rospy.Publisher('/cmd_vel',Twist,queue_size = 1)
if name == āmainā:
main()
Is there any fault in the logic?
In the client side I have give sides as 1 and 4 for small and big square respectively.
This is my error showing in the grader
Can you share the actual behavior of the robot working with your program?
I see that the wait_time
you define is the distance specified by your server. If you specify a short distance (say 0.5 meters), then the robot will only move for 0.5 seconds per side. This means that The square is probably too small.
My robot is completing the square. As you have mentioned the square may be too small. So how can I decide what time to select to make the square move for a sufficient distance?
The small square needs to be 1 sqm, and the big one 2 sqm. This is specified in the instructions. You need to figure out how much time to publish your messages in order to satisfy those dimensions.
Can you please help me outā¦ I am stuck on the quiz related to services in ROS Basics in 5 days C++ courseā¦ Upon submission of quiz, I got āBB8 did not move enoughāā¦ I couldnāt find anything in the instructions like you have mentioned that āThe small square needs to be 1 sqm, and the big one 2 sqm.ā Can you please elaborate or give clear instructions for this quiz. I need this certificate badly.
Hi @talhawahab1947 , you are correct. This specification was not stated in the C++ course. I have just added it. Please let me know if you need an extra submission attempt.
@roalgoal Yes pleaseā¦ If you can please give back my 4 wasted submissions because i tried the same code for 4 timesā¦ And can you please confirm that the big square needs to be of 2 sqm (1.414mX1.414m)? Thank youā¦
I have replied you on this post: