Main Content

Set Up Gazebo Simulation Environment

All examples showcasing Gazebo based VEX® simulation use a virtual machine (VM) that is available for download. To download and install the same, use the link available under Download Virtual Machine section in Get Started with Gazebo and a Simulated TurtleBot.

Note

By default, the virtual machine is configured to use 4 GB RAM and two CPU Cores. For better performance, you can extend the RAM and CPU cores depending on the specifications of your host machine.

Once the virtual machine opens, ensure that it displays an IP address in the top right corner. Enter this IP address in the Simulink®, so that Simulink can reach the Gazebo server running on this IP address. If the IP address does not show, restart the Virtual Machine. If the issue persists, configure the network correctly on the virtual machine.

Test Connection

Perform these steps to test the connection.

  1. Open the Command Prompt window.

  2. Contact the virtual machine using the ping command with the IP address of the virtual machine. Use this command.

    ping 192.168.23.128

    If the ping command times out, check if the network is configured correctly on the Ubuntu® virtual machine.

    VM IP

Open Gazebo World

To open the preconfigured VEX Robot environment, on the Ubuntu desktop, click Gazebo VEX Clawbot icon.

Gazebo World

Preconfigured Gazebo Simulation Environment

The desktop shortcut opens Gazebo simulator with VEX Robot and an environment with game objects. For more information on the Gazebo graphical user interface, see Gazebo User Interface.

Preconfigured Gazebo Simulation

If the Gazebo simulator fails to open, the default Gazebo port (11345) might be blocked by some other application. Restart the Virtual Machine to fix this issue.

Required Products

Other Dependencies

Install a C++ Compiler supported by gazebogenmsg.

After installing the C++ Compiler, start MATLAB® and run these commands.

mex -setup c
mex -setup c++ 

If you have installed multiple compilers in your machine, select the compiler that is supported by gazebogenmsg command.

Set Up and Run Simulink Model

A Simulink template or preconfigured simulink examples are available in the support package. Instructions to configure/run the template or examples are similar.

You can use the Gazebo Simulation template to model a system and then simulate the dynamic behavior of that system in Gazebo. Perform these steps to build your model.

  1. On the MATLAB Home tab click Simulink.

    Simulink

  2. On the Simulink Start Page, navigate to Simulink Coder Support Package for VEX EDR V5 Robot Brain and select the Gazebo Simulation template. Click Create Model.

    Gazebo simulation model

    The Gazebo Simulation template model opens. This is a blank template setup to work with Gazebo Simulator. It contains blocks for simulating the following devices.

    • Distance Sensor

    • Inertial Sensor

    • Bumper Switch

    • Vision Sensor

    • Encoders on Arm, Claw, and drivetrain

    • Smart Motors on Arm, Claw, and drivetrain

    • Game pad simulator for providing manual inputs to the simulation from joystick.

    Various autonomous tasks can be simulated by using combinations of these sensors and actuators.

    Gazebo simulation model

  3. From the Simulation tab, select Save > Save as. In the File name text box, enter a name for your model. Click Save. The model is saved with the file extension .slx.

  4. To get started with basic robot movement in Gazebo simulator, connect left and right motor outputs from Stateflow chart to Smart Motors block.

    Stateflow logic

  5. Double-click the Gazebo Pacer block.

  6. In the block parameter dialog box, click Configure Gazebo network and simulation settings. Enter the virtual machine IP Address. Set the Port to 14581.

    Pacer IP Address

    Gazebo and Simulink communicate over network using Co-simulation blocks from Robotics System Toolbox. To enable this communication, you must specify the IP address of the machine which is running Gazebo. In this case, it will be Virtual Machine’s IP address.

  7. Click Test to verify the connection to Gazebo model. Click Ok to complete setting up the Gazebo simulation environment.

See Also

|