Recent Updates
-
Updated on: Jan 20, 2023
Setting the default command for a subsystem
Once you have some commands created, you can set one of them to be the default command for a subsystem. Default commands run automatically when nothing else is running that requires that subsystem. A good example is having a drive train subsystem with a default command that reads joysticks. That way, whenever the robot program isn't running other commands to operate the drive train under program control, it will operate with joysticks.
Manual RobotBuilder -
Updated on: Jan 20, 2023
Operating a compressor for pneumatics
The Compressor class is designed to operate any FRC supplied compressor on the robot. A Compressor object is constructed with 2 input/output ports:
• The Digital Relay output port connected to the Spike relay that controls the power to the compressor. (A digital output or Solenoid module port alone doesn’t supply enough current to operate the compressor.)
• The Digital input port connected to the pressure switch that monitors the accumulator pressure.
The Compressor class will automatically create a task that runs in the background and twice a second turns the compressor on or off based on the pressure switch value. If the system pressure is above the high set point of the switch, the compressor turns off. If the pressure is below the low set point, the compressor turns on.
Manual WPILib programming -
Updated on: Jan 20, 2023
Composite controllers - RobotDrive
The RobotDrive class is designed to simplify the operation of the drive motors based on a model of the drive train configuration. The program describes the layout of the motors. Then the class can generate all the speed values to operate the motors for different configurations. For cases that fit the model, it provides a significant simplification to standard driving code. For more complex cases that aren’t directly supported by the RobotDrive class it may be subclassed to add additional features or not used at all.
Manual WPILib programming -
Updated on: Jan 20, 2023
Driving motors with speed controller objects (Victors, Talons and Jaguars)
The WPI Robotics library has extensive support for motor control. There are a number of classes that represent different types of speed controllers and servos. The WPI Robotics Library currently supports two classes of speed controllers, PWM based motor controllers (Jaguars, Victors and Talons) and CAN based motor controllers (Jaguar). WPILIb also contains a composite class called RobotDrive which allows you to control multiple motors with a single object. This article will cover the details of PWM motor controllers, CAN controllers and RobotDrive will be covered in separate articles.
Manual WPILib programming -
Updated on: Jan 20, 2023
Analog triggers
An analog trigger is a way to convert an analog signal into a digital signal using resources built into the FPGA. The resulting digital signal can then be used directly or fed into other digital components of the FPGA such as the counter or encoder modules. The analog trigger module works by comparing analog signals to a voltage range set by the code. The specific return types and meanings depend on the analog trigger mode in use.
Manual WPILib programming -
Updated on: Jan 20, 2023
Analog inputs
The NI 9201 Analog to Digital module has a number of features not available on simpler controllers. It will automatically sample the analog channels in a round robin fashion, providing a combined sample rate of 500 ks/s (500,000 samples / second). These channels can be optionally oversampled and averaged to provide the value that is used by the program. There are raw integer and floating point voltage outputs available in addition to the averaged values. The diagram below outlines this process.
Manual WPILib programming -
Updated on: Jan 20, 2023
Measuring robot distance to a surface using Ultrasonic sensors
Ultrasonic sensors are a common way to find the distance from a robot to the nearest surface
Manual WPILib programming -
Updated on: Jan 20, 2023
Determine robot orientation with a compass
A compass uses the earth’s magnetic field to determine the heading of the robot.
Manual WPILib programming -
Updated on: Jan 20, 2023
Gyros to control robot driving direction
Gyros typically in the FIRST kit of parts are provided by Analog Devices, and are actually angular rate sensors. The output voltage is proportional to the rate of rotation of the axis perpendicular to the top package surface of the gyro chip. The value is expressed in mV/°/second (degrees/second or rotation expressed as a voltage). By integrating (summing) the rate output over time, the system can derive the relative heading of the robot.
Another important specification for the gyro is its full-scale range. Gyros with high full-scale ranges can measure fast rotation without “pinning” the output. The scale is much larger so faster rotation rates can be read, but there is less resolution due to a much larger range of values spread over the same number of bits of digital to analog input. In selecting a gyro, you would ideally pick the one that had a full-scale range that matched the fastest rate of rotation your robot would experience. This would yield the highest accuracy possible, provided the robot never exceeded that range.
Manual WPILib programming -
Updated on: Jan 20, 2023
Potentiometers to measure joint angle or linear motion
Potentiometers are a common analog sensor used to measure absolute angular rotation or linear motion (string pots) of a mechanism. A potentiometer is a three terminal device that uses a moving contact to from a variable resistor divider. When the outer contacts are connected to 5V and ground and the variable contact is connected to an analog input, the analog input will see an analog voltage that varies as the potentiometer is turned.
Manual WPILib programming