mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Updated the HAL library to work with the new version 3 headers from NI. There were multiple changes in this verison: more PWM generators were added, so the functions for setting PWM signals have been updated. UserWatchdog has been removed, and Watchdog has been removed from WPILib to accomodate for this. Digital selection has been consolidated to one function in the NI headers, so this has been updated in the HAL. New SPI and I2C libraries have been added, but need to be implemented in the HAL before they will work.
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
#include "WPILib.h"
|
|
|
|
/**
|
|
* This is a demo program showing the use of the RobotBase class.
|
|
* The SimpleRobot class is the base of a robot application that will automatically call your
|
|
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
|
|
* the driver station or the field controls.
|
|
*/
|
|
class Robot: public SimpleRobot
|
|
{
|
|
RobotDrive myRobot; // robot drive system
|
|
Joystick stick; // only joystick
|
|
|
|
public:
|
|
Robot() :
|
|
myRobot(1, 2), // these must be initialized in the same order
|
|
stick(1) // as they are declared above.
|
|
{
|
|
myRobot.SetExpiration(0.1);
|
|
}
|
|
|
|
/**
|
|
* Drive left & right motors for 2 seconds then stop
|
|
*/
|
|
void Autonomous()
|
|
{
|
|
myRobot.SetSafetyEnabled(false);
|
|
myRobot.Drive(-0.5, 0.0); // drive forwards half speed
|
|
Wait(2.0); // for 2 seconds
|
|
myRobot.Drive(0.0, 0.0); // stop robot
|
|
}
|
|
|
|
/**
|
|
* Runs the motors with arcade steering.
|
|
*/
|
|
void OperatorControl()
|
|
{
|
|
myRobot.SetSafetyEnabled(true);
|
|
while (IsOperatorControl())
|
|
{
|
|
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
|
|
Wait(0.005); // wait for a motor update time
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Runs during test mode
|
|
*/
|
|
void Test()
|
|
{
|
|
|
|
}
|
|
};
|
|
|
|
START_ROBOT_CLASS(Robot);
|