Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

MoCapEvent.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_MoCapEvent_h_
00003 #define INCLUDED_MoCapEvent_h_
00004 
00005 #include "EventBase.h"
00006 #include "Shared/fmat.h"
00007 #include <map>
00008 
00009 //! Provides notification of new external localization data
00010 /*! Could be feedback from simulation, GPS, or a full motion-capture system.
00011  *  May not include data for all reference frames, or may only provide one of position or orientation...
00012  *  You can probably assume at least BaseFrame will be included e.g. getPosition(BaseFrame)/getOrientation(BaseFrame),
00013  *  otherwise you can also access #positions or #orientations directly for lookup/iteration.
00014  *
00015  *  Mirage allows some control over what frames are reported, see MoCapPos and MoCapOri
00016  *  in EnvConfig.h (assigned via command line or a .mirage world configuration file).
00017  *  By default only the base frame is reported for both position and orientation. */
00018 class MoCapEvent : public EventBase {
00019 public:
00020   typedef std::map<unsigned int, fmat::Column<3> >::const_iterator position_iterator;
00021   typedef std::map<unsigned int, fmat::Quaternion >::const_iterator orientation_iterator;
00022   
00023   //! Constructor
00024   explicit MoCapEvent(const std::string& srcName, size_t sid=0) : EventBase(mocapEGID,sid,statusETID,0,srcName), positions(), orientations() {}
00025   
00026   //! Clone implementation
00027   virtual EventBase* clone() const { return new MoCapEvent(*this); }
00028   
00029   //! Attempts to look up a position reading for the specified reference frame, throws std::out_of_range if not found
00030   const fmat::Column<3>& getPosition(unsigned int frameIdx) const;
00031   
00032   //! Attempts to look up an orientation reading for the specified reference frame, throws std::out_of_range if not found
00033   const fmat::Quaternion& getOrientation(unsigned int frameIdx) const;
00034   
00035   //! Constructs a transformation matrix for the specified reference frame, throws std::out_of_range if not found for either position or orientation
00036   /*! The transformation matrix can be right-multiplied by a point relative to the frame
00037    *  to obtain the corresponding world-frame position.  In a perfect simulation, this
00038    *  transform should be equivalent to <tt>getPose(BaseFrameOffset) * kine->getT(frameIdx)</tt>
00039    *  but in both simulation and the real world, gravity and obstacles may pull
00040    *  a joint away from its ideal target pose. */
00041   const fmat::Transform getPose(unsigned int frameIdx) const {
00042     return fmat::Transform(getOrientation(frameIdx),getPosition(frameIdx));
00043   }
00044   
00045   std::map<unsigned int, fmat::Column<3> > positions; //!< position data (may not cover all reference frames!)
00046   std::map<unsigned int, fmat::Quaternion > orientations; //!< orientation data (may not cover all reference frames!)
00047 };
00048 
00049 /*! @file
00050  * @brief Describes MoCapEvent, an event for communicating localization information
00051  * @author ejt (Creator)
00052  */
00053 
00054 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:45 2016 by Doxygen 1.6.3