Inserting ROS code in a NON-ROS project
Hi,
I have a non-ros simulation running in which I receive xy-coordinates. Now I want to pass those coordinates to my ROS node. How do I short circuit my other program to do this since running the ROS package requires me to use rosrun package name filename. I can not seem to find a solution or relevant keywords for this scenario.
Asked by hassamsheikh1 on 2018-10-02 12:57:06 UTC
Answers
I just figured out, for ROSPY you do not need to do any of that stuff. You can simply use ros code like standard python code.
Asked by hassamsheikh1 on 2018-10-02 13:07:33 UTC
Comments
A quick and dirty method to achieve this is using a system call to execute the rostopic command line utility.
The command:
rostopic pub -1 my_topic geometry_msgs/vector3 '{x: 0.1, y: 1.1, z: 2.1}'
Will publish a single message of the topic then return. You can execute this command from a non ROS c program using the system function from stdlib.h. There are better ways of achieving this but none of them are as simple as this.
It's worth noting that you can execute ROS nodes by simply executing the binary as well as using rosrun
. It's just a bit trickier to find where those binaries actually exist if you're not used to the directory structure.
Hope this helps.
Asked by PeteBlackerThe3rd on 2018-10-02 13:09:18 UTC
Comments
I just found out that if you are using ROSPY, you do not need to do any of that stuff. Just use ros code as standard python code. It will work
Asked by hassamsheikh1 on 2018-10-02 13:11:05 UTC
Comments
nitpick: but that is not needed at all.
Asked by gvdhoorn on 2018-10-03 02:52:34 UTC