qbsofthand_research_api.h
Go to the documentation of this file.
1 /***
2  * Software License Agreement: BSD 3-Clause License
3  *
4  * Copyright (c) 2015-2021, qbrobotics®
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
8  * following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
11  * following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
14  * following disclaimer in the documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
17  * products derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef QBROBOTICS_DRIVER_QBSOFTHAND_RESEARCH_API_H
29 #define QBROBOTICS_DRIVER_QBSOFTHAND_RESEARCH_API_H
30 
32 
33 namespace qbrobotics_research_api {
34 
35 class qbSoftHandResearch : public Device {
36  public:
37  class Params : public Device::Params {
38  public:
39  Params() = default;
40  ~Params() override = default;
41 
42  void initParams(const std::vector<int8_t> &param_buffer) override;
43 
44  uint8_t use_emg_calibration {false};
45  std::vector<uint16_t> emg_thresholds;
46  std::vector<uint32_t> emg_max_value;
47  uint8_t emg_speed {0};
48  uint8_t use_double_encoder {false};
49  int8_t handle_ratio {0};
50  uint8_t use_pwm_rescaling {false};
51  std::vector<float> current_lookup_table;
52  };
53 
54  explicit qbSoftHandResearch(std::shared_ptr<Communication> communication, std::string name, std::string serial_port, uint8_t id);
55  explicit qbSoftHandResearch(std::shared_ptr<Communication> communication, std::string name, std::string serial_port, uint8_t id, bool init_params);
56  explicit qbSoftHandResearch(std::shared_ptr<Communication> communication, std::string name, std::string serial_port, uint8_t id, bool init_params, std::unique_ptr<Device::Params> params);
57  ~qbSoftHandResearch() override = default;
58 
59  int openCloseCycles(uint16_t speed, uint16_t cycles);
60  int getEMGs(std::vector<int16_t> &emg_values);
61  int getJoystick(std::vector<int16_t> &joystick_values);
62 
64  int getParamUseEMGCalibration(uint8_t &use_emg_calibration);
66  int getParamEMGThresholds(std::vector<uint16_t> &emg_thresholds);
68  int getParamEMGMaxValues(std::vector<uint32_t> &emg_max_value);
69  int getParamEMGSpeed();
70  int getParamEMGSpeed(uint8_t &emg_speed);
72  int getParamUseDoubleEncoder(uint8_t &use_double_encoder);
73  int getParamHandleRatio();
74  int getParamHandleRatio(int8_t &handle_ratio);
76  int getParamUsePWMRescaling(uint8_t &use_pwm_rescaling);
78  int getParamCurrentLookupTable(std::vector<float> &current_lookup_table);
79  int getParamRateLimiter();
80  int getParamRateLimiter(uint8_t &rate_limiter);
81 
82  int setParamUseEMGCalibration(uint8_t use_emg_calibration);
83  int setParamEMGThresholds(const std::vector<uint16_t> &emg_thresholds);
84  int setParamEMGMaxValues(const std::vector<uint32_t> &emg_max_value);
85  int setParamEMGSpeed(uint8_t emg_speed);
86  int setParamUseDoubleEncoder(uint8_t use_double_encoder);
87  int setParamHandleRatio(int8_t handle_ratio);
88  int setParamUsePWMRescaling(uint8_t use_pwm_rescaling);
89  int setParamCurrentLookupTable(const std::vector<float> &current_lookup_table);
90  int setParamRateLimiter(uint8_t rate_limiter);
91 };
92 
94  public:
95  class Params : public qbSoftHandResearch::Params {
96  public:
97  Params() = default;
98  ~Params() override = default;
99 
100 // void initParams(const std::vector<int8_t> &param_buffer) override; // not necessary at the moment
101  };
102 
103  explicit qbSoftHandLegacyResearch(std::shared_ptr<Communication> communication, std::string name, std::string serial_port, uint8_t id);
104  explicit qbSoftHandLegacyResearch(std::shared_ptr<Communication> communication, std::string name, std::string serial_port, uint8_t id, bool init_params);
105  explicit qbSoftHandLegacyResearch(std::shared_ptr<Communication> communication, std::string name, std::string serial_port, uint8_t id, bool init_params, std::unique_ptr<Device::Params> params);
106  ~qbSoftHandLegacyResearch() override = default;
107 
108  // same as qbmoveOldResearch
109  int setMotorStates(bool motor_state) override;
110 
111  int setParameter(uint16_t param_type, const std::vector<int8_t> &param_data) override;
112  int setParamId(uint8_t id) override;
113  int setParamZeros() override;
114 };
115 
116 } // namespace qbrobotics_research_api
117 
118 #endif // QBROBOTICS_DRIVER_QBSOFTHAND_RESEARCH_API_H
qbrobotics_research_api::qbSoftHandResearch::getParamRateLimiter
int getParamRateLimiter()
Definition: qbsofthand_research_api.cpp:185
qbrobotics_research_api::qbSoftHandResearch::Params::~Params
~Params() override=default
qbrobotics_research_api::qbSoftHandLegacyResearch::Params::Params
Params()=default
qbrobotics_research_api::qbSoftHandResearch::Params::use_pwm_rescaling
uint8_t use_pwm_rescaling
Definition: qbsofthand_research_api.h:125
qbrobotics_research_api::qbSoftHandResearch::Params::current_lookup_table
std::vector< float > current_lookup_table
Definition: qbsofthand_research_api.h:126
qbrobotics_research_api::qbSoftHandResearch::~qbSoftHandResearch
~qbSoftHandResearch() override=default
qbrobotics_research_api::qbSoftHandResearch::getParamCurrentLookupTable
int getParamCurrentLookupTable()
Definition: qbsofthand_research_api.cpp:172
qbrobotics_research_api::qbSoftHandResearch::getJoystick
int getJoystick(std::vector< int16_t > &joystick_values)
Definition: qbsofthand_research_api.cpp:72
qbrobotics_research_api::qbSoftHandResearch::Params::emg_max_value
std::vector< uint32_t > emg_max_value
Definition: qbsofthand_research_api.h:121
qbrobotics_research_api::qbSoftHandLegacyResearch::Params::~Params
~Params() override=default
qbrobotics_research_api::qbSoftHandResearch::Params::handle_ratio
int8_t handle_ratio
Definition: qbsofthand_research_api.h:124
qbrobotics_research_api::qbSoftHandLegacyResearch::setParameter
int setParameter(uint16_t param_type, const std::vector< int8_t > &param_data) override
Set the Parameter specified by param_type with the values stored in param_data.
Definition: qbsofthand_research_api.cpp:289
qbrobotics_research_api::qbSoftHandResearch::Params
Definition: qbsofthand_research_api.h:87
qbrobotics_research_api::qbSoftHandResearch
Definition: qbsofthand_research_api.h:60
qbrobotics_research_api::qbSoftHandResearch::setParamUseDoubleEncoder
int setParamUseDoubleEncoder(uint8_t use_double_encoder)
Definition: qbsofthand_research_api.cpp:230
qbrobotics_research_api
Definition: qbmove_research_api.h:33
qbrobotics_research_api::qbSoftHandLegacyResearch::~qbSoftHandLegacyResearch
~qbSoftHandLegacyResearch() override=default
qbrobotics_research_api::qbSoftHandLegacyResearch::setParamZeros
int setParamZeros() override
Set motor(s) zero(s) to actual encoder reading.
Definition: qbsofthand_research_api.cpp:308
qbrobotics_research_api::qbSoftHandResearch::setParamEMGThresholds
int setParamEMGThresholds(const std::vector< uint16_t > &emg_thresholds)
Definition: qbsofthand_research_api.cpp:206
qbrobotics_research_api::qbSoftHandResearch::getParamUsePWMRescaling
int getParamUsePWMRescaling()
Definition: qbsofthand_research_api.cpp:159
qbrobotics_research_api::qbSoftHandResearch::setParamEMGMaxValues
int setParamEMGMaxValues(const std::vector< uint32_t > &emg_max_value)
Definition: qbsofthand_research_api.cpp:214
qbrobotics_research_api::qbSoftHandResearch::getEMGs
int getEMGs(std::vector< int16_t > &emg_values)
Definition: qbsofthand_research_api.cpp:63
qbrobotics_research_api.h
qbrobotics_research_api::qbSoftHandResearch::getParamEMGThresholds
int getParamEMGThresholds()
Definition: qbsofthand_research_api.cpp:94
qbrobotics_research_api::qbSoftHandResearch::Params::emg_speed
uint8_t emg_speed
Definition: qbsofthand_research_api.h:122
qbrobotics_research_api::qbSoftHandResearch::getParamEMGMaxValues
int getParamEMGMaxValues()
Definition: qbsofthand_research_api.cpp:107
qbrobotics_research_api::qbSoftHandResearch::getParamUseDoubleEncoder
int getParamUseDoubleEncoder()
Definition: qbsofthand_research_api.cpp:133
qbrobotics_research_api::qbSoftHandResearch::getParamHandleRatio
int getParamHandleRatio()
Definition: qbsofthand_research_api.cpp:146
qbrobotics_research_api::qbSoftHandResearch::Params::use_emg_calibration
uint8_t use_emg_calibration
Definition: qbsofthand_research_api.h:119
qbrobotics_research_api::qbSoftHandResearch::Params::emg_thresholds
std::vector< uint16_t > emg_thresholds
Definition: qbsofthand_research_api.h:120
qbrobotics_research_api::qbSoftHandResearch::setParamUsePWMRescaling
int setParamUsePWMRescaling(uint8_t use_pwm_rescaling)
Definition: qbsofthand_research_api.cpp:246
qbrobotics_research_api::qbSoftHandResearch::getParamEMGSpeed
int getParamEMGSpeed()
Definition: qbsofthand_research_api.cpp:120
qbrobotics_research_api::qbSoftHandResearch::qbSoftHandResearch
qbSoftHandResearch(std::shared_ptr< Communication > communication, std::string name, std::string serial_port, uint8_t id)
Definition: qbsofthand_research_api.cpp:45
qbrobotics_research_api::qbSoftHandResearch::setParamCurrentLookupTable
int setParamCurrentLookupTable(const std::vector< float > &current_lookup_table)
Definition: qbsofthand_research_api.cpp:254
qbrobotics_research_api::qbSoftHandResearch::setParamRateLimiter
int setParamRateLimiter(uint8_t rate_limiter)
Definition: qbsofthand_research_api.cpp:262
qbrobotics_research_api::qbSoftHandResearch::Params::use_double_encoder
uint8_t use_double_encoder
Definition: qbsofthand_research_api.h:123
qbrobotics_research_api::qbSoftHandLegacyResearch::setMotorStates
int setMotorStates(bool motor_state) override
Activate or deactivate the motor(s)
Definition: qbsofthand_research_api.cpp:283
qbrobotics_research_api::qbSoftHandResearch::setParamHandleRatio
int setParamHandleRatio(int8_t handle_ratio)
Definition: qbsofthand_research_api.cpp:238
qbrobotics_research_api::qbSoftHandResearch::Params::Params
Params()=default
qbrobotics_research_api::qbSoftHandResearch::getParamUseEMGCalibration
int getParamUseEMGCalibration()
Definition: qbsofthand_research_api.cpp:81
qbrobotics_research_api::qbSoftHandResearch::openCloseCycles
int openCloseCycles(uint16_t speed, uint16_t cycles)
Definition: qbsofthand_research_api.cpp:54
qbrobotics_research_api::qbSoftHandLegacyResearch::qbSoftHandLegacyResearch
qbSoftHandLegacyResearch(std::shared_ptr< Communication > communication, std::string name, std::string serial_port, uint8_t id)
Definition: qbsofthand_research_api.cpp:274
qbrobotics_research_api::qbSoftHandLegacyResearch::setParamId
int setParamId(uint8_t id) override
Set the ID of the device.
Definition: qbsofthand_research_api.cpp:297
qbrobotics_research_api::qbSoftHandResearch::setParamUseEMGCalibration
int setParamUseEMGCalibration(uint8_t use_emg_calibration)
Definition: qbsofthand_research_api.cpp:198
qbrobotics_research_api::qbSoftHandResearch::Params::initParams
void initParams(const std::vector< int8_t > &param_buffer) override
Definition: qbsofthand_research_api.cpp:32
qbrobotics_research_api::qbSoftHandResearch::setParamEMGSpeed
int setParamEMGSpeed(uint8_t emg_speed)
Definition: qbsofthand_research_api.cpp:222
qbrobotics_research_api::qbSoftHandLegacyResearch
Definition: qbsofthand_research_api.h:118


qb_device_driver
Author(s): qbrobotics®
autogenerated on Thu Apr 27 2023 02:36:32