Home | Tutorials | Wiki | Issues
Ask Your Question
0

Changing physics engine through URDF [closed]

asked 2016-09-10 08:53:58 -0500

Masoud gravatar image

updated 2016-09-10 08:56:20 -0500

Hi everybody

Would you please tell me that how can I change physics engine (eg. ODE, Bullet , ...) through launch file and URDF. I have created a package that contains one xacro file (which is used to model and inverted pendulum) and two launch file that are as follow:

///////////////// Inverted_pendulum_world.launch ////////////////

<launch>

  <!-- these are the arguments you can pass this launch file, for example paused:=true -->
  <arg name="paused" default="false"/>
  <arg name="use_sim_time" default="true"/>
  <arg name="gui" default="true"/>
  <arg name="headless" default="false"/>
  <arg name="debug" default="false"/>

  <!-- We resume the logic in empty_world.launch -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="debug" value="$(arg debug)" />
    <arg name="gui" value="$(arg gui)" />
    <arg name="paused" value="$(arg paused)"/>
    <arg name="use_sim_time" value="$(arg use_sim_time)"/>
    <arg name="headless" value="$(arg headless)"/>
  </include>

  <!-- Load the URDF into the ROS Parameter Server -->
  <param name="robot_description" command="$(find xacro)/xacro.py '$(find ip_cloned)/urdf/inverted_pendulum.xacro'" />


  <!-- Run a python script to the send a service call to gazebo_ros to spawn a URDF robot -->
   <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
    args="-urdf -model inverted_pendulum -param robot_description"/>


</launch>

////////////////////Inverted_pendulum_gazebo_control.launch /////////////////

<launch>
  <!-- Launch Gazebo  -->
  <include file="$(find ip_cloned)/launch/inverted_pendulum_world.launch" />   


  <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam file="$(find ip_cloned)/config/inverted_pendulum_gazebo_control.yaml" command="load"/>


  <!-- load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen" ns="/inverted_pendulum" args="joint_state_controller
                      joint1_position_controller"/>


  <!-- convert joint states to TF transforms for rviz, etc -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
    respawn="false" output="screen">
    <remap from="/joint_states" to="/inverted_pendulum/joint_states" />
  </node>

</launch>

I'm using gazebo 2.2 + Ubuntu 14.04 + ROS Indigo

Thanks

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Masoud
close date 2016-09-27 02:07:31.567855

3 Answers

Sort by ยป oldest newest most voted
1

answered 2016-09-26 05:07:37 -0500

Nestor94Gonzalez gravatar image

updated 2016-09-26 05:08:16 -0500

The easiest thing is to change the .world file you are launching. There you can specify the physics engine and the maximum_step_size. You can add the following code to your world file if you want to speed up simulation to the maximum:

<physics type='ode'>
  <max_step_size>0.01</max_step_size>
  <real_time_factor>1</real_time_factor>
  <real_time_update_rate>0</real_time_update_rate>
  <gravity>0 0 -9.8</gravity>
</physics>
edit flag offensive delete link more
1

answered 2016-09-12 14:14:06 -0500

nkoenig gravatar image

URDF does not have the ability to change the physics engine. URDF can represent a single model, but it has no concept of simulation.

You will need to use SDF to change the physics engine.

edit flag offensive delete link more
0

answered 2016-09-14 20:51:12 -0500

JLiviero gravatar image

You can specify your physics engine in empty_world.launch: https://github.com/ros-simulation/gaz...

You can do this by adding <arg name="physics" value="your_preferred_physics_engine" /> in Inverted_pendulum_world.launch, like so:

  <!-- We resume the logic in empty_world.launch -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="physics" value="your_preferred_physics_engine" />  <!-- this line added -->
    <arg name="debug" value="$(arg debug)" />
    <arg name="gui" value="$(arg gui)" />
    <arg name="paused" value="$(arg paused)"/>
    <arg name="use_sim_time" value="$(arg use_sim_time)"/>
    <arg name="headless" value="$(arg headless)"/>
  </include>

If that isn't sufficient, or you need to do more detailed tailoring of the physics, you could make a copy of empty.world (in which physics properties are specified), and pass that into empty_world.launch instead.

edit flag offensive delete link more

Comments

Thank you JLivero... I'm also wondering if there is a similar way to change maximum_step_size through editing empty_world.lanuch ?

Masoud gravatar imageMasoud ( 2016-09-25 05:51:28 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-09-10 08:53:58 -0500

Seen: 623 times

Last updated: Sep 26 '16