AURobotServers
4
|
#include <uressmr.h>
Public Member Functions | |
virtual void | closeConnection () |
double | doSmrDrive (const char *cmd, int repeat) |
double | doUserEvent (int repeat) |
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) |
virtual void | eventWatchFired (const char *name, double atTime) |
A watch event occured, update as needed. More... | |
double | getAcc () |
double | getMinTurnRad () |
double | getSpeed () |
double | getTurnAcc () |
bool | isInsLogOpen () |
is the INS logfile (ins.log) open More... | |
bool | isStreaming () |
bool | methodCall (const char *name, const char *paramOrder, char **strings, const double *pars, double *value, UDataBase **returnStruct=NULL, int *returnStructCnt=NULL) |
void | openINSlog (bool open) |
opens or reopens the INS logfile. The logfile is intended to be used with data streamed from MRC, and especially when connected to HAKO tractor with cross-bow INS module. More... | |
virtual const char * | print (const char *preString, char *buff, int buffCnt) |
bool | sendAddWatch (const char *name, const char *condition) |
int | sendUserEvent (const char *evPreString, int evNumber) |
bool | setResource (UResBase *resource, bool remove) |
void | stopRobot () |
bool | testEvent (int evID, UTime *eventTime, bool removeIfFound) |
UResSmrIf () | |
void | UResSmrIfInit () |
virtual | ~UResSmrIf () |
Public Member Functions inherited from UResVarPool | |
int | addMethod (const char *formalName, const char *paramTypes, const char *comment) |
int | addMethodV (const char *formalName, const char *paramTypes, const char *comment) |
UVarPool * | addStruct (const char *name, const char *comment, bool copy=false) |
UVariable * | addVar (const char *name, const double initialValue, const char *type, const char *comment) |
UVariable * | addVar (const char *name, const char *initialValue, const char *type, const char *comment) |
UVariable * | addVarA (const char *name, const char *initialValue, const char *type, const char *comment) |
bool | callGlobal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt) |
bool | callGlobalV (const char *name, const char *paramOrder, UVariable **params, UDataBase **returnStruct, int *returnStructCnt) |
Call a method from the root var pool scope It may be in the structure direct (no '.') or in any sub-structure that the 'name.subname' indicate. More... | |
bool | callLocal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt) |
bool | callVS (const char *function, const char *stringParam) |
int | callVSCD (const char *function, const char *strPar, UDataBase *data, int cooSys) |
void | createBaseVar () |
virtual bool | createVarSpace (const int varCnt, const int structCnt, const int methCnt, const char *note, bool copy=false) |
bool | getGlobalString (const char *name, const char **value) |
bool | getGlobalValue (const char *name, double *value) |
bool | getGlobalValue (const char *name, const char **value) |
bool | getGlobalValue (const char *name, bool *value) |
bool | getGlobalValue (const char *name, UTime *value) |
bool | getLocalValue (const char *name, double *value) |
get a value in this variable tree More... | |
bool | getLocalValue (const char *name, bool *value) |
bool | getLocalValue (const char *name, UTime *value) |
double | getLocalValue (int idx) |
UPosition | getLocalValue3D (int idx) |
UPosRot | getLocalValue6D (int idx) |
bool | getLocalValueBool (int idx) |
int | getLocalValueInt (int idx) |
UTime | getLocalValueTime (int idx) |
const char * | getLogFileName () |
const char * | getVarDescription (int idx) |
UVarCalc * | getVarPool () |
virtual bool | gotAllResources (char *missingThese, int missingTheseCnt) |
bool | isLogFileOpen () |
bool | isLogFileOpen (const char *structName) |
bool | isVarPoolUpdated (int lastCnt, int *newCnt) |
void | logFileClose () |
bool | logFileOpen () |
void | logFileStart (const char *structName, bool open) |
bool | setGlobalVar (const char *name, const double value, bool mayAdd) |
Assigns a value to a variable. The variable may be a part of a structure. More... | |
bool | setLocalVar (int idx, double value, const int element) |
bool | setLocalVar (const char *name, const double value, bool mayAdd) |
Assigns a value to a variable. The variable may be a part of a structure. More... | |
bool | setLocalVar3D (int idx, UPosition *value) |
bool | setLocalVar6D (int idx, UPosRot *value) |
bool | setLocalVarAdd (int idx, double value, const int element) |
bool | setLocalVarPose (int idx, UPose *value) |
void | setVarPool (UVarCalc *sharedVarPool) |
int | updateQTvars (int structIdx) |
UResVarPool () | |
virtual | ~UResVarPool () |
Public Member Functions inherited from UResBase | |
void | createReplayVar (UVarPool *pool) |
virtual void | createResources () |
UCmdExe * | getCorePointer () |
char * | getLogFileName (char *fn, const int fnCnt) |
int | getResFuncIdx () |
const char * | getResID () |
int | getResVersion () |
bool | isA (const char *idStr) |
bool | isAlsoA (const char *id) |
virtual void | print (const char *preString) |
virtual void | saveSettings () |
void | setCorePointer (UCmdExe *serverCore) |
void | setResFuncIdx (int idx) |
virtual void | setResID (const char *id, const int version) |
virtual void | stop (bool) |
virtual void | updateReplayStatus () |
UResBase () | |
virtual | ~UResBase () |
Public Member Functions inherited from UReplay | |
void | addChild (UReplay *child) |
virtual bool | decodeReplayLine (char *) |
char * | getLogFileName (char *fn, const int fnCnt) |
char * | getReplayFileName (char *fn, const int fnCnt) |
int | getReplayLogLine () |
bool | isReplay () |
bool | isReplayFileOpen () |
void | removeChild (UReplay *child) |
virtual void | replayAdvanceTime (UTime untilTime) |
void | replaySetBaseFileName (const char *name, const char *preName="") |
void | replaySetFileName (const char *name) |
virtual bool | replayStep () |
int | replayStep (int steps) |
virtual bool | replayToTime (UTime untilTime) |
void | setParent (UReplay *parent) |
bool | setReplay (bool value) |
UReplay () | |
virtual | ~UReplay () |
Public Member Functions inherited from ULock | |
bool | lock () |
void | lockInit () |
void | post () |
bool | tryLock () |
bool | tryWait () |
ULock () | |
void | unlock () |
bool | wait () |
~ULock () | |
Public Member Functions inherited from UVarMethodImplement | |
virtual bool | methodCallV (const char *name, const char *paramOrder, UVariable *params[], UDataBase **returnStruct, int *returnStructCnt) |
virtual | ~UVarMethodImplement () |
Public Member Functions inherited from USmrCl | |
bool | doDisconnect () |
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 () |
Public Member Functions inherited from UServerPush | |
int | addPushCommand (UServerInMsg *msg) |
virtual void | callGotNewDataWithObject () |
bool | doPushCall (UServerPushElement *pe, const char *value) |
void | flushClientCmds (int clientIdx) |
UServerPushImplement * | getImplementor () |
int | getPushCmdCnt (int *cmdCnt, int *callCnt) |
UServerPushQueue * | getPushQueue () |
bool | gotCmdExe () |
void | gotNewData (void *pData) |
bool | isUpdated (int lastCnt, int *newCnt) |
bool | needNewData () |
void | print (const char *preString) |
void | print (const char *preString, char *buff, int buffCnt) |
void | servicePendingPushCmds () |
void | setCmdExe (UServerPushImplement *executor) |
void | setImplementor (UServerPushImplement *executor) |
bool | setResource (UResBase *resource, bool remove) |
bool | setUpdated (const char *value) |
Add watch object if needed. An image or other object is updated. set object as updated, with an extra qualifier, that may be used as a parameter in a push call. this push list is then added to the to the push list examined by the server thread. when server thread reach this push list it will call to get a possible associated data structure by a call to needNewData() whish is expected to call gotNewData(void * data_structure) - but now in the server thread. More... | |
UServerPush () | |
virtual | ~UServerPush () |
Static Public Member Functions | |
static const char * | getResClassID () |
Static Public Member Functions inherited from UResVarPool | |
static const char * | getResClassID () |
Protected Member Functions | |
virtual void | connectionChange (bool connected) |
void | createBaseVar () |
Create the smrif related variables. More... | |
void | flushMRCUserEvents () |
virtual void | gotUserEvent (const char *eventString) |
virtual void | lineStateUpdated () |
Protected Member Functions inherited from UResVarPool | |
void | setDescription (const char *note, bool copy=false) |
Protected Member Functions inherited from UResBase | |
UResBase * | getStaticResource (const char *resName, bool mayCreate, bool staticOnly=true) |
get a pointer to a static resource. More... | |
Protected Member Functions inherited from USmrCl | |
bool | getDataFromLine (int timeout, bool waitFullTime) |
bool | getLineFromSocket (int timeout_ms) |
virtual void | info (const char *msg, int type=0) |
bool | isMessageInBuffer () |
bool | setDriveState (bool *idEevent, bool *eventTimeout, bool *streamData) |
void | toLog (const char *logString, const int logLevel) |
Static Protected Attributes | |
static const int | MAX_DRIVE_COMMAND_LENGTH = 500 |
Static Protected Attributes inherited from UReplay | |
static const int | MAX_LOG_LINE_LENGTH = 10000 |
static const int | REPLAY_FILE_NAME_LENGTH = 264 |
max length of replay filename More... | |
Static Protected Attributes inherited from USmrCl | |
static const int | MaxEvalLen = 500 |
Additional Inherited Members | |
Public Attributes inherited from UReplay | |
bool | replayTimeAdvancePending |
UTime | replayTimeNow |
Public Attributes inherited from USmrCl | |
int | cmdLineFinished |
int | cmdLineQueued |
int | cmdLineStarted |
int | cmdLineStopCnd |
int | cmdLineSyntaxError |
int | cmdLineUserEvent |
bool | cmdStop |
double | gpsVals [maxGpsVals] |
double | ins [INSV] |
ULogFile | logIO |
USmrOdoState | odoState |
double | streamInsTime |
int | streamShowGpsCnt |
int | streamShowGpsEvery |
int | streamShowInsCnt |
int | streamShowInsEvery |
int | streamShowOdoCnt |
int | streamShowOdoEvery |
bool | tryHoldConnection |
Static Public Attributes inherited from USmrCl | |
static const int | INSV = 7 |
static const int | maxGpsVals = 6 |
number of doubles in gps streaming array (E,N,H, mode, sats, dof) More... | |
This is the shared resource class. It must enherit from the resource base class (or one of its decendent) as shown.
|
inline |
Constructor
|
virtual |
Destructor
References USmrCl::doDisconnect(), flushMRCUserEvents(), and logINS.
|
virtual |
Stop the robot and shut down the socket connection
Reimplemented from USmrCl.
References USmrCl::closeConnection(), USmrCl::connected, and stopRobot().
|
protectedvirtual |
Called when connection to MRC is created or lost.
Reimplemented from USmrCl.
References UVariable::b, UResVarPool::getVarPool(), poseStreaming, USmrCl::sendString(), UVarPool::setLocalVar(), and UServerPush::setUpdated().
|
protected |
Create the smrif related variables.
References UResVarPool::addMethod(), UResVarPool::addVar(), varAcc, varHakoManual, varIdFinished, varIdQueued, varIdStarted, varIdSyntaxErr, varIdUserEvent, varLiftPos, varMinTurnRad, varPtoSpeed, varSpeed, and varTurnAcc.
Referenced by UResSmrIfInit().
double UResSmrIf::doSmrDrive | ( | const char * | cmd, |
int | repeat | ||
) |
Issue a drive command (and wait until finished
References doUserEvent(), and USmrCl::sendString().
Referenced by methodCall().
double UResSmrIf::doUserEvent | ( | int | repeat | ) |
Issue a drive command (and wait until finished
References USmrCl::cmdLineUserEvent, driveUserEventID, UTime::getMicrosec(), UTime::getSec(), and sendUserEvent().
Referenced by doSmrDrive(), UResSmrCtl::methodCall(), and methodCall().
|
virtual |
A new GPS position is received from MRC with these values. is called from smr interface when streaming is active only.
heading | may be from odo-gps kalman filter This requires that the MRC is connected to a gps, as for the HAKO. |
Reimplemented from USmrCl.
References UResPoseHist::addIfNeeded(), ULogFile::getF(), UTime::getMicrosec(), UTime::getSec(), UPose::h, ULogFile::isOpen(), logGPS, logGPSuse, UTime::now(), ULogFile::openLog(), UPoseTVQ::q, ULogFile::setLogName(), UPoseTime::t, utmPose, UPoseTVQ::vel, UPose::x, and UPose::y.
|
virtual |
hako status variables are received
Reimplemented from USmrCl.
References UVariable::setValued(), varHakoManual, varLiftPos, and varPtoSpeed.
|
virtual |
A new INS data is received from MRC with these values. It is called if ins-time is updated.
Reimplemented from USmrCl.
References UTime::getMicrosec(), UTime::getSec(), logINS, and UTime::now().
|
virtual |
A new pose state is available in the odoPose structure - update pose history
Reimplemented from USmrCl.
References UResPoseHist::addIfNeeded(), UPose::h, USmrCl::odoState, USmrOdoState::pose, poseHist, poseStreaming, UPoseTVQ::set(), UPoseTime::t, USmrOdoState::velocity, UPose::x, and UPose::y.
|
virtual |
A watch event occured, update as needed.
name | is the name of the watch fired |
atTime | is the MRC time reported. |
Reimplemented from USmrCl.
References UResVarPool::getLocalValue(), and UResVarPool::setLocalVar().
|
protected |
Flush all received but not yet tested user events
References events, and UMRCUserEvent::next.
Referenced by methodCall(), and ~UResSmrIf().
double UResSmrIf::getAcc | ( | ) |
References UVariable::getValued(), and varAcc.
Referenced by UResSmrCtl::sendNewManoeuvreToSMR().
double UResSmrIf::getMinTurnRad | ( | ) |
References UVariable::getValued(), and varMinTurnRad.
Referenced by UResSmrCtl::sendNewManoeuvreToSMR().
|
inlinestatic |
Fixed name of this resource type
Referenced by UResSmrCtl::setResource().
double UResSmrIf::getSpeed | ( | ) |
Stop any running action, we are going down
References UVariable::getValued(), and varSpeed.
Referenced by UResSmrCtl::sendNewManoeuvreToSMR().
double UResSmrIf::getTurnAcc | ( | ) |
References UVariable::getValued(), and varTurnAcc.
Referenced by UResSmrCtl::sendNewManoeuvreToSMR().
|
protectedvirtual |
Is called by interface when a non-numeric userevent is received from MRC
eventstring | is the string returned by MRC after the keyword 'userevent' and stripped for whitespace. |
Reimplemented from USmrCl.
References events, eventsLock, UMRCUserEvent::eventTime, UMRCUserEvent::id, ULock::lock(), UMRCUserEvent::next, UTime::now(), and ULock::unlock().
|
inline |
|
inline |
Is pose updates received from MRC and transferred to poseHist?
Referenced by UFunctionSmrIf::handleSmr(), and UResSmrCtl::startPoseStreaming().
|
protectedvirtual |
This function is called when an ID-queued -started or finished is received
Reimplemented from USmrCl.
References USmrCl::cmdLineFinished, USmrCl::cmdLineQueued, USmrCl::cmdLineStarted, USmrCl::cmdLineSyntaxError, USmrCl::cmdLineUserEvent, UVariable::setValued(), varIdFinished, varIdQueued, varIdStarted, varIdSyntaxErr, and varIdUserEvent.
|
virtual |
The varPool has methods, and a call to one of these are needed. Do the call now and return (a double sized) result in 'value' and
Reimplemented from UResVarPool.
References doSmrDrive(), doUserEvent(), flushMRCUserEvents(), UTime::getDecSec(), roundi(), USmrCl::saveMrcLog(), sendAddWatch(), USmrCl::sendSMReval(), USmrCl::sendString(), sendUserEvent(), testEvent(), and USmrCl::verbose.
void UResSmrIf::openINSlog | ( | bool | open | ) |
opens or reopens the INS logfile. The logfile is intended to be used with data streamed from MRC, and especially when connected to HAKO tractor with cross-bow INS module.
References dataPath, logINS, and MAX_FILENAME_LENGTH.
Referenced by UFunctionSmrIf::handleSmr().
|
virtual |
print status to a string buffer
Reimplemented from UResVarPool.
References bool2str(), USmrCl::getPort(), and USmrCl::isConnected().
bool UResSmrIf::sendAddWatch | ( | const char * | name, |
const char * | condition | ||
) |
send command to MRC to create a new watch trap
name | name of the watch - a local structure will be added with this name |
condition | the condition on wich the watch should be fired (using MRC variables) |
References UResVarPool::getLocalValue(), USmrCl::sendString(), and UResVarPool::setLocalVar().
Referenced by methodCall().
int UResSmrIf::sendUserEvent | ( | const char * | evPreString, |
int | evNumber | ||
) |
Send a user event (with a new unique ID (increasing number from 101 and up).
evPreString | This string is put in fromt of the ID number - if empty (""), then no string is added. |
evNumber | This is the number (positive) put after the pre-string. if evNumber is negative, the autogenerated number is used (old type) -1 if not send (not connected or communication error). |
References driveUserEventID, and USmrCl::sendString().
Referenced by doUserEvent(), methodCall(), and UResSmrCtl::sendNewManoeuvreToSMR().
|
virtual |
Called by server core when new resources are available. return true is resouurce is used Save a pointer to the resource as needed.
Reimplemented from UResVarPool.
References UResPoseHist::getOdoPoseID(), UCmdExe::getResClassID(), UResPoseHist::getUtmPoseID(), UResBase::isA(), UResBase::isAlsoA(), poseHist, UServerPush::setCmdExe(), UResVarPool::setResource(), and utmPose.
void UResSmrIf::stopRobot | ( | ) |
Stop robot by sending flushcmds, stop and idle commands. The connection needs to be open. The socket connection is unchanged after the call.
References USmrCl::connected, and USmrCl::sendString().
Referenced by closeConnection(), and UFunctionSmrIf::handleSmr().
bool UResSmrIf::testEvent | ( | int | evID, |
UTime * | eventTime, | ||
bool | removeIfFound | ||
) |
Test if a specific event is received from MRC
References events, eventsLock, UMRCUserEvent::eventTime, UMRCUserEvent::id, ULock::lock(), UMRCUserEvent::next, and ULock::unlock().
Referenced by methodCall().
void UResSmrIf::UResSmrIfInit | ( | ) |
Initialize class
References createBaseVar(), UResVarPool::createVarSpace(), driveUserEventID, events, logGPSuse, logINS, poseHist, poseStreaming, and utmPose.
|
protected |
Drive command ID and other options
|
protected |
Drive command ID and other options
Referenced by doUserEvent(), sendUserEvent(), and UResSmrIfInit().
|
protected |
Command last executed List of received user events with keyword "ev"
Referenced by flushMRCUserEvents(), gotUserEvent(), testEvent(), and UResSmrIfInit().
|
protected |
Lock to ensyre that elements are inserted and deleted in an orderly manner.
Referenced by gotUserEvent(), and testEvent().
|
protected |
File handle for GPS log received from MRC
Referenced by eventGpsUpdate().
|
protected |
Should a log be made for GPS data
Referenced by eventGpsUpdate(), and UResSmrIfInit().
|
protected |
File handle for GPS log received from MRC
Referenced by eventInsUpdate(), openINSlog(), UResSmrIfInit(), and ~UResSmrIf().
|
staticprotected |
Maximum length of a drive command in the SMRCL language
|
protected |
Pointer to pose history resource.
Referenced by eventPoseUpdated(), setResource(), and UResSmrIfInit().
|
protected |
Is poses received using a stream command? The value is set when data is received.
Referenced by connectionChange(), eventPoseUpdated(), and UResSmrIfInit().
|
protected |
Pointer to pose history resource.
Referenced by eventGpsUpdate(), setResource(), and UResSmrIfInit().
|
protected |
index to local variable acc
Referenced by createBaseVar(), and getAcc().
|
protected |
hako manual-automatic flag
Referenced by createBaseVar(), and eventHakoVarUpdate().
|
protected |
Index to line ID started
Referenced by createBaseVar(), and lineStateUpdated().
|
protected |
Index to line ID queued
Referenced by createBaseVar(), and lineStateUpdated().
|
protected |
Index to line ID finished
Referenced by createBaseVar(), and lineStateUpdated().
|
protected |
Index to line ID with syntax error
Referenced by createBaseVar(), and lineStateUpdated().
|
protected |
Index to value of user event
Referenced by createBaseVar(), and lineStateUpdated().
|
protected |
position of lift
Referenced by createBaseVar(), and eventHakoVarUpdate().
|
protected |
index to local variable minimum turn radius
Referenced by createBaseVar(), and getMinTurnRad().
|
protected |
speed of power take off
Referenced by createBaseVar(), and eventHakoVarUpdate().
|
protected |
local variables provided by this resource. index to local variable speed
Referenced by createBaseVar(), and getSpeed().
|
protected |
index to local variable turnAcc
Referenced by createBaseVar(), and getTurnAcc().