6.4 Services Quiz

I am getting an error constantly for the quiz
please guide me through this

indent preformatted text by 4 spaces

#! /usr/bin/env python

import rospy

from my_custom_srv_msg_pkg.srv import BB8CustomServiceMessage, BB8CustomServiceMessageResponse

from geometry_msgs.msg import Twist

def my_callback(request):

rospy.loginfo("The Service move_bb8_in_square_custom has been called")

i = 0

while  i <=request.repetitions:

    move_square.linear.x = 1*request.size

    move_square.angular.z = 1.57

    move_sqaure.angular.y = 1*request.size

    move_ssquare.angular.z = 1.57

    my_pub.publish(move_square)

rospy.loginfo("Finished service move_bb8_in_square_custom")



response = BB8CustomServiceMessageResponse()

response.success = True

return response # the service Response class, in this case EmptyResponse

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

my_pub = rospy.Publisher(’/cmd_vel’, Twist, queue_size=1)

move_circle = Twist()

rate = rospy.Rate(1)

rospy.loginfo(“Service /move_bb8_in_square_custom Ready”)

rospy.spin() # mantain the service open.

Hello @Ankit_Kumar ,

Well, the error is clearly in this line

from my_custom_srv_msg_pkg.srv import BB8CustomServiceMessage, BB8CustomServiceMessageResponse

Apparently, your script is not able to do this import. Have you properly compiled this message in the my_custom_srv_msg_pkg package? In case you have done so, have you added this package as a dependency of the services_quiz package?

In any case, I’d suggest you create this custom message BB8CustomServiceMessage in the services_quiz package (instead of the my_custom_srv_msg_pkg package), as it is requested by the Quiz.

I tried creating BB8CustomServiceMessage in the services_quiz package. However, when I am running catkin_make it’s giving me this error.

I am using this file that you can download from -
https://i-030fb78b28a2e01e4.robotigniteacademy.com/39d681d8-df7f-422b-b814-28b26e738912/files/download/?id=6791512a-e6b7-47ae-b922-4bf4203fd190

Hello @Ankit_Kumar ,

I’ve done some modifications that should fix this error you showed in the image.

I tried everything yet I this error is coming. Please guide me through this it’s being more than two weeks I am struck at this. I might be doing wrong in Cmake and pakage.xml
here’s the download link
https://i-01bfc8d0c01bf3c90.robotigniteacademy.com/ff56753b-4488-4ca2-a116-a8f2ca0db650/files/download/?id=59c3384e-8645-41a7-8496-d480656c96af

Hello @Ankit_Kumar ,

This line of code

from my_custom_srv.srv import BB8CustomServiceMessage, BB8CustomServiceMessageRequest

says that you have a package named my_custom_srv where you have created the custom service message. From what the error is saying (No module named ‘my_custom_srv’) and what I can see in your screenshot, it looks like you don’t have this package.