PC side Elisa-3 library
|
#include "elisa3-lib.h"
Defines | |
#define | FRONT_IR_ON(x) ((x) |= (1 << 1)) |
#define | BACK_IR_ON(x) ((x) |= (1 << 0)) |
#define | ALL_IR_ON(x) ((x) |= (1<<0) | (1 << 1)) |
#define | TV_REMOTE_ON(x) ((x) |= (1<<2)) |
#define | SLEEP_ON(x) ((x) = 0x08) |
#define | CALIBRATION_ON(x) ((x) |= (1<<4)) |
#define | OBSTACLE_AVOID_ON(x) ((x) |= (1<<6)) |
#define | CLIFF_AVOID_ON(x) ((x) |= (1<<7)) |
#define | FRONT_IR_OFF(x) ((x) &= ~(1 << 1)) |
#define | BACK_IR_OFF(x) ((x) &= ~(1 << 0)) |
#define | ALL_IR_OFF(x) ((x) &= ~(1 << 0) & ~(1 << 1)) |
#define | TV_REMOTE_OFF(x) ((x) &= ~(1 << 2)) |
#define | SLEEP_OFF(x) ((x) &= ~(1 << 3)) |
#define | CALIBRATION_OFF(x) ((x) &= ~(1 << 4)) |
#define | OBSTACLE_AVOID_OFF(x) ((x) &= ~(1 << 6)) |
#define | CLIFF_AVOID_OFF(x) ((x) &= ~(1 << 7)) |
#define | RAD_2_DEG 57.2957796 |
#define | NUM_ROBOTS 4 |
#define | PAYLOAD_SIZE 13 |
#define | ADDR_SIZE 2 |
#define | ROBOT_PACKET_SIZE (PAYLOAD_SIZE+ADDR_SIZE) |
#define | PACKETS_SIZE 64 |
#define | OVERHEAD_SIZE (2*NUM_ROBOTS+1) |
#define | UNUSED_BYTES 3 |
Functions | |
char | speed (char value) |
int | computeVerticalAngle (signed int x, signed int y) |
int | getIdFromAddress (int address) |
void | startCommunication (int *robotAddr, int numRobots) |
To be called once at the beginning, it init the USB communication with the RF module that is responsible to send data to the robots and initialize the list of robots to be controlled; max number of simultaneous robots is 100. | |
void | stopCommunication () |
To be called once at the end, it closes the USB communication. | |
void | setMutexTx () |
void | freeMutexTx () |
void | setMutexRx () |
void | freeMutexRx () |
void | setMutexThread () |
void | freeMutexThread () |
unsigned char | checkConcurrency (int id) |
void | setLeftSpeed (int robotAddr, char value) |
Set the left speed of the robot. | |
void | setRightSpeed (int robotAddr, char value) |
Set the right speed of the robot. | |
void | setLeftSpeedForAll (char *value) |
Set the left speed of all the robots specified in the list. | |
void | setRightSpeedForAll (char *value) |
Set the right speed of all the robots specified in the list. | |
void | setRed (int robotAddr, unsigned char value) |
Set the red intensity of the RGB led on the robot. | |
void | setGreen (int robotAddr, unsigned char value) |
Set the green intensity of the RGB led on the robot. | |
void | setBlue (int robotAddr, unsigned char value) |
Set the blue intensity of the RGB led on the robot. | |
void | setRedForAll (unsigned char *value) |
Set the red intensity of the RGB led of all the robots specified in the list. | |
void | setGreenForAll (unsigned char *value) |
Set the green intensity of the RGB led of all the robots specified in the list. | |
void | setBlueForAll (unsigned char *value) |
Set the blue intensity of the RGB led of all all the robots specified in the list. | |
void | turnOnFrontIRs (int robotAddr) |
Turn on both the front IRs transmitter on the robot. | |
void | turnOffFrontIRs (int robotAddr) |
Turn off both the front IRs transmitter on the robot. | |
void | turnOnBackIR (int robotAddr) |
Turn on the back IR transmitter on the robot. | |
void | turnOffBackIR (int robotAddr) |
Turn off the back IR transmitter on the robot. | |
void | turnOnAllIRs (int robotAddr) |
Turn on all the 3 IRs transmitter on the robot. | |
void | turnOffAllIRs (int robotAddr) |
Turn off all the 3 IRs transmitter on the robot. | |
void | enableTVRemote (int robotAddr) |
Enable the reception of commands from a TV remote. | |
void | disableTVRemote (int robotAddr) |
Disable the reception of commands from a TV remote. | |
void | enableSleep (int robotAddr) |
Put the robot in sleep mode (energy saving mode). | |
void | disableSleep (int robotAddr) |
Put the robot in normal mode (out of sleep). | |
void | enableObstacleAvoidance (int robotAddr) |
Enable the onboard obstacle avoidance. | |
void | disableObstacleAvoidance (int robotAddr) |
Disable the onboard obstacle avoidance. | |
void | enableCliffAvoidance (int robotAddr) |
Enable the onboard cliff avoidance. | |
void | disableCliffAvoidance (int robotAddr) |
Disable the onboard cliff avoidance. | |
void | resetRobotData (int robotIndex) |
void | setRobotAddress (int robotIndex, int robotAddr) |
Set the address of a robot related to a particular index, the index must be in the range of the robot list size. | |
void | setRobotAddresses (int *robotAddr, int numRobots) |
Set the addresses of the robots that need to be controlled; max number of simultaneous robots is 100. | |
unsigned int | getProximity (int robotAddr, int proxId) |
Request one of the proximity sensors value of the robot. | |
unsigned int | getProximityAmbient (int robotAddr, int proxId) |
Request one of the ambient value (from proximity sensors) of the robot. | |
unsigned int | getGround (int robotAddr, int groundId) |
Request one of the ground sensors value of the robot. | |
unsigned int | getGroundAmbient (int robotAddr, int groundId) |
Request one of the ambient value (from ground sensors) of the robot. | |
void | getAllProximity (int robotAddr, unsigned int *proxArr) |
Request all the proximity sensors values at once. | |
void | getAllProximityAmbient (int robotAddr, unsigned int *proxArr) |
Request all the ambient values (from proximity sensors) at once. | |
void | getAllGround (int robotAddr, unsigned int *groundArr) |
Request all the ground sensors values at once. | |
void | getAllGroundAmbient (int robotAddr, unsigned int *groundArr) |
Request all the ambient values (from ground sensors) at once. | |
void | getAllProximityFromAll (unsigned int proxArr[][8]) |
Request all the proximity sensors values of all the robots specified in the list. | |
void | getAllProximityAmbientFromAll (unsigned int proxArr[][8]) |
Request all the ambient values (from proximity sensors) of all the robots specified in the list. | |
void | getAllGroundFromAll (unsigned int groundArr[][4]) |
Request all the ground sensors values of all the robots specified in the list. | |
void | getAllGroundAmbientFromAll (unsigned int groundArr[][4]) |
Request all the ambient values (from ground sensors) of all the robots specified in the list. | |
unsigned int | getBatteryAdc (int robotAddr) |
Request the raw battery value, it contains the sampled value of the battery. | |
unsigned int | getBatteryPercent (int robotAddr) |
Request the charge percentage of the battery. | |
signed int | getAccX (int robotAddr) |
Request the raw value of the accelerometer x axis. | |
signed int | getAccY (int robotAddr) |
Request the raw value of the accelerometer y axis. | |
signed int | getAccZ (int robotAddr) |
Request the raw value of the accelerometer z axis. | |
unsigned char | getSelector (int robotAddr) |
Request the selector position. | |
unsigned char | getTVRemoteCommand (int robotAddr) |
Request last command received from the TV remote. | |
signed int | getOdomTheta (int robotAddr) |
Request the current orientation of the robot computed from the measured speed of the motors. | |
signed int | getOdomXpos (int robotAddr) |
Request the current position (x component) of the robot computed from the measured speed of the motors. | |
signed int | getOdomYpos (int robotAddr) |
Request the current position (y component) of the robot computed from the measured speed of the motors. | |
void | setSmallLed (int robotAddr, int ledId, int state) |
Set a new stato (on or off) for the small green leds around the robot. | |
void | turnOffSmallLeds (int robotAddr) |
Turn off all the small green leds around the robot. | |
void | turnOnSmallLeds (int robotAddr) |
Turn on all the small green leds around the robot. | |
int | getVerticalAngle (int robotAddr) |
Request the current orientation of the robot given by the accelerometer. This function is usable only if the robot is moving vertically. | |
void | calibrateSensors (int robotAddr) |
Calibrate the sensors of the robot (proximity, accelerometer). | |
void | calibrateSensorsForAll () |
Calibrate the sensors (proximity, accelerometer) of all the robots specified in the list. | |
void | startOdometryCalibration (int robotAddr) |
Start the odometry calibration. | |
unsigned char | robotIsCharging (int robotAddr) |
Tell whether the robot is charging or not. | |
unsigned char | robotIsCharged (int robotAddr) |
Tell whether the robot is completely charged or not. | |
unsigned char | buttonIsPressed (int robotAddr) |
Tell whether the button on the back side of the robot is pressed or not. | |
void | resetFlagTX (int robotAddr) |
Reset all the flags sent to the robot. | |
unsigned char | getFlagTX (int robotAddr, int flagInd) |
Request the current flags value (raw) sent to the robot. | |
unsigned char | getFlagRX (int robotAddr) |
Request the current flags value (raw) received from the robot. | |
signed long int | getLeftMotSteps (int robotAddr) |
Request the current raw value of the left motor steps (sum of the measured speed). | |
signed long int | getRightMotSteps (int robotAddr) |
Request the current raw value of the right motor steps (sum of the measured speed). | |
void | resetMessageIsSentFlag (int robotAddr) |
Reset the flag indicating that the last modified packet is sent to the robot; it should be called before using "messageIsSent". | |
unsigned char | messageIsSent (int robotAddr) |
Request if the last modified packet is sent to the robot; this function is thought to be used in polling mode (continue to check whether the message is sent untill it is actually sent). Before the polling the function "resetMessageIsSentFlag" need to be called. It can be used for both check whether the robots received the new messages and to know when new data from the robots are available. | |
double | getRFQuality (int robotAddr) |
Request the current percentage of failed trasnfers in the last 5 seconds. | |
void | stopTransferData () |
This function stop the transmission of the packets to the robots. | |
void | resumeTransferData () |
This function resume the transmission of the packets to the robots. | |
void | setCompletePacket (int robotAddr, char red, char green, char blue, char flags[2], char left, char right, char leds) |
Set all the values of a robot at one time. | |
void | setCompletePacketForAll (int *robotAddr, char *red, char *green, char *blue, char flags[][2], char *left, char *right, char *leds) |
Set all the values of all the robots specified in the list. | |
unsigned char | sendMessageToRobot (int robotAddr, char red, char green, char blue, char flags[2], char left, char right, char leds, unsigned long us) |
Send a message to a particular robot resetting the list of robots to a single one (all previous address set with "startCommunication" will be lost). | |
unsigned char | waitForUpdate (int robotAddr, unsigned long us) |
Wait for updated data coming from the robot; if the robot isn't reachable (out of range, discharged, ...) then the function will exit after the amount of time specified as parameter even if no data are received. this function can be used also to check whether a message is successfully sent to a robot or not. | |
void | transferData () |
This function need to be called periodically (as fast as possible) in order to exchange data with the robots. | |
Variables | |
int | robotAddress [100] |
char | leftSpeed [100] |
char | rightSpeed [100] |
char | redLed [100] |
char | greenLed [100] |
char | blueLed [100] |
unsigned int | proxValue [100][8] |
unsigned int | proxAmbientValue [100][8] |
unsigned int | groundValue [100][4] |
unsigned int | groundAmbientValue [100][4] |
unsigned int | batteryAdc [100] |
unsigned int | batteryPercent [100] |
signed int | accX [100] |
signed int | accY [100] |
signed int | accZ [100] |
unsigned char | selector [100] |
unsigned char | tvRemote [100] |
unsigned char | flagsRX [100] |
unsigned char | flagsTX [100][2] |
unsigned char | smallLeds [100] |
signed long int | leftMotSteps [100] |
signed long int | rightMotSteps [100] |
signed int | robTheta [100] |
signed int | robXPos [100] |
signed int | robYPos [100] |
unsigned char | sleepEnabledFlag [100] |
char | RX_buffer [64] = {0} |
char | TX_buffer [64] = {0} |
double | numOfErrors [100] |
double | numOfPackets = 0 |
double | errorPercentage [100] |
unsigned char | lastMessageSentFlag [100] |
unsigned char | calibrationSent [100] |
unsigned char | calibrateOdomSent [100] |
unsigned char | stopTransmissionFlag = 0 |
unsigned int | currNumRobots = 0 |
unsigned int | currPacketId = 0 |
unsigned char | usbCommOpenedFlag = 0 |
#define ADDR_SIZE 2 |
#define ALL_IR_OFF | ( | x | ) | ((x) &= ~(1 << 0) & ~(1 << 1)) |
#define ALL_IR_ON | ( | x | ) | ((x) |= (1<<0) | (1 << 1)) |
#define BACK_IR_OFF | ( | x | ) | ((x) &= ~(1 << 0)) |
#define BACK_IR_ON | ( | x | ) | ((x) |= (1 << 0)) |
#define CALIBRATION_OFF | ( | x | ) | ((x) &= ~(1 << 4)) |
#define CALIBRATION_ON | ( | x | ) | ((x) |= (1<<4)) |
#define CLIFF_AVOID_OFF | ( | x | ) | ((x) &= ~(1 << 7)) |
#define CLIFF_AVOID_ON | ( | x | ) | ((x) |= (1<<7)) |
#define FRONT_IR_OFF | ( | x | ) | ((x) &= ~(1 << 1)) |
#define FRONT_IR_ON | ( | x | ) | ((x) |= (1 << 1)) |
#define NUM_ROBOTS 4 |
#define OBSTACLE_AVOID_OFF | ( | x | ) | ((x) &= ~(1 << 6)) |
#define OBSTACLE_AVOID_ON | ( | x | ) | ((x) |= (1<<6)) |
#define OVERHEAD_SIZE (2*NUM_ROBOTS+1) |
#define PACKETS_SIZE 64 |
#define PAYLOAD_SIZE 13 |
#define RAD_2_DEG 57.2957796 |
#define ROBOT_PACKET_SIZE (PAYLOAD_SIZE+ADDR_SIZE) |
#define SLEEP_OFF | ( | x | ) | ((x) &= ~(1 << 3)) |
#define SLEEP_ON | ( | x | ) | ((x) = 0x08) |
#define TV_REMOTE_OFF | ( | x | ) | ((x) &= ~(1 << 2)) |
#define TV_REMOTE_ON | ( | x | ) | ((x) |= (1<<2)) |
#define UNUSED_BYTES 3 |
unsigned char buttonIsPressed | ( | int | robotAddr | ) |
Tell whether the button on the back side of the robot is pressed or not.
robotAddr | the address of the robot from which receive data. |
void calibrateSensors | ( | int | robotAddr | ) |
Calibrate the sensors of the robot (proximity, accelerometer).
robotAddr | the address of the robot for which to change the packet. |
void calibrateSensorsForAll | ( | ) |
Calibrate the sensors (proximity, accelerometer) of all the robots specified in the list.
unsigned char checkConcurrency | ( | int | id | ) |
int computeVerticalAngle | ( | signed int | x, |
signed int | y | ||
) |
void disableCliffAvoidance | ( | int | robotAddr | ) |
Disable the onboard cliff avoidance.
robotAddr | the address of the robot for which to change the packet. |
void disableObstacleAvoidance | ( | int | robotAddr | ) |
Disable the onboard obstacle avoidance.
robotAddr | the address of the robot for which to change the packet. |
void disableSleep | ( | int | robotAddr | ) |
Put the robot in normal mode (out of sleep).
robotAddr | the address of the robot for which to change the packet. |
void disableTVRemote | ( | int | robotAddr | ) |
Disable the reception of commands from a TV remote.
robotAddr | the address of the robot for which to change the packet. |
void enableCliffAvoidance | ( | int | robotAddr | ) |
Enable the onboard cliff avoidance.
robotAddr | the address of the robot for which to change the packet. |
void enableObstacleAvoidance | ( | int | robotAddr | ) |
Enable the onboard obstacle avoidance.
robotAddr | the address of the robot for which to change the packet. |
void enableSleep | ( | int | robotAddr | ) |
Put the robot in sleep mode (energy saving mode).
robotAddr | the address of the robot for which to change the packet. |
void enableTVRemote | ( | int | robotAddr | ) |
Enable the reception of commands from a TV remote.
robotAddr | the address of the robot for which to change the packet. |
void freeMutexRx | ( | ) |
void freeMutexThread | ( | ) |
void freeMutexTx | ( | ) |
signed int getAccX | ( | int | robotAddr | ) |
Request the raw value of the accelerometer x axis.
robotAddr | the address of the robot from which receive data. |
signed int getAccY | ( | int | robotAddr | ) |
Request the raw value of the accelerometer y axis.
robotAddr | the address of the robot from which receive data. |
signed int getAccZ | ( | int | robotAddr | ) |
Request the raw value of the accelerometer z axis.
robotAddr | the address of the robot from which receive data. |
void getAllGround | ( | int | robotAddr, |
unsigned int * | groundArr | ||
) |
Request all the ground sensors values at once.
robotAddr | the address of the robot from which receive data. |
groundArr | destination array for the ground values (size must be 4). |
void getAllGroundAmbient | ( | int | robotAddr, |
unsigned int * | groundArr | ||
) |
Request all the ambient values (from ground sensors) at once.
robotAddr | the address of the robot from which receive data. |
groundArr | destination array for the ambient values (size must be 4). |
void getAllGroundAmbientFromAll | ( | unsigned int | groundArr[][4] | ) |
Request all the ambient values (from ground sensors) of all the robots specified in the list.
groundArr | destination matrix for the ambient values (size must be list_size x 4). |
void getAllGroundFromAll | ( | unsigned int | groundArr[][4] | ) |
Request all the ground sensors values of all the robots specified in the list.
groundArr | destination matrix for the ground values (size must be list_size x 4). |
void getAllProximity | ( | int | robotAddr, |
unsigned int * | proxArr | ||
) |
Request all the proximity sensors values at once.
robotAddr | the address of the robot from which receive data. |
proxArr | destination array for the proximity values (size must be 8). |
void getAllProximityAmbient | ( | int | robotAddr, |
unsigned int * | proxArr | ||
) |
Request all the ambient values (from proximity sensors) at once.
robotAddr | the address of the robot from which receive data. |
proxArr | destination array for the ambient values (size must be 8). |
void getAllProximityAmbientFromAll | ( | unsigned int | proxArr[][8] | ) |
Request all the ambient values (from proximity sensors) of all the robots specified in the list.
proxArr | destination matrix for the ambient values (size must be list_size x 8). |
void getAllProximityFromAll | ( | unsigned int | proxArr[][8] | ) |
Request all the proximity sensors values of all the robots specified in the list.
proxArr | destination matrix for the proximity values (size must be list_size x 8). |
unsigned int getBatteryAdc | ( | int | robotAddr | ) |
Request the raw battery value, it contains the sampled value of the battery.
robotAddr | the address of the robot from which receive data. |
unsigned int getBatteryPercent | ( | int | robotAddr | ) |
Request the charge percentage of the battery.
robotAddr | the address of the robot from which receive data. |
unsigned char getFlagRX | ( | int | robotAddr | ) |
Request the current flags value (raw) received from the robot.
robotAddr | the address of the robot from which receive data. |
unsigned char getFlagTX | ( | int | robotAddr, |
int | flagInd | ||
) |
Request the current flags value (raw) sent to the robot.
robotAddr | the address of the robot from which receive data. |
flagInd | 0 or 1 |
unsigned int getGround | ( | int | robotAddr, |
int | groundId | ||
) |
Request one of the ground sensors value of the robot.
robotAddr | the address of the robot from which receive data. |
groundId | from 0 to 3 (0 is on the left side, then increases clockwise). |
unsigned int getGroundAmbient | ( | int | robotAddr, |
int | groundId | ||
) |
Request one of the ambient value (from ground sensors) of the robot.
robotAddr | the address of the robot from which receive data. |
groundId | from 0 to 3 (0 is on the left side, then increases clockwise). |
int getIdFromAddress | ( | int | address | ) |
signed long int getLeftMotSteps | ( | int | robotAddr | ) |
Request the current raw value of the left motor steps (sum of the measured speed).
robotAddr | the address of the robot from which receive data. |
signed int getOdomTheta | ( | int | robotAddr | ) |
Request the current orientation of the robot computed from the measured speed of the motors.
robotAddr | the address of the robot from which receive data. |
signed int getOdomXpos | ( | int | robotAddr | ) |
Request the current position (x component) of the robot computed from the measured speed of the motors.
robotAddr | the address of the robot from which receive data. |
signed int getOdomYpos | ( | int | robotAddr | ) |
Request the current position (y component) of the robot computed from the measured speed of the motors.
robotAddr | the address of the robot from which receive data. |
unsigned int getProximity | ( | int | robotAddr, |
int | proxId | ||
) |
Request one of the proximity sensors value of the robot.
robotAddr | the address of the robot from which receive data. |
proxId | from 0 to 7 (0 is in front, then increases clockwise). |
unsigned int getProximityAmbient | ( | int | robotAddr, |
int | proxId | ||
) |
Request one of the ambient value (from proximity sensors) of the robot.
robotAddr | the address of the robot from which receive data. |
proxId | from 0 to 7 (0 is in front, then increases clockwise). |
double getRFQuality | ( | int | robotAddr | ) |
Request the current percentage of failed trasnfers in the last 5 seconds.
robotAddr | the address of the robot from which receive data. |
signed long int getRightMotSteps | ( | int | robotAddr | ) |
Request the current raw value of the right motor steps (sum of the measured speed).
robotAddr | the address of the robot from which receive data. |
unsigned char getSelector | ( | int | robotAddr | ) |
Request the selector position.
robotAddr | the address of the robot from which receive data. |
unsigned char getTVRemoteCommand | ( | int | robotAddr | ) |
Request last command received from the TV remote.
robotAddr | the address of the robot from which receive data. |
int getVerticalAngle | ( | int | robotAddr | ) |
Request the current orientation of the robot given by the accelerometer. This function is usable only if the robot is moving vertically.
robotAddr | the address of the robot from which receive data. |
unsigned char messageIsSent | ( | int | robotAddr | ) |
Request if the last modified packet is sent to the robot; this function is thought to be used in polling mode (continue to check whether the message is sent untill it is actually sent). Before the polling the function "resetMessageIsSentFlag" need to be called. It can be used for both check whether the robots received the new messages and to know when new data from the robots are available.
robotAddr | the address of the robot from which receive data. |
void resetFlagTX | ( | int | robotAddr | ) |
Reset all the flags sent to the robot.
robotAddr | the address of the robot for which to change data. |
void resetMessageIsSentFlag | ( | int | robotAddr | ) |
Reset the flag indicating that the last modified packet is sent to the robot; it should be called before using "messageIsSent".
robotAddr | the address of the robot for which to change data. |
void resetRobotData | ( | int | robotIndex | ) |
void resumeTransferData | ( | ) |
This function resume the transmission of the packets to the robots.
unsigned char robotIsCharged | ( | int | robotAddr | ) |
Tell whether the robot is completely charged or not.
robotAddr | the address of the robot from which receive data. |
unsigned char robotIsCharging | ( | int | robotAddr | ) |
Tell whether the robot is charging or not.
robotAddr | the address of the robot from which receive data. |
unsigned char sendMessageToRobot | ( | int | robotAddr, |
char | red, | ||
char | green, | ||
char | blue, | ||
char | flags[2], | ||
char | left, | ||
char | right, | ||
char | leds, | ||
unsigned long | us | ||
) |
Send a message to a particular robot resetting the list of robots to a single one (all previous address set with "startCommunication" will be lost).
robotAddr | the address of the robot for which to change data. |
red,green,red | RGB channels intensity, range is between 0 (led off) to 100 (max power). |
flags | raw flag bytes: byte0:
|
left,right | left and right speed, range is -128..127. |
leds | raw byte value for small green leds (bit0=0/1 turn off/on led0, bit1=0/1 turn off/on led1, ...). |
us | function timeout given in microseconds |
void setBlue | ( | int | robotAddr, |
unsigned char | value | ||
) |
Set the blue intensity of the RGB led on the robot.
robotAddr | the address of the robot for which to change the packet. |
value | The intensity, range is between 0 (led off) to 100 (max power). |
void setBlueForAll | ( | unsigned char * | value | ) |
Set the blue intensity of the RGB led of all all the robots specified in the list.
value | The intensity array, range is between 0 (led off) to 100 (max power). |
void setCompletePacket | ( | int | robotAddr, |
char | red, | ||
char | green, | ||
char | blue, | ||
char | flags[2], | ||
char | left, | ||
char | right, | ||
char | leds | ||
) |
Set all the values of a robot at one time.
robotAddr | the address of the robot for which to change data. |
red,green,red | RGB channels intensity, range is between 0 (led off) to 100 (max power). |
flags | raw flag bytes: byte0:
|
left,right | left and right speed, range is -128..127. |
leds | raw byte value for small green leds (bit0=0/1 turn off/on led0, bit1=0/1 turn off/on led1, ...). |
void setCompletePacketForAll | ( | int * | robotAddr, |
char * | red, | ||
char * | green, | ||
char * | blue, | ||
char | flags[][2], | ||
char * | left, | ||
char * | right, | ||
char * | leds | ||
) |
Set all the values of all the robots specified in the list.
robotAddr | array the addresses of the robots for which to change data. |
red,green,red | arrays RGB channels intensity, range is between 0 (led off) to 100 (max power). |
flags | array raw flag bytes: byte0:
|
left,right | arrays left and right speed, range is -128..127. |
leds | array raw byte value for small green leds (bit0=0/1 turn off/on led0, bit1=0/1 turn off/on led1, ...). |
void setGreen | ( | int | robotAddr, |
unsigned char | value | ||
) |
Set the green intensity of the RGB led on the robot.
robotAddr | the address of the robot for which to change the packet. |
value | The intensity, range is between 0 (led off) to 100 (max power). |
void setGreenForAll | ( | unsigned char * | value | ) |
Set the green intensity of the RGB led of all the robots specified in the list.
value | The intensity array, range is between 0 (led off) to 100 (max power). |
void setLeftSpeed | ( | int | robotAddr, |
char | value | ||
) |
Set the left speed of the robot.
robotAddr | the address of the robot for which to change the packet. |
value | The speed, range is between -128 to 127. |
void setLeftSpeedForAll | ( | char * | value | ) |
Set the left speed of all the robots specified in the list.
value | The speed array, range is between -128 to 127. |
void setMutexRx | ( | ) |
void setMutexThread | ( | ) |
void setMutexTx | ( | ) |
void setRed | ( | int | robotAddr, |
unsigned char | value | ||
) |
Set the red intensity of the RGB led on the robot.
robotAddr | the address of the robot for which to change the packet. |
value | The intensity, range is between 0 (led off) to 100 (max power). |
void setRedForAll | ( | unsigned char * | value | ) |
Set the red intensity of the RGB led of all the robots specified in the list.
value | The intensity array, range is between 0 (led off) to 100 (max power). |
void setRightSpeed | ( | int | robotAddr, |
char | value | ||
) |
Set the right speed of the robot.
robotAddr | the address of the robot for which to change the packet. |
value | The speed, range is between -128 to 127. |
void setRightSpeedForAll | ( | char * | value | ) |
Set the right speed of all the robots specified in the list.
value | The speed array, range is between -128 to 127. |
void setRobotAddress | ( | int | robotIndex, |
int | robotAddr | ||
) |
Set the address of a robot related to a particular index, the index must be in the range of the robot list size.
robotIndex | from 0 to number of robots - 1 (set with "setRobotAddresses" function) |
robotAddr | the address of the robot |
void setRobotAddresses | ( | int * | robotAddr, |
int | numRobots | ||
) |
Set the addresses of the robots that need to be controlled; max number of simultaneous robots is 100.
robotAddr | array list of robot addresses to be handled. |
numRobots | the array size (number of robots to handle). |
void setSmallLed | ( | int | robotAddr, |
int | ledId, | ||
int | state | ||
) |
Set a new stato (on or off) for the small green leds around the robot.
robotAddr | the address of the robot from which receive data. |
ledId | the led to change, from 0 to 7 (0 is in front, then increases clockwise). |
state | 0 to turn off, 1 to turn on. |
char speed | ( | char | value | ) |
void startCommunication | ( | int * | robotAddr, |
int | numRobots | ||
) |
To be called once at the beginning, it init the USB communication with the RF module that is responsible to send data to the robots and initialize the list of robots to be controlled; max number of simultaneous robots is 100.
robotAddr | array list of robot addresses to be handled. |
numRobots | the array size (number of robots to handle). |
void startOdometryCalibration | ( | int | robotAddr | ) |
Start the odometry calibration.
robotAddr | the address of the robot for which to change the packet. |
void stopCommunication | ( | ) |
To be called once at the end, it closes the USB communication.
void stopTransferData | ( | ) |
This function stop the transmission of the packets to the robots.
void transferData | ( | ) |
This function need to be called periodically (as fast as possible) in order to exchange data with the robots.
void turnOffAllIRs | ( | int | robotAddr | ) |
Turn off all the 3 IRs transmitter on the robot.
robotAddr | the address of the robot for which to change the packet. |
void turnOffBackIR | ( | int | robotAddr | ) |
Turn off the back IR transmitter on the robot.
robotAddr | the address of the robot for which to change the packet. |
void turnOffFrontIRs | ( | int | robotAddr | ) |
Turn off both the front IRs transmitter on the robot.
robotAddr | the address of the robot for which to change the packet. |
void turnOffSmallLeds | ( | int | robotAddr | ) |
Turn off all the small green leds around the robot.
robotAddr | the address of the robot from which receive data. |
void turnOnAllIRs | ( | int | robotAddr | ) |
Turn on all the 3 IRs transmitter on the robot.
robotAddr | the address of the robot for which to change the packet. |
void turnOnBackIR | ( | int | robotAddr | ) |
Turn on the back IR transmitter on the robot.
robotAddr | the address of the robot for which to change the packet. |
void turnOnFrontIRs | ( | int | robotAddr | ) |
Turn on both the front IRs transmitter on the robot.
robotAddr | the address of the robot for which to change the packet. |
void turnOnSmallLeds | ( | int | robotAddr | ) |
Turn on all the small green leds around the robot.
robotAddr | the address of the robot from which receive data. |
unsigned char waitForUpdate | ( | int | robotAddr, |
unsigned long | us | ||
) |
Wait for updated data coming from the robot; if the robot isn't reachable (out of range, discharged, ...) then the function will exit after the amount of time specified as parameter even if no data are received. this function can be used also to check whether a message is successfully sent to a robot or not.
robotAddr | the address of the robot from which receive data. |
us | function timeout given in microseconds |
signed int accX[100] |
signed int accY[100] |
signed int accZ[100] |
unsigned int batteryAdc[100] |
unsigned int batteryPercent[100] |
char blueLed[100] |
unsigned char calibrateOdomSent[100] |
unsigned char calibrationSent[100] |
unsigned int currNumRobots = 0 |
unsigned int currPacketId = 0 |
double errorPercentage[100] |
unsigned char flagsRX[100] |
unsigned char flagsTX[100][2] |
char greenLed[100] |
unsigned int groundAmbientValue[100][4] |
unsigned int groundValue[100][4] |
unsigned char lastMessageSentFlag[100] |
signed long int leftMotSteps[100] |
char leftSpeed[100] |
double numOfErrors[100] |
double numOfPackets = 0 |
unsigned int proxAmbientValue[100][8] |
unsigned int proxValue[100][8] |
char redLed[100] |
signed long int rightMotSteps[100] |
char rightSpeed[100] |
int robotAddress[100] |
signed int robTheta[100] |
signed int robXPos[100] |
signed int robYPos[100] |
char RX_buffer[64] = {0} |
unsigned char selector[100] |
unsigned char sleepEnabledFlag[100] |
unsigned char smallLeds[100] |
unsigned char stopTransmissionFlag = 0 |
unsigned char tvRemote[100] |
char TX_buffer[64] = {0} |
unsigned char usbCommOpenedFlag = 0 |