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

Inverse kinematic solver generation/integration in Python

asked 2020-04-20 17:55:28 -0600

xman236 gravatar image

updated 2020-04-21 07:37:38 -0600

gvdhoorn gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-04-21 04:56:11 -0600

gvdhoorn gravatar image

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.

edit flag offensive delete link more

Comments

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?

xman236 gravatar image xman236  ( 2020-04-21 05:13:34 -0600 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-21 05:31:16 -0600 )edit

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?

xman236 gravatar image xman236  ( 2020-04-21 07:28:50 -0600 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-21 07:40:17 -0600 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-21 07:41:03 -0600 )edit
1

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

hashirzahir gravatar image hashirzahir  ( 2020-04-22 07:26:34 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-04-20 17:55:28 -0600

Seen: 494 times

Last updated: Apr 21 '20