|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
36 if (config.
check(
"help") ==
true) {
37 yCInfo(SERIALSERVOBOARD,
"SerialServoBoard Available Options:");
38 yCInfo(SERIALSERVOBOARD,
" -board NAME, where name is one of ssc32, minissc, pontech_sv203x, mondotronic_smi, parallax, pololu_usb_16servo, picopic");
39 yCInfo(SERIALSERVOBOARD,
" -comport NAME, where name is COMx on Windows, and /dev/ttySx on Linux");
40 yCInfo(SERIALSERVOBOARD,
" -baudrate RATE, where RATE is the Board baudrate");
41 yCInfo(SERIALSERVOBOARD,
" -help shows this help");
51 if (strcmp(servoboard_,
"ssc32") == 0) {
54 }
else if (strcmp(servoboard_,
"minissc") == 0) {
57 }
else if (strcmp(servoboard_,
"pontech_sv203x") == 0) {
60 }
else if (strcmp(servoboard_,
"mondotronic_smi") == 0) {
63 }
else if (strcmp(servoboard_,
"pololu_usb_16servo") == 0) {
66 }
else if (strcmp(servoboard_,
"picopic") == 0) {
80 conf.
put(
"device",
"serialport");
81 conf.
put(
"comport", comport);
82 conf.
put(
"baudrate", baudrate);
83 conf.
put(
"rcvenb", 1);
84 conf.
put(
"stopbits", 2);
85 conf.
put(
"databits", 8);
86 conf.
put(
"paritymode",
"none");
90 yCError(SERIALSERVOBOARD,
"Failed to create and configure a device");
94 if (!dd.view(serial)) {
95 yCError(SERIALSERVOBOARD,
"Failed to view device through ISerialDevice interface");
100 positions = (
double*)malloc(
sizeof(
double) * 32);
101 speeds = (
double*)malloc(
sizeof(
double) * 32);
119 if (servoboard ==
SSC32) {
121 }
else if (servoboard ==
MINISSC) {
129 }
else if (servoboard ==
PICOPIC) {
141 return move(j, ref, positions, speeds, serial);
147 for (
int k = 0; k < 32; k++) {
148 this->positionMove(k, refs[k]);
157 this->positionMove(j, positions[j] + delta);
165 for (
int k = 0; k < 32; k++) {
166 this->positionMove(k, positions[k] + deltas[k]);
199 for (
int k = 0; k < 32; k++) {
200 setRefSpeed(k, spds[k]);
229 for (
int k = 0; k < 32; k++) {
296 int pos = 1500 +
round(positions[j] * 11.11);
300 if (
FABS(speeds[j]) < 0.1) {
301 std::snprintf(str, 80,
"#%dP%d\r", j, pos);
303 int speed =
round(speeds[j] * 11.11);
305 std::snprintf(str, 80,
"#%dP%dS%d\r", j, pos, speed);
320 auto pos = (
unsigned char)((
int)(positions[j] * 1.411) + 127);
326 cmd[1] = (
unsigned char)j;
329 serial->
send(cmd, 3);
337 auto pos = (
unsigned char)((
int)(positions[j] * 1.411) + 127);
341 std::snprintf(str, 80,
"BD1SV%dM%d", j + 1, pos);
353 auto pos = (
unsigned char)((
int)(positions[j] * 1.411) + 127);
359 cmd[1] = (
unsigned char)j;
362 serial->
send(cmd, 3);
370 int pos = 1500 +
round(positions[j] * 11.11);
378 cmd[3] = (
unsigned char)j;
380 cmd[4] = (
unsigned char)(pos >> 8);
381 cmd[5] = (
unsigned char)pos;
383 serial->
send(cmd, 6);
391 int pos = 1500 +
round(positions[j] * 11.11);
395 cmd[0] = (int)(j / 20) + 1;
398 cmd[2] = (
unsigned char)(pos >> 8);
399 cmd[3] = (
unsigned char)pos;
401 if (
FABS(speeds[j]) < 0.1) {
404 auto speed = (
unsigned char)((
int)(speeds[j] * 1.411) + 127);
409 serial->
send(cmd, 5);
A simple collection of objects that can be described and transmitted in a portable way.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
A base class for nested structures that can be searched.
#define YARP_LOG_COMPONENT(name,...)
bool getRefAcceleration(int j, double *acc) override
Get reference acceleration for a joint.
bool setRefSpeeds(const double *spds) override
Set reference speed on all joints.
bool movessc32(int j, double ref, double *positions, double *speeds, ISerialDevice *serial)
A generic interface to serial port devices.
bool movepololu(int j, double ref, double *positions, double *speeds, ISerialDevice *serial)
define control board standard interfaces
An interface for the device drivers.
bool getRefAccelerations(double *accs) override
Get reference acceleration of all joints.
bool movepicopic(int j, double ref, double *positions, double *speeds, ISerialDevice *serial)
bool checkMotionDone(int j, bool *flag) override
Check if the current trajectory is terminated.
bool getAxes(int *ax) override
Get the number of controlled axes.
bool movemondotronic(int j, double ref, double *positions, double *speeds, ISerialDevice *serial)
bool getRefSpeeds(double *spds) override
Get reference speed of all joints.
bool setRefSpeed(int j, double sp) override
Set reference speed for a joint, this is the speed used during the interpolation of the trajectory.
bool close() override
Close the DeviceDriver.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
bool positionMove(int j, double ref) override
Set new reference point for a single axis.
bool movepontech(int j, double ref, double *positions, double *speeds, ISerialDevice *serial)
bool getRefSpeed(int j, double *ref) override
Get reference speed for a joint.
#define yCError(component,...)
#define yCInfo(component,...)
An interface to the operating system, including Port based communication.
bool setRefAcceleration(int j, double acc) override
Set reference acceleration for a joint.
bool setRefAccelerations(const double *accs) override
Set reference acceleration on all joints.
bool stop() override
Stop motion, multiple joints.
virtual bool send(const yarp::os::Bottle &msg)=0
Sends a string of chars to the serial communications channel.
A single value (typically within a Bottle).
bool relativeMove(int j, double delta) override
Set relative position.
bool open(Searchable &config) override
Open the DeviceDriver.
bool moveminissc(int j, double ref, double *positions, double *speeds, ISerialDevice *serial)
A class for storing options and configuration information.