Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement in RobotModule in Python + load XML robot models #244

Open
rohanpsingh opened this issue Mar 30, 2022 · 3 comments
Open

Implement in RobotModule in Python + load XML robot models #244

rohanpsingh opened this issue Mar 30, 2022 · 3 comments
Labels
enhancement New feature or request Python Related to Python bindings

Comments

@rohanpsingh
Copy link
Contributor

I have two questions:

  • Is it possible to implement a RobotModule in Python? In the tutorial, it shows a C++ example only, so I assume it's not straightforward to do so in Python. Still, I would like to know how it could be done.

  • I want to build a parser for XML models so I'd be able to something likeinit(rbd::parsers::from_xml_file(xml_path)) while creating the robot module. A, do you think it is a good idea? and, B, do you have any pointers?

@gergondet
Copy link
Member

Hi Rohan,

Is it possible to implement a RobotModule in Python?

No but it isn't impossible to implement either.

Still, I would like to know how it could be done.

You need two pieces:

  • a Python object that the user can creates that contains a RobotModule C++ object, we already have this in the bindings (ref) but the implementation does not allow you to overwrite every member in RobotModule
  • a loader from Python to C++. Since RobotModule does not implement any behavior I think the simplest approach is to have a Python module similar to the Python controller but it will just instantiate a Python RobotModule object so that you can extract the C++ RobotModule from inside.

You would use the loader as such:

MainRobot: Python#my_module.MyRobot

Where MyRobot is a Python class that derives from mc_rbdyn.RobotModule that you instantiate in the Python RobotModule (and then extract the C++ RobotModule from the object)

do you think it is a good idea?

I would avoid using the name from_xml_file since it's a little too broad and you probably have a particular kind of XML model in mind (so e.g. from_mujoco_xml_file?)

do you have any pointers?

Not really. The only thing the function has to do is return a rbd::parsers::ParserResult and from there most of the work is done :)

@gergondet
Copy link
Member

Hi @rohanpsingh

Is this still an active topic for you?

@rohanpsingh
Copy link
Contributor Author

Hi @gergondet
Sorry I got involved with several other stuff recently so did not have time to work on this.
I started implementing your suggestions above and ultimately want to get this done, but it's currently a low priority for me.

@gergondet gergondet added enhancement New feature or request Python Related to Python bindings labels Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Python Related to Python bindings
Projects
None yet
Development

No branches or pull requests

2 participants