SVHControllerFeedback.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 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 #ifndef SVHCONTROLLERFEEDBACK_H
29 #define SVHCONTROLLERFEEDBACK_H
30 
31 #include <icl_comm/ByteOrderConversion.h>
32 
33 namespace driver_svh {
34 
39 {
44 
50  SVHControllerFeedback(const int32_t& _position = 0,const int16_t& _current = 0):
51  position(_position),
52  current(_current)
53  {}
54 
56  bool operator == (const SVHControllerFeedback& other) const
57  {
58  return (position == other.position && current == other.current);
59  }
60 };
61 
66 {
68  std::vector<SVHControllerFeedback> feedbacks;
69 
83  const SVHControllerFeedback& _feedback2,const SVHControllerFeedback& _feedback3,
84  const SVHControllerFeedback& _feedback4,const SVHControllerFeedback& _feedback5,
85  const SVHControllerFeedback& _feedback6,const SVHControllerFeedback& _feedback7,
86  const SVHControllerFeedback& _feedback8)
87  {
88  feedbacks.push_back(_feedback0);
89  feedbacks.push_back(_feedback1);
90  feedbacks.push_back(_feedback2);
91  feedbacks.push_back(_feedback3);
92  feedbacks.push_back(_feedback4);
93  feedbacks.push_back(_feedback5);
94  feedbacks.push_back(_feedback6);
95  feedbacks.push_back(_feedback7);
96  feedbacks.push_back(_feedback8);
97  }
98 
104  SVHControllerFeedbackAllChannels(std::vector<SVHControllerFeedback> _feedbacks)
105  {
106  feedbacks.insert(feedbacks.begin(),_feedbacks.begin(),_feedbacks.end());
107  }
108 
113  feedbacks(9)
114  { }
115 
116 
119  {
120  return (feedbacks == other.feedbacks);
121  }
122 };
123 
125 inline icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab,const SVHControllerFeedback& data)
126 {
127  ab << data.position
128  << data.current;
129  return ab;
130 }
131 
132 
134 inline icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHControllerFeedback& data)
135 {
136  ab >> data.position
137  >> data.current;
138  return ab;
139 }
140 
142 inline std::ostream& operator << (std::ostream& o, const SVHControllerFeedback& cf)
143 {
144  o << "Pos: " << cf.position << " Cur: " << cf.current << std::endl;
145  return o;
146 }
147 
148 
150 inline icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab,SVHControllerFeedbackAllChannels& data)
151 {
152  // The Data is transmitted not channel by channel but rather position first, Currents afterwards for all channels
153  for (std::vector<SVHControllerFeedback>::iterator it = data.feedbacks.begin() ; it != data.feedbacks.end(); ++it)
154  {
155  ab << it->position;
156  }
157 
158  for (std::vector<SVHControllerFeedback>::iterator it = data.feedbacks.begin() ; it != data.feedbacks.end(); ++it)
159  {
160  ab << it->current;
161  }
162  return ab;
163 }
164 
165 
167 inline icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHControllerFeedbackAllChannels& data)
168 {
169  // The Data is transmitted not channel by channel but rather position first, Currents afterwards for all channels
170  for (std::vector<SVHControllerFeedback>::iterator it = data.feedbacks.begin() ; it != data.feedbacks.end(); ++it)
171  {
172  ab >> it->position;
173  }
174 
175  for (std::vector<SVHControllerFeedback>::iterator it = data.feedbacks.begin() ; it != data.feedbacks.end(); ++it)
176  {
177  ab >> it->current;
178  }
179  return ab;
180 }
181 
183 inline std::ostream& operator << (std::ostream& o, const SVHControllerFeedbackAllChannels& cf)
184 {
185  o << "Feedbacks: " ;
186  unsigned int i = 0;
187  for (std::vector<SVHControllerFeedback>::const_iterator it = cf.feedbacks.begin() ; it != cf.feedbacks.end(); ++it,++i)
188  {
189  o << "Chan " << i << " : "<< *it;
190  }
191  o << std::endl;
192  return o;
193 }
194 
195 }
196 
197 #endif // SVHCONTROLLERFEEDBACK_H
signed int int32_t
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
std::vector< SVHControllerFeedback > feedbacks
Vector holding multiple channels.
SVHControllerFeedbackAllChannels(const SVHControllerFeedback &_feedback0, const SVHControllerFeedback &_feedback1, const SVHControllerFeedback &_feedback2, const SVHControllerFeedback &_feedback3, const SVHControllerFeedback &_feedback4, const SVHControllerFeedback &_feedback5, const SVHControllerFeedback &_feedback6, const SVHControllerFeedback &_feedback7, const SVHControllerFeedback &_feedback8)
Constructs a SVHControllerFeedbackAllChannels data structure from explicit ffedback elements...
The SVHControllerFeedback saves the feedback of a single motor.
icl_comm::ArrayBuilder & operator<<(icl_comm::ArrayBuilder &ab, const SVHControlCommand &data)
int16_t current
Returned current value of the motor [mA].
SVHControllerFeedbackAllChannels(std::vector< SVHControllerFeedback > _feedbacks)
Creates a SVHControllerFeedbackAllChannels structure from a vector.
signed short int16_t
SVHControllerFeedbackAllChannels()
Constructs an empty SVHControllerFeedbackAllChannels objects, prefilled with 9 default channel feedba...
bool operator==(const SVHControllerFeedback &other) const
Compares two SVHControllerFeedback objects.
The SVHControllerFeedbackAllChannes saves the feedback of a all motors.
SVHControllerFeedback(const int32_t &_position=0, const int16_t &_current=0)
standard constructor


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