Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SensorInfo.cc

Go to the documentation of this file.
00001 #include <cmath>
00002 
00003 #include "SensorInfo.h" 
00004 #include "Shared/FamilyFactory.h"
00005 
00006 using namespace std; 
00007 
00008 PLIST_CLONE_IMP(SensorRangeFinder,new SensorRangeFinder(*this));
00009 PLIST_CLONE_IMP(SensorContact,new SensorContact(*this));
00010 PLIST_CLONE_IMP(SensorFeedback,new SensorFeedback(*this));
00011 PLIST_CLONE_IMP(GPSSensor,new GPSSensor(*this));
00012 PLIST_CLONE_IMP(OdometrySensor,new OdometrySensor(*this));
00013 
00014 
00015 
00016 const std::string SensorRangeFinder::autoRegister = FamilyFactory<SensorInfo>::getRegistry().registerType<SensorRangeFinder>("RangeFinder");
00017 const std::string SensorContact::autoRegister = FamilyFactory<SensorInfo>::getRegistry().registerType<SensorContact>("Contact");
00018 const std::string SensorFeedback::autoRegister = FamilyFactory<SensorInfo>::getRegistry().registerType<SensorFeedback>("Feedback");
00019 const std::string GPSSensor::autoRegister = FamilyFactory<SensorInfo>::getRegistry().registerType<GPSSensor>("GPS");
00020 const std::string OdometrySensor::autoRegister = FamilyFactory<SensorInfo>::getRegistry().registerType<OdometrySensor>("Odometry");
00021 
00022 
00023 
00024 bool SensorContact::testPoint(float x, float y, float z) {
00025   if(lx[0]!=lx[1]) {
00026     if(x<lx[0] || lx[1]<x)
00027       return false;
00028   }
00029   if(ly[0]!=ly[1]) {
00030     if(y<ly[0] || ly[1]<y)
00031       return false;
00032   }
00033   if(lz[0]!=lz[1]) {
00034     if(z<lz[0] || lz[1]<z)
00035       return false;
00036   }
00037   if(ax[0]!=ax[1]) {
00038     float a = std::atan2(z, y);
00039     if(a<ax[0] || ax[1]<a)
00040       return false;
00041   }
00042   if(ay[0]!=ay[1]) {
00043     float a = std::atan2(x, z);
00044     if(a<ay[0] || ay[1]<a)
00045       return false;
00046   }
00047   if(az[0]!=az[1]) {
00048     float a = std::atan2(y, x);
00049     if(a<az[0] || az[1]<a)
00050       return false;
00051   }
00052   return true;
00053 }
00054 
00055 namespace plist {
00056   template<> SensorInfo* loadXML(xmlNode* node) {
00057     plist::Dictionary d;
00058     plist::Primitive<std::string> t;
00059     d.addEntry("SensorType",t);
00060     d.setUnusedWarning(false);
00061     d.setLoadPolicy(plist::Collection::FIXED);
00062     d.loadXML(node);
00063     if(t.size()==0)
00064       throw XMLLoadSave::bad_format(node,"KinematicJoint::SensorInfo entry missing SensorType, cannot instantiate");
00065     SensorInfo* si = FamilyFactory<SensorInfo>::getRegistry().create(t);
00066     if(si==NULL)
00067       throw XMLLoadSave::bad_format(node,"KinematicJoint::SensorInfo unknown SensorType '"+t+"', cannot instantiate");
00068     si->loadXML(node);
00069     return si;
00070   }
00071 }
00072 
00073 /*! @file
00074  * @brief 
00075  * @author Ethan Tira-Thompson (ejt) (Creator)
00076  */

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