Simulation with Gazebo and MoveIt!

Max Svetlik edited this page Feb 13, 2018 · 2 revisions

Running Revel in ROS simulation

This section covers the primary methods for running Revel in a simulated environment. Simulated environments are only as good as their physical model of the world. Its difficult to model the internal physics of motors and dynamic systems due to latent variables (friction, viscosity, etc).

However, simulation is useful for testing programs quickly, limiting potentially dangerous movements to simulation. It is also useful as a familiarity tool.

Gazebo (Standlone)

Gazebo is a powerful simulator that attempts to emulate physics and system dynamics more completely. To control Revel in Gazebo, we use ros_control which can be used both in Gazebo on on the actual robot.

To launch a Gazebo simulation, run

 roslaunch svenzva_simulation gazebo_ros_control.launch run_trajectory:=false

Which will bring up Gazebo simulator and ros_control controllers. With run_trajectory set to false, each joint is running a position controller. We can check on the state of the first motor with

rostopic echo /svenzva_controllers/joint_1/state

and can command a joint with

rostopic pub /svenzva_controllers/joint_1/command std_msgs/Float64 "data: 0.5"

which will set the goal parameter of the controller for joint_1 to 0.5 radians. You can see a full list of controllers for all the joints with

rostopic list

MoveIt! (Standalone)

In this tutorial we'll launch the MoveIt! stack demonstration in stand-alone simulation mode.

With the svenzva_ros stack installed, launch the svenzva_moveit demo file in simulation mode with: roslaunch svenzva_moveit demo.launch simulation:=true

This launches MoveIt! and opens a RViz window with MoveIt!'s planning plugins. This is what the RViz window looks like.

We see the arm in its all-zero configuration. Next we can try invoking MoveIt! to make a plan. Click the Planning tab.

We can move the arm by clicking and dragging the blue interactive marker near the robot's gripper. You'll see the robot in orange follow the marker around. That is the target goal position that MoveIt! will solve for. You can see the current state of the robot in semi-opaque white.

Once you're ready to plan to the new pose, click the Plan button.

If MoveIt! was able to plan successfully, you'll see an outline of the path the arm will take.

Finally, we can make the arm actually move to that pose by clicking the Execute button. This will make the simulated arm follow the plan MoveIt! generated.


The steps for running MoveIt! when the arm is connected are very similar. Running any MoveIt! plans in simulation will translate 1-1 on the real robot, because this simulation does not attempt to emulate dynamics- only kinematics.

You can launch this demo and also control MoveIt! programmatically, ie without needing to specify poses & planning by hand. Instead, you can use the forward and inverse kinematic services exposed by MoveIt!. For more information on this, check out MoveIt! documentation.

Gazebo + MoveIt!

We can run Gazebo with MoveIt! if we load the correct controllers through ros_control, which we do through the run_trajectory argument. This time, bring up Gazebo with

roslaunch svenzva_simulation gazebo_ros_control.launch

Now instead of position controllers, a single trajectory controller is brought up for the whole arm. In a separate terminal we can bring up MoveIt! with

roslaunch svenzva_simulation moveit_demo.launch

This launches the same MoveIt! RViz demo as MoveIt tutorial above, but configured to work with Gazebo. You can do the same planning as in the MoveIt tutorial and the arm will be commanded to move in Gazebo.

Simulation Caveats

Using ros_control with Gazebo requires defining PID parameters for each joint, regardless if in position control or trajectory control mode. These will generally be sub-optimal and may give over/under shoot in the simulation.

The simulator isn't a perfect model of the physical robot and the PID values do not translate directly to using ros_control on the physical robot.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.