Updated on: Jan 19, 2015
There are two ways of running programs onto the roboRIO. You can
- Attach to the roboRIO and run the program using the debugger from your development system OR
- Load it onto the roboRIO flash drive so it will run on reboot.
For tournaments you should always download the program so that it will be there when the robot is restarted and the match is played. This article will cover loading the program onto the roboRIO to run on reboot. The next article will cover the debugger.
Updated on: Jan 19, 2015
In an effort to provide information to aid in debugging, the FRC Driver Station creates log files of important diagnostic data while running. These logs can be reviewed later using the FRC Driver Station Log Viewer. The Log Viewer can be found via the shortcut installed in the Start menu or in the FRC Driver Station folder in Program Files.Manual FRC Driver Station
Updated on: Jan 19, 2015
The Power Distribution Panel (PDP) for 2015 adds the capability to measure the current to each device connected to any of the circuit breaker protected 12V outputs. Having this capability offers the opportunity to use a number of algorithm requiring sensing of the torque being developed by motors without requiring additional hardware. The PDP is connected to the RoboRIO through the CAN bus and the libraries take care of managing the communications.
Create an instance of the PowerDistributionPanel object to use it:
PowerDistributionPanel pdp = new PowerDistributionPanel();
Note: it is not necessary to create a PowerDistributionPanel object unless you need to read values from it. The board will work and supply power on all the channels even if the object is never created.Manual FRC Java Programming
Updated on: Jan 15, 2015
When used with CAN control, Jaguars are smart speed controllers. You can simply send a command to the Jaguar such as a position setpoint and it will use attached sensors to move to that position and maintain it. This relieves the robot controller from having to run control loops that read the sensors, determine the error, and supply correction values.
To use the Jaguar speed controller in one of the CAN modes, you set the speed controller mode to one of:
- Voltage mode - you supply the positive or negative voltage that is within the bounds of the actual bus voltage (typically around 12V) that you would like the speed controller to output to the motor. The bus voltage will typically vary depending on how long the battery has been in use, so supplying absolute values will guarantee consistant output voltage provided that the request is less than or equal to the actual bus voltage.
- Percentage mode - you supply a percentage of bus voltage expressed as a floating point between -1 and 1. The actual voltage supplied to the motor will vary depending on the charge of the battery and will actually change as the robot is operating.
- Position mode - the CANJaguar object uses a specified sensor (either a quadrature encoder or potentiometer) and PID values to move the motor to a specified setpoint. All the closed loop control is done inside the speed controller itself so that your program doesn't need to hold the position in software.
- Current mode - a current value is supplied in Amps which is effectively the requested motor torque (twisting effort). The Jaguar uses an internal current sensor and your PID values to keep the current to the requested value.
- Speed mode - CANJaguar object uses a specified sensor (encoder or quadrature encoder) and PID values to move the motor at a requested speed in rotations per minutes (RPM).
When using speed or position mode a sensor is attached to the inputs on the Jaguar (not to the RoboRIO). This sensor is referred to as the reference device. This reference device is used to determine the error for closed loop feedback control. The choices of reference devices are potentiometers (for position mode), quadrature encoders (for position or speed mode), or single-input encoders (for speed mode). Even though there are separate inputs for potentiometers and encoders on the Jaguar, only one reference device can be in use at a time.
In addition, a reference device may be supplied for Voltage, Percentage, and Current modes that is not used for closed loop control, but can be read to monitor the performance of the speed controller.
The Jaguar also has inputs for forward and reverse limit switches. The limit switches will turn the Jaguar off when the switch corresponding to the direction of motion is pressed (should be wired so that this opens the switch, also known as "Normally Open" or NO) while allowing the motor to operate in the opposite direction. This is used to limit the travel of a mechanism without writing any code. For example, when the switch at the top of travel for an arm is closed, the motor will stop moving in that direction. Which is forward and which is reverse depends on the motor polarity so it is a good idea to test to make sure that it is stopping the motor in the correct direction at the correct limit.
In all case, a new CANJaguar object is instantiated, the mode is selected, then you can begin using it in your program.
Updated on: Jan 08, 2015
Commands are scheduled to run based on a number of factors such as triggers, default commands when no other running commands require a subsystem, a prior command in a group finishes, button presses, autonomous period starting, etc. Although many commands may be running virtually at the same time, there is only a single thread (the main robot thread). This is to reduce the complexity of synchronization between threads. There are threads that run in the system for systems like PID loops, communications, etc. but those are all self contained with very little interaction requiring complex synchronization. This makes the system much more robust and predictable.
This is accomplished by a class called Scheduler. It has a run() method that is called periodically (typically every 20ms in response to a driver station update) that tries to make progress on every command that is currently running. This is done by calling the execute() method on the command followed by the isFinished() method. If isFinished() returns true, the command is marked to be removed from execution on the next pass through the scheduler. So if there are a number of commands all scheduled to run at the same time, then every time the Scheduler.run() method is called, each of the active commands execute() and isFinished() methods are called. This has the same effect as using multiple threads.
Updated on: Jan 07, 2015
Often you might write a command that has an "isFinished" condition that is based on a sensor reaching a particular value or a switch closing. For example, a command might rotate a robot 45 degrees by turning until the heading from a gyro reaches 45. Suppose the gyro fails or a wire pulls loose. Now the gyro will always report the same heading, probably zero degrees, and the robot will keep turning for ever. One way of making your commands more robust is to have them "time out" or quit after some time has elapsed. In the case of the turn to 45 degrees, you might know that this will always complete within 2 seconds. You could set a timeout for 3 or 4 seconds to the command will finish even if the robot never reaches the desired heading. This will allow the program to continue running rather than be stuck waiting for the roboRIO to read a heading that will never happen.
Updated on: Jan 05, 2015
After you start getting a significant part of your robot designed in RobotBuilder you can generate a Java project for use with Eclipse. The code that is generated includes project files that will let you just open the project and start adding your robot specific code. In addition, if you later make changes in RobotBuilder, you can regenerate the project again and it will not overwrite your changes. This process is described in detail below.
Updated on: Jan 05, 2015
After you've set up your robot framework in RobotBuilder, you'll need to export the code and load it into Eclipse. This article describes the process for doing so.
Updated on: Jan 04, 2015
RobotBuilder is a Java program and as such should be able to run on any platform that is supported by Java. We have been running RobotBuilder on Mac OS X, Windows 7, and various versions of Linux successfully.
Updated on: Jan 03, 2015
WPILib supports a method of writing programs called "Command based programming". Command based programming is a design pattern to help you organize your robot programs. Some of the characteristics of robot programs that might be different from other desktop programs are:
- Activities happen over time, for example a sequence of steps to shoot a Frisbee or raise an elevator and place a tube on a goal.
- These activities occur concurrently, that is it might be desirable for an elevator, wrist and gripper to all be moving into a pickup position at the same time to increase robot performance.
- It is desirable to test the robot mechanisms and activities each individually to help debug your robot.
- Often the program needs to be augmented with additional autonomous programs at the last minute, perhaps at competitions, so easily extendable code is important.
Command based programming supports all these goals easily to make the robot program much simpler than using some less structured technique.