Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

MotionHook Class Reference

#include <MotionHook.h>

Inheritance diagram for MotionHook:

List of all members.


Detailed Description

Interface for connections to remote hosts and hardware devices which should be polled with output values.

  • Override motionCheck() if your hardware needs to have a value specified for every output on every update, regardless of whether it changes.
    • Override motionUpdated() if you only need to process the outputs which have changed.

You can expect to be called every FrameTime*NumFrame milliseconds in terms of simulator time. However, keep in mind this is relative to SharedGlobals::timeScale (Config.Speed) in terms of wall-clock time, and is also subject to the simulator being paused, set to full-speed mode, or hitting a breakpoint in the debugger. See enteringRealtime() and leavingRealtime() if you want updates when the user switches simulation modes, although there's still no way to get notification if a debugger breakpoint is hit

Definition at line 19 of file MotionHook.h.


Public Member Functions

 MotionHook ()
 constructor
virtual ~MotionHook ()
 no-op destructor
virtual void motionStarting ()
 Called when motion process is starting.
virtual void motionCheck (const float outputs[][NumOutputs])
 Called each time the motion process has polled active motion commands.
virtual void motionUpdated (const std::vector< size_t > &, const float[][NumOutputs])
 Called by motionCheck(), after comparing the new output values to lastOutputs, and before lastOutputs is updated.
virtual void motionStopping ()
 Called when motion process is stopping.
virtual void enteringRealtime ()
 Called when the controller is going to be running in realtime mode, which is probably the normal mode you'd expect.
virtual void leavingRealtime (bool)
 Called when leaving realtime mode, which means you have no idea when motionCheck is going to be called in terms of wall-clock time.
virtual void setMotionHookVerbose (int v)
 Called by simulator thread to indicate level of verbosity for diagnostics and reporting errors.

Protected Attributes

int verbose
 stores current verbosity
bool isFirstCheck
 set to false following the first motionCheck, reset to true by motionStopping
float lastOutputs [NumOutputs]
 stores the last frame of the outputs, updated by motionCheck()

Constructor & Destructor Documentation

MotionHook (  )  [inline]

constructor

Definition at line 22 of file MotionHook.h.

virtual ~MotionHook (  )  [inline, virtual]

no-op destructor

Definition at line 25 of file MotionHook.h.


Member Function Documentation

virtual void motionStarting (  )  [inline, virtual]

Called when motion process is starting.

Reimplemented in CreateDriver, DynamixelDriver, SSC32Driver, and TeRKDriver.

Definition at line 28 of file MotionHook.h.

Referenced by SSC32Driver::motionStarting(), DynamixelDriver::motionStarting(), and CreateDriver::motionStarting().

virtual void motionCheck ( const float  outputs[][NumOutputs]  )  [inline, virtual]

Called each time the motion process has polled active motion commands.

When in realtime mode, this should be called every FrameTime*NumFrames (defined in the RobotInfo) milliseconds if running at full speed. See enteringRealtime() and leavingRealtime().

This default implementation checks to see which outputs have changed value since the last call and passes the summary on to motionUpdated(). lastOutputs will be updated with the new values after the call to motionUpdated().

If you need to process all the outputs on every frame, you only need to override this function. Your subclass doesn't need to call the MotionHook implementation unless you want to have lastOutputs updated for you.

If you only need to process the changed outputs for each frame, override motionUpdated() instead. motionUpdated() is always called for each update, even if there aren't any changes, so you can still use that if there are some outputs which need to be updated every cycle.

Reimplemented in CreateDriver, DynamixelDriver, SSC32Driver, and IPCMotionHook.

Definition at line 45 of file MotionHook.h.

Referenced by SSC32Driver::motionCheck(), DynamixelDriver::motionCheck(), and CreateDriver::motionCheck().

virtual void motionUpdated ( const std::vector< size_t > &  ,
const   float[][NumOutputs] 
) [inline, virtual]

Called by motionCheck(), after comparing the new output values to lastOutputs, and before lastOutputs is updated.

Override this if you only need to send commands to the hardware for values that have changed. This function is always called for each update, even though changedIndices might be empty.

Reimplemented in TeRKDriver.

Definition at line 69 of file MotionHook.h.

Referenced by motionCheck().

virtual void motionStopping (  )  [inline, virtual]

Called when motion process is stopping.

Reimplemented in CreateDriver, DynamixelDriver, SSC32Driver, and TeRKDriver.

Definition at line 72 of file MotionHook.h.

Referenced by SSC32Driver::motionStopping(), DynamixelDriver::motionStopping(), and CreateDriver::motionStopping().

virtual void enteringRealtime (  )  [inline, virtual]

Called when the controller is going to be running in realtime mode, which is probably the normal mode you'd expect.

No guarantees though! You might be in realtime mode, but a debugger breakpoint will still pause things.

Definition at line 76 of file MotionHook.h.

virtual void leavingRealtime ( bool   )  [inline, virtual]

Called when leaving realtime mode, which means you have no idea when motionCheck is going to be called in terms of wall-clock time.

Argument set to true if entering full speed mode, which may mean motionCheck will be called at a high(er) frequency, or slower the computation is overwhelming the host hardware. However, if false, almost certainly indicates updates will be sparse.

A non-realtime mode might be triggered if the user wants to pause the simulator/controller to debug something... No guarantees though! The debugger might catch a breakpoint and stop things, and this won't be called!

Definition at line 85 of file MotionHook.h.

virtual void setMotionHookVerbose ( int  v  )  [inline, virtual]

Called by simulator thread to indicate level of verbosity for diagnostics and reporting errors.

Definition at line 88 of file MotionHook.h.


Member Data Documentation

int verbose [protected]

stores current verbosity

Definition at line 92 of file MotionHook.h.

Referenced by CreateDriver::connect(), SSC32Driver::motionCheck(), DynamixelDriver::motionCheck(), and setMotionHookVerbose().

bool isFirstCheck [protected]

set to false following the first motionCheck, reset to true by motionStopping

Definition at line 94 of file MotionHook.h.

Referenced by SSC32Driver::getData(), SSC32Driver::motionCheck(), motionCheck(), DynamixelDriver::motionCheck(), and motionStopping().

float lastOutputs[NumOutputs] [protected]

stores the last frame of the outputs, updated by motionCheck()

Definition at line 96 of file MotionHook.h.

Referenced by SSC32Driver::motionCheck(), motionCheck(), and DynamixelDriver::motionCheck().


The documentation for this class was generated from the following file:

Tekkotsu Hardware Abstraction Layer 4.0
Generated Thu Nov 22 01:01:22 2007 by Doxygen 1.5.4