Libbarrett  1.2.4
include/barrett/products/tactile_puck.h
Go to the documentation of this file.
00001 
00032 #ifndef BARRETT_PRODUCTS_TACTILE_PUCK_H_
00033 #define BARRETT_PRODUCTS_TACTILE_PUCK_H_
00034 
00035 
00036 #include <barrett/math/matrix.h>
00037 #include <barrett/bus/abstract/communications_bus.h>
00038 #include <barrett/products/puck.h>
00039 #include <barrett/products/abstract/special_puck.h>
00040 
00041 
00042 namespace barrett {
00043 
00044 
00045 class TactilePuck : public SpecialPuck {
00046 public:
00047         static const size_t NUM_SENSORS = 24;
00048         typedef math::Vector<NUM_SENSORS>::type v_type;
00049 
00050 protected:
00051         enum TactState { NONE, TOP10_FORMAT, FULL_FORMAT, TARE };
00052 
00053 public:
00057         TactilePuck(Puck* puck = NULL) : SpecialPuck() { setPuck(puck); }
00058         ~TactilePuck() {}
00062         void setPuck(Puck* puck);
00066         void tare() { p->setProperty(Puck::TACT, TARE); }
00070         void updateFull(bool realtime = false) {
00071                 requestFull();
00072                 receiveFull(realtime);
00073         }
00074 //      void updateTop10(bool realtime = false);
00078         const v_type& getFullData() const { return full; }
00079 
00083         void requestFull();
00087         void receiveFull(bool realtime = false);
00088 
00092         struct FullTactParser {
00093                 static int busId(int id, int propId) {
00094                         return Puck::encodeBusId(id, PuckGroup::FGRP_TACT_FULL);
00095                 }
00096 
00097                 typedef v_type result_type;
00098                 static int parse(int id, int propId, result_type* result, const unsigned char* data, size_t len);
00099         };
00100         // TODO(dc): Implement Top10TactParser
00101 //      struct Top10TactParser {
00102 //              static int busId(int id, int propId) {
00103 //                      return Puck::encodeBusId(id, PuckGroup::FGRP_TACT_TOP10);
00104 //              }
00105 //
00106 //              typedef int result_type;
00107 //              static int parse(int id, int propId, result_type* result, const unsigned char* data, size_t len) { return 0; }
00108 //      };
00109 
00110 protected:
00111         const bus::CommunicationsBus* bus;
00112         int id;
00113         int propId;
00114 
00115         enum TactState tact;
00116         v_type full;
00117 //      int top10;
00118 
00119 
00120         static const size_t NUM_FULL_MESSAGES = 5;
00121         static const size_t NUM_SENSORS_PER_FULL_MESSAGE = 5;
00122         static const double FULL_SCALE_FACTOR = 256.0;
00123 
00124 
00125         friend class Hand;
00126 };
00127 
00128 
00129 }
00130 
00131 
00132 #endif /* BARRETT_PRODUCTS_TACTILE_PUCK_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Defines