Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00038
00039 #ifndef DRIVER_SVH_SVH_CONTROLLER_H_INCLUDED
00040 #define DRIVER_SVH_SVH_CONTROLLER_H_INCLUDED
00041
00042 #include <driver_svh/ImportExport.h>
00043 #include <driver_svh/SVHSerialInterface.h>
00044 #include <driver_svh/SVHReceiveThread.h>
00045 #include <driver_svh/SVHControlCommand.h>
00046 #include <driver_svh/SVHControllerFeedback.h>
00047 #include <driver_svh/SVHCurrentSettings.h>
00048 #include <driver_svh/SVHFirmwareInfo.h>
00049 #include <driver_svh/SVHPositionSettings.h>
00050 #include <driver_svh/SVHControllerState.h>
00051 #include <driver_svh/SVHEncoderSettings.h>
00052
00053 namespace driver_svh {
00054
00056 enum{
00057 eSVH_ALL = -1,
00058 eSVH_THUMB_FLEXION = 0,
00059 eSVH_THUMB_OPPOSITION,
00060 eSVH_INDEX_FINGER_DISTAL,
00061 eSVH_INDEX_FINGER_PROXIMAL,
00062 eSVH_MIDDLE_FINGER_DISTAL,
00063 eSVH_MIDDLE_FINGER_PROXIMAL,
00064 eSVH_RING_FINGER,
00065 eSVH_PINKY,
00066 eSVH_FINGER_SPREAD,
00067 eSVH_DIMENSION
00068 } typedef SVHChannel;
00069
00077 class DRIVER_SVH_IMPORT_EXPORT SVHController
00078 {
00079 public:
00081 SVHController();
00082
00086 ~SVHController();
00087
00093 bool connect(const std::string &dev_name);
00094
00096 void disconnect();
00097
00103 void setControllerTarget(const SVHChannel& channel, const int32_t &position);
00104
00109 void setControllerTargetAllChannels(const std::vector<int32_t>& positions);
00110
00111
00112
00117 void enableChannel(const SVHChannel& channel);
00118
00123 void disableChannel(const SVHChannel& channel);
00124
00126 void requestControllerState();
00127
00132 void requestControllerFeedback(const SVHChannel& channel);
00133
00138 void requestPositionSettings(const SVHChannel& channel);
00139
00145 void setPositionSettings(const SVHChannel& channel,const SVHPositionSettings& position_settings);
00146
00151 void requestCurrentSettings(const SVHChannel& channel);
00152
00158 void setCurrentSettings(const SVHChannel& channel,const SVHCurrentSettings& current_settings);
00159
00163 void requestEncoderValues();
00164
00169 void setEncoderValues(const SVHEncoderSettings& encoder_settings);
00170
00171
00175 void requestFirmwareInfo();
00176
00182 void receivedPacketCallback(const SVHSerialPacket& packet, unsigned int packet_count);
00183
00195 bool getControllerFeedback(const SVHChannel &channel,SVHControllerFeedback& controller_feedback);
00196
00203 bool getPositionSettings(const SVHChannel &channel,SVHPositionSettings& position_settings);
00204
00211 bool getCurrentSettings(const SVHChannel &channel,SVHCurrentSettings& current_settings);
00212
00217 SVHFirmwareInfo getFirmwareInfo();
00218
00223 unsigned int getSentPackageCount();
00224
00229 unsigned int getReceivedPackageCount();
00230
00234 void resetPackageCounts();
00235
00241 bool isEnabled(const SVHChannel &channel);
00242
00244 static const char * m_channel_description[];
00245
00247 static const float channel_effort_constants[9];
00248
00250 void getControllerFeedbackAllChannels(SVHControllerFeedbackAllChannels &controller_feedback);
00251 private:
00252
00253
00254
00256 std::vector<SVHCurrentSettings> m_current_settings;
00257
00259 std::vector<SVHPositionSettings> m_position_settings;
00260
00262 std::vector<SVHControllerFeedback> m_controller_feedback;
00263
00265 SVHControllerState m_controller_state;
00266
00268 SVHEncoderSettings m_encoder_settings;
00269
00271 SVHFirmwareInfo m_firmware_info;
00272
00273
00274
00276 SVHSerialInterface * m_serial_interface;
00277
00279 uint16_t m_enable_mask;
00280
00282 unsigned int m_received_package_count;
00283
00284
00285
00286
00287 };
00288
00289 }
00290
00291 #endif