mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Squashed commit of the following: commit f317b3522e312cf7e7bb9eb0494f2f96a7f6363c Author: Kevin O'Connor <koconnor@usfirst.org> Date: Mon Oct 20 17:15:46 2014 -0400 Send unhandled exceptions back to the DS. Change-Id: I0e658fdb6d43593ee20457f20f71f4f4cd2d21c3 commit f834ef8c791945697ad483c27b4167eb917ac242 Author: Kevin O'Connor <koconnor@usfirst.org> Date: Mon Oct 20 16:05:24 2014 -0400 Add StackTrace to Java errors Change-Id: I83b162afcc5f294703705770fbcd8623b0895539 commit 02e040b0c79067ce046ada29e26004e0460fceb0 Author: Kevin O'Connor <koconnor@usfirst.org> Date: Mon Oct 20 15:07:44 2014 -0400 HAL Errors to DS in Java Change-Id: I5fb51e4066bbc26ea59ca513c03c5ec5ace98831 commit 03775ddc42b129c27fdf403f17f0796009311c3c Author: Kevin O'Connor <koconnor@usfirst.org> Date: Mon Oct 20 13:38:18 2014 -0400 Update AnalogInput to report errors for getting and setting sample rate Change-Id: I00eb78f52fc5b17a60bc84456f0ec9842cc40ef7 commit 4c10cb79612ae81e3cbb6bd4d6da8cf3b8955821 Author: Kevin O'Connor <koconnor@usfirst.org> Date: Mon Oct 20 11:46:03 2014 -0400 Define errors in HAL Change-Id: I96595472e42ba61f0f3d0da17caf01a748d0422a commit 56cb5dcd93e5e849a016f63ac9d0dc245a23eb2b Author: Kevin O'Connor <koconnor@usfirst.org> Date: Fri Oct 17 10:59:29 2014 -0400 Throttle errors (1 report per second per error code) and fix issue with GetTime conflicting with GetTime from Timer.h/Timer.cpp Change-Id: Ibe4dc2e400fc4671b240b876a46959256ea65ad7 commit 71c78826e548682ecd0c1548255f8a6552cece32 Author: Kevin O'Connor <koconnor@usfirst.org> Date: Thu Oct 16 16:41:04 2014 -0400 Feed errors to DS from C++ Change-Id: I009a7798499fd93e9fdd976ff00aa74c0bd094ae commit 81030c6cee7f18a5ddf0e95c4e402a6cf7b5de6c Author: Kevin O'Connor <koconnor@usfirst.org> Date: Thu Oct 16 16:40:50 2014 -0400 Don't try to de-mangle lines without any symbols in them Change-Id: Icea02494b68f2ec9116d6cbf20a35a3a132234f8 Change-Id: If7717025b03914183736ccd95da5c9d49819a6f3
132 lines
3.8 KiB
C++
132 lines
3.8 KiB
C++
/*----------------------------------------------------------------------------*/
|
|
/* 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. */
|
|
/*----------------------------------------------------------------------------*/
|
|
#pragma once
|
|
|
|
#include "simulation/msgs/msgs.h"
|
|
#include <gazebo/transport/transport.hh>
|
|
#include "SensorBase.h"
|
|
#include "RobotState.h"
|
|
#include "Task.h"
|
|
|
|
struct HALCommonControlData;
|
|
class AnalogInput;
|
|
|
|
using namespace gazebo;
|
|
|
|
/**
|
|
* Provide access to the network communication data to / from the Driver Station.
|
|
*/
|
|
class DriverStation : public SensorBase, public RobotStateInterface
|
|
{
|
|
public:
|
|
enum Alliance
|
|
{
|
|
kRed,
|
|
kBlue,
|
|
kInvalid
|
|
};
|
|
|
|
virtual ~DriverStation();
|
|
static DriverStation *GetInstance();
|
|
static void ReportError(std::string error);
|
|
|
|
static const uint32_t kBatteryChannel = 7;
|
|
static const uint32_t kJoystickPorts = 4;
|
|
static const uint32_t kJoystickAxes = 6;
|
|
|
|
float GetStickAxis(uint32_t stick, uint32_t axis);
|
|
bool GetStickButton(uint32_t stick, uint32_t button);
|
|
short GetStickButtons(uint32_t stick);
|
|
|
|
float GetAnalogIn(uint32_t channel);
|
|
bool GetDigitalIn(uint32_t channel);
|
|
void SetDigitalOut(uint32_t channel, bool value);
|
|
bool GetDigitalOut(uint32_t channel);
|
|
|
|
bool IsEnabled();
|
|
bool IsDisabled();
|
|
bool IsAutonomous();
|
|
bool IsOperatorControl();
|
|
bool IsTest();
|
|
bool IsFMSAttached();
|
|
|
|
uint32_t GetPacketNumber();
|
|
Alliance GetAlliance();
|
|
uint32_t GetLocation();
|
|
void WaitForData();
|
|
double GetMatchTime();
|
|
float GetBatteryVoltage();
|
|
uint16_t GetTeamNumber();
|
|
|
|
|
|
|
|
void IncrementUpdateNumber()
|
|
{
|
|
m_updateNumber++;
|
|
}
|
|
|
|
/** Only to be used to tell the Driver Station what code you claim to be executing
|
|
* for diagnostic purposes only
|
|
* @param entering If true, starting disabled code; if false, leaving disabled code */
|
|
void InDisabled(bool entering)
|
|
{
|
|
m_userInDisabled = entering;
|
|
}
|
|
/** Only to be used to tell the Driver Station what code you claim to be executing
|
|
* for diagnostic purposes only
|
|
* @param entering If true, starting autonomous code; if false, leaving autonomous code */
|
|
void InAutonomous(bool entering)
|
|
{
|
|
m_userInAutonomous = entering;
|
|
}
|
|
/** Only to be used to tell the Driver Station what code you claim to be executing
|
|
* for diagnostic purposes only
|
|
* @param entering If true, starting teleop code; if false, leaving teleop code */
|
|
void InOperatorControl(bool entering)
|
|
{
|
|
m_userInTeleop = entering;
|
|
}
|
|
/** Only to be used to tell the Driver Station what code you claim to be executing
|
|
* for diagnostic purposes only
|
|
* @param entering If true, starting test code; if false, leaving test code */
|
|
void InTest(bool entering)
|
|
{
|
|
m_userInTest = entering;
|
|
}
|
|
|
|
protected:
|
|
DriverStation();
|
|
|
|
private:
|
|
static void InitTask(DriverStation *ds);
|
|
static DriverStation *m_instance;
|
|
static uint8_t m_updateNumber;
|
|
///< TODO: Get rid of this and use the semaphore signaling
|
|
static constexpr float kUpdatePeriod = 0.02;
|
|
|
|
void stateCallback(const msgs::ConstDriverStationPtr &msg);
|
|
void joystickCallback(const msgs::ConstJoystickPtr &msg, int i);
|
|
void joystickCallback1(const msgs::ConstJoystickPtr &msg);
|
|
void joystickCallback2(const msgs::ConstJoystickPtr &msg);
|
|
void joystickCallback3(const msgs::ConstJoystickPtr &msg);
|
|
void joystickCallback4(const msgs::ConstJoystickPtr &msg);
|
|
|
|
uint8_t m_digitalOut;
|
|
MULTIWAIT_ID m_waitForDataSem;
|
|
MUTEX_ID m_stateSemaphore;
|
|
MUTEX_ID m_joystickSemaphore;
|
|
double m_approxMatchTimeOffset;
|
|
bool m_userInDisabled;
|
|
bool m_userInAutonomous;
|
|
bool m_userInTeleop;
|
|
bool m_userInTest;
|
|
|
|
transport::SubscriberPtr stateSub;
|
|
transport::SubscriberPtr joysticksSub[4];
|
|
msgs::DriverStationPtr state;
|
|
msgs::JoystickPtr joysticks[4];
|
|
};
|