Why does this error comes?

@bayodesegun

Sir, Why this error is there ??

AttributeError: type object ‘Empty’ has no attribute ‘_request_class’

Hi @bhuratsidhu,

You need to check your code, you are trying to use an object of type Empty (a ROS message I guess) wrongly (perhaps as a request object)

What is wrong is this ??

Yes.

You have imported two differrent Empty objects, so the last one imported will win. You should import (and use) the second one with another name. E.g:

from std_msgs.msg import Empty as EmptyMsg

Other suggestions:

  • Create the service last, just before rospy.spin(), so that all the global variables used with the callback will already exist.
  • Remove the rate object - it’s useless here: Proper use of rospy.Rate or ros::Rate

@bayodesegun

And what about this error ???

SyntaxError: Non-ASCII character ‘\xe2’ in file /home/user/catkin_ws/src/path_exam/src/distance_motion_service.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

And this is the code

@bayodesegun
Please can i know my mistake for the above error

@bayodesegun
Please can i know why is that error coming if there is nothing on that line 4

@bhuratsidhu,

Have you tried removing the line? Sometimes you think there’s nothing there but there is if the computer says so :wink:.

Yes , I have tried removing the line

Hi, are you able to solve this? There is/was definitely some strange character within the file. If you are not able to solve it yet, I’ll take a look.

@bayodesegun

No I wasnt able to solve it and that part was not corrected successfully

Please take a look

I have fixed the error.

I was able to fix it just by using the backspace button to remove the line. And when I put it back (using the RETURN key), the problem didn’t return! Weird things like this happen.

Now you have other errors to fix, among others:

  • you have used time without importing it.

Cheers.