-
Notifications
You must be signed in to change notification settings - Fork 0
API Documentation
This is the API documentation for the Srobko robot.
struct ArmPosition {
int armX;
int armY;
int armRot;
int elbow;
int handRot;
int handAngle;
ArmPosition(): armX(0), armY(0), armRot(0), elbow(0), handRot(0), handAngle(0) {}
};Stores the position of an arm.
- Attributes
-
int armX- holds the horizontal angle of an arm -
int armY- holds the vertical angle of an arm -
int armRot- holds the rotation of an arm -
int elbow- holds the angle of an elbow -
int handRot- holds the rotation of a hand -
int handAngle- holds the angle of fingers
All values are in degrees, range is from 0 to 180.
-
- Functions
-
ArmPosition(): armX(0), armY(0), armRot(0), elbow(0), handRot(0), handAngle(0)
Creates a new ArmPosition object
-
struct HeadPosition {
int headX;
int headY;
HeadPosition(): headX(0), headY(0) {}
};Stores the position of the robot head.
- Attributes
-
int headX- holds the horizontal angle of a head -
int headY- holds the vertical angle of a head
All values are in degrees, range is from 0 to 180.
-
- Functions
-
HeadPosition(): headX(0), headY(0)
Creates a new HeadPosition object
-
struct RobotPosition {
HeadPosition head;
ArmPosition leftArm;
ArmPosition rightArm;
RobotPosition(): head(HeadPosition()), leftArm(ArmPosition()), rightArm(ArmPosition()) {}
void parseRawData(uint8_t data[25]);
void toRawData(char data[25]);
}Stores the position of the robot.
- Attributes
-
HeadPosition head- holds the position of a head -
ArmPosition leftArm- holds the position of a left arm -
ArmPosition rightArm- holds the position of a right arm
-
- Functions
-
RobotPosition(): head(HeadPosition()), leftArm(ArmPosition()), rightArm(ArmPosition())
Creates a new RobotPosition object -
void parseRawData(uint8_t data[25])Parses raw servo values to RobotPosition object.- Parameters
uint8_t data[25]
- Parameters
-
void toRawData(char data[25])Converts RobotPosition object to raw servo data.- Parameters
-
uint8_t data[25]- the output data.
-
- Parameters
-
Motors();Creates a New motors object. Motor pins are set to default.
- Returns:
Motors
Motors(uint8_t motorPins[25]);Creates a New motors object.
- Parameters:
uint8_t motorPins[25]
- Returns:
Motors
void move(RobotPosition position);Moves the robot to a specified position.
- Parameters:
RobotPosition position
void moveRightArm(ArmPosition position);Moves the right arm of robot to a specified position.
- Parameters:
ArmPosition position
void moveLeftArm(ArmPosition position);Moves the left arm of robot to a specified position.
- Parameters:
ArmPosition position
void moveHead(HeadPosition position);Moves the head of robot to a specified position.
- Parameters:
HeadPosition position
void writeMotor(int motorIndex, int value);Sets a motor to a specified value.
- Parameters:
-
int motorIndex(from 0 to 24) -
int value(in degrees, from 0 to 180)
-
Radio();Creates a new Radio object. Radio pins are set to default.
- Returns:
Radio
Radio(uint8_t cePin, uint8_t csnPin);Creates a new Radio object.
- Parameters:
uint8_t cePinuint8_t csnPin
- Returns:
Radio
bool readData(RobotPosition &position);Reads data from radio.
- Parameters:
-
RobotPosition &position- read data asRobotPosition, pass a reference to get the read value.
-
- Returns:
-
bool-
true- new data was read -
false- no new data arrived
-
-
Button(uint8_t _buttonIndex);Creates a new Button object.
- Parameters
-
uint8_t _buttonIndex(from 0 to 5)
-
- Returns
-
Buttonobject
-
bool isPressed();Returns the current state of the button.
- Returns
-
bool-
true- the button is pressed -
false- the button is not pressed
-
-
Speaker();Creates a new Speaker object.
- Returns
-
Speakerobject
-
void play(int toneFreq, int duration);Plays a specified tone for a specified amount of time.
- Parameters
int toneFreq-
int durationin milliseconds
Contains the definitions of tones frequency.