can i use python with ros_control package ?
Hello there,
I am building a custom robot and i need to use roscontrol to take advantage of it's functions, I am used to writing in Python and not C++ but the implementation of roscontrol is in C++ and I am not very proficient with it, so is there's a way to use Python instead or how can I deal with this situation ?
Asked by karim on 2018-06-26 11:09:07 UTC
Answers
is there's a way to use Python instead
No, unfortunately not.
Edit: well, it depends actually. What do you want to do exactly? Communicate with a ros_control
based robot (ie: send trajectories and setpoints), or write your own controllers and/or hardware_interface
implementations? The former is perfectly possible with Python, the latter basically requires C++ (although it could be interesting to see whether something like boost::python
could be used).
Asked by gvdhoorn on 2018-06-26 11:11:52 UTC
Comments
I want to write the hardware_interface in python, I am using a RPi so it would be perfect for me if I could do so
Asked by karim on 2018-06-26 11:26:25 UTC
Then the 'default' answer would be: no, you cannot use Python for that.
If you feel adventurous, and know what you are doing, you could see whether boost::python
in combination with the c-api would work. You could write a very simple hardware_interface
implementation that essentially forwards all calls to a Python module that is loaded and interacted with using the c-api
.
But to get that hardware_interface
in place, you'd have to use C++, so perhaps this is a catch-22.
Asked by gvdhoorn on 2018-06-26 11:40:39 UTC
awesome, I will see what can I do and tell you if I got positive results :)
Asked by karim on 2018-06-26 11:52:09 UTC
As I wrote: you're going to have to use C++ to be able to integrate the Python stuff, so I'm not sure how much sense all of this makes, but ok.
Asked by gvdhoorn on 2018-06-26 14:47:49 UTC
Hi @karim I wanted to ask if you found a solution for this issue?
Asked by azerila on 2020-06-15 09:41:31 UTC
@gvdhoorn "You could write a very simple hardware_interface implementation that essentially forwards all calls to a Python module that is loaded and interacted with using the c-api."
Would it be safe to do this in a realtime enviroment like ros_control?
Asked by Neuromorphic on 2020-08-23 11:47:11 UTC
Would it be safe to do this in a realtime enviroment like ros_control?
Most likely not.
But there are plenty of people who write a hardware_interface
which communicates using topics or services, or even a plain TCP/IP connection. So in those cases adding one more non-deterministic element won't change anything.
Asked by gvdhoorn on 2020-08-23 14:44:32 UTC
Comments