ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

can i use python with ros_control package ?

asked 2018-06-26 11:09:07 -0500

karim gravatar image

Hello there,

I am building a custom robot and i need to use ros_control to take advantage of it's functions, I am used to writing in Python and not C++ but the implementation of ros_control 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 ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-06-26 11:11:52 -0500

gvdhoorn gravatar image

updated 2018-06-26 11:13:12 -0500

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).

edit flag offensive delete link more

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

karim gravatar image karim  ( 2018-06-26 11:26:25 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-26 11:40:39 -0500 )edit

awesome, I will see what can I do and tell you if I got positive results :)

karim gravatar image karim  ( 2018-06-26 11:52:09 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-26 14:47:49 -0500 )edit
1

Hi @karim I wanted to ask if you found a solution for this issue?

azerila gravatar image azerila  ( 2020-06-15 09:41:31 -0500 )edit

@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?

Neuromorphic gravatar image Neuromorphic  ( 2020-08-23 11:47:11 -0500 )edit
1

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.

gvdhoorn gravatar image gvdhoorn  ( 2020-08-23 14:44:32 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-06-26 11:09:07 -0500

Seen: 2,030 times

Last updated: Jun 26 '18