OpenAI ROS Core

This is the heart of OpenAI ROS. Here you can finc the classes that tie ROS, Gazebo and OpenAi together.

openai_ros.robot_gazebo_env module

class openai_ros.robot_gazebo_env.RobotGazeboEnv(robot_name_space, controllers_list, reset_controls, start_init_physics_parameters=True, reset_world_or_sim='SIMULATION')[source]

Bases: gym.core.Env

__init__(robot_name_space, controllers_list, reset_controls, start_init_physics_parameters=True, reset_world_or_sim='SIMULATION')[source]
__module__ = 'openai_ros.robot_gazebo_env'

Checks that all the sensors, publishers and other simulation systems are operational.

_compute_reward(observations, done)[source]

Calculates the reward to give based on the observations given.


Initial configuration of the environment. Can be used to configure initial state and extract information from the simulation.


Returns the observation.


Inits variables needed to be initialised each time we reset at the start of an episode.


Indicates whether or not the episode is done ( the robot has fallen for example).

_publish_reward_topic(reward, episode_number=1)[source]

This function publishes the given reward in the reward topic for easy access from ROS infrastructure. :param reward: :param episode_number: :return:


Resets a simulation


Applies the given action to the simulation.


Sets the Robot in its init pose


Publishes the cumulated reward of the episode and increases the episode number by one. :return:


Function executed when closing the environment. Use it for closing GUIS and other systems that need closing. :return:


Function executed each time step. Here we get the action execute it in a time step and retrieve the observations generated by that action. :param action: :return: obs, reward, done, info

openai_ros.gazebo_connection module

class openai_ros.gazebo_connection.GazeboConnection(start_init_physics_parameters, reset_world_or_sim)[source]
__init__(start_init_physics_parameters, reset_world_or_sim)[source]
__module__ = 'openai_ros.gazebo_connection'
change_gravity(x, y, z)[source]

We initialise the physics parameters of the simulation, like gravity, friction coeficients and so on.


This was implemented because some simulations, when reseted the simulation the systems that work with TF break, and because sometime we wont be able to change them we need to reset world that ONLY resets the object position, not the entire simulation systems.


openai_ros.controllers_connection module

class openai_ros.controllers_connection.ControllersConnection(namespace, controllers_list)[source]
__init__(namespace, controllers_list)[source]
__module__ = 'openai_ros.controllers_connection'

We turn on and off the given controllers :param controllers_reset: [“name_controler_1”, “name_controller2”,...,”name_controller_n”] :return:

switch_controllers(controllers_on, controllers_off, strictness=1)[source]

Give the controllers you want to switch on or off. :param controllers_on: [“name_controler_1”, “name_controller2”,...,”name_controller_n”] :param controllers_off: [“name_controler_1”, “name_controller2”,...,”name_controller_n”] :return: