I am trying to run the given solution, but I keep getting an error regarding the existence of the EmptyResponse and EmptyRequest in the std_srvs.srv module.
Specifically the error says “No name ‘EmptyRequest’ in module ‘std_srvs.srv’”
I am trying to run the given solution, but I keep getting an error regarding the existence of the EmptyResponse and EmptyRequest in the std_srvs.srv module.
Specifically the error says “No name ‘EmptyRequest’ in module ‘std_srvs.srv’”
Hi @bethanyannec ,
Welcome to this Community!
From the info that you have posted, I can understand that you are working on ROS Basics in 5 Days in Python, and on the Services Unit.
And, since you need Request
, I am assuming you are working on Service Client.
I am sure that you are getting this error on the IDE function hinting popup tooltip window.
Please do not follow those error hinting/suggestions by the IDE. It is sometimes misleading.
Reason: The IDE has no clue where the import files are located.
These Request
and Response
classes for any ROS message are created upon compilation of that message. ROS built-in messages like std_srvs
comes precompiled and they are most of the times not detected by the IDE. This often happens in custom service and action messages where one of the parts of the message is blank / empty.
The only errors that you should be concerned about is when you build your package or during execution.
Python based packages mostly gives an error during runtime / execution, while for C++, you will get during compilation / build time. This is only in case of ROS1.
So, in conclusion,
You know a service message exists in ROS1 when you do rossrv list
, the service message is listed. If the service message exists, then you can surely use <Srv>Request
and <Srv>Response
classes, even if the IDE tells you that they do not exist.
I hope I clarified your doubts.
Regards,
Girish
Hi @bethanyannec ,
rossrv list
shows only the available service messages on the system that has ROS1 installed.
rosservice list
shows the available services that are currently active in the system.
Do not confuse them.
If you cannot find a certain service message when you do rossrv list
then the message is either not defined or compiled.
You can run a service with any service message, but if the service message is not available, then you will just not be able to use that particular service message. You can otherwise still run any service.
I hope this clarified your doubts. Let me know if you still have any questions.
Regards,
Girish
One more question – is it possible to run this service with the IDE error beyond seeing it in the rosservice list? When I try to run the service I get the following error,
“shutdown request: [/service_move_bb8_in_circle_server] Reason: new node registered with same name”
even though I have the files named exactly the same as the solution set. I have tried experimenting with the names of the nodes as well to ensure that none of them are named the same, and this issue still appears. Additionally, I have reconfigured the environment using the rm functions and the catkin_make and resourcing.
I am not sure if this is coming from the IDE error, or some other issue that I am not understanding.
Hi @bethanyannec ,
The error message gives you the reason very clearly. There seems to be two nodes running with the same node name. Mostly because you are (accidentally) running the same program in two terminals or one of the program was not terminated before the same program was started again.
Try closing all running programs in the webshells / terminals and launch the program again.
This should resolve your problem. Let me know if this does not.
Regards,
Girish
I am still getting this same error. I have the named the python file “bb8_move_in_circle_service_server.py” located in a folder under ~/catkin_ws/src/unit_5_services/scripts and the launch file “start_bb8_move_in_circle_service_server.launch” in ~/catkin_ws/src/unit_5_services/launch
The contents of these files is copy and pasted from the solution with the exception of changing the package name to “unit_5_services” in the launch file.
My process is changing the working directory to the catkin_ws in both web shells.
In the first shell I run rosrun unit_5_services bb8_move_in_circle_service_server.py
This seems to work fine until the launch is ran.
In the second shell I run roslaunch unit_5_services start_bb8_move_in_circle_service_server.launch
At this point, the error shows in the first webshell, and both processes are exited.
As an outside test, I have tested the service using rosservice call /move_bb8_in_circle
This succeeds in calling the service. The only error right now is coming from the actual launching process.
I am also getting this same error while proceeding with other examples. I believe there must be something wrong with either my launch file process or something that I am completely missing.
Hi @bethanyannec ,
Just like I said, you are running the same program on two webshells (without you actually knowing it). That is understandable. No problem, just a beginner mistake.
In the python file bb8_move_in_circle_service_server.py
the node name is defined as move_bb8_in_circle_service_server
.
So start_bb8_move_in_circle_service_server.launch
actually launches the the node whose name is move_bb8_in_circle_service_server
.
Also, rosrun unit_5_services bb8_move_in_circle_service_server.py
does the same thing as roslaunch unit_5_services start_bb8_move_in_circle_service_server.launch
.
Do you see the conflict here? The node names are the same in the file launched by rosrun ...
as well as roslaunch ...
.
The only difference is that, when you do rosrun ...
you are launching just the single node without any other nodes.
Whereas in a launch file, you have the ability to launch several nodes along with the main node that you want to launch.
**Only in ROS1,** rosrun ...
would do the same thing as roslaunch ...
for just that single node. [You cannot do this in ROS2].
No. There is nothing wrong in your files and you are not missing anything. You just did not understand the concept that I have described above - the relation between rosrun ...
and roslaunch ...
command lines.
I hope I clarified your doubts. Let me know if you are still unclear.
Regards,
Girish
I now understand. Thank you very much for your help!