Defines a Gazebo-based OpenAI gym environment for a ROPOD robot.
- Defined environments
- Gazebo entities
A navigation environment for a ropod with a discrete action space. In each episode, the robot's objective is to reach a randomly generated navigation goal without colliding with obstacles (a collision ends the episode).
The action space contains the following actions:
0: forward motion with
1: left motion with
2: right motion with
3: left turn with
0.1m/slinear speed and
4: right turn with
0.1m/slinear speed and
5: backward motion with
The observation at each step is a list of 500 laser measurements obtained from a front laser scanner.
The reward is calculated using the following equation:
d is the distance from the robot to the goal,
c_t indicates whether the robot has collided at time
a_t denotes the action taken at time
t. We thus want the robot to reach the goal without making unnecessary direction changes and without collisions. The values of the constants
c_2 are set to
reset environment functions return a tuple of four elements
(goal, obs, reward, done), where:
goal: a 2D pose in the format (x, y, theta) representing the current goal the robot is pursuing
obs: a list of laser scans
reward: the above reward
done: a Boolean indicating whether the episode has finished
Gazebo worlds are included under
model_config/worlds. The world to be used in a simulation is specified when creating the environment and its elements are loaded on the fly. The currently defined worlds are briefly described below.
A simple square world without any static obstacles (other than the walls); any other obstacles are added on the fly at randomised positions. The world with the robot and two randomly added obstacles is shown below.
Object models used in the simulation are included under
model_config/models (the robot model is however not in this repository, but in
ropod_sim_model). These models are used for adding environment obstacles on the fly.
- Set up the package:
(sudo) python setup.py [develop|install]
- Set the
ROPOD_GYM_MODEL_PATHenvironment variable to the absolute path of the
A simple usage example for the environment is given below. In this case, we load the square world and add five obstacles to it.
import gym launch_file = '/path/to/my_simulation_launch_file.launch' # create, render, and reset the environment env = gym.make('ropod-nav-discrete-v0', launch_file_path=launch_file, env_type='square', number_of_obstacles=5) env.render(mode='human') env.reset() # sample an action action = env.action_space.sample() # apply the sampled action and get information about the outcome (goal, obs, reward, done) = env.step(action)
Test scripts that illustrate the environment use and should run out of the box can be found under test.
- Python 3.5+
The implementation is heavily based on this Toyota HSR gym environment