The class to communicate with a SDH via RS232. More...
#include <sdhserial.h>
Public Member Functions | |
Internal methods | |
cSDHSerial (int _debug_level=0) | |
Constructor of cSDHSerial. | |
virtual | ~cSDHSerial () |
void | Open (cSerialBase *_com) throw (cSDHLibraryException*) |
void | Close () throw (cSDHLibraryException*) |
virtual bool | IsOpen (void) |
void | Send (char const *s, int nb_lines=All, int nb_lines_total=All, int max_retries=3) throw ( cSDHLibraryException* ) |
void | ExtractFirmwareState () throw ( cSDHErrorCommunication* ) |
double | GetDuration (char *line) throw ( cSDHErrorCommunication* ) |
double | get_duration (void) |
void | Sync () throw ( cSDHErrorCommunication* ) |
void | BinarySync (double timeout_s=0.5) throw ( cSDHErrorCommunication* ) |
void | SyncUnknown () throw ( cSDHErrorCommunication* ) |
cSimpleVector | AxisCommand (char const *command, int axis=All, double *value=NULL) throw (cSDHLibraryException*) |
cSimpleVector | BinaryAxisCommand (eCommandCode command, int axis=All, double *value=NULL) throw (cSDHLibraryException*) |
Setup and configuration methods | |
cSimpleVector | pid (int axis, double *p=NULL, double *i=NULL, double *d=NULL) throw (cSDHLibraryException*) |
cSimpleVector | kv (int axis=All, double *kv=NULL) throw (cSDHLibraryException*) |
cSimpleVector | ilim (int axis=All, double *limit=NULL) throw (cSDHLibraryException*) |
cSimpleVector | power (int axis=All, double *flag=NULL) throw (cSDHLibraryException*) |
Misc. methods | |
void | demo (bool onoff) |
int | property (char const *propname, int value) |
int | user_errors (int value) |
int | terminal (int value) |
int | debug (int value) |
Movement methods | |
cSimpleVector | v (int axis=All, double *velocity=NULL) throw (cSDHLibraryException*) |
cSimpleVector | tvav (int axis=All, double *velocity=NULL) throw (cSDHLibraryException*) |
cSimpleVector | vlim (int axis=All, double *dummy=NULL) throw (cSDHLibraryException*) |
cSimpleVector | alim (int axis=All, double *dummy=NULL) throw (cSDHLibraryException*) |
cSimpleVector | a (int axis=All, double *acceleration=NULL) throw (cSDHLibraryException*) |
cSimpleVector | p (int axis=All, double *angle=NULL) throw (cSDHLibraryException*) |
cSimpleVector | tpap (int axis=All, double *angle=NULL) throw (cSDHLibraryException*) |
double | m (bool sequ) throw (cSDHLibraryException*) |
void | stop (void) throw (cSDHLibraryException*) |
eVelocityProfile | vp (eVelocityProfile velocity_profile=eVP_INVALID) throw (cSDHLibraryException*) |
eControllerType | con (eControllerType controller) throw (cSDHLibraryException*) |
Diagnostic and identification methods | |
cSimpleVector | pos (int axis=All, double *dummy=NULL) throw (cSDHLibraryException*) |
cSimpleVector | pos_save (int axis=All, double *value=NULL) throw (cSDHLibraryException*) |
cSimpleVector | ref (int axis=All, double *value=NULL) throw (cSDHLibraryException*) |
cSimpleVector | vel (int axis=All, double *dummy=NULL) throw (cSDHLibraryException*) |
cSimpleVector | rvel (int axis, double *dummy=NULL) throw (cSDHLibraryException*) |
cSimpleVector | state (int axis=All, double *dummy=NULL) throw (cSDHLibraryException*) |
cSimpleVector | temp (void) throw (cSDHLibraryException*) |
cSimpleVector | temp_electronics (void) throw (cSDHLibraryException*) |
char * | ver (void) throw (cSDHLibraryException*) |
char * | ver_date (void) throw (cSDHLibraryException*) |
char * | id (void) throw (cSDHLibraryException*) |
char * | sn (void) throw (cSDHLibraryException*) |
char * | soc (void) throw (cSDHLibraryException*) |
char * | soc_date (void) throw (cSDHLibraryException*) |
int | numaxis (void) throw (cSDHLibraryException*) |
Grip methods | |
cSimpleVector | igrip (int axis=All, double *limit=NULL) throw (cSDHLibraryException*) |
cSimpleVector | ihold (int axis=All, double *limit=NULL) throw (cSDHLibraryException*) |
double | selgrip (eGraspId grip, bool sequ) throw (cSDHLibraryException*) |
double | grip (double close, double velocity, bool sequ) throw (cSDHLibraryException*) |
Protected Attributes | |
cSerialBase * | com |
The communication object to the serial device (RS232 port or ESD CAN net) | |
char const * | EOL |
String to use as "End Of Line" marker when sending to SDH. | |
double | m_sequtime |
additional time in seconds to wait for sequential execution of m command (as these are always executed non-sequentially by the SDH firmware | |
int | nb_lines_to_ignore |
number of remaining reply lines of a previous (non-sequential) command | |
cSimpleStringList | reply |
Space for the replies from the SDH. | |
Friends | |
struct | sSDHBinaryRequest |
struct | sSDHBinaryResponse |
The class to communicate with a SDH via RS232.
End-Users should NOT use this class directly! The interface of cSDHSerial is subject to change in future releases. End users should use the class cSDH instead, as that interface is considered more stable.
Definition at line 91 of file sdhserial.h.
cSDHSerial::cSDHSerial | ( | int | _debug_level = 0 | ) |
Constructor of cSDHSerial.
_debug_level | : debug level of the created object. If the debug_level of an object is > 0 then it will output debug messages. (forwared to constructor of base class) |
virtual cSDHSerial::~cSDHSerial | ( | ) | [inline, virtual] |
virtual destructor to make compiler happy
Definition at line 143 of file sdhserial.h.
cSimpleVector cSDHSerial::a | ( | int | axis = All , |
double * | acceleration = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set target acceleration for axis. (NOT the actual acceleration!)
Accelerations are set/reported in degrees per second squared.
cSimpleVector cSDHSerial::alim | ( | int | axis = All , |
double * | dummy = NULL |
||
) | throw (cSDHLibraryException*) |
Get acceleration limits.
dummy parameter is just needed to make this function have the same signature as e.g. v(), so it can be used as a function pointer.
Acceleration limits are reported in degrees per (second*second).
cSimpleVector cSDHSerial::AxisCommand | ( | char const * | command, |
int | axis = All , |
||
double * | value = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set values.
cSimpleVector cSDHSerial::BinaryAxisCommand | ( | eCommandCode | command, |
int | axis = All , |
||
double * | value = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set values using binary mode.
void cSDHSerial::BinarySync | ( | double | timeout_s = 0.5 | ) | throw ( cSDHErrorCommunication* ) |
Read all available bytes within timeout_s seconds to resync execution of PC and SDH.
void cSDHSerial::Close | ( | ) | throw (cSDHLibraryException*) |
Close connection to serial port.
eControllerType cSDHSerial::con | ( | eControllerType | controller | ) | throw (cSDHLibraryException*) |
Get/set controller type.
If controller is < 0 then the actually set controller is read from the SDH firmware and returned. Else the given controller type is set in the SDH firmware if valid.
int cSDHSerial::debug | ( | int | value | ) |
void cSDHSerial::demo | ( | bool | onoff | ) |
Enable/disable SCHUNK demo
void cSDHSerial::ExtractFirmwareState | ( | ) | throw ( cSDHErrorCommunication* ) |
Try to extract the state of the SDH firmware from the last reply
double cSDHSerial::get_duration | ( | void | ) |
Send get_duration command. Returns the calculated duration of the currently configured movement (target positions, velocities, accelerations and velocity profile.
return the expected duration of the execution of the command in seconds
double cSDHSerial::GetDuration | ( | char * | line | ) | throw ( cSDHErrorCommunication* ) |
Return duration of the execution of a SDH command as reported by line
double cSDHSerial::grip | ( | double | close, |
double | velocity, | ||
bool | sequ | ||
) | throw (cSDHLibraryException*) |
send "grip=close,velocity" command to SDH close : [0.0 .. 1.0] where 0.0 is 'fully opened' and 1.0 is 'fully closed' velocity : ]0.0 .. 100.0] where 0.0 (not allowed) is very slow and 100.0 is very fast
If sequ is True then wait until SDH hardware fully executed the command. Else return immediately and do not wait until SDH hardware fully executed the command.
This seems to work with sin square velocity profile only, so the velocity profile is switched to that if necessary.
return the expected duration of the execution of the command in seconds
char* cSDHSerial::id | ( | void | ) | throw (cSDHLibraryException*) |
Return id of SDH
cSimpleVector cSDHSerial::igrip | ( | int | axis = All , |
double * | limit = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set motor current limits for grip commands
cSimpleVector cSDHSerial::ihold | ( | int | axis = All , |
double * | limit = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set motor current limits for hold commands
cSimpleVector cSDHSerial::ilim | ( | int | axis = All , |
double * | limit = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set actual motor current limit for m command
virtual bool cSDHSerial::IsOpen | ( | void | ) | [virtual] |
Return true if connection to SDH firmware/hardware is open
Implements cSDHBase.
cSimpleVector cSDHSerial::kv | ( | int | axis = All , |
double * | kv = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set kv parameter
double cSDHSerial::m | ( | bool | sequ | ) | throw (cSDHLibraryException*) |
Send move command. Moves all enabled axes to their previously set target angle. The movement duration is determined by that axis that takes longest with its actually set velocity. The actual velocity of all other axes is set so that all axes begin and end their movements synchronously.
If sequ is True then wait until SDH hardware fully executed the command. Else return immediately and do not wait until SDH hardware fully executed the command.
return the expected duration of the execution of the command in seconds
int cSDHSerial::numaxis | ( | void | ) | throw (cSDHLibraryException*) |
Return number of axis of SDH
void cSDHSerial::Open | ( | cSerialBase * | _com | ) | throw (cSDHLibraryException*) |
Open the serial device and check connection to SDH by querying the SDH firmware version
_com | - ptr to the serial device to use |
This may throw an exception on failure.
The serial port on the PC-side can be opened successfully even if no SDH is attached. Therefore this routine tries to read the SDH firmware version with a 1s timeout after the port is opened. If the SDH does not reply in time then
cSimpleVector cSDHSerial::p | ( | int | axis = All , |
double * | angle = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set target angle for axis. (NOT the actual angle!)
Angles are set/reported in degrees.
cSimpleVector cSDHSerial::pid | ( | int | axis, |
double * | p = NULL , |
||
double * | i = NULL , |
||
double * | d = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set PID controller parameters
cSimpleVector cSDHSerial::pos | ( | int | axis = All , |
double * | dummy = NULL |
||
) | throw (cSDHLibraryException*) |
Get actual angle/s of axis/axes.
Angles are reported in degrees.
cSimpleVector cSDHSerial::pos_save | ( | int | axis = All , |
double * | value = NULL |
||
) | throw (cSDHLibraryException*) |
Save actual angle/s to non volatile memory. (Usefull for axes that dont have an absolute encoder)
cSimpleVector cSDHSerial::power | ( | int | axis = All , |
double * | flag = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set actual power state
int cSDHSerial::property | ( | char const * | propname, |
int | value | ||
) |
Set named property
Valid propnames are:
cSimpleVector cSDHSerial::ref | ( | int | axis = All , |
double * | value = NULL |
||
) | throw (cSDHLibraryException*) |
Do reference movements with selected axes. (Usefull for axes that dont have an absolute encoder)
each value must be either
cSimpleVector cSDHSerial::rvel | ( | int | axis, |
double * | dummy = NULL |
||
) | throw (cSDHLibraryException*) |
Get current reference angular velocity/s of axis/axes. The reference angular velocity is used by the eCT_VELOCITY_ACCELERATION controller type only.
Angular velocities are reported in degrees/second.
double cSDHSerial::selgrip | ( | eGraspId | grip, |
bool | sequ | ||
) | throw (cSDHLibraryException*) |
Send "selgrip grip" command to SDH. Where grip is in [0..eGID_DIMENSION-1] or one of the eGraspId enums.
If sequ is True then wait until SDH hardware fully executed the command. Else return immediately and do not wait until SDH hardware fully executed the command.
This seems to work with sin square velocity profile only, so the velocity profile is switched to that if necessary.
return the expected duration of the execution of the command in seconds
void cSDHSerial::Send | ( | char const * | s, |
int | nb_lines = All , |
||
int | nb_lines_total = All , |
||
int | max_retries = 3 |
||
) | throw ( cSDHLibraryException* ) |
Send command string s+EOL to com and read reply according to nb_lines.
If nb_lines == All then reply lines are read until a line without "@" prefix is found. If nb_lines != All it is the number of lines to read.
firmware_state is set according to reply (if read) nb_lines_total contains the total number of lines replied for the s command. If fewer lines are read then nb_lines_total-nb_lines will be remembered to be ignored before the next command can be sent.
Return a list of all read lines of the reply from the SDH hardware.
char* cSDHSerial::sn | ( | void | ) | throw (cSDHLibraryException*) |
Return sn of SDH
char* cSDHSerial::soc | ( | void | ) | throw (cSDHLibraryException*) |
Return soc (System On Chip) ID of SDH
char* cSDHSerial::soc_date | ( | void | ) | throw (cSDHLibraryException*) |
Return date of soc (System On Chip) ID of SDH
cSimpleVector cSDHSerial::state | ( | int | axis = All , |
double * | dummy = NULL |
||
) | throw (cSDHLibraryException*) |
Get actual state/s of axis/axes.
A state of 0 means "not moving" while 1 means "moving".
void cSDHSerial::stop | ( | void | ) | throw (cSDHLibraryException*) |
Stop sdh.
Will NOT interrupt a previous "selgrip" or "grip" command, only an "m" command!
void cSDHSerial::Sync | ( | ) | throw ( cSDHErrorCommunication* ) |
Read all pending lines from SDH to resync execution of PC and SDH.
void cSDHSerial::SyncUnknown | ( | ) | throw ( cSDHErrorCommunication* ) |
Read an unknown number of lines from SDH to resync execution of PC and SDH.
cSimpleVector cSDHSerial::temp | ( | void | ) | throw (cSDHLibraryException*) |
Get actual temperatures of the axis motors
Returns a list of the actual controller and driver temperature in degrees celsius.
cSimpleVector cSDHSerial::temp_electronics | ( | void | ) | throw (cSDHLibraryException*) |
Get actual temperatures of the electronics, i.e. teh FPGA and the PCB. (FPGA = Field Programmable Gate Array = the reprogrammable chip with the soft processors) (PCB = Printed Circuit Board)
Returns a list of the actual controller and driver temperature in degrees celsius.
int cSDHSerial::terminal | ( | int | value | ) |
cSimpleVector cSDHSerial::tpap | ( | int | axis = All , |
double * | angle = NULL |
||
) | throw (cSDHLibraryException*) |
Set target angle and get actual angle for axis.
Angles are set/reported in degrees.
cSimpleVector cSDHSerial::tvav | ( | int | axis = All , |
double * | velocity = NULL |
||
) | throw (cSDHLibraryException*) |
Set target velocity and get actual velocity!)
The default velocity is 40 deg/s for axes 0-6 in eCT_POSE controller type. The default velocity is 0.0 deg/s for axes 0-6 in eCT_VELOCITY and eCT_VELOCITY_ACCELERATION controller types.
Velocities are set/reported in degrees per second.
int cSDHSerial::user_errors | ( | int | value | ) |
cSimpleVector cSDHSerial::v | ( | int | axis = All , |
double * | velocity = NULL |
||
) | throw (cSDHLibraryException*) |
Get/Set target velocity. (NOT the actual velocity!)
The default velocity is 40 deg/s for axes 0-6 in eCT_POSE controller type. The default velocity is 0.0 deg/s for axes 0-6 in eCT_VELOCITY and eCT_VELOCITY_ACCELERATION controller types.
Velocities are set/reported in degrees per second.
cSimpleVector cSDHSerial::vel | ( | int | axis = All , |
double * | dummy = NULL |
||
) | throw (cSDHLibraryException*) |
Get actual angular velocity/s of axis/axes.
Angular velocities are reported in degrees/second.
char* cSDHSerial::ver | ( | void | ) | throw (cSDHLibraryException*) |
Return version of SDH firmware
char* cSDHSerial::ver_date | ( | void | ) | throw (cSDHLibraryException*) |
Return date of SDH firmware
cSimpleVector cSDHSerial::vlim | ( | int | axis = All , |
double * | dummy = NULL |
||
) | throw (cSDHLibraryException*) |
Get velocity limits.
dummy parameter is just needed to make this function have the same signature as e.g. v(), so it can be used as a function pointer.
Velocity limits are reported in degrees per second.
eVelocityProfile cSDHSerial::vp | ( | eVelocityProfile | velocity_profile = eVP_INVALID | ) | throw (cSDHLibraryException*) |
Get/set velocity profile.
If velocity_profile is < 0 then the actually set velocity profile is read from the SDH firmware and returned. Else the given velocity_profile type is set in the SDH firmware if valid.
friend struct sSDHBinaryRequest [friend] |
Definition at line 93 of file sdhserial.h.
friend struct sSDHBinaryResponse [friend] |
Definition at line 94 of file sdhserial.h.
cSerialBase* cSDHSerial::com [protected] |
The communication object to the serial device (RS232 port or ESD CAN net)
Definition at line 108 of file sdhserial.h.
char const* cSDHSerial::EOL [protected] |
String to use as "End Of Line" marker when sending to SDH.
Definition at line 105 of file sdhserial.h.
double cSDHSerial::m_sequtime [protected] |
additional time in seconds to wait for sequential execution of m command (as these are always executed non-sequentially by the SDH firmware
Definition at line 102 of file sdhserial.h.
int cSDHSerial::nb_lines_to_ignore [protected] |
number of remaining reply lines of a previous (non-sequential) command
Definition at line 115 of file sdhserial.h.
cSimpleStringList cSDHSerial::reply [protected] |
Space for the replies from the SDH.
Definition at line 112 of file sdhserial.h.