Interface to a serial-servo-controller. More...
#include <Devices/ssc.H>
Public Member Functions | |
SSC (OptionManager &mgr, const std::string &descrName="Mini-SSC Servo Driver", const std::string &tagName="MiniSSCdriver", const char *defdev="/dev/ttyS0") | |
Default constructor; see ModelComponent.H. | |
~SSC () | |
Destructor. | |
bool | move (const int servo, const float position) |
Moves servo # to given position in [-1.0 .. 1.0]. | |
float | getPosition (const int servo) const |
Gets the current position of given servo. | |
void | calibrate (const int servo, const byte neutralval, const byte minval, const byte maxval) |
Calibrate a servo. | |
bool | moveRaw (const int servo, const byte rawpos) |
Moves servo # to given RAW (uncalibrated) position in [0..255]. | |
bool | moveRawHack (const int servo, const byte rawpos, const int port=1) |
hack work around for moveRaw. Remove when serial stuff is fixed | |
byte | getPositionRaw (const int servo) const |
Gets the current RAW (uncalibrated) position [0..255] of given servo. | |
Protected Member Functions | |
float | rawToCalib (const int servo, const byte rawpos) const |
Convert from raw (0..255) to calibrated (-1.0..1.0) position. | |
byte | calibToRaw (const int servo, const float position) const |
Convert from calibrated (-1.0..1.0) to raw (0..255) position. | |
Protected Attributes | |
nub::soft_ref< Serial > | itsPort |
Serial port to use. | |
rutz::shared_ptr< NModelParam < float > > * | zero |
zero calibration values | |
rutz::shared_ptr< NModelParam < float > > * | posmult |
positive multiplier calib | |
rutz::shared_ptr< NModelParam < float > > * | negmult |
negative multiplier calib | |
byte * | pos |
raw servo positions [0..255] |
Interface to a serial-servo-controller.
The ssc.C and ssc.H files has the mini_SSC controller code that help control the servos via the controller. The class is SSC class. Its functions include moving a servo to a specified position, using a serial port. There are two ways to move the servos and thet their current positions: either using calibrated values in [-1.0..1.0], or using raw positions in [0..255]. Calibrated positions are converted to raw using two linear ramps (one for each side of the neutral position) that can be set using the calibrate() function. EXAMPLE: if you do a calibrate(servo, 100, 20, 150), then, subsequently, move(servo, 0.0F) will be equivalent to moveRaw(servo, 100), move(servo, -1.0F) will be equivalent to moveRaw(servo, 20) and move(servo, 1.0F) will be equivalent to moveRaw(servo, 150).
Definition at line 62 of file ssc.H.
SSC::SSC | ( | OptionManager & | mgr, | |
const std::string & | descrName = "Mini-SSC Servo Driver" , |
|||
const std::string & | tagName = "MiniSSCdriver" , |
|||
const char * | defdev = "/dev/ttyS0" | |||
) |
Default constructor; see ModelComponent.H.
Definition at line 44 of file ssc.C.
References ModelComponent::addSubComponent(), itsPort, negmult, pos, posmult, and zero.
byte SSC::calibToRaw | ( | const int | servo, | |
const float | position | |||
) | const [protected] |
float SSC::getPosition | ( | const int | servo | ) | const |
Gets the current position of given servo.
Definition at line 84 of file ssc.C.
References pos, and rawToCalib().
byte SSC::getPositionRaw | ( | const int | servo | ) | const |
bool SSC::move | ( | const int | servo, | |
const float | position | |||
) |
Moves servo # to given position in [-1.0 .. 1.0].
Returns true on success, false if some serial error occurred.
Definition at line 80 of file ssc.C.
References calibToRaw(), and moveRaw().
bool SSC::moveRaw | ( | const int | servo, | |
const byte | rawpos | |||
) |
bool SSC::moveRawHack | ( | const int | servo, | |
const byte | rawpos, | |||
const int | port = 1 | |||
) |
float SSC::rawToCalib | ( | const int | servo, | |
const byte | rawpos | |||
) | const [protected] |
nub::soft_ref<Serial> SSC::itsPort [protected] |
rutz::shared_ptr<NModelParam<float> >* SSC::negmult [protected] |
negative multiplier calib
Definition at line 102 of file ssc.H.
Referenced by calibrate(), calibToRaw(), rawToCalib(), and SSC().
raw servo positions [0..255]
Definition at line 103 of file ssc.H.
Referenced by getPosition(), getPositionRaw(), moveRaw(), and SSC().
rutz::shared_ptr<NModelParam<float> >* SSC::posmult [protected] |
positive multiplier calib
Definition at line 101 of file ssc.H.
Referenced by calibrate(), calibToRaw(), rawToCalib(), and SSC().
rutz::shared_ptr<NModelParam<float> >* SSC::zero [protected] |
zero calibration values
Definition at line 100 of file ssc.H.
Referenced by calibrate(), calibToRaw(), rawToCalib(), and SSC().