SVHSerialPacket.h
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 //----------------------------------------------------------------------
35 //----------------------------------------------------------------------
36 #ifndef SVHSERIALPACKET_H
37 #define SVHSERIALPACKET_H
38 
40 
41 namespace driver_svh {
42 
43 //===============
44 // Some constants
45 //===============
46 
47 // packet sizes
48 const size_t C_PACKET_APPENDIX_SIZE = 8;
49 const size_t C_DEFAULT_PACKET_SIZE = 48;
50 
51 // packet headers
52 const uint8_t PACKET_HEADER1 = 0x4C;
53 const uint8_t PACKET_HEADER2 = 0xAA;
54 
55 // adress constants for commands
56 const uint8_t SVH_GET_CONTROL_FEEDBACK =
57  0x00;
58 const uint8_t SVH_SET_CONTROL_COMMAND = 0x01;
60  0x02;
61 const uint8_t SVH_SET_CONTROL_COMMAND_ALL = 0x03;
63  0x04;
64 const uint8_t SVH_SET_POSITION_SETTINGS = 0x05;
65 const uint8_t SVH_GET_CURRENT_SETTINGS =
66  0x06;
67 const uint8_t SVH_SET_CURRENT_SETTINGS = 0x07;
68 const uint8_t SVH_GET_CONTROLLER_STATE =
69  0x08;
70 const uint8_t SVH_SET_CONTROLLER_STATE =
71  0x09;
72 const uint8_t SVH_GET_ENCODER_VALUES = 0x0A;
73 const uint8_t SVH_SET_ENCODER_VALUES = 0x0B;
74 const uint8_t SVH_GET_FIRMWARE_INFO = 0x0C;
75 
81 {
85  uint8_t index;
87  uint8_t address;
89  std::vector<uint8_t> data;
90 
96  SVHSerialPacket(size_t data_length = 0, uint8_t address = SVH_GET_CONTROL_FEEDBACK)
97  : address(address)
98  , data(data_length, 0)
99  {
100  }
101 
103  bool operator==(const SVHSerialPacket& other) const
104  {
105  return (index == other.index && address == other.address && data == other.data);
106  }
107 };
108 
110 driver_svh::ArrayBuilder& operator<<(driver_svh::ArrayBuilder& ab, const SVHSerialPacket& data);
111 
114 
116 std::ostream& operator<<(std::ostream& o, const SVHSerialPacket& sp);
117 
118 } // namespace driver_svh
119 #endif // SVHSERIALPACKET_H
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::SVH_SET_ENCODER_VALUES
const uint8_t SVH_SET_ENCODER_VALUES
Set new encoder scalings.
Definition: SVHSerialPacket.h:73
driver_svh::SVHSerialPacket
The SerialPacket holds the (non generated) header and data of one message to the SVH-Hardware.
Definition: SVHSerialPacket.h:80
driver_svh::ArrayBuilder
Definition: ByteOrderConversion.h:146
driver_svh::SVH_GET_POSITION_SETTINGS
const uint8_t SVH_GET_POSITION_SETTINGS
Requests the active settings of the position controller.
Definition: SVHSerialPacket.h:62
driver_svh::SVHSerialPacket::operator==
bool operator==(const SVHSerialPacket &other) const
Compares two SVHSerialPackets objects.
Definition: SVHSerialPacket.h:103
driver_svh::SVHSerialPacket::data
std::vector< uint8_t > data
Payload of the package.
Definition: SVHSerialPacket.h:89
driver_svh::SVH_GET_CONTROL_FEEDBACK_ALL
const uint8_t SVH_GET_CONTROL_FEEDBACK_ALL
Requests the positions and currents of ALL channels.
Definition: SVHSerialPacket.h:59
driver_svh::C_DEFAULT_PACKET_SIZE
const size_t C_DEFAULT_PACKET_SIZE
Default packet payload size in bytes.
Definition: SVHSerialPacket.h:49
driver_svh::SVH_GET_CONTROL_FEEDBACK
const uint8_t SVH_GET_CONTROL_FEEDBACK
Request the position and current of a channel to be sent.
Definition: SVHSerialPacket.h:56
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::PACKET_HEADER2
const uint8_t PACKET_HEADER2
Header sync byte 2.
Definition: SVHSerialPacket.h:53
driver_svh::C_PACKET_APPENDIX_SIZE
const size_t C_PACKET_APPENDIX_SIZE
The packet overhead size in bytes.
Definition: SVHSerialPacket.h:48
driver_svh::SVHSerialPacket::SVHSerialPacket
SVHSerialPacket(size_t data_length=0, uint8_t address=SVH_GET_CONTROL_FEEDBACK)
SVHSerialPacket contains the send and received data in raw format (bytewise)
Definition: SVHSerialPacket.h:96
driver_svh::SVH_SET_POSITION_SETTINGS
const uint8_t SVH_SET_POSITION_SETTINGS
Sets new settings for the position controller.
Definition: SVHSerialPacket.h:64
driver_svh::PACKET_HEADER1
const uint8_t PACKET_HEADER1
Header sync byte 1.
Definition: SVHSerialPacket.h:52
driver_svh::SVH_GET_FIRMWARE_INFO
const uint8_t SVH_GET_FIRMWARE_INFO
Request the firmware info to be transmitted.
Definition: SVHSerialPacket.h:74
driver_svh::SVHSerialPacket::address
uint8_t address
Adress denotes the actual function of the package.
Definition: SVHSerialPacket.h:87
driver_svh::SVH_GET_CONTROLLER_STATE
const uint8_t SVH_GET_CONTROLLER_STATE
Requests the state of the controller (active,faults,enabled channels)
Definition: SVHSerialPacket.h:68
driver_svh::SVH_GET_ENCODER_VALUES
const uint8_t SVH_GET_ENCODER_VALUES
Request the current encoder scalings.
Definition: SVHSerialPacket.h:72
driver_svh::operator>>
driver_svh::ArrayBuilder & operator>>(driver_svh::ArrayBuilder &ab, SVHControlCommand &data)
overload stream operator to easily deserialize control commands for one channel
Definition: SVHControlCommand.h:143
driver_svh::operator<<
driver_svh::ArrayBuilder & operator<<(driver_svh::ArrayBuilder &ab, const SVHControlCommand &data)
Definition: SVHControlCommand.h:134
driver_svh::SVH_SET_CURRENT_SETTINGS
const uint8_t SVH_SET_CURRENT_SETTINGS
Sets new settings for the current controller.
Definition: SVHSerialPacket.h:67
driver_svh::SVH_SET_CONTROL_COMMAND_ALL
const uint8_t SVH_SET_CONTROL_COMMAND_ALL
Sends the target position to ALL the channels.
Definition: SVHSerialPacket.h:61
driver_svh::SVH_GET_CURRENT_SETTINGS
const uint8_t SVH_GET_CURRENT_SETTINGS
Requests the active settings of the current controller.
Definition: SVHSerialPacket.h:65
driver_svh::SVH_SET_CONTROLLER_STATE
const uint8_t SVH_SET_CONTROLLER_STATE
Sets new controller states (enable channels, clear faults)
Definition: SVHSerialPacket.h:70


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