MRC interface

From Rsewiki
Jump to: navigation, search

Socket interface to MRC

Loads two resources called smr and smrctl

The smr is the socket interface that keeps track of interface status, and can receive streamed odometry and gps poses from the MRC.

The smrctl resource converts manoeuvres defined - in a UManSeq structure - to smrcl commands and sends these for the next short distance to the MRC.

Author: Christian Andersen

(for svn version 1090)

Contents

SMR resource

Configuration variables SMR

  • speed=0.4 Desired drive speed
  • acc=0.33 Used acceleration in MRC commands
  • turnAcc=0.33 Maximum desired turn acceleration
  • minTurnRad=0.1 Minimum turn radius to be suggested

Result/status variables SMR

  • connected=0 (ro) Connected to MRC if '1'
  • idQueued=-1 (ro) Last line number queued by MRC
  • idStarted=-1 (ro) last line number started by MRC
  • idFinished=-1 (ro) last line number finished by MRC
  • idSyntaxErr=-1 (ro) Last line that had a syntax error
  • idUserEvent=-1 (ro) Last user event received from MRC
  • hakomanual=0 (r) is hako in manual mode (else automatic)
  • liftPos=-1 (r) is current position of lift (100 is about mid, 80 is high, 120 is low).
  • PTOspeed=-1 (r) is current PTO speed.

Functions calls SMR

  • send(s) - Send this string to MRC
  • eval(s) - Get value of this variable in MRC
  • do(s) - Send this command to the smr connection - returns 0 if not send or syntax eror, 1 if send and not completed, 2 if send and completed.
  • do(sd) - Send this command to the smr connection - as above, but may be used as a control statement. If second parameter 'd' > 0 then the call just check the completion state (returns 2 for completed).
  • event(d) - Put an event on the MRC queue (if 'd'==0) and return 2 when completed Returnes 1 if send but not completed and 0 if not send or syntax error. If 'd'>0 just the test is performed.
  • addWatch(ss) - Add a watch to MRC, first parameter is the watch name, second is the trigger condition.
  • gotEvent(d) - Test if a user event 'evX' is received, where X is the integer part of the provided parameter. Returnes 1 (true) if event was received and 0 (false) if not. The event is removed after the call (if received).
  • gotEvent(dd) - Same as above, but saves the event if parameter 2 is 1 (true).
  • gotEventTime(d) - Test if a user event 'evX' is received and return the receive time if found. if not found, then 0 (false) is returned. event is removed after the call (if event 'evX' is received).
  • eventFlush() Flush all received 'evX' type events.
  • putEvent(d) Add a 'evX' type events on the MRC command queue, where X is a positive integer ID number. Returns ID if queued and 0 (false) if not.
  • savemrclog() - Tell the MRC to save the log with a timestamp - as mrc_yyyymmdd_hhmmss.ccc.logg. Restarts logging after save.



SMRCTL resource

Configuration variables SMRCTL

  • manRenewDriveDist=1.2 (rw) Max distance to travel using the same old manoeuver plan, when the new plan looks the same.
  • renewDestDist=0.3 (rw) Max destination distance change (m) before command is renewed.
  • renewDestHeading=0.1 (rw) Max destination heading change (radians) before command is renewed.
  • renewDestVel=0.1 (rw) Max destination velocity change (m/s) before command is renewed.
  • manPlanDist=2.2 (rw) Max distance to use of a plan shut-down is implemented.
  • useDriveonHeading=3 (rw) Max heading deviation relative to end pose for using direct drive (rather than arc-line-arc).
  • useDriveonDist=0.8 (rw) Max distance from end pose line where a driveon command should be used (rather than arc-line-arc).
  • useDriveonIfDirect=0.2 (r/w) Use a driveon command, if the manIsDirect flag is true
  • directOrWait=0 (rw) Are we keeping a path with no space for avoidance manoeuvres, then set this flag to true.
  • directWait=0 (r) Are we waiting for a direct manoeuvre (and discarded last manoeuvre).

Result/status variables SMRCTL

  • running=1 (r) Is control loop (thread) running
  • manEndID=-1 (r) Event ID posted to mark end of current manoeuvre (see smr.idUserEvent)
  • manEndTime=0 (r) Event ID posted at this time
  • manQueueingTime=0.5 (r) Time to queue last manouvre
  • manIsDirect=-1 (r) Is the received plan direct - i.e. one turn-drive-turn set only (-1 os no plan)

Functions calls SMRCTL

  • setPlan(sc) Set the path plan to be implemented. the first string parameter is a pointer to a driver name, the second parameter is a structure 'UManSeq' holding the lines and arcs to follow

driver() Get current driver name as the first returned structure.

  • finished() Checks the ID that is finished from the smr with the last of the main commands posted to the smr. If this is finished, then the returned value is true (1) else false (0).


Functions commands (for both SMR and SMRCTL resource)

  • connect[=host:port] Connect to MRC (connected=false)
  • host='host' Set host name (is '127.0.0.1')
  • port='P' Set connection port number (is '31001')
  • cmd='cmd' Send this command to MRC
  • do='cmd' Send this command to MRC
  • hup Stop and hang up connection to MRC
  • stop Stop the robot now (keeps connection open)
  • eval='variable' Get value of variable in MRC
  • getevent Empty the getevent buffer from MRC
  • log=false start or stop smrcl.log (open=true)
  • logMode=0..3 0=just errors, 1=+send, 2=+rec, 3+mgmt (is=2)
  • saveMrcLog Tell MRC to save log (mrc_yyyymmdd.hhmmss.ccc.logg)
  • logCtl[=false] drive control log 'mrcctl.log' (open=true)
  • logPrim[=false] drive control lines and arcs 'mrcprim.log' (open=true)
  • stream=n Start streaming at this interval - (odo and gps) (started=false)
  • streamShowOdo=N Show odo every N update on console (N is 0 - now 0 received)
  • streamShowGps=N Show gps every N update on console (N is 0 - now 0 received)
  • streamShowIns=N Show INS every N update on console (N is 0 - now 0 received)
  • help This message
  • See also smrConnect (on connect actions)


Configuration example

configuration example in aunav.ini

module load="./ausmr.so.0" smrConnect cmd="smr cmd='log "$time" "$odox" "$odoy" "$odoth"

  1. smrConnect cmd="smr stream=1"

smr log smr logmode=2 smr logctl smr logprim smr connect=localhost:31001

var smrctl.useDriveonDist=0.8 var smrctl.useDriveonHeading=0.2 var smrctl.useDriveonIfDirect=3.142 var smrctl.renewDestDist=0.30 var smrctl.renewDestHeading=0.1

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox