ros_gazebo

Functions related to launch of the Gazebo simulation, along functions to change simulator parameters and handling of simulator objects.

ros_gazebo.launch_Gazebo(paused=False, use_sim_time=True, gui=True, recording=False, debug=False, verbose=False, output='screen', custom_world_path=None, custom_world_pkg=None, custom_world_name=None, respawn_gazebo=False, pub_clock_frequency=100, server_required=False, gui_required=False, launch_new_term=True) bool[source]

Launch Gazebo using the ROS network.

Parameters
  • paused (bool) – if True, init gzserver paused.

  • use_sim_time (bool) – if True, use the simulation time.

  • gui (bool) – if True, launch Gazebo with the GUI (gzclient).

  • recording (bool) – if True, record the data from gazebo.

  • debug (bool) – if True, use the debug configuration.

  • verbose (bool) – if True, print debug information.

  • output (str [screen, log]) – choose the output method for gazebo (screen, log).

  • custom_world_path (str) – if not None, use this world path.

  • custom_world_pkg (str) – if the custom_world_path is None, use a world file from this package, specified in custom_world_name.

  • custom_world_name (str) – if the custom_world_path is None, use the world file with this name from the custom_world_pkg.

  • respawn_gazebo (bool) – if True, gazebo will be respawned if it is killed, default is False.

  • pub_clock_frequency (int) – the frequency of the clock publisher (in Hz)

  • server_required (bool) – if True, the launch file will wait until gzserver is running.

  • gui_required (bool) – if True, the launch file will wait until gzclient is running.

  • launch_new_term (bool) – Launch the gazebo node in a new terminal (Xterm).

Returns

True if the launch was successful, False otherwise.

Return type

bool

ros_gazebo.close_Gazebo() bool[source]

Function to close gazebo if its running.

Returns

True if gazebo was closed, False otherwise.

Return type

bool

ros_gazebo.gazebo_set_max_update_rate(max_update_rate) bool[source]

Function to set the max update rate for gazebo in real time factor: 1 is real time, 10 is 10 times real time.

Parameters

max_update_rate (float) – the max update rate for gazebo in real time factor.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_get_max_update_rate() float[source]

Function to get the current max update rate.

Returns

the max update rate.

Return type

float

ros_gazebo.gazebo_set_time_step(new_time_step) bool[source]

Function to set the time step for gazebo.

Parameters

new_time_step (float) – the new time step.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_get_time_step() float[source]

Function to get the current time step for gazebo.

Returns

the time step.

Return type

float

ros_gazebo.gazebo_set_gravity(x, y, z) bool[source]

Function to set the gravity for gazebo.

Parameters
  • x (float) – the x component of the gravity vector.

  • y (float) – the y component of the gravity vector.

  • z (float) – the z component of the gravity vector.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_get_gravity() geometry_msgs.msg.Vector3[source]

Function to get the current gravity vector for gazebo.

Returns

the gravity vector.

Return type

Vector3

ros_gazebo.gazebo_set_ODE_physics(auto_disable_bodies, sor_pgs_precon_iters, sor_pgs_iters, sor_pgs_w, sor_pgs_rms_error_tol, contact_surface_layer, contact_max_correcting_vel, cfm, erp, max_contacts) bool[source]

Function to set the ODE physics for gazebo.

Returns

True if the command was sent and False otherwise.

ros_gazebo.gazebo_get_ODE_physics() gazebo_msgs.msg.ODEPhysics[source]

Function to get the current ODE physics for gazebo.

Returns

the ODE physics.

Return type

ODEPhysics

ros_gazebo.gazebo_set_default_properties() bool[source]

Function to set the default gazebo properties.

Returns

True if the command was sent and False otherwise.

ros_gazebo.gazebo_reset_sim(retries=5) bool[source]

Function to reset the simulation, which reset models to original poses AND reset the simulation time.

Parameters

retries (int) – The number of times to retry the service call.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_reset_world(retries=5) bool[source]

Function to reset the world, which reset models to original poses WITHOUT resetting the simulation time.

Parameters

retries (int) – The number of times to retry the service call.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_pause_physics(retries=5) bool[source]

Function to pause the physics in the simulation.

Parameters

retries (int) – The number of times to retry the service call.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_unpause_physics(retries=5) bool[source]

Function to unpause the physics in the simulation.

Parameters

retries (int) – The number of times to retry the service call.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_step_physics(steps=1) bool[source]

Function to step the physics in the simulation.

Parameters

steps (int) – The number of times to step the simulation.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_delete_model(model_name) bool[source]

Function to delete a model from the simulation.

Parameters

model_name (str) – The name of the model to delete.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_spawn_urdf_path(model_path, model_name='robot1', robot_namespace='/', reference_frame='world', pos_x=0.0, pos_y=0.0, pos_z=0.0, ori_x=0.0, ori_y=0.0, ori_z=0.0, ori_w=1.0) bool[source]

Function to spawn a model from a URDF file.

Parameters
  • model_path (str) – The path to the URDF file.

  • model_name (str) – Name of model to spawn

  • robot_namespace (str) – change ROS namespace of gazebo-plugins.

  • reference_frame (str) – Name of the model/body where initial pose is defined. If left empty or specified as “world”, gazebo world frame is used

  • pos_x (float) – x position of model in model’s reference frame

  • pos_y (float) – y position of model in model’s reference frame

  • pos_z (float) – z position of model in model’s reference frame

  • ori_x (float) – X part of Quaternion of model orientation in model’s reference frame.

  • ori_y (float) – Y part of Quaternion of model orientation in model’s reference frame.

  • ori_z (float) – Z part of Quaternion of model orientation in model’s reference frame.

  • ori_w (float) – W part of Quaternion of model orientation in model’s reference frame.

Returns

[True if the command was sent and False otherwise, Status message].

Return type

[bool, str]

ros_gazebo.gazebo_spawn_urdf_pkg(pkg_name, file_name, file_folder='/urdf', model_name='robot1', robot_namespace='/', reference_frame='world', pos_x=0.0, pos_y=0.0, pos_z=0.0, ori_x=0.0, ori_y=0.0, ori_z=0.0, ori_w=1.0) bool[source]

Function to spawn a model from a URDF file.

Parameters
  • pkg_name (str) – Name of the package to import the URDF file from.

  • file_name (str) – Name of the URDF file to import.

  • file_folder (str) – Folder where the URDF file is located. Defaults to “/urdf”.

  • model_name (str) – Name of model to spawn

  • robot_namespace (str) – change ROS namespace of gazebo-plugins.

  • reference_frame (str) – Name of the model/body where initial pose is defined. If left empty or specified as “world”, gazebo world frame is used

  • pos_x (float) – x position of model in model’s reference frame

  • pos_y (float) – y position of model in model’s reference frame

  • pos_z (float) – z position of model in model’s reference frame

  • ori_x (float) – X part of Quaternion of model orientation in model’s reference frame.

  • ori_y (float) – Y part of Quaternion of model orientation in model’s reference frame.

  • ori_z (float) – Z part of Quaternion of model orientation in model’s reference frame.

  • ori_w (float) – W part of Quaternion of model orientation in model’s reference frame.

Returns

[True if the command was sent and False otherwise, Status message].

Return type

[bool, str]

ros_gazebo.gazebo_spawn_urdf_string(model_string, model_name='robot1', robot_namespace='/', reference_frame='world', pos_x=0.0, pos_y=0.0, pos_z=0.0, ori_x=0.0, ori_y=0.0, ori_z=0.0, ori_w=1.0) bool[source]

Function to spawn a model from a URDF file.

Parameters
  • model_string (str) – URDF string to import.

  • model_name (str) – Name of model to spawn

  • robot_namespace (str) – change ROS namespace of gazebo-plugins.

  • reference_frame (str) – Name of the model/body where initial pose is defined. If left empty or specified as “world”, gazebo world frame is used.

  • pos_x (float) – x position of model in model’s reference frame

  • pos_y (float) – y position of model in model’s reference frame

  • pos_z (float) – z position of model in model’s reference frame

  • ori_x (float) – X part of Quaternion of model orientation in model’s reference frame.

  • ori_y (float) – Y part of Quaternion of model orientation in model’s reference frame.

  • ori_z (float) – Z part of Quaternion of model orientation in model’s reference frame.

  • ori_w (float) – W part of Quaternion of model orientation in model’s reference frame.

Returns

[True if the command was sent and False otherwise, Status message].

Return type

[bool, str]

ros_gazebo.gazebo_spawn_urdf_param(param_name, model_name='robot1', robot_namespace='/', reference_frame='world', pos_x=0.0, pos_y=0.0, pos_z=0.0, ori_x=0.0, ori_y=0.0, ori_z=0.0, ori_w=1.0) bool[source]

Function to spawn a model from a URDF in the param server.

Parameters
  • param_name (str) – Name of model to spawn

  • model_name (str) – Name of model to spawn

  • robot_namespace (str) – change ROS namespace of gazebo-plugins.

  • reference_frame (str) – Name of the model/body where initial pose is defined. If left empty or specified as “world”, gazebo world frame is used.

  • pos_x (float) – x position of model in model’s reference frame

  • pos_y (float) – y position of model in model’s reference frame

  • pos_z (float) – z position of model in model’s reference frame

  • ori_x (float) – X part of Quaternion of model orientation in model’s reference frame.

  • ori_y (float) – Y part of Quaternion of model orientation in model’s reference frame.

  • ori_z (float) – Z part of Quaternion of model orientation in model’s reference frame.

  • ori_w (float) – W part of Quaternion of model orientation in model’s reference frame.

Returns

[True if the command was sent and False otherwise, Status message].

Return type

[bool, str]

ros_gazebo.gazebo_spawn_sdf_path(model_path, model_name='robot1', robot_namespace='/', reference_frame='world', pos_x=0.0, pos_y=0.0, pos_z=0.0, ori_x=0.0, ori_y=0.0, ori_z=0.0, ori_w=1.0) bool[source]

Function to spawn a model from a SDF file.

Parameters
  • model_path (str) – The path to the SDF file.

  • model_name (str) – Name of model to spawn

  • robot_namespace (str) – change ROS namespace of gazebo-plugins.

  • reference_frame (str) – Name of the model/body where initial pose is defined. If left empty or specified as “world”, gazebo world frame is used

  • pos_x (float) – x position of model in model’s reference frame

  • pos_y (float) – y position of model in model’s reference frame

  • pos_z (float) – z position of model in model’s reference frame

  • ori_x (float) – X part of Quaternion of model orientation in model’s reference frame.

  • ori_y (float) – Y part of Quaternion of model orientation in model’s reference frame.

  • ori_z (float) – Z part of Quaternion of model orientation in model’s reference frame.

  • ori_w (float) – W part of Quaternion of model orientation in model’s reference frame.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_spawn_sdf_pkg(pkg_name, file_name, file_folder='/sdf', model_name='robot1', robot_namespace='/', reference_frame='world', pos_x=0.0, pos_y=0.0, pos_z=0.0, ori_x=0.0, ori_y=0.0, ori_z=0.0, ori_w=1.0) bool[source]

Function to spawn a model from a SDF file.

Parameters
  • pkg_name (str) – Name of the package to import the SDF file from.

  • file_name (str) – Name of the SDF file to import.

  • file_folder (str) – Folder where the SDF file is located. Default is “/sdf”.

  • model_name (str) – Name of model to spawn

  • robot_namespace (str) – change ROS namespace of gazebo-plugins.

  • reference_frame (str) – Name of the model/body where initial pose is defined. If left empty or specified as “world”, gazebo world frame is used

  • pos_x (float) – x position of model in model’s reference frame

  • pos_y (float) – y position of model in model’s reference frame

  • pos_z (float) – z position of model in model’s reference frame

  • ori_x (float) – X part of Quaternion of model orientation in model’s reference frame.

  • ori_y (float) – Y part of Quaternion of model orientation in model’s reference frame.

  • ori_z (float) – Z part of Quaternion of model orientation in model’s reference frame.

  • ori_w (float) – W part of Quaternion of model orientation in model’s reference frame.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_spawn_sdf_string(model_string, model_name='robot1', robot_namespace='/', reference_frame='world', pos_x=0.0, pos_y=0.0, pos_z=0.0, ori_x=0.0, ori_y=0.0, ori_z=0.0, ori_w=1.0) bool[source]

Function to spawn a model from a SDF file.

Parameters
  • model_string (str) – SDF string to import.

  • model_name (str) – Name of model to spawn

  • robot_namespace (str) – change ROS namespace of gazebo-plugins.

  • reference_frame (str) – Name of the model/body where initial pose is defined. If left empty or specified as “world”, gazebo world frame is used.

  • pos_x (float) – x position of model in model’s reference frame

  • pos_y (float) – y position of model in model’s reference frame

  • pos_z (float) – z position of model in model’s reference frame

  • ori_x (float) – X part of Quaternion of model orientation in model’s reference frame.

  • ori_y (float) – Y part of Quaternion of model orientation in model’s reference frame.

  • ori_z (float) – Z part of Quaternion of model orientation in model’s reference frame.

  • ori_w (float) – W part of Quaternion of model orientation in model’s reference frame.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_spawn_sdf_param(param_name, model_name='robot1', robot_namespace='/', reference_frame='world', pos_x=0.0, pos_y=0.0, pos_z=0.0, ori_x=0.0, ori_y=0.0, ori_z=0.0, ori_w=1.0) bool[source]

Function to spawn a model from a SDF in the param server.

Parameters
  • param_name (str) – Name of model to spawn

  • model_name (str) – Name of model to spawn

  • robot_namespace (str) – change ROS namespace of gazebo-plugins.

  • reference_frame (str) – Name of the model/body where initial pose is defined. If left empty or specified as “world”, gazebo world frame is used.

  • pos_x (float) – x position of model in model’s reference frame

  • pos_y (float) – y position of model in model’s reference frame

  • pos_z (float) – z position of model in model’s reference frame

  • ori_x (float) – X part of Quaternion of model orientation in model’s reference frame.

  • ori_y (float) – Y part of Quaternion of model orientation in model’s reference frame.

  • ori_z (float) – Z part of Quaternion of model orientation in model’s reference frame.

  • ori_w (float) – W part of Quaternion of model orientation in model’s reference frame.

Returns

True if the command was sent and False otherwise.

Return type

bool

ros_gazebo.gazebo_get_model_state(model_name, relative_entity_name='world')[source]

Function to get the state of a model.

Parameters
  • model_name (str) – Name of model to get the state of.

  • relative_entity_name (str) – Return pose and twist relative to this entity (an entity can be a model, body, or geom).

Returns

The header of the message, the pose of the model, the twist of the model, and success.

ros_gazebo.gazebo_set_model_state(model_name, ref_frame='world', pos_x=0.0, pos_y=0.0, pos_z=0.0, ori_x=0.0, ori_y=0.0, ori_z=0.0, ori_w=0.0, lin_vel_x=0.0, lin_vel_y=0.0, lin_vel_z=0.0, ang_vel_x=0.0, ang_vel_y=0.0, ang_vel_z=0.0, sleep_time=0.05) bool[source]

Function to set the model name in gazebo.

Parameters
  • model_name (str) – Name of model to set.

  • ref_frame (str) – Reference frame of model.

  • pos_x (float) – x position of model in model’s reference frame

  • pos_y (float) – y position of model in model’s reference frame

  • pos_z (float) – z position of model in model’s reference frame

  • ori_x (float) – X part of Quaternion of model orientation in model’s reference frame.

  • ori_y (float) – Y part of Quaternion of model orientation in model’s reference frame.

  • ori_z (float) – Z part of Quaternion of model orientation in model’s reference frame.

  • ori_w (float) – W part of Quaternion of model orientation in model’s reference frame.

  • lin_vel_x (float) – X part of linear velocity of model in model’s reference frame.

  • lin_vel_y (float) – Y part of linear velocity of model in model’s reference frame.

  • lin_vel_z (float) – Z part of linear velocity of model in model’s reference frame.

  • ang_vel_x (float) – X part of angular velocity of model in model’s reference frame.

  • ang_vel_y (float) – Y part of angular velocity of model in model’s reference frame.

  • ang_vel_z (float) – Z part of angular velocity of model in model’s reference frame.

  • sleep_time (float) – Time to sleep bewteen sending request and getting response.

Returns

True if the command was sent and False otherwise.

Return type

bool