Main Content

Pick-and-Place Simulation for VEX Robot Using Gazebo Simulator

This example shows how to model the pick-and-place algorithm for a VEX® robot and then simulate the robot in a Gazebo simulator. This example uses a pre-configured Simulink model created for Gazebo simulator (along with a virtual world). The robot's control algorithm is modelled as a Stateflow® chart in Simulink. Simulink reads data from sensors and writes commands to motors in Gazebo using Gazebo co-simulation blocks.

Using this example you can:

  • Drive the robot relative to wall using distance sensor.

  • Turn the robot using the inertial sensor.

  • Pick and place objects using the arm and claw mechanism.

Set up Gazebo Simulation Environment

To run this example, download and set up the preconfigured Virtual Machine with ROS and Gazebo. For more information, see Set Up Gazebo Simulation Environment. In the Setup Gazebo Simulation Environment topic, perform the steps listed in these topics.

Simulink Model

1. Open the preconfigured Simulink example model.


2. Open Gazebo Pacer block.

3. Click Configure Gazebo network and simulation settings. Enter the virtual machine IP Address. Set the Port to 14581.

4. Click Test connection to verify the connection to Gazebo model. Click Ok and close the block dialog.

Program Logic

The control algorithm of the robot is modeled in the program logic Stateflow chart. Double-click the chart to view the control algorithm.

Each block inside the Stateflow chart models a state of robot. Some examples of states include:

  • Arm raised or lowered

  • Claw closed or open

  • Robot driving or turning or being still

The robot transitions from one state to another when it fulfills conditions based on the following parameters,

  • Elapsed time

  • Feedback from sensors, such as distance to wall

  • User input

For example, the following transition initiates the robot to turn once it is at a distance of 0.76 m from the wall.

The transitions when combined enable the robot to move towards an object, pick it up, and drop it in another location.

Simulate Model

In the preconfigured Simulink model, on the Simulation tab, click Run to simulate the model.

Other Things to Try

  • Use a different combination of sensors to pick and place objects.

  • Try solving a different autonomous problem.

See Also