SVHControlCommand.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of the SCHUNK SVH Driver suite.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2014 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
12 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
13 //
14 // -- END LICENSE BLOCK ------------------------------------------------
15 
16 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 #ifndef SVHCONTROLCOMMAND_H
28 #define SVHCONTROLCOMMAND_H
29 
30 #include <icl_comm/ByteOrderConversion.h>
31 
32 namespace driver_svh {
33 
39 {
42 
47  SVHControlCommand(const int32_t& _position = 0):
48  position(_position)
49  {}
50 
52  bool operator == (const SVHControlCommand& other) const
53  {
54  return (position == other.position);
55  }
56 
57 };
58 
64 {
66  std::vector<SVHControlCommand> commands;
67 
80  SVHControlCommandAllChannels(const int32_t& _position0,const int32_t& _position1,const int32_t& _position2,
81  const int32_t& _position3,const int32_t& _position4,const int32_t& _position5,
82  const int32_t& _position6,const int32_t& _position7,const int32_t& _position8)
83  {
84  commands.push_back(SVHControlCommand(_position0));
85  commands.push_back(SVHControlCommand(_position1));
86  commands.push_back(SVHControlCommand(_position2));
87  commands.push_back(SVHControlCommand(_position3));
88  commands.push_back(SVHControlCommand(_position4));
89  commands.push_back(SVHControlCommand(_position5));
90  commands.push_back(SVHControlCommand(_position6));
91  commands.push_back(SVHControlCommand(_position7));
92  commands.push_back(SVHControlCommand(_position8));
93  }
94 
99  SVHControlCommandAllChannels(const std::vector<int32_t>& positions)
100  {
101  commands.insert(commands.begin(),positions.begin(),positions.begin()+9);
102  }
103 
109  commands(9,SVHControlCommand())
110  { }
111 
114  {
115  return (commands == other.commands);
116  }
117 };
118 
119 
122 inline icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab, const SVHControlCommand& data)
123 {
124  ab << data.position;
125  return ab;
126 }
127 
128 
130 inline icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHControlCommand& data)
131 {
132  ab >> data.position;
133  return ab;
134 }
135 
137 inline std::ostream& operator << (std::ostream& o, const SVHControlCommand& cc)
138 {
139  o << "Pos: " << cc.position << std::endl;
140  return o;
141 }
142 
144 inline icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab, const SVHControlCommandAllChannels& data)
145 {
146  // We could also just give the whole vector in ...
147  for (std::vector<SVHControlCommand>::const_iterator it = data.commands.begin() ; it != data.commands.end(); ++it)
148  {
149  ab << *it;
150  }
151  return ab;
152 }
153 
154 
156 inline icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHControlCommandAllChannels& data)
157 {
158  for (std::vector<SVHControlCommand>::iterator it = data.commands.begin() ; it != data.commands.end(); ++it)
159  {
160  ab >> *it;
161  }
162  return ab;
163 }
164 
165 
167 inline std::ostream& operator << (std::ostream& o, const SVHControlCommandAllChannels& cc)
168 {
169  o << "Commands: " ;
170  unsigned int i = 0;
171  for (std::vector<SVHControlCommand>::const_iterator it = cc.commands.begin() ; it != cc.commands.end(); ++it)
172  {
173  o << "Chan " << i << " : "<< *it;
174  ++i;
175  }
176  o << std::endl;
177  return o;
178 }
179 }
180 
181 #endif // SVHCONTROLCOMMAND_H
signed int int32_t
Structure for transmitting all controllcommands at once.
bool operator==(const SVHControlCommand &other) const
Compares two SVHControlCommand objects.
int32_t position
Returned position value of the motor [Ticks].
icl_comm::ArrayBuilder & operator>>(icl_comm::ArrayBuilder &ab, SVHControlCommand &data)
overload stream operator to easily deserialize control commands for one channel
SVHControlCommandAllChannels(const int32_t &_position0, const int32_t &_position1, const int32_t &_position2, const int32_t &_position3, const int32_t &_position4, const int32_t &_position5, const int32_t &_position6, const int32_t &_position7, const int32_t &_position8)
Constructs a controllcommand adressing all channels at once All.
SVHControlCommandAllChannels()
Constructs an empty SVHControlCommandAllChannels structure pre filled with 9 empty SVHControlCommands...
icl_comm::ArrayBuilder & operator<<(icl_comm::ArrayBuilder &ab, const SVHControlCommand &data)
ControlCommands are given as a single target position for the position controller (given in ticks) ...
SVHControlCommand(const int32_t &_position=0)
Constructs a new control command to comandeer the position of the fingers.
SVHControlCommandAllChannels(const std::vector< int32_t > &positions)
Construct a control command for all channels from a vector. Only the first 9 Values are used...
std::vector< SVHControlCommand > commands
Multiple controllcommands that shall be send at once.


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Mon Jun 10 2019 15:04:59