Manages the Firmata connection to an Arduino running the Stepper Controller program.
More...
#include <arduino_stepper_controller.hpp>
|
void | setupArduino (const int &version) |
| Completes configuration of the Stepper Controller Arduino once a Firmata link has been established. More...
|
|
void | handleSysex (const std::vector< unsigned char > &message) |
| Handles System-Exclusive (Sysex) messages received on the Firmata link with the Stepper Controller Arduino. More...
|
|
|
Helper functions for decoding the parameters of Sysex commands processed by handleSysex before forwarding to their associated signal.
- Parameters
-
message | the de-firmatified Sysex payload |
|
void | handleEArduinoEcho (const std::vector< unsigned char > &message) |
|
void | handleESetSpeed (const std::vector< unsigned char > &message) |
|
void | handleEGetSpeed (const std::vector< unsigned char > &message) |
|
void | handleESendStep (const std::vector< unsigned char > &message) |
|
void | handleESeekPosition (const std::vector< unsigned char > &message) |
|
void | handleEGetPosition (const std::vector< unsigned char > &message) |
|
void | handleESetGripper (const std::vector< unsigned char > &message) |
|
Manages the Firmata connection to an Arduino running the Stepper Controller program.
Responses are conveyed through Boost signals.
◆ getPosition()
bool ArduinoStepperController::getPosition |
( |
const uint8_t |
motor | ) |
|
Sends a SysexCommands::GET_POS command to query the current position of a motor.
- Parameters
-
motor | the ID of the motor to query |
- Returns
true
if successfully written to the serial connection
◆ getSpeed()
bool ArduinoStepperController::getSpeed |
( |
const uint8_t |
motor | ) |
|
Sends a SysexCommands::GET_SPEED command to query the speed of a motor.
Response callbacks are available through EGetSpeed.
- Parameters
-
motor | the ID of the motor to query |
- Returns
true
if successfully written to the serial connection
◆ handleSysex()
void ArduinoStepperController::handleSysex |
( |
const std::vector< unsigned char > & |
message | ) |
|
|
protected |
Handles System-Exclusive (Sysex) messages received on the Firmata link with the Stepper Controller Arduino.
- Parameters
-
message | the message payload |
◆ isSetup()
bool ArduinoStepperController::isSetup |
( |
| ) |
const |
Returns whether the connection to the stepper controller Arduino has been fully established.
- Returns
true
if so
◆ seekPosition()
bool ArduinoStepperController::seekPosition |
( |
const uint8_t |
motor, |
|
|
const int32_t |
position, |
|
|
const int16_t |
speed |
|
) |
| |
Sends a SysexCommands::SEEK_POS command to move a motor to specific step position.
Since this command seeks a position, the sign of the speed is ignored.
- Parameters
-
motor | the ID of the motor to move |
position | the target position in number of steps from the motor's zero point |
speed | the signed target speed to move the motor at, in 1/10 RPM. Note that the absolute value is taken. |
- Returns
true
if successfully written to the serial connection
◆ sendEcho()
bool ArduinoStepperController::sendEcho |
( |
const std::vector< uint8_t > & |
payload | ) |
|
Sends a SysexCommands::ARDUINO_ECHO command with the provided payload.
Response callbacks are available through EArduinoEcho.
- Parameters
-
payload | byte vector to echo off the Stepper Controller Arduino |
- Returns
true
if successfully written to the serial connection
◆ sendStep()
bool ArduinoStepperController::sendStep |
( |
const uint8_t |
motor, |
|
|
const uint16_t |
num_steps, |
|
|
const int16_t |
speed |
|
) |
| |
Sends a SysexCommands::SEND_STEP command to move a motor a fixed number of steps.
Direction is controlled by the sign of the target speed. Response callbacks are available through ESendStep.
- Parameters
-
motor | the ID of the motor to move |
num_steps | the number of steps to move |
speed | the signed target speed to move the motor at, in 1/10 RPM |
- Returns
true
if successfully written to the serial connection
◆ setGripper()
bool ArduinoStepperController::setGripper |
( |
const uint8_t |
position | ) |
|
Sends a SysexCommands::SET_GRIPPER command to set the target position of the gripper servo.
Response callbacks are available through ESetGripper.
- Parameters
-
position | the target servo angle, mapped to [0, 180] |
- Returns
true
if successfully written to the serial connection
◆ setSpeed()
bool ArduinoStepperController::setSpeed |
( |
const uint8_t |
motor, |
|
|
const int16_t |
speed |
|
) |
| |
Sends a SysexCommands::SET_SPEED command to set the speed of a motor.
Response callbacks are available through ESetSpeed.
- Parameters
-
motor | the ID of the motor to control |
speed | the signed target speed to set the motor to, in 1/10 RPM |
- Returns
true
if successfully written to the serial connection
◆ setupArduino()
void ArduinoStepperController::setupArduino |
( |
const int & |
version | ) |
|
|
protected |
Completes configuration of the Stepper Controller Arduino once a Firmata link has been established.
- Parameters
-
◆ connectionInitialized
boost::signals2::connection ArduinoStepperController::connectionInitialized |
|
protected |
The documentation for this class was generated from the following files: