Libbarrett  1.2.4
include/barrett/products/low_level_wam.h
00001 
00025 /*
00026  * @file low_level_wam.h
00027  * @date 10/13/2010
00028  * @author Chris Dellin
00029  * @author Dan Cody
00030  *
00031  */
00032 
00033 #ifndef BARRETT_PRODUCTS_LOW_LEVEL_WAM_H_
00034 #define BARRETT_PRODUCTS_LOW_LEVEL_WAM_H_
00035 
00036 
00037 #include <vector>
00038 
00039 #include <boost/array.hpp>
00040 #include <Eigen/Core>
00041 #include <libconfig.h++>
00042 
00043 #include <barrett/units.h>
00044 #include <barrett/products/puck.h>
00045 #include <barrett/products/motor_puck.h>
00046 #include <barrett/products/safety_module.h>
00047 #include <barrett/products/puck_group.h>
00048 #include <barrett/products/abstract/multi_puck_product.h>
00049 
00050 
00051 namespace barrett {
00052 
00053 
00054 template<size_t DOF>
00055 class LowLevelWam : public MultiPuckProduct {
00056         BARRETT_UNITS_TEMPLATE_TYPEDEFS(DOF);
00057 
00058 public:
00059         // pucks must be ordered by joint and must break into torque groups as arranged
00060         LowLevelWam(const std::vector<Puck*>& pucks, SafetyModule* safetyModule,
00061                         const libconfig::Setting& setting,
00062                         std::vector<int> torqueGroupIds = std::vector<int>());
00063         ~LowLevelWam();
00064 
00065 
00066         enum PositionSensor { PS_BEST, PS_MOTOR_ENCODER, PS_JOINT_ENCODER };
00067         const jp_type& getJointPositions(enum PositionSensor sensor = PS_BEST) const;
00068         const jv_type& getJointVelocities() const { return jv_best; }
00069 
00070 
00071         bool hasJointEncoders() const { return !noJointEncoders; }
00072         void setPositionSensor(enum PositionSensor sensor);
00073         enum PositionSensor getPositionSensor() const { return positionSensor; }
00074         bool usingJointEncoder(size_t jointIndex) const { return useJointEncoder[jointIndex]; }
00075 
00076 
00077         const jp_type& getHomePosition() const { return home; }
00078 
00079         const sqm_type& getJointToMotorPositionTransform() const { return j2mp; }
00080         const sqm_type& getMotorToJointPositionTransform() const { return m2jp; }
00081         const sqm_type& getJointToMotorTorqueTransform() const { return j2mt; }
00082 
00083         const sqm_type& getJointToPuckPositionTransform() const { return j2pp; }
00084         const sqm_type& getPuckToJointPositionTransform() const { return p2jp; }
00085         const sqm_type& getJointToPuckTorqueTransform() const { return j2pt; }
00086         const v_type& getJointEncoderToJointPositionTransform() const { return jointEncoder2jp; }
00087 
00088 
00089         void update();
00090         void setTorques(const jt_type& jt);
00091         void definePosition(const jp_type& jp);
00092 
00093 
00094         SafetyModule* getSafetyModule() const { return safetyModule; }
00095 
00096 protected:
00097         SafetyModule* safetyModule;
00098         std::vector<PuckGroup*> torqueGroups;
00099 
00100         jp_type home;
00101         sqm_type j2mp, m2jp, j2mt;
00102         sqm_type j2pp, p2jp, j2pt;
00103         v_type jointEncoder2jp;
00104 
00105         bool noJointEncoders;
00106         boost::array<bool, DOF> useJointEncoder;
00107         enum PositionSensor positionSensor;
00108 
00109         double lastUpdate;
00110         v_type pp;
00111         math::Matrix<DOF,2> pp_jep;
00112         jp_type jp_motorEncoder, jp_jointEncoder;
00113         jp_type jp_best, jp_best_1;
00114         jv_type jv_best;
00115 
00116         v_type pt;
00117         int torquePropId;
00118 
00119 private:
00120         static const enum Puck::Property props[];
00121 
00122         DISALLOW_COPY_AND_ASSIGN(LowLevelWam);
00123 
00124 public:
00125         EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00126 };
00127 
00128 
00129 }
00130 
00131 
00132 // include template definitions
00133 #include <barrett/products/detail/low_level_wam-inl.h>
00134 
00135 
00136 #endif /* BARRETT_PRODUCTS_LOW_LEVEL_WAM_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Defines