0
$\begingroup$

Rosanswers logo

I am stuck in something that should be pretty easy... I have a service called "set_odometry", which I can use doing rosservice from the bash. This service is installed from apt-get so I don't have the code for it, I guess it is written in C++ but it shares the .srv file in /opt/kinetic/share/PATH_TO_SERVICE/set_odometry.srv

Now, I want to use it from my python based node. Of course, I can simply do a rosservice call from the script, but I think this is not the way to proceed. I am trying to use it as if it was a service that I defined, this means using rospy.ServiceProxy. However, I can not import the .srv in my python code. I have tried several ways to do

from set_odometry.srv import *

It always answers no module named set_odometry. I have included /opt/kinetic/share/PATH_TO_SERVICE/ in my python path, I have added init.py in the folder... nothing has worked so far. I think this should be something easy and standard to do, I mean, using another one's service from my code, but I am unable to do it.

Thanks in advance.


Originally posted by Bernat Gaston on ROS Answers with karma: 119 on 2020-05-12

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hi, I'm not sure about your definition of the service file. A quick google search lead me to https://github.com/RobotnikAutomation/robotnik_msgs/blob/master/srv/set_odometry.srv which provides a service definition and maybe was released for kinetic, so the path would be /opt/ros/kinetic/….

My assumption is you confused the package name with the service name here. Like in the Tutorial (http://wiki.ros.org/ROS/Tutorials/WritingServiceClient%28python%29) you have to from package_name.srv import *, so in your case from robotnik_msgs.srv import * (even though in general just import the things you need, so SetOdometry and SetOdometryRequest in this case)

If the command line command rossrv show robotnik_msgs/SetOdometry works, then the import statement of your python script should work as well.

Hope this helps.


Originally posted by ipa-jba with karma: 153 on 2020-05-12

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Bernat Gaston on 2020-05-12:
Thanks! it worked. Ok I understand the error that I was doing. Thank you so much

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.