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 
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_;
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_);
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_);
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_);
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 
287  {
288  return valid_fields_ & field;
289  }
290 
291  // Overrides - SimpleSerialize
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 */
industrial::joint_feedback::JointFeedback
Class encapsulated joint feedback data. This data represents the current state of each robot joint,...
Definition: joint_feedback.h:83
industrial::joint_feedback::JointFeedback::JointFeedback
JointFeedback(void)
Default constructor.
Definition: joint_feedback.cpp:49
industrial::joint_feedback::ValidFieldTypes::ValidFieldType
ValidFieldType
Definition: joint_feedback.h:54
industrial::joint_feedback::JointFeedback::setVelocities
void setVelocities(industrial::joint_data::JointData &velocities)
Sets joint velocity data.
Definition: joint_feedback.h:208
industrial::joint_feedback::JointFeedback::getAccelerations
bool getAccelerations(industrial::joint_data::JointData &dest)
Returns a copy of the acceleration data.
Definition: joint_feedback.h:251
industrial::joint_data::JointData
Class encapsulated joint data (positions, accelerations, velocity, torque, and/or effort).
Definition: joint_data.h:68
industrial::joint_feedback::ValidFieldType
ValidFieldTypes::ValidFieldType ValidFieldType
Definition: joint_feedback.h:59
industrial::joint_feedback::JointFeedback::valid_fields_
industrial::shared_types::shared_int valid_fields_
bit-mask of (optional) fields that have been initialized with valid data
Definition: joint_feedback.h:310
industrial::joint_feedback::JointFeedback::getVelocities
bool getVelocities(industrial::joint_data::JointData &dest)
Returns a copy of the velocity data.
Definition: joint_feedback.h:220
industrial
Definition: byte_array.h:45
simple_message.h
industrial::joint_feedback::JointFeedback::setTime
void setTime(industrial::shared_types::shared_real time)
Sets joint feedback timestamp.
Definition: joint_feedback.h:144
industrial::joint_feedback::JointFeedback::is_valid
bool is_valid(ValidFieldType field)
check the validity state for a given field
Definition: joint_feedback.h:286
industrial::joint_feedback::JointFeedback::clearVelocities
void clearVelocities()
Clears the velocity data.
Definition: joint_feedback.h:229
industrial::joint_feedback::JointFeedback::setPositions
void setPositions(industrial::joint_data::JointData &positions)
Sets joint position data.
Definition: joint_feedback.h:176
industrial::joint_feedback::JointFeedback::getRobotID
industrial::shared_types::shared_int getRobotID()
Gets robot_id. Robot group # (0-based), for controllers with multiple axis-groups.
Definition: joint_feedback.h:134
industrial::joint_feedback::JointFeedback::operator==
bool operator==(JointFeedback &rhs)
== operator implementation
Definition: joint_feedback.cpp:93
industrial::joint_feedback::JointFeedback::time_
industrial::shared_types::shared_real time_
joint data timestamp Typically, time since controller booted (in seconds)
Definition: joint_feedback.h:315
industrial::joint_feedback::JointFeedback::clearTime
void clearTime()
Clears the joint feedback timestamp.
Definition: joint_feedback.h:165
industrial::shared_types::shared_real
float shared_real
Definition: shared_types.h:66
industrial::joint_feedback::JointFeedback::~JointFeedback
~JointFeedback(void)
Destructor.
Definition: joint_feedback.cpp:53
industrial::joint_feedback::JointFeedback::clearAccelerations
void clearAccelerations()
Clears the acceleration data.
Definition: joint_feedback.h:260
industrial::joint_feedback::JointFeedback::getTime
bool getTime(industrial::shared_types::shared_real &time)
Returns joint feedback timestamp.
Definition: joint_feedback.h:156
industrial::joint_data::JointData::byteLength
unsigned int byteLength()
Virtual method returns the object size when packed into a ByteArray.
Definition: joint_data.h:147
industrial::byte_array::ByteArray
The byte array wraps a dynamic array of bytes (i.e. char).
Definition: byte_array.h:80
industrial::joint_feedback::JointFeedback::setRobotID
void setRobotID(industrial::shared_types::shared_int robot_id)
Sets robot_id. Robot group # (0-based), for controllers with multiple axis-groups.
Definition: joint_feedback.h:123
industrial::joint_feedback::JointFeedback::byteLength
unsigned int byteLength()
Virtual method returns the object size when packed into a ByteArray.
Definition: joint_feedback.h:294
industrial::joint_feedback::JointFeedback::unload
bool unload(industrial::byte_array::ByteArray *buffer)
Virtual method for unloading an object from a ByteArray.
Definition: joint_feedback.cpp:147
industrial::joint_feedback::JointFeedback::clearPositions
void clearPositions()
Clears the position data.
Definition: joint_feedback.h:197
industrial::joint_feedback::JointFeedback::getPositions
bool getPositions(industrial::joint_data::JointData &dest)
Returns a copy of the position data.
Definition: joint_feedback.h:188
industrial::joint_data::JointData::init
void init()
Initializes a empty joint data.
Definition: joint_data.cpp:57
industrial::joint_feedback::JointFeedback::copyFrom
void copyFrom(JointFeedback &src)
Copies the passed in value.
Definition: joint_feedback.cpp:83
industrial::joint_feedback::ValidFieldTypes::VELOCITY
@ VELOCITY
Definition: joint_feedback.h:56
shared_types.h
industrial::simple_serialize::SimpleSerialize
Interface for loading and unloading a class to/from a ByteArray.
Definition: simple_serialize.h:52
industrial::joint_feedback::JointFeedback::robot_id_
industrial::shared_types::shared_int robot_id_
robot group # (0-based) for controllers that support multiple axis-groups
Definition: joint_feedback.h:305
industrial::shared_types::shared_int
int shared_int
Definition: shared_types.h:62
industrial::joint_feedback::JointFeedback::accelerations_
industrial::joint_data::JointData accelerations_
joint feedback acceleration data
Definition: joint_feedback.h:327
industrial::joint_feedback::ValidFieldTypes::POSITION
@ POSITION
Definition: joint_feedback.h:56
joint_data.h
industrial::joint_feedback::JointFeedback::positions_
industrial::joint_data::JointData positions_
joint feedback positional data
Definition: joint_feedback.h:320
industrial::joint_data::JointData::copyFrom
void copyFrom(JointData &src)
Copies the passed in value.
Definition: joint_data.cpp:107
industrial::joint_feedback::JointFeedback::velocities_
industrial::joint_data::JointData velocities_
joint feedback velocity data
Definition: joint_feedback.h:324
industrial::joint_feedback::JointFeedback::init
void init()
Initializes a empty joint feedback.
Definition: joint_feedback.cpp:58
industrial::joint_feedback::JointFeedback::setAccelerations
void setAccelerations(industrial::joint_data::JointData &accelerations)
Sets joint acceleration data.
Definition: joint_feedback.h:239
simple_serialize.h
industrial::joint_feedback::ValidFieldTypes::TIME
@ TIME
Definition: joint_feedback.h:56
industrial::joint_feedback::JointFeedback::load
bool load(industrial::byte_array::ByteArray *buffer)
Virtual method for loading an object into a ByteArray.
Definition: joint_feedback.cpp:103
industrial::joint_feedback::ValidFieldTypes::ACCELERATION
@ ACCELERATION
Definition: joint_feedback.h:56


simple_message
Author(s): Shaun Edwards
autogenerated on Wed Mar 2 2022 00:24:53