FIRSTSim/FTC setup

The FIRST library in Gazebo provides a partial model of the 2013 “Ring It Up” arena, including two modified FTC robots based on Team 4220, The Landroids. In order to run this package, you must have the FIRST model files, as well as the world files and ROS plugin files. The full package of these files can be obtained here, but is better obtained by following the instructions below. To run this simulation, please check to make sure you meet the requirements.
 * 1) Installation

Requirements

To install the simulation, start with a clean installation of Ubuntu Linux, preferably 12.04 LTS. Install the current version of Gazebo and ROS. From here, type the following commands:

sudo apt-get update sudo apt-get install ftcsim source /usr/share/ftcsim/setup.sh

The last line of this block is a temporary reference to the ftcsim files that will only be stored in the active window; once closed, you will need to type it again. If you would like to make this a permanent solution, now type the line:

echo "source /usr/share/ftcsim/setup.sh" >> ~/.bashrc source ~/.bashrc

Next, you must install the joystick drivers and associate the joysticks with ROS. To do this, type the commands:

sudo apt-get install ros-groovy-joystick-drivers rosdep install joy rosmake joy

Now follow these instructions, copied from the ros.org website:

ls /dev/input/ sudo jstest /dev/input/jsX

Where X is a number from 0 through 9, based on what comes up in the list of input devices reported in the first line. Test this out by moving the joystick around, to confirm that it is working. If you don’t see anything changing, try changing the value of X to one of the other listed input devices. Remember the value of X that you typed – you will need it later. Now make this joystick available to ROS:

sudo chmod a+rw /dev/input/jsX

To test if this is working, follow this process. First, start the ROS core:

roscore

Now, open a second terminal by hitting Ctrl+Shift+T and type:

rosparam set joystick/dev "/dev/input/js0" rosrun joy joy_node

Finally, open a third terminal and type:

rostopic echo joy

Move the joystick around and confirm that it is working. If you intend to play with 2 players and therefore require a second joystick, plug in the second joystick now and and determine the input device number, similar to the process above:

ls /dev/input/ sudo jstest /dev/input/jsY sudo chmod a+rw /dev/input/jsY

where Y is the new input device that showed up when you installed the second joystick. If the values for X and Y were 0 and 1, you are now ready to run the simulation. If not, skip down a few steps to see how to modify the robot files to reconfigure for the correct joystick inputs.

To run the command line to start the Gazebo package with ROS dependencies, type the following:
 * 1) Running the FTC Simulator

roslaunch ftcsim_utils ftc_demo.launch

This should start Gazebo with the FTC arena and two robots, a red and a blue, along with separate windows for the virtual webcams associated with each robot. The game should start in a paused condition; to start it, click the 'play' triangle on the bottom bar of the Gazebo user interface.

If you would like to modify which joystick controls which robot, open the file ftc_demo.launch:

gedit /usr/share/ftcsim-0.1/ros/ftcsim_utils/launch/ftc_demo.launch

Inside, you will see the following:

 



   



   



The button mappings are as follows, with joystick 0 configured to use an Xbox controller and joystick 1 configured to run a Logitech joystick with yaw control:
 * 1) Controls


 * 1) Joystick 0 (Xbox-style controller):


 * Left joystick up/down: Robot forward / backwards
 * Left joystick left/right: Robot strafe left / right
 * Right joystick left / right: Robot rotate counterclockwise / clockwise
 * Right joystick up / down: Nothing
 * Right rear trigger: Raise arm
 * Button 3 held: Arm max height = lower rung of center rack
 * Button 1 held: Arm max height = upper rung of center rack


 * 1) Joystick 1 (Logitech yaw-enabled joystick):


 * Joystick up / down: Robot forward / backwards
 * Joystick left/right: Robot strafe left / right
 * Joystick rotate clockwise / counterclockwise: Robot rotate clockwise / counterclockwise
 * Throttle axis up / down: Raise / lower arm
 * Joystick hat neutral: Arm max height = middle rung of center rack
 * Joystick hat up: Arm max height = upper rung of center rack
 * Joystick hat down: Arm max height = lower rung of center rack

If you would like to experiment with modifying these settings, you will have to download the source files for the robot plugins, modify them, and rebuild them. This can be a bit tricky, and will be described in the tutorial Advanced Robot Controls.
 * 1) Reconfiguring Joystick Commands

 If your input device list is different from js0 and js1 in the process above, or your joysticks are reversed (joystick controls on gamepad joystick and vice versa), you need to edit the launch file described above. Reopen the ftc_demo.launch file and look for the sections starting with  and . Inside of these, you will see mappings between the input devices and the controller for each of the robots. Red robot = OCU, blue robot = OCU2. Update the values in this launch file to whatever you need to use to get the proper inputs.
 * 1) Reconfiguring to Alternate Joysticks / Swapping Joysticks