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

Update Python package with new ScenarI/O APIs #176

Merged
merged 35 commits into from
Apr 20, 2020

Conversation

diegoferigo
Copy link
Member

@diegoferigo diegoferigo commented Apr 15, 2020

This PR updates most of the Python resources to work with the new ScenarI/O APIs. In particular:

  • Removes the former Robot interfaces in favour of the new Model interface
    • Remove Python Robot interfaces ceccd7f
    • Remove GazeboRobot class a113c01
    • Add new interfaces for Scenario Model classes 2325327
    • Add new cartpole and pendulum examples 981285e
  • Remove PyBullet, it will be substituted by the new bullet backend of ignition physics as soon as it lands upstream

What's more meaningful to review are the following items:

  • Update Task in e49366d. Now the task no longer exposes also the gym.Env interfaces. It's only the selected runtime that exposes it. This allows treating the runtime as environment and not anymore as wrapper, removing a forwarding step.
  • Update GazeboRuntime to use ScenarI/O bindings 70404c1

This PR is already quite heavy and I don't want to add anything else. The environments will be still composed of a Runtime and a Task, but now this is no longer enough. In fact, there will be a third component that populates the environments: the Randomizer (and they are implemented as environment wrappers that extend gym.Env.reset()). The introduction of randomizers was necessary to allow Tasks to operate on multiple models. The next PR will introduce them.

@diegoferigo diegoferigo self-assigned this Apr 15, 2020
@diegoferigo diegoferigo changed the title Updat Python package with new ScenarI/O APIs Update Python package with new ScenarI/O APIs Apr 15, 2020
They are relay classes that wrap a scenario::base::Model class
@diegoferigo
Copy link
Member Author

Ready to be reviewed

@diegoferigo diegoferigo marked this pull request as ready for review April 19, 2020 16:58
@@ -50,6 +50,7 @@ namespace scenario {
std::string getModelFileFromFuel(const std::string& URI,
const bool useCache = false);
std::string getRandomString(const size_t length);
std::string getInstallPrefix();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to document that this is only valid if gym-ignition is installed in Developer mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I take advantage and I will document all the utils functions together in a new commit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9e8f58e

@@ -94,6 +94,11 @@ target_link_libraries(ScenarioGazebo
set_target_properties(ScenarioGazebo PROPERTIES
PUBLIC_HEADER "${SCENARIO_PUBLIC_HDRS}")

if(NOT CMAKE_BUILD_TYPE STREQUAL "PyPI")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make life complicated for anyone packaging the project in any form, being it as part of a superbuild, as Debian packages or a conda recipe. Instead of conflating build logic and packaging logic, could we have an explicit CMake variable to select if the gym-ignition project get installed in User mode or Developer mode, and then just specify the default based on the CMAKE_BUILD_TYPE , something like:

if(NOT CMAKE_BUILD_TYPE STREQUAL "PyPI")
  set(GYM_IGNITION_DEVELOPER_MODE_DEFAULT ON)
else()
   set(GYM_IGNITION_DEVELOPER_MODE_DEFAULT OFF)
endif() 
option(GYM_IGNITION_DEVELOPER_MODE "If ON, gym-ignition is installed in Developer mode, otherwise in user mode" ${GYM_IGNITION_DEVELOPER_MODE_DEFAULT})
if(GYM_IGNITION_DEVELOPER_MODE)
    target_compile_options(ScenarioGazebo PRIVATE
        -DGYMIGNITION_CMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
endif()

Copy link
Member Author

@diegoferigo diegoferigo Apr 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion of propagating the build type as normal option. I will have a look at it. I don't remember precisely why we had to define a new build type for PyPI in the first place, for sure I tried to use a normal CMake variable as first attempt and then I faced problems that led me to this build type workaround, that is much more convoluted. What I'm sure is that I didn't do it if there were more simple solutions :)

I am planning to give a refreshing also to the CMake project, I will keep you comment in mind.

This will make life complicated for anyone packaging the project in any form, being it as part of a superbuild, as Debian packages or a conda recipe.

This is something I don't understand. The PyPI type is not meant to be used by any downstream user or packager. It is meant to be used to create packages for PyPI, as the name (and we are the maintainers of the packages). Any other usage is not supported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make life complicated for anyone packaging the project in any form, being it as part of a superbuild, as Debian packages or a conda recipe.

This is something I don't understand. The PyPI type is not meant to be used by any downstream user or packager. It is meant to be used to create packages for PyPI, as the name (and we are the maintainers of the packages). Any other usage is not supported.

Exactly. With this modification, now the only way to properly install gym-ignition in a relocatable way is to set the CMAKE_BUILD_TYPE to PyPI, and I guess that this is not supported if you are not installing for PyPI. I guess we want to support "proper" installation also if the project is not installed with PyPI .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ow ok now I understood your initial point: supporting a relocatable installation which could be implemented in the same way we package the project for PyPI.

Note the using PyPI for this purpose is wrong. In fact, due to how the shared libraries must be placed in the site_package folder, you need to have the following installation tree:

install_tree/
├── gym_ignition
│   ├── [...]
│   ├── __init__.py
│   └── plugins
│       ├── libControllerRunner.so
│       ├── libECMProvider.so
│       ├── libJointController.so
│       └── libPhysicsSystem.so
├── gym_ignition_environments
│   ├── __init__.py
│   └── [...]
├── libECMSingleton.so
├── scenario_bindings.py
└── _scenario_bindings.so

As you can see, shared libraries are installed in the root of the CMAKE_INSTALL_PREFIX, and plugins inside gym_ignition/plugins. This is not what you want to obtain in a regular installation! In light of this, we should start thinking how to make coexist a (static) relocatable Developer installation with the PyPI build type without messing too much with the CMake project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what you want to obtain in a regular installation! In light of this, we should start thinking how to make coexist a (static) relocatable Developer installation with the PyPI build type without messing too much with the CMake project.

Yes, we can also have a separate issue for that.

@diegoferigo diegoferigo merged commit 424d295 into robotology:refactoring Apr 20, 2020
@diegoferigo diegoferigo deleted the refactor/python branch April 20, 2020 12:59
Gazebo simulator.

Args:
task_cls: The class of the handled task.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which classes are supported?

Comment on lines +121 to +122
# Execute a paused step
ok_run = self.gazebo.run(paused=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to explain the meaning of and need for a paused step in this context somewhere in the documentation in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link for future #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants