SVHControllerInitSendTest.cpp
Go to the documentation of this file.
1 //
3 // © Copyright 2022 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
4 // © Copyright 2022 FZI Forschungszentrum Informatik, Karlsruhe, Germany
5 //
6 // This file is part of the Schunk SVH Library.
7 //
8 // The Schunk SVH Library is free software: you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or (at your
11 // option) any later version.
12 //
13 // The Schunk SVH Library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16 // Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License along with
19 // the Schunk SVH Library. If not, see <https://www.gnu.org/licenses/>.
20 //
22 
23 //----------------------------------------------------------------------
30 //----------------------------------------------------------------------
31 
32 #include <chrono>
35 #include <thread>
36 
37 using namespace driver_svh;
38 
39 // testing serial interface of svh driver
40 int main(int argc, const char* argv[])
41 {
42  std::string serial_device_name = "/dev/ttyUSB0";
43 
44  SVHController controller;
45  controller.connect(serial_device_name);
46 
47  // initilize default position settings
48  std::vector<SVHPositionSettings> default_position_settings(SVH_DIMENSION);
49  SVHPositionSettings pos_set_thumb(
50  -1.0e6f, 1.0e6f, 3.4e3f, 1.00f, 1e-3f, -500.0f, 500.0f, 0.5f, 0.05f, 0.0f);
51  SVHPositionSettings pos_set_finger(
52  -1.0e6f, 1.0e6f, 8.5e3f, 1.00f, 1e-3f, -500.0f, 500.0f, 0.5f, 0.05f, 0.0f);
53  SVHPositionSettings pos_set_spread(
54  -1.0e6f, 1.0e6f, 17.0e3f, 1.00f, 1e-3f, -500.0f, 500.0f, 0.5f, 0.05f, 0.0f);
55 
56  default_position_settings[0] = pos_set_thumb; // thumb flexion
57  default_position_settings[1] = pos_set_thumb; // thumb opposition
58  default_position_settings[2] = pos_set_finger; // index finger distal joint
59  default_position_settings[3] = pos_set_finger; // index finger proximal joint
60  default_position_settings[4] = pos_set_finger; // middle finger distal joint
61  default_position_settings[5] = pos_set_finger; // middle finger proximal joint
62  default_position_settings[6] = pos_set_finger; // ring finger
63  default_position_settings[7] = pos_set_finger; // pinky
64  default_position_settings[8] = pos_set_spread; // finger spread
65 
66  // initilize default current settings
67  std::vector<SVHCurrentSettings> default_current_settings(SVH_DIMENSION);
68  SVHCurrentSettings cur_set_thumb(
69  -191.0f, 191.0f, 0.405f, 4e-6f, -300.0f, 300.0f, 0.850f, 85.0f, -254.0f, 254.0f);
70  SVHCurrentSettings cur_set_distal_joint(
71  -176.0f, 176.0f, 0.405f, 4e-6f, -300.0f, 300.0f, 0.850f, 85.0f, -254.0f, 254.0f);
72  SVHCurrentSettings cur_set_proximal_joint(
73  -167.0f, 167.0f, 0.405f, 4e-6f, -300.0f, 300.0f, 0.850f, 85.0f, -254.0f, 254.0f);
74 
75  default_current_settings[0] = cur_set_thumb; // thumb flexion
76  default_current_settings[1] = cur_set_thumb; // thumb opposition
77  default_current_settings[2] = cur_set_distal_joint; // index finger distal joint
78  default_current_settings[3] = cur_set_proximal_joint; // index finger proximal joint
79  default_current_settings[4] = cur_set_distal_joint; // middle finger distal joint
80  default_current_settings[5] = cur_set_proximal_joint; // middle finger proximal joint
81  default_current_settings[6] = cur_set_distal_joint; // ring finger
82  default_current_settings[7] = cur_set_distal_joint; // pinky
83  default_current_settings[8] = cur_set_proximal_joint; // finger spread
84 
85  // request firmware info
86  std::cout << "sending request firmware info" << std::endl;
87  controller.requestFirmwareInfo();
88 
89  // initialize all channels
90  for (size_t i = 0; i < SVH_DIMENSION; ++i)
91  {
92  SVHChannel channel = SVHChannel(i);
93 
94  // request controller feedback
95  std::cout << "sending request controller feedback" << std::endl;
96  controller.requestControllerFeedback(channel);
97 
98  // set position settings
99  std::cout << "set position settings" << std::endl;
100  controller.setPositionSettings(channel, default_position_settings[channel]);
101  // std::cout << "Position settings of channel " << channel << " " <<
102  // default_position_settings[channel] << std::endl;
103 
104  // set current settings
105  std::cout << "set current settings" << std::endl;
106  controller.setCurrentSettings(channel, default_current_settings[channel]);
107  // std::cout << "Current settings of channel " << channel << " " <<
108  // default_current_settings[channel] << std::endl;
109  }
110 
111  std::this_thread::sleep_for(std::chrono::seconds(20));
112 
113  controller.disconnect();
114 }
void setPositionSettings(const SVHChannel &channel, const SVHPositionSettings &position_settings)
activate a new set of position controller settings for a specific channel
The SVHCurrentSettings save the current controller paramters for a single motor.
bool connect(const std::string &dev_name)
Open serial device connection.
int main(int argc, const char *argv[])
void requestControllerFeedback(const SVHChannel &channel)
request feedback (position and current) to a specific channel
void setCurrentSettings(const SVHChannel &channel, const SVHCurrentSettings &current_settings)
activate a new set of current controller settings for a specific channel
void disconnect()
disconnect serial device
This class controls the the SCHUNK five finger hand.
Definition: SVHController.h:87
The SVHPositionSettings save the position controller paramters for a single motor.
void requestFirmwareInfo()
request a transmission of formware information


schunk_svh_library
Author(s): Georg Heppner, Lars Pfotzer, Felix Exner, Johannes Mangler, Stefan Scherzinger, Pascal Becker
autogenerated on Fri Apr 14 2023 02:26:23