Introduction to FRCSim

With FRCSim, you should be able to finish 90% Of your programming without ever touching a RoboRIO.

We want you to be able to test your code BEFORE you put in on your robot, and before the robot is even built.

 

FRCSim allows robot code written in C++ or Java that normally runs on your RoboRIO to be run on your laptop or desktop. It connects to custom robot models in the Gazebo robot simulator.

How it works

The project as a whole is pretty simple. The C++ and Java libraries actually have two versions, one for the RoboRIO and one for simulation. They share a lot of the same code, but differ when it comes to things like setting motor speed and reading sensors.

Your Robot Program

When you compile or run in simulation, you are using the simulation versions of WPILib. We try to keep everything the same between the two versions, so that you never have to change your code in order to run in simulation. However, if you do need to change it, you can use the following constructs.

 

Java:

if (Robot.isReal()){ #Robot here is a class extending RobotBase
  // do something 
}
else {
  // do something different
}

C++:

   #ifdef REAL
        // do something
	#else
        // do something different
	#endif

Your Robot Model

Your robot is represented in Gazebo in a file format called SDF (http://sdformat.org)

SDF Is a complicated file format based on XML, but we built a solidworks exporter to help! We've got lots of tutorials on using it. You can start here: Installing SolidWorks Gazebo Exporter plugin

It is very difficult to make good models by hand, so please try the exporter.

Gazebo Transport

Gazebo Transport is the glue holding everything together. Similar to ROS (https://wiki.ros.org) Gazebo Transport is a library built of Google's Protobuf (https://developers.google.com/protocol-buffers/?hl=en) that allows messages to be sent back and forth between different programs.

More specifically, your robot program sends out and receives messages over Gazebo Transport. The driver station also sends messages through gazebo transport, and so does your robot model. In fact, all those gazebo plugins like dc_motor send and receive messages over Gazebo Transport.

There is a utility program galled gz that can help you see what's going on and help debug your system. Type gz topic --help to get some helpful information on how to use the program.

Video Tutorials

There is a series of simulation videos on this channel:

https://www.youtube.com/channel/UC_xEeMJeS3UQ388lxNItmzQ

2016 Field

A world file for the 2016 Field can be downloaded here!

first.wpi.edu/FRC/roborio/release/simulation

0 Report Errors

Use this form to report any errors with the documentation. For help with WPILib, please use the FIRST Forums at http://forums.usfirst.org For reporting WPILib bugs, please submit an issue on GitHub at https://github.com/wpilibsuite/allwpilib/issues/new

Ignore