xrp style wpilib comms
|
top level class for the XRP-style WPILib communications This class handles the UDP communication, message parsing, and data retrieval/sending. More...
#include <xrp-style-wpilib-comms.h>
Classes | |
class | MessageTypeFactory |
Factory class to create message types based on their tag. This is only used internally by the XSWC class. More... | |
Public Member Functions | |
bool | getData_xrp_motor (xrp_motor_t &data, const uint8_t id) |
Retrieves data for a specific motor by ID. | |
float | getValue_xrp_motor (const uint8_t id) |
Retrieves the value of a specific motor by ID. | |
bool | getData_xrp_servo (xrp_servo_t &data, const uint8_t id) |
Retrieves data for a specific servo by ID. | |
float | getValue_xrp_servo (const uint8_t id) |
Retrieves the value of a specific servo by ID. | |
bool | getData_xrp_dio (xrp_dio_t &data, const uint8_t id) |
Retrieves data for a specific digital input/output by ID. | |
bool | getValue_xrp_dio (const uint8_t id) |
Retrieves the value of a specific digital input/output by ID. | |
bool | getData_xrp_analog (xrp_analog_t &data, const uint8_t id) |
Retrieves data for a specific analog input by ID. | |
float | getValue_xrp_analog (const uint8_t id) |
Retrieves the value of a specific analog input by ID. | |
bool | sendData_xrp_dio (const xrp_dio_t &data, bool checkUniqueness=false) |
Sends data for a specific digital input by ID. | |
bool | sendValue_xrp_dio (const uint8_t id, bool value, bool checkUniqueness=false) |
Send a boolean value for a specific digital input/output by ID. | |
bool | sendData_xrp_analog (const xrp_analog_t &data, bool checkUniqueness=false) |
Sends data for a specific analog input by ID. | |
bool | sendValue_xrp_analog (const uint8_t id, float value, bool checkUniqueness=false) |
Sends a float value for a specific analog input by ID. | |
bool | sendData_xrp_encoder (const xrp_encoder_t &data, bool checkUniqueness=false) |
Sends data for a specific encoder by ID. | |
bool | sendValue_xrp_encoder (const uint8_t id, int32_t count, int32_t period=0, int32_t divisor=1, bool checkUniqueness=false) |
Sends values for a specific encoder by ID. | |
bool | sendData_xrp_gyro (const xrp_gyro_t &data, bool checkUniqueness=false) |
Sends gyroscope data. | |
bool | sendValue_xrp_gyro (float xRate, float yRate, float zRate, float roll, float pitch, float yaw, bool checkUniqueness=false) |
Sends gyroscope values. | |
bool | sendData_xrp_accel (const xrp_accel_t &data, bool checkUniqueness=false) |
Sends accelerometer data. | |
bool | sendValue_xrp_accel (const uint8_t id, float xAccel, float yAccel, float zAccel, bool checkUniqueness=false) |
Sends accelerometer values. | |
XSWC () | |
constructor of XSWC class, use the global xswc instance to access this class | |
bool | begin (void(*_receiveCallback)(void), void(*_sendCallback)(void), uint16_t port=3540) |
begin udp communication on given port | |
bool | begin (const char *ssid, const char *password, void(*_receiveCallback)(void), void(*_sendCallback)(void), const char *hostname="XRP-XSWC", uint16_t port=3540) |
connect to a WiFi network and begin udp communication on given port | |
bool | update () |
call this in void loop() | |
bool | isConnected () |
bool | isEnabled () |
bool | isConnectedAndEnabled () |
Public Attributes | |
unsigned long | TIMEOUT_MS = 1000 |
unsigned long | MIN_UPDATE_TIME_MS = 50 |
bool | useAP = false |
set to true before calling begin() to skip straight to creating an Access Point | |
Protected Member Functions | |
template<typename T > | |
bool | getData (T &data, const uint8_t id) |
template<typename T > | |
bool | sendData (T data, bool checkUniqueness) |
boolean | processReceivedBufferIntoMessages (char *buffer, int length) |
int | processMessagesIntoBufferToSend (char *buffer, int length) |
Protected Attributes | |
WiFiUDP | udp |
std::vector< MessageType * > | receivedMessages |
std::vector< MessageType * > | sentMessages |
boolean | cmdEnable = false |
unsigned long | millisWhenLastMessageReceived = -TIMEOUT_MS |
unsigned long | millisWhenLastSent = -MIN_UPDATE_TIME_MS |
uint16_t | txSeq = 0 |
char | rxBuf [UDP_PACKET_MAX_SIZE_XRP+1] |
char | txBuf [UDP_PACKET_MAX_SIZE_XRP+1] |
bool | connectedToRemote = false |
IPAddress | udpRemoteAddr = IPAddress() |
int32_t | udpRemotePort = -1 |
void(* | sendCallback )(void) |
void(* | receiveCallback )(void) |
top level class for the XRP-style WPILib communications This class handles the UDP communication, message parsing, and data retrieval/sending.
XSWC::XSWC | ( | ) |
constructor of XSWC class, use the global xswc instance to access this class
bool XSWC::begin | ( | const char * | ssid, |
const char * | password, | ||
void(* | _receiveCallback )(void), | ||
void(* | _sendCallback )(void), | ||
const char * | hostname = "XRP-XSWC", | ||
uint16_t | port = 3540 ) |
connect to a WiFi network and begin udp communication on given port
ssid | the SSID of the WiFi network to connect to |
password | the password for the WiFi network |
_receiveCallback | a function to call when data is received (add getData methods to the function to retrieve the data) |
_sendCallback | a function to call to collect data to send (add sendData methods to the function to send the data) |
hostname | the hostname to use for the WiFi connection, default "XRP-XSWC" |
port | the UDP port to use for communication, default 3540 |
(bool) | true if connection was successful, false otherwise |
bool XSWC::begin | ( | void(* | _receiveCallback )(void), |
void(* | _sendCallback )(void), | ||
uint16_t | port = 3540 ) |
begin udp communication on given port
_receiveCallback | a function to call when data is received (add getData methods to the function to retrieve the data) |
_sendCallback | a function to call to collect data to send (add sendData methods to the function to send the data) |
port | udp port, default 3540 |
(bool) | true if connection was successful, false otherwise |
|
inlineprotected |
|
inline |
Retrieves data for a specific analog input by ID.
data | a reference to an xrp_analog_t structure to fill with data |
id | the ID of the analog input |
(bool) | true if data was found, false otherwise |
|
inline |
Retrieves data for a specific digital input/output by ID.
data | a reference to an xrp_dio_t structure to fill with data |
id | the ID of the digital input/output |
(bool) | true if data was found, false otherwise |
|
inline |
Retrieves data for a specific motor by ID.
data | a reference to an xrp_motor_t structure to fill with data |
id | the ID of the motor |
(bool) | true if data was found, false otherwise |
|
inline |
Retrieves data for a specific servo by ID.
data | a reference to an xrp_servo_t structure to fill with data |
id | the ID of the servo |
(bool) | true if data was found, false otherwise |
|
inline |
Retrieves the value of a specific analog input by ID.
id | the ID of the analog input |
(float) | the value of the analog input, or 0.0 if not found |
|
inline |
Retrieves the value of a specific digital input/output by ID.
id | the ID of the digital input/output |
(bool) | true if the value is 1 (true), false if the value is 0 (false) or not found |
|
inline |
Retrieves the value of a specific motor by ID.
id | the ID of the motor |
(float) | the value of the motor, or 0.0 if not found |
|
inline |
Retrieves the value of a specific servo by ID.
id | the ID of the servo |
(float) | the value of the servo, or 0.0 if not found |
bool XSWC::isConnected | ( | ) |
bool XSWC::isConnectedAndEnabled | ( | ) |
bool XSWC::isEnabled | ( | ) |
|
protected |
|
protected |
|
inlineprotected |
|
inline |
Sends accelerometer data.
data | the xrp_accel_t structure containing the accelerometer data |
checkUniqueness | If true, it checks if a message with the same ID already exists in the sent messages, default false |
(bool) | true if data was queued successfully, false otherwise |
|
inline |
Sends data for a specific analog input by ID.
data | the xrp_analog_t structure containing the data to send (including ID) |
checkUniqueness | If true, it checks if a message with the same ID already exists in the sent messages, default false |
(bool) | true if data was queued successfully, false otherwise |
|
inline |
Sends data for a specific digital input by ID.
data | the xrp_dio_t structure containing the data to send (including ID) |
checkUniqueness | if true, it checks if a message with the same ID already exists in the sent messages, default false |
(bool) | true if data was queued successfully, false otherwise |
|
inline |
Sends data for a specific encoder by ID.
data | the xrp_encoder_t structure containing the data to send (including ID) |
checkUniqueness | If true, it checks if a message with the same ID already exists in the sent messages, default false |
(bool) | true if data was queued successfully, false otherwise |
|
inline |
Sends gyroscope data.
data | the xrp_gyro_t structure containing the gyroscope data |
checkUniqueness | If true, it checks if a message with the same ID already exists in the sent messages, default false |
(bool) | true if data was queued successfully, false otherwise |
|
inline |
Sends accelerometer values.
xAccel | (float) acceleration in X/forward direction |
yAccel | (float) acceleration in Y/left direction |
zAccel | (float) acceleration in Z/up direction |
checkUniqueness | If true, it checks if a message with the same ID already exists in the sent messages, default false |
(bool) | true if data was queued successfully, false otherwise |
|
inline |
Sends a float value for a specific analog input by ID.
id | the ID of the analog input |
value | (float) the value to send |
checkUniqueness | If true, it checks if a message with the same ID already exists in the sent messages, default false |
(bool) | true if data was queued successfully, false otherwise |
|
inline |
Send a boolean value for a specific digital input/output by ID.
id | the ID of the digital input/output |
value | (bool) the boolean value to send (true or false) |
checkUniqueness | If true, it checks if a message with the same ID already exists in the sent messages, default false |
(bool) | true if data was queued successfully, false otherwise |
|
inline |
Sends values for a specific encoder by ID.
id | the ID of the encoder |
count | (int32_t) count of encoder ticks |
period | (int32_t) encoder period |
divisor | (int32_t) encoder divisor |
checkUniqueness | If true, it checks if a message with the same ID already exists in the sent messages, default false |
(bool) | true if data was queued successfully, false otherwise |
|
inline |
Sends gyroscope values.
xRate | (float) gyro rate around X/roll axis |
yRate | (float) gyro rate around Y/pitch axis |
zRate | (float) gyro rate around Z/yaw axis |
roll | (float) angle around X axis |
pitch | (float) angle around Y axis |
yaw | (float) angle around Z axis |
checkUniqueness | If true, it checks if a message with the same ID already exists in the sent messages, default false |
(bool) | true if data was queued successfully, false otherwise |
bool XSWC::update | ( | ) |
call this in void loop()
true | if data was just received |
|
protected |
|
protected |
|
protected |
|
protected |
unsigned long XSWC::MIN_UPDATE_TIME_MS = 50 |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
unsigned long XSWC::TIMEOUT_MS = 1000 |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
bool XSWC::useAP = false |
set to true before calling begin() to skip straight to creating an Access Point