Hello
I have tried completing the services quiz. While it seems like the robot turns correctly compared to the GIF in the notebook, the autograder fails me with the following message:
“The robot did NOT fully perform the expected turn”
I watched the movement closely for a while, and it seems like the robot continues to drift a very tiny bit to the right. This seemed weird, so I changed the script to specifically set all the values for both linear and angular velocities of the /cmd_vel topic to 0.0. Sadly this did not fix the drifting, and even when I echo the commands sent to the /cmd_vel topic, the last message published is:
linear:
x: 0.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0
Here is the used service callback function:
def turn_service_callback(self, request, response):
# The callback function receives the self-class parameter,
# received along with two parameters called request and response
# - receive the data by request
# - return a result as a response
# create a Twist message
msg = Twist()
msg.linear.x = 0.0
msg.linear.y = 0.0
msg.linear.z = 0.0
msg.angular.x = 0.0
msg.angular.y = 0.0
msg.angular.z = 0.0
if request.direction == "right":
msg.angular.z = -request.angular_velocity
self.get_logger().info(f'Turning right with a velocity of {request.angular_velocity} rad/s for {request.time} seconds!!')
self.publisher_.publish(msg)
response.success = True
# Sleep for movement duration
time.sleep(request.time)
# Stop turning
self.get_logger().info('Done with movement!')
msg.angular.z = 0.0
self.publisher_.publish(msg)
elif request.direction == "left":
msg.angular.z = request.angular_velocity
self.get_logger().info(f'Turning left with a velocity of {request.angular_velocity} rad/s for {request.time} seconds!!')
self.publisher_.publish(msg)
response.success = True
# Sleep for movement duration
time.sleep(request.time)
# Stop turning
self.get_logger().info('Done with movement!')
msg.angular.z = 0.0
self.publisher_.publish(msg)
return response
Any help would be highly appreciated!