joint_feedback.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, Southwest Research Institute
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of the Southwest Research Institute, nor the names
16  * of its contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef JOINT_FEEDBACK_H
33 #define JOINT_FEEDBACK_H
34 
35 #ifndef FLATHEADERS
40 #else
41 #include "joint_data.h"
42 #include "simple_message.h"
43 #include "simple_serialize.h"
44 #include "shared_types.h"
45 #endif
46 
47 namespace industrial
48 {
49 namespace joint_feedback
50 {
51 
52 namespace ValidFieldTypes
53 {
55 {
56  TIME = 0x01, POSITION = 0x02, VELOCITY = 0x04, ACCELERATION = 0x08
57 };
58 }
60 
84 {
85 public:
86 
93  JointFeedback(void);
98  ~JointFeedback(void);
99 
104  void init();
105 
110  void init(industrial::shared_types::shared_int robot_id,
115  industrial::joint_data::JointData & accelerations);
116 
124  {
125  this->robot_id_ = robot_id;
126  }
127 
135  {
136  return this->robot_id_;
137  }
138 
145  {
146  this->time_ = time;
147  this->valid_fields_ |= ValidFieldTypes::TIME; // set the bit
148  }
149 
157  {
158  time = this->time_;
159  return is_valid(ValidFieldTypes::TIME);
160  }
161 
165  void clearTime()
166  {
167  this->time_ = 0;
168  this->valid_fields_ &= ~ValidFieldTypes::TIME; // clear the bit
169  }
170 
177  {
178  this->positions_.copyFrom(positions);
179  this->valid_fields_ |= ValidFieldTypes::POSITION; // set the bit
180  }
181 
189  {
190  dest.copyFrom(this->positions_);
191  return is_valid(ValidFieldTypes::POSITION);
192  }
193 
198  {
199  this->positions_.init();
200  this->valid_fields_ &= ~ValidFieldTypes::POSITION; // clear the bit
201  }
202 
209  {
210  this->velocities_.copyFrom(velocities);
211  this->valid_fields_ |= ValidFieldTypes::VELOCITY; // set the bit
212  }
213 
221  {
222  dest.copyFrom(this->velocities_);
223  return is_valid(ValidFieldTypes::VELOCITY);
224  }
225 
230  {
231  this->velocities_.init();
232  this->valid_fields_ &= ~ValidFieldTypes::VELOCITY; // clear the bit
233  }
240  {
241  this->accelerations_.copyFrom(accelerations);
242  this->valid_fields_ |= ValidFieldTypes::ACCELERATION; // set the bit
243  }
244 
252  {
253  dest.copyFrom(this->accelerations_);
254  return is_valid(ValidFieldTypes::ACCELERATION);
255  }
256 
261  {
262  this->accelerations_.init();
263  this->valid_fields_ &= ~ValidFieldTypes::ACCELERATION; // clear the bit
264  }
265 
266 
272  void copyFrom(JointFeedback &src);
273 
279  bool operator==(JointFeedback &rhs);
280 
286  bool is_valid(ValidFieldType field)
287  {
288  return valid_fields_ & field;
289  }
290 
291  // Overrides - SimpleSerialize
292  bool load(industrial::byte_array::ByteArray *buffer);
293  bool unload(industrial::byte_array::ByteArray *buffer);
294  unsigned int byteLength()
295  {
297  + 3*this->positions_.byteLength();
298  }
299 
300 private:
301 
316 
328 
329 };
330 
331 }
332 }
333 
334 #endif /* JOINT_FEEDBACK_H */
unsigned int byteLength()
Virtual method returns the object size when packed into a ByteArray.
bool getTime(industrial::shared_types::shared_real &time)
Returns joint feedback timestamp.
bool getPositions(industrial::joint_data::JointData &dest)
Returns a copy of the position data.
void setRobotID(industrial::shared_types::shared_int robot_id)
Sets robot_id. Robot group # (0-based), for controllers with multiple axis-groups.
void clearPositions()
Clears the position data.
void init(const M_string &remappings)
industrial::shared_types::shared_int robot_id_
robot group # (0-based) for controllers that support multiple axis-groups
industrial::joint_data::JointData positions_
joint feedback positional data
industrial::joint_data::JointData accelerations_
joint feedback acceleration data
Interface for loading and unloading a class to/from a ByteArray.
industrial::joint_data::JointData velocities_
joint feedback velocity data
void setAccelerations(industrial::joint_data::JointData &accelerations)
Sets joint acceleration data.
bool getAccelerations(industrial::joint_data::JointData &dest)
Returns a copy of the acceleration data.
void copyFrom(JointData &src)
Copies the passed in value.
Definition: joint_data.cpp:107
The byte array wraps a dynamic array of bytes (i.e. char).
Definition: byte_array.h:80
void setVelocities(industrial::joint_data::JointData &velocities)
Sets joint velocity data.
Class encapsulated joint data (positions, accelerations, velocity, torque, and/or effort)...
Definition: joint_data.h:68
void setTime(industrial::shared_types::shared_real time)
Sets joint feedback timestamp.
bool is_valid(ValidFieldType field)
check the validity state for a given field
void clearVelocities()
Clears the velocity data.
industrial::shared_types::shared_int valid_fields_
bit-mask of (optional) fields that have been initialized with valid data
bool getVelocities(industrial::joint_data::JointData &dest)
Returns a copy of the velocity data.
Class encapsulated joint feedback data. This data represents the current state of each robot joint...
void setPositions(industrial::joint_data::JointData &positions)
Sets joint position data.
industrial::shared_types::shared_int getRobotID()
Gets robot_id. Robot group # (0-based), for controllers with multiple axis-groups.
industrial::shared_types::shared_real time_
joint data timestamp Typically, time since controller booted (in seconds)
void clearTime()
Clears the joint feedback timestamp.
void clearAccelerations()
Clears the acceleration data.


simple_message
Author(s): Shaun Edwards
autogenerated on Sat Sep 21 2019 03:30:09