0
$\begingroup$

Rosanswers logo

Hi community,

I am trying to write my own ik solver using python. Here, I found an example of a custon ik plugin implemented in c++. My question is how it differs when the plugin is written in python. Below the steps that I planned:

  1. Download the plugin from the link above.
  2. In ur_kinematics/src change ur_moveit_plugin.cpp with my_ik_solver_plugin.py
  3. catkin_make install
  4. In kinematics.yaml file change the solver to my solver...

But how should the CMakeLists.txt be changed ? Do I have to care about the CMakeLists when I write the plugin in python?


Originally posted by xman236 on ROS Answers with karma: 51 on 2020-04-20

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

2. In ur_kinematics/src change ur_moveit_plugin.cpp with my_ik_solver_plugin.py

[..]

4. In kinematics.yaml file change the solver to my solver...

This will not work.

(MoveIt) IK plugins can only be written in C++ right now, so what you suggest will not work.


Edit: what you could potentially do is write a stub/wrapper C++ IK plugin which embeds a Python interpreter and then forwards calls to the C++ methods of the IK solver plugin to the Python interpreter.

But that would not be a typical setup, and would probably require quite a bit of development. There is no documentation about this either.


Originally posted by gvdhoorn with karma: 86574 on 2020-04-21

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by xman236 on 2020-04-21:
Thank you for sharing the info: "IK plugins can only be written in C++". Are there any other plugins (e.g. trajectory planner, motion planner, etc) that is limited to C++. Is there a list or where do you have the information from?

Comment by gvdhoorn on 2020-04-21:
I would say (from experience): almost everything in ROS 1 which is called a "plugin" and which is not an RQT plugin typically only supports C++.

At least MoveIt's plugin infrastructure is C++ oriented.

Comment by xman236 on 2020-04-21:
Please allow me to ask you one more newbi question...If the standard language for ROS1 is C++ how do the other developers cope with the all AI algorithms developed in python?

Comment by gvdhoorn on 2020-04-21:\

If the standard language for ROS1 is C++

pedantic, but that's not what I wrote.

I stated that for pluginlib plugins (which is what you asked about), C++ is the only language supported. That is something else.

how do the other developers cope with the all AI algorithms developed in python?

Tbh I wouldn't know, as I'm not one of those developers. But the whole point of wrapping algorithms in ROS nodes is to use their ROS API to communicate (ie: topics, services and actions) instead of function/method calls (ie: linking code together at the object level).

So one way I could imagine would be by invoking services, publish and subscribing messages and using action servers.

Comment by gvdhoorn on 2020-04-21:
Another approach as I already alluded to would be to use wrappers such as pybind11 or boost::python and embedding Python interpreters inside C++ nodes/plugins. But that's not necessarily the first thing to do.

Comment by hashirzahir on 2020-04-22:
Yes what gvdhoorn says is accurate. I am a ROS developer who uses ROS on a frequent basis for robotic applications. Most ROS developers are familiar with both C++ and python, choosing the appropriate language / tools for the task at hand. I suspect a lot of the early infrastructure was written in C++ as it is likely more efficient and has a lot of advantages when planning out a huge architecture, which can be very problematic when done in python. However, python does have it strengths when it comes to quick prototyping, I use it often to quickly test out new algorithms or do some simple republishers or data processing. And python is also a good tool for higher level deep learning frameworks and computer vision applications since algorithms and configurations can be tested easily. However, most of the lower level control applications for robots are typically written in c++ since these rarely change.

$\endgroup$

Your Answer

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