#include <usmrcl.h>
|
bool | doDisconnect () |
|
virtual void | eventGpsUpdate (UPoseTime odoState, double easting, double northing, double heading, double quality, double satellites, double dop) |
|
virtual void | eventHakoVarUpdate (int hakoManual, int liftPos, int ptoSpeed) |
|
virtual void | eventInsUpdate (UPoseTime odoState, double accx, double accy, double accz, double roll, double tilt, double pan, double insTime) |
|
virtual void | eventPoseUpdated (bool streamSource) |
|
char * | getHost () |
|
int | getLogMode () |
|
int | getPort () |
|
virtual bool | getSimulatedPose () |
|
int | getStopCondition () |
|
bool | handleLineData (const int timeoutMs) |
|
bool | isConnected () |
|
bool | isLogging () |
|
void | print (const char *prestring) |
|
void | run () |
|
void | saveMrcLog (bool restart) |
|
bool | sendSMReval (const char *varName, double timeoutSec, double *value, char *valStr=NULL, const int valStrCnt=0) |
|
bool | sendString (const char *s1, const char *s2=NULL, const char *s3=NULL) |
|
int | setHost (const char *iHost) |
|
bool | setIOLog (const char *path, const char *name, const int mode) |
|
void | setIOLogClosed () |
|
void | setLogMode (int value) |
|
bool | setOdoLog (const char *, const char *) |
|
bool | setOdoLogClosed () |
|
int | setPort (int iPort) |
|
void | setVerbose (bool value) |
|
bool | start () |
|
bool | startOdoStream (const int samplesInterval) |
|
void | stop (bool andWait) |
|
bool | tryConnect () |
|
| USmrCl () |
|
virtual | ~USmrCl () |
|
bool | lock () |
|
void | lockInit () |
|
void | post () |
|
bool | tryLock () |
|
bool | tryWait () |
|
| ULock () |
|
void | unlock () |
|
bool | wait () |
|
| ~ULock () |
|
|
static const int | INSV = 7 |
|
static const int | maxGpsVals = 6 |
| number of doubles in gps streaming array (E,N,H, mode, sats, dof) More...
|
|
|
bool | handleGetevents (const int timeoutMs) |
|
bool | listen (int timeout, const char **gotReply, bool *handled, bool *handledID, bool *handledEventTimeout, bool *handledStream) |
|
bool | sendOnly (const char *cmd) |
|
Connection to SMR-CL
- Author
- Christian Andersen
void USmrCl::closeConnection |
( |
| ) |
|
|
protectedvirtual |
void USmrCl::connectionChange |
( |
bool |
connected | ) |
|
|
protectedvirtual |
A connection change has happened. The function is calle if connected or disconnected
Reimplemented in UResSmrIf.
References bool2str().
bool USmrCl::doDisconnect |
( |
| ) |
|
void USmrCl::eventGpsUpdate |
( |
UPoseTime |
odoState, |
|
|
double |
easting, |
|
|
double |
northing, |
|
|
double |
heading, |
|
|
double |
quality, |
|
|
double |
satellites, |
|
|
double |
dop |
|
) |
| |
|
virtual |
A new GPS position is received from MRC with these values. The function should be overwritten at a higher level
- Parameters
-
heading | may be from odo-gps kalman filter to prevent printout of the received position. |
Reimplemented in UResSmrIf.
References UTime::getMicrosec(), UTime::getSec(), and UPoseTime::t.
virtual void USmrCl::eventHakoVarUpdate |
( |
int |
hakoManual, |
|
|
int |
liftPos, |
|
|
int |
ptoSpeed |
|
) |
| |
|
inlinevirtual |
the hako variables may be updated - tell possible users.
- Parameters
-
hakoManual | manual or automatic enabled - probably useless |
liftPos | is the detected lift position - 100 is about center 80 is high and 120 is low |
ptoSpeed | is the RPM? of the power take off. all from: "stream %d \"$hakomanual" "$hakoliftinggearpos" "$hakopowertakeoffspeed"
", |
Reimplemented in UResSmrIf.
void USmrCl::eventInsUpdate |
( |
UPoseTime |
odoState, |
|
|
double |
accx, |
|
|
double |
accy, |
|
|
double |
accz, |
|
|
double |
roll, |
|
|
double |
tilt, |
|
|
double |
pan, |
|
|
double |
insTime |
|
) |
| |
|
virtual |
A new INS data is received from MRC with these values. The function should be overwritten at a higher level to prevent printout of the received position. virtual void eventInsUpdate(UPoseTime odoState, double accx, double accy, double accz, double roll, double tilt, double pan, double insTime);
Reimplemented in UResSmrIf.
References UTime::getMicrosec(), UTime::getSec(), and UTime::setTime().
void USmrCl::eventPoseUpdated |
( |
bool |
streamSource | ) |
|
|
virtual |
A new pose state is available in the 'odoState' structure
Reimplemented in UResSmrIf.
virtual void USmrCl::eventWatchFired |
( |
const char * |
, |
|
|
double |
|
|
) |
| |
|
inlineprotectedvirtual |
A watch event occured, update as needed.
- Parameters
-
name | is the name of the watch fired |
atTime | is the MRC time reported. |
Reimplemented in UResSmrIf.
bool USmrCl::getDataFromLine |
( |
int |
timeout, |
|
|
bool |
waitFullTime |
|
) |
| |
|
protected |
Listen to the line for the timeout period of time and collect the reply to the reply buffer. The timeout should be about 10 ms, to ensure that the reply to the request is available. If 'waitFullTime' is false, then function returns after first data is received (or timeout). Reply and replyCnt holds the reply. Returns true if new data is available, and false if timeout.
References UTime::getTimePassed(), MAX_REPLY_LENGTH, maxi(), UTime::Now(), roundi(), scWarning, and Wait().
char* USmrCl::getHost |
( |
| ) |
|
|
inline |
bool USmrCl::getLineFromSocket |
( |
int |
timeout_ms | ) |
|
|
protected |
Get a reply from MRC, wait no longer than timout for the reply. Reply may be split over more than one message block, or more than one line may be received Function returns when a '
' is found in the reply, or a timeout has occured. Returns true if data is available. Setc connected flag if a connection error occured. Received data is stored in 'reply[]', with length in replyCnt
int USmrCl::getLogMode |
( |
| ) |
|
|
inline |
bool USmrCl::getSimulatedPose |
( |
| ) |
|
|
virtual |
Get new simulated or replay data, as determined by this virtual function. It should be filled by an appropriate virtual function. Returns true if new data is filled into the odoState.
int USmrCl::getStopCondition |
( |
| ) |
|
|
inline |
Get stop condition on last finished command
virtual void USmrCl::gotUserEvent |
( |
const char * |
| ) |
|
|
inlineprotectedvirtual |
An interface specification for handling of user events
- Parameters
-
eventstring | is the string returned by MRC after the keyword 'userevent' and stripped for whitespace. |
Reimplemented in UResSmrIf.
bool USmrCl::handleGetevents |
( |
const int |
timeoutMs | ) |
|
|
private |
Handle all inut and empty 'event' queue, until an eventtimeout has occured. the 'Eventtimeout' could be short, as each receive should be handled in one MRC sampletime (10 ms) + transmission time. Returns true if an event timeout were received.
bool USmrCl::handleLineData |
( |
const int |
timeoutMs | ) |
|
Listen to the line from the smr and handle any stream data (and not handled getevents. Returns true if data is received.
void USmrCl::info |
( |
const char * |
msg, |
|
|
int |
type = 0 |
|
) |
| |
|
protectedvirtual |
There is info to report. this function may be overwritten by parent class.
References scError, scInfo, and scWarning.
bool USmrCl::isConnected |
( |
| ) |
|
|
inline |
bool USmrCl::isLogging |
( |
| ) |
|
|
inline |
bool USmrCl::isMessageInBuffer |
( |
| ) |
|
|
protected |
Test for avaiable message in reply buffer, that is not yet handled
void USmrCl::lineStateUpdated |
( |
| ) |
|
|
protectedvirtual |
Called when a getevent returnes a change in line status, i.e. a queued, finished or started
Reimplemented in UResSmrIf.
bool USmrCl::listen |
( |
int |
timeout, |
|
|
const char ** |
gotReply, |
|
|
bool * |
handled, |
|
|
bool * |
handledID, |
|
|
bool * |
handledEventTimeout, |
|
|
bool * |
handledStream |
|
) |
| |
|
private |
Listen for a line, and handle any known reply types these are IDXX queued, started, stopcond, flushed, syntaxErr, stream (assumed odometry), if handled then 'handled' is returned true. Returnes after first line, but more may be available. 'gotReply' holds the received line. Returns true if a line were received. Function sets 'connected' flag as apprppriate. If simulated flag is set, then odometry data is updated as appropriate.
void USmrCl::print |
( |
const char * |
prestring | ) |
|
void USmrCl::saveMrcLog |
( |
bool |
restart | ) |
|
bool USmrCl::sendOnly |
( |
const char * |
cmd | ) |
|
|
private |
Send a message to the MRC and return true if send. connected is set to false, if it is not possible to send.
References scWarning.
bool USmrCl::sendSMReval |
( |
const char * |
varName, |
|
|
double |
timeoutSec, |
|
|
double * |
value, |
|
|
char * |
valStr = NULL , |
|
|
const int |
valStrCnt = 0 |
|
) |
| |
Send this buffer of data and wait for reply. Returns true if send and reply received. Reply 'eventtimeout' and 'streem' do not count as reply. Send a drive command and wait for the queue number. If the queued reply is available within the timeout period, its number is returned at 'lineID', else last queued line is used, and the function returns false. If 'mustBeQueued', then a IDXX queued must be handled within timeout period to return true. Get the value of a variable from the MRC (MRC), if the value is received within timeout period, 'value' will hold the returned value.
- Parameters
-
varName | is the variable name in the MRC (MRC), possibly including the initial '$' as needed. |
timeoutSec | Minimum timeout period is about 0.75 sec if message flow is low, so a low 'timeoutSec' is replaced by this period. |
value | is a pointer to the place where the value is returned. |
valStr | is a buffer string, where the reply string from the MRC is placed. |
valStrCnt | is the length of the buffer |
- Returns
- true if a value is received.
References UTime::getTimePassed(), and UTime::Now().
Referenced by UFunctionSmrIf::handleSmr(), UResSmrIf::methodCall(), and testsmrcl().
bool USmrCl::sendString |
( |
const char * |
s1, |
|
|
const char * |
s2 = NULL , |
|
|
const char * |
s3 = NULL |
|
) |
| |
Send string direct to smr, and do not wait for a replay The connection is locked while sending to avoid conflict with service thread and menoeuvre delivery.
- Parameters
-
s1 | string to send |
s2 | any additional string to send, e.g. a terminaing line feed or extra stop condition |
s3 | any additional string to send, e.g. a terminaing line feed |
- Returns
- true if send within the timeout period
References ULock::lock(), and ULock::unlock().
Referenced by UResSmrIf::connectionChange(), UResSmrIf::doSmrDrive(), UFunctionSmrIf::handleSmr(), UResSmrIf::methodCall(), UResSmrIf::sendAddWatch(), UResSmrCtl::sendNewManoeuvreToSMR(), UResSmrIf::sendUserEvent(), UResSmrIf::stopRobot(), and testsmrcl().
bool USmrCl::setDriveState |
( |
bool * |
idEevent, |
|
|
bool * |
eventTimeout, |
|
|
bool * |
streamData |
|
) |
| |
|
protected |
int USmrCl::setHost |
( |
const char * |
iHost | ) |
|
|
inline |
bool USmrCl::setIOLog |
( |
const char * |
path, |
|
|
const char * |
name, |
|
|
const int |
mode |
|
) |
| |
Set input - output log for the connection to MRC. if mode is 0, nothing is logged - except errors. if mode is 1, all output is logged, including ID events numbers if mode is 2, all input and output is logged.
void USmrCl::setIOLogClosed |
( |
| ) |
|
void USmrCl::setLogMode |
( |
int |
value | ) |
|
|
inline |
Set logging mode ( 0 = just errors. 1=errors + output to smr, 3=errors + output + info, 4=errors + output + info + input from smr) (everything)
Referenced by UFunctionSmrIf::handleSmr().
bool USmrCl::setOdoLog |
( |
const char * |
, |
|
|
const char * |
|
|
) |
| |
|
inline |
Set odometry logfile. The filename is appended with timestamp and a '.log' extension. sample: path/name _yyyymmdd_hhmmss.ddd.log
bool USmrCl::setOdoLogClosed |
( |
| ) |
|
|
inline |
int USmrCl::setPort |
( |
int |
iPort | ) |
|
|
inline |
void USmrCl::setVerbose |
( |
bool |
value | ) |
|
|
inline |
bool USmrCl::startOdoStream |
( |
const int |
samplesInterval | ) |
|
void USmrCl::stop |
( |
bool |
andWait | ) |
|
Stop read thread
References Wait().
void USmrCl::toLog |
( |
const char * |
logString, |
|
|
const int |
logLevel |
|
) |
| |
|
protected |
Get odometer measurements command from MRC (as eval) Returns true if valid reply is available within timeout (in seconds) Save this string in 'log' (communication log), if 'log' is open and logmode is higher or equal to this 'logLevel'
References UTime::getMicrosec(), UTime::getSec(), and UTime::Now().
bool USmrCl::tryConnect |
( |
| ) |
|
int USmrCl::cmdLineFinished |
int USmrCl::cmdLineQueued |
int USmrCl::cmdLineStarted |
int USmrCl::cmdLineStopCnd |
stop condition for last command
int USmrCl::cmdLineSyntaxError |
int USmrCl::cmdLineUserEvent |
unsigned int USmrCl::connCnt |
|
protected |
Number of connections tried
unsigned int USmrCl::errCnt |
|
protected |
semaphore when waiting for eval result, implemented as request number and request and result number. evalReq is incremented before eval is send, and evalRes is set to evalReq on reply received. This is to allow recovery when MRC goes down or do not accept eval (e.g. syntax error)
bool USmrCl::gotGeteventReply |
|
private |
set true, whenever a valid event reply is received
Gps streamed values. The values are Easting, Northing, Satellites, dop, not used. DOP is Dillution Of Prediction 1 is perfect, 6 is OK, 50 is bad.
Referenced by UFunctionSmrIf::handleSmr().
Name of host to connect to
INS values last received - beeing accx, accy, accz, roll, tilt, pan, time
const int USmrCl::INSV = 7 |
|
static |
number of stored INS values
Log outgoing and incomming values, including Log getevent, eval, and all incomming. 0 = no logging 1 = log outgoing only 2 = log all
const int USmrCl::MaxEvalLen = 500 |
|
staticprotected |
Eval result string length
const int USmrCl::maxGpsVals = 6 |
|
static |
number of doubles in gps streaming array (E,N,H, mode, sats, dof)
Port used when connecting to host
unsigned int USmrCl::readCnt |
|
protected |
Number of reads (with >0 bytes returned).
reply from MRC, may be a line and a bit
last fully received line from MRC
Stream IMU data or hako tool details
double USmrCl::streamInsTime |
Count of gps stream updates
int USmrCl::streamShowGpsCnt |
int USmrCl::streamShowGpsEvery |
int USmrCl::streamShowInsCnt |
int USmrCl::streamShowInsEvery |
int USmrCl::streamShowOdoCnt |
int USmrCl::streamShowOdoEvery |
Thread handle for read loop.
bool USmrCl::tryHoldConnection |
When true the control loop will try and reestables connection if the connection fails.
unsigned int USmrCl::txCnt |
|
protected |
Number of transmitted messages
The documentation for this class was generated from the following files: