2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) FIRST 2008. All Rights Reserved. */
|
|
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "DriverStation.h"
|
2014-06-12 18:07:45 -04:00
|
|
|
#include "AnalogInput.h"
|
2014-05-02 17:54:01 -04:00
|
|
|
#include "HAL/cpp/Synchronized.hpp"
|
2013-12-15 18:30:16 -05:00
|
|
|
#include "Timer.h"
|
2014-08-08 17:05:49 -04:00
|
|
|
#include "NetworkCommunication/FRCComm.h"
|
|
|
|
|
#include "NetworkCommunication/UsageReporting.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
#include "MotorSafetyHelper.h"
|
|
|
|
|
#include "Utility.h"
|
|
|
|
|
#include "WPIErrors.h"
|
|
|
|
|
#include <string.h>
|
2014-05-02 17:54:01 -04:00
|
|
|
#include "Log.hpp"
|
2014-01-06 10:12:21 -05:00
|
|
|
|
|
|
|
|
// set the logging level
|
|
|
|
|
TLogLevel dsLogLevel = logDEBUG;
|
2014-12-03 11:02:12 -05:00
|
|
|
const double JOYSTICK_UNPLUGGED_MESSAGE_INTERVAL = 1.0;
|
2014-01-06 10:12:21 -05:00
|
|
|
|
|
|
|
|
#define DS_LOG(level) \
|
2014-08-06 11:29:15 -04:00
|
|
|
if (level > dsLogLevel) ; \
|
|
|
|
|
else Log().Get(level)
|
2013-12-15 18:30:16 -05:00
|
|
|
|
|
|
|
|
const uint32_t DriverStation::kJoystickPorts;
|
|
|
|
|
DriverStation* DriverStation::m_instance = NULL;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* DriverStation contructor.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* This is only called once the first time GetInstance() is called
|
|
|
|
|
*/
|
|
|
|
|
DriverStation::DriverStation()
|
2014-11-21 13:14:48 -05:00
|
|
|
: m_task ("DriverStation", (FUNCPTR)DriverStation::InitTask)
|
2013-12-15 18:30:16 -05:00
|
|
|
, m_newControlData(0)
|
2014-11-16 16:57:02 -05:00
|
|
|
, m_packetDataAvailableMultiWait(0)
|
2013-12-15 18:30:16 -05:00
|
|
|
, m_waitForDataSem(0)
|
|
|
|
|
, m_userInDisabled(false)
|
|
|
|
|
, m_userInAutonomous(false)
|
|
|
|
|
, m_userInTeleop(false)
|
|
|
|
|
, m_userInTest(false)
|
2014-12-03 07:42:48 -05:00
|
|
|
, m_nextMessageTime(0)
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
|
|
|
|
// Create a new semaphore
|
2014-11-16 16:57:02 -05:00
|
|
|
m_packetDataAvailableMultiWait = initializeMultiWait();
|
2014-01-06 10:12:21 -05:00
|
|
|
m_newControlData = initializeSemaphore(SEMAPHORE_EMPTY);
|
2013-12-15 18:30:16 -05:00
|
|
|
|
|
|
|
|
m_waitForDataSem = initializeMultiWait();
|
2014-11-08 14:27:49 -05:00
|
|
|
m_waitForDataMutex = initializeMutexNormal();
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2014-11-16 16:57:02 -05:00
|
|
|
m_packetDataAvailableMultiWait = initializeMultiWait();
|
|
|
|
|
m_packetDataAvailableMutex = initializeMutexNormal();
|
|
|
|
|
|
|
|
|
|
// Register that semaphore with the network communications task.
|
|
|
|
|
// It will signal when new packet data is available.
|
|
|
|
|
HALSetNewDataSem(m_packetDataAvailableMultiWait);
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
AddToSingletonList();
|
|
|
|
|
|
|
|
|
|
if (!m_task.Start((int32_t)this))
|
|
|
|
|
{
|
|
|
|
|
wpi_setWPIError(DriverStationTaskError);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DriverStation::~DriverStation()
|
|
|
|
|
{
|
|
|
|
|
m_task.Stop();
|
|
|
|
|
m_instance = NULL;
|
|
|
|
|
deleteMultiWait(m_waitForDataSem);
|
|
|
|
|
// Unregister our semaphore.
|
2014-01-06 10:12:21 -05:00
|
|
|
HALSetNewDataSem(0);
|
2014-11-16 16:57:02 -05:00
|
|
|
deleteMultiWait(m_packetDataAvailableMultiWait);
|
|
|
|
|
deleteMutex(m_packetDataAvailableMutex);
|
2014-11-08 14:27:49 -05:00
|
|
|
deleteMutex(m_waitForDataMutex);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DriverStation::InitTask(DriverStation *ds)
|
|
|
|
|
{
|
|
|
|
|
ds->Run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DriverStation::Run()
|
|
|
|
|
{
|
2014-11-25 17:34:38 -05:00
|
|
|
HALControlWord controlWord;
|
2013-12-15 18:30:16 -05:00
|
|
|
int period = 0;
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
2014-11-25 17:34:38 -05:00
|
|
|
// need to get the controlWord to keep the motors enabled
|
|
|
|
|
HALGetControlWord(&controlWord);
|
|
|
|
|
takeMultiWait(m_packetDataAvailableMultiWait, m_packetDataAvailableMutex, 0);
|
2013-12-15 18:30:16 -05:00
|
|
|
giveMultiWait(m_waitForDataSem);
|
2014-11-21 13:14:48 -05:00
|
|
|
giveSemaphore(m_newControlData);
|
2014-11-25 17:34:38 -05:00
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
if (++period >= 4)
|
|
|
|
|
{
|
|
|
|
|
MotorSafetyHelper::CheckMotors();
|
|
|
|
|
period = 0;
|
|
|
|
|
}
|
|
|
|
|
if (m_userInDisabled)
|
2014-01-06 10:12:21 -05:00
|
|
|
HALNetworkCommunicationObserveUserProgramDisabled();
|
2013-12-15 18:30:16 -05:00
|
|
|
if (m_userInAutonomous)
|
2014-01-06 10:12:21 -05:00
|
|
|
HALNetworkCommunicationObserveUserProgramAutonomous();
|
2014-08-06 11:29:15 -04:00
|
|
|
if (m_userInTeleop)
|
|
|
|
|
HALNetworkCommunicationObserveUserProgramTeleop();
|
|
|
|
|
if (m_userInTest)
|
|
|
|
|
HALNetworkCommunicationObserveUserProgramTest();
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return a pointer to the singleton DriverStation.
|
|
|
|
|
*/
|
|
|
|
|
DriverStation* DriverStation::GetInstance()
|
|
|
|
|
{
|
|
|
|
|
if (m_instance == NULL)
|
|
|
|
|
{
|
|
|
|
|
m_instance = new DriverStation();
|
|
|
|
|
}
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-08-06 11:29:15 -04:00
|
|
|
* Read the battery voltage.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @return The battery voltage.
|
|
|
|
|
*/
|
|
|
|
|
float DriverStation::GetBatteryVoltage()
|
|
|
|
|
{
|
2014-08-08 14:56:22 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
float voltage = getVinVoltage(&status);
|
|
|
|
|
wpi_setErrorWithContext(status, "getVinVoltage");
|
|
|
|
|
|
|
|
|
|
return voltage;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-12-03 07:42:48 -05:00
|
|
|
void DriverStation::ReportJoystickUnpluggedError(std::string message) {
|
|
|
|
|
double currentTime = Timer::GetFPGATimestamp();
|
|
|
|
|
if (currentTime > m_nextMessageTime) {
|
|
|
|
|
ReportError(message);
|
|
|
|
|
m_nextMessageTime = currentTime + JOYSTICK_UNPLUGGED_MESSAGE_INTERVAL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* Get the value of the axis on a joystick.
|
|
|
|
|
* This depends on the mapping of the joystick connected to the specified port.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param stick The joystick to read.
|
|
|
|
|
* @param axis The analog axis value to read from the joystick.
|
|
|
|
|
* @return The value of the axis on the joystick.
|
|
|
|
|
*/
|
|
|
|
|
float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis)
|
|
|
|
|
{
|
2014-10-01 11:25:51 -04:00
|
|
|
if (stick >= kJoystickPorts)
|
2014-08-06 11:29:15 -04:00
|
|
|
{
|
|
|
|
|
wpi_setWPIError(BadJoystickIndex);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-21 13:14:48 -05:00
|
|
|
HALJoystickAxes joystickAxes;
|
|
|
|
|
HALGetJoystickAxes(stick, &joystickAxes);
|
|
|
|
|
if (axis >= joystickAxes.count)
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
2014-10-24 23:47:17 -07:00
|
|
|
if (axis >= kMaxJoystickAxes)
|
|
|
|
|
wpi_setWPIError(BadJoystickAxis);
|
|
|
|
|
else
|
2014-12-03 07:42:48 -05:00
|
|
|
ReportJoystickUnpluggedError("WARNING: Joystick Axis missing, check if all controllers are plugged in\n");
|
2014-08-06 11:29:15 -04:00
|
|
|
return 0.0f;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-11-21 13:14:48 -05:00
|
|
|
int8_t value = joystickAxes.axes[axis];
|
2014-08-06 11:29:15 -04:00
|
|
|
|
|
|
|
|
if(value < 0)
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
2014-08-06 11:29:15 -04:00
|
|
|
return value / 128.0f;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
else
|
2014-08-06 11:29:15 -04:00
|
|
|
{
|
|
|
|
|
return value / 127.0f;
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-10-17 14:46:25 -04:00
|
|
|
/**
|
|
|
|
|
* Get the state of a POV on the joystick.
|
|
|
|
|
*
|
|
|
|
|
* @return the angle of the POV in degrees, or -1 if the POV is not pressed.
|
|
|
|
|
*/
|
|
|
|
|
int DriverStation::GetStickPOV(uint32_t stick, uint32_t pov) {
|
|
|
|
|
if (stick >= kJoystickPorts)
|
|
|
|
|
{
|
|
|
|
|
wpi_setWPIError(BadJoystickIndex);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2014-11-21 13:14:48 -05:00
|
|
|
|
|
|
|
|
HALJoystickPOVs joystickPOVs;
|
|
|
|
|
HALGetJoystickPOVs(stick, &joystickPOVs);
|
|
|
|
|
if (pov >= joystickPOVs.count)
|
2014-10-17 14:46:25 -04:00
|
|
|
{
|
2014-10-24 23:47:17 -07:00
|
|
|
if (pov >= kMaxJoystickPOVs)
|
|
|
|
|
wpi_setWPIError(BadJoystickAxis);
|
|
|
|
|
else
|
2014-12-03 07:42:48 -05:00
|
|
|
ReportJoystickUnpluggedError("WARNING: Joystick POV missing, check if all controllers are plugged in\n");
|
2014-10-17 14:46:25 -04:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-21 13:14:48 -05:00
|
|
|
return joystickPOVs.povs[pov];
|
2014-10-17 14:46:25 -04:00
|
|
|
}
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* The state of the buttons on the joystick.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param stick The joystick to read.
|
|
|
|
|
* @return The state of the buttons on the joystick.
|
|
|
|
|
*/
|
2014-11-21 11:32:08 -05:00
|
|
|
bool DriverStation::GetStickButton(uint32_t stick, uint8_t button)
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
2014-10-01 11:25:51 -04:00
|
|
|
if (stick >= kJoystickPorts)
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
2014-08-06 11:29:15 -04:00
|
|
|
wpi_setWPIError(BadJoystickIndex);
|
|
|
|
|
return 0;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
2014-11-21 11:32:08 -05:00
|
|
|
HALJoystickButtons joystickButtons;
|
|
|
|
|
HALGetJoystickButtons(stick, &joystickButtons);
|
2014-12-04 14:21:33 -05:00
|
|
|
if(button > joystickButtons.count)
|
2014-11-21 11:32:08 -05:00
|
|
|
{
|
2014-12-03 07:42:48 -05:00
|
|
|
ReportJoystickUnpluggedError("WARNING: Joystick Button missing, check if all controllers are plugged in\n");
|
2014-11-21 11:32:08 -05:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return ((0x1 << (button-1)) & joystickButtons.buttons) !=0;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DriverStation::IsEnabled()
|
|
|
|
|
{
|
2014-11-21 13:14:48 -05:00
|
|
|
HALControlWord controlWord;
|
2014-11-25 17:34:38 -05:00
|
|
|
memset(&controlWord, 0, sizeof(controlWord));
|
2014-11-21 13:14:48 -05:00
|
|
|
HALGetControlWord(&controlWord);
|
|
|
|
|
return controlWord.enabled && controlWord.dsAttached;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DriverStation::IsDisabled()
|
|
|
|
|
{
|
2014-11-21 13:14:48 -05:00
|
|
|
HALControlWord controlWord;
|
2014-11-25 17:34:38 -05:00
|
|
|
memset(&controlWord, 0, sizeof(controlWord));
|
2014-11-21 13:14:48 -05:00
|
|
|
HALGetControlWord(&controlWord);
|
|
|
|
|
return !(controlWord.enabled && controlWord.dsAttached);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DriverStation::IsAutonomous()
|
|
|
|
|
{
|
2014-11-21 13:14:48 -05:00
|
|
|
HALControlWord controlWord;
|
2014-11-25 17:34:38 -05:00
|
|
|
memset(&controlWord, 0, sizeof(controlWord));
|
2014-11-21 13:14:48 -05:00
|
|
|
HALGetControlWord(&controlWord);
|
|
|
|
|
return controlWord.autonomous;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DriverStation::IsOperatorControl()
|
|
|
|
|
{
|
2014-11-21 13:14:48 -05:00
|
|
|
HALControlWord controlWord;
|
2014-11-25 17:34:38 -05:00
|
|
|
memset(&controlWord, 0, sizeof(controlWord));
|
2014-11-21 13:14:48 -05:00
|
|
|
HALGetControlWord(&controlWord);
|
|
|
|
|
return !(controlWord.autonomous || controlWord.test);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DriverStation::IsTest()
|
|
|
|
|
{
|
2014-11-21 13:14:48 -05:00
|
|
|
HALControlWord controlWord;
|
|
|
|
|
HALGetControlWord(&controlWord);
|
|
|
|
|
return controlWord.test;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-11-18 10:56:25 -05:00
|
|
|
bool DriverStation::IsDSAttached()
|
|
|
|
|
{
|
|
|
|
|
HALControlWord controlWord;
|
2014-11-25 17:34:38 -05:00
|
|
|
memset(&controlWord, 0, sizeof(controlWord));
|
2014-11-18 10:56:25 -05:00
|
|
|
HALGetControlWord(&controlWord);
|
|
|
|
|
return controlWord.dsAttached;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DriverStation::IsSysActive()
|
|
|
|
|
{
|
|
|
|
|
int32_t status = 0;
|
|
|
|
|
bool retVal = HALGetSystemActive(&status);
|
|
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DriverStation::IsSysBrownedOut()
|
|
|
|
|
{
|
|
|
|
|
int32_t status = 0;
|
|
|
|
|
bool retVal = HALGetBrownedOut(&status);
|
|
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* Has a new control packet from the driver station arrived since the last time this function was called?
|
|
|
|
|
* Warning: If you call this function from more than one place at the same time,
|
|
|
|
|
* you will not get the get the intended behavior
|
|
|
|
|
* @return True if the control data has been updated since the last call.
|
|
|
|
|
*/
|
|
|
|
|
bool DriverStation::IsNewControlData()
|
|
|
|
|
{
|
2014-01-06 10:12:21 -05:00
|
|
|
return tryTakeSemaphore(m_newControlData) == 0;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Is the driver station attached to a Field Management System?
|
|
|
|
|
* Note: This does not work with the Blue DS.
|
|
|
|
|
* @return True if the robot is competing on a field being controlled by a Field Management System
|
|
|
|
|
*/
|
|
|
|
|
bool DriverStation::IsFMSAttached()
|
|
|
|
|
{
|
2014-11-21 13:14:48 -05:00
|
|
|
HALControlWord controlWord;
|
|
|
|
|
HALGetControlWord(&controlWord);
|
|
|
|
|
return controlWord.fmsAttached;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the alliance that the driver station says it is on.
|
|
|
|
|
* This could return kRed or kBlue
|
|
|
|
|
* @return The Alliance enum
|
|
|
|
|
*/
|
|
|
|
|
DriverStation::Alliance DriverStation::GetAlliance()
|
|
|
|
|
{
|
2014-11-21 13:14:48 -05:00
|
|
|
HALAllianceStationID allianceStationID;
|
|
|
|
|
HALGetAllianceStation(&allianceStationID);
|
|
|
|
|
switch(allianceStationID)
|
2014-08-06 11:29:15 -04:00
|
|
|
{
|
|
|
|
|
case kHALAllianceStationID_red1:
|
|
|
|
|
case kHALAllianceStationID_red2:
|
|
|
|
|
case kHALAllianceStationID_red3:
|
|
|
|
|
return kRed;
|
|
|
|
|
case kHALAllianceStationID_blue1:
|
|
|
|
|
case kHALAllianceStationID_blue2:
|
|
|
|
|
case kHALAllianceStationID_blue3:
|
|
|
|
|
return kBlue;
|
|
|
|
|
default:
|
|
|
|
|
return kInvalid;
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the driver station location on the field
|
|
|
|
|
* This could return 1, 2, or 3
|
|
|
|
|
* @return The location of the driver station
|
|
|
|
|
*/
|
|
|
|
|
uint32_t DriverStation::GetLocation()
|
|
|
|
|
{
|
2014-11-21 13:14:48 -05:00
|
|
|
HALAllianceStationID allianceStationID;
|
|
|
|
|
HALGetAllianceStation(&allianceStationID);
|
|
|
|
|
switch(allianceStationID)
|
2014-08-06 11:29:15 -04:00
|
|
|
{
|
|
|
|
|
case kHALAllianceStationID_red1:
|
|
|
|
|
case kHALAllianceStationID_blue1:
|
|
|
|
|
return 1;
|
|
|
|
|
case kHALAllianceStationID_red2:
|
|
|
|
|
case kHALAllianceStationID_blue2:
|
|
|
|
|
return 2;
|
|
|
|
|
case kHALAllianceStationID_red3:
|
|
|
|
|
case kHALAllianceStationID_blue3:
|
|
|
|
|
return 3;
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Wait until a new packet comes from the driver station
|
|
|
|
|
* This blocks on a semaphore, so the waiting is efficient.
|
|
|
|
|
* This is a good way to delay processing until there is new driver station data to act on
|
|
|
|
|
*/
|
|
|
|
|
void DriverStation::WaitForData()
|
|
|
|
|
{
|
2014-11-08 14:27:49 -05:00
|
|
|
takeMultiWait(m_waitForDataSem, m_waitForDataMutex, SEMAPHORE_WAIT_FOREVER);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the approximate match time
|
|
|
|
|
* The FMS does not currently send the official match time to the robots
|
|
|
|
|
* This returns the time since the enable signal sent from the Driver Station
|
|
|
|
|
* At the beginning of autonomous, the time is reset to 0.0 seconds
|
|
|
|
|
* At the beginning of teleop, the time is reset to +15.0 seconds
|
|
|
|
|
* If the robot is disabled, this returns 0.0 seconds
|
|
|
|
|
* Warning: This is not an official time (so it cannot be used to argue with referees)
|
|
|
|
|
* @return Match time in seconds since the beginning of autonomous
|
|
|
|
|
*/
|
|
|
|
|
double DriverStation::GetMatchTime()
|
|
|
|
|
{
|
2014-11-21 10:37:29 -05:00
|
|
|
float matchTime;
|
|
|
|
|
HALGetMatchTime(&matchTime);
|
|
|
|
|
return (double)matchTime;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
2014-10-20 17:19:28 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Report an error to the DriverStation messages window.
|
|
|
|
|
* The error is also printed to the program console.
|
|
|
|
|
*/
|
|
|
|
|
void DriverStation::ReportError(std::string error)
|
|
|
|
|
{
|
|
|
|
|
std::cout << error << std::endl;
|
|
|
|
|
HALSetErrorData(error.c_str(), error.size(), 0);
|
|
|
|
|
}
|