SVHSendFeedbackPacketTest.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>
38 #include <thread>
39 
41 using namespace driver_svh;
42 
45 
46 // testing serial interface of svh driver
47 int main(int argc, const char* argv[])
48 {
49  std::string serial_device_name = "/dev/ttyUSB0";
50 
51  SVHSerialInterface serial_com(NULL);
52  serial_com.connect(serial_device_name);
53 
54  // build feedback serial packet for sending
55  ArrayBuilder packet;
56  SVHChannel channel = SVH_PINKY;
57  SVHSerialPacket test_serial_packet(40,
58  SVH_SET_CONTROL_COMMAND | static_cast<uint8_t>(channel << 4));
59  SVHControllerFeedback test_controller_feedback(0, 140);
60 
61  // serialize test controller feedback to paket
62  packet << test_controller_feedback;
63  test_serial_packet.index = 0; //
64  // Set the payload (converted array of position settings)
65  test_serial_packet.data = packet.array;
66 
67  // send packet via serial port
68  serial_com.sendPacket(test_serial_packet);
69 
70  std::this_thread::sleep_for(std::chrono::seconds(5));
71 
72  test_controller_feedback.position = -8000;
73 
74  // serialize test controller feedback to paket
75  packet.reset(0);
76  packet << test_controller_feedback;
77  test_serial_packet.index = 0; //
78  // Set the payload (converted array of position settings)
79  test_serial_packet.data = packet.array;
80 
81  // send packet via serial port
82  serial_com.sendPacket(test_serial_packet);
83 
84  serial_com.close();
85 }
driver_svh::SVH_SET_CONTROL_COMMAND
const uint8_t SVH_SET_CONTROL_COMMAND
Sets the target position of a channel.
Definition: SVHSerialPacket.h:58
driver_svh::ArrayBuilder::array
std::vector< uint8_t > array
array of template type TArray
Definition: ByteOrderConversion.h:163
driver_svh::SVHSerialPacket
The SerialPacket holds the (non generated) header and data of one message to the SVH-Hardware.
Definition: SVHSerialPacket.h:80
SVHControllerFeedback.h
driver_svh::ArrayBuilder
Definition: ByteOrderConversion.h:146
driver_svh::SVHSerialPacket::data
std::vector< uint8_t > data
Payload of the package.
Definition: SVHSerialPacket.h:89
SVHController.h
SVHSerialInterface.h
driver_svh::SVHSerialInterface::close
void close()
canceling receive thread and closing connection to serial port
Definition: SVHSerialInterface.cpp:109
driver_svh::SVHSerialPacket::index
uint8_t index
Continuosly incremented counter per package.
Definition: SVHSerialPacket.h:85
driver_svh
Definition: SVHControlCommand.h:39
ByteOrderConversion.h
driver_svh::SVH_PINKY
@ SVH_PINKY
Definition: SVHController.h:75
main
int main(int argc, const char *argv[])
Definition: SVHSendFeedbackPacketTest.cpp:47
driver_svh::SVHControllerFeedback
The SVHControllerFeedback saves the feedback of a single motor.
Definition: SVHControllerFeedback.h:45
driver_svh::SVHChannel
SVHChannel
Definition: SVHController.h:65
SVHSerialPacket.h
driver_svh::SVHSerialInterface::sendPacket
bool sendPacket(SVHSerialPacket &packet)
function for sending packets via serial device to the SVH
Definition: SVHSerialInterface.cpp:134
driver_svh::ArrayBuilder::reset
void reset(size_t array_size=1)
Resets the Arraybuilder to initial state, all values will be deleted.
Definition: ByteOrderConversion.cpp:82
driver_svh::serial::Serial
Enables acces to serial devices.
Definition: Serial.h:68
driver_svh::serial::SerialFlags
Short description of tSerialFlags.
Definition: SerialFlags.h:52
driver_svh::SVHSerialInterface
Basic communication handler for the SCHUNK five finger hand.
Definition: SVHSerialInterface.h:57
driver_svh::SVHSerialInterface::connect
bool connect(const std::string &dev_name)
connecting to serial device and starting receive thread
Definition: SVHSerialInterface.cpp:63


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