Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef FLATHEADERS
00032 #include "simple_message/joint_feedback.h"
00033 #include "simple_message/shared_types.h"
00034 #include "simple_message/log_wrapper.h"
00035 #else
00036 #include "joint_feedback.h"
00037 #include "shared_types.h"
00038 #include "log_wrapper.h"
00039 #endif
00040
00041 using namespace industrial::joint_data;
00042 using namespace industrial::shared_types;
00043
00044 namespace industrial
00045 {
00046 namespace joint_feedback
00047 {
00048
00049 JointFeedback::JointFeedback(void)
00050 {
00051 this->init();
00052 }
00053 JointFeedback::~JointFeedback(void)
00054 {
00055
00056 }
00057
00058 void JointFeedback::init()
00059 {
00060 this->robot_id_ = 0;
00061 this->valid_fields_ = 0;
00062 this->time_ = 0.0;
00063 this->positions_.init();
00064 this->velocities_.init();
00065 this->accelerations_.init();
00066 }
00067
00068 void JointFeedback::init(industrial::shared_types::shared_int robot_id,
00069 industrial::shared_types::shared_int valid_fields,
00070 industrial::shared_types::shared_real time,
00071 industrial::joint_data::JointData & positions,
00072 industrial::joint_data::JointData & velocities,
00073 industrial::joint_data::JointData & accelerations)
00074 {
00075 this->setRobotID(robot_id);
00076 this->setTime(time);
00077 this->setPositions(positions);
00078 this->setVelocities(velocities);
00079 this->setAccelerations(accelerations);
00080 this->valid_fields_ = valid_fields;
00081 }
00082
00083 void JointFeedback::copyFrom(JointFeedback &src)
00084 {
00085 this->setRobotID(src.getRobotID());
00086 src.getTime(this->time_);
00087 src.getPositions(this->positions_);
00088 src.getVelocities(this->velocities_);
00089 src.getAccelerations(this->accelerations_);
00090 this->valid_fields_ = src.valid_fields_;
00091 }
00092
00093 bool JointFeedback::operator==(JointFeedback &rhs)
00094 {
00095 return this->robot_id_ == rhs.robot_id_ &&
00096 this->valid_fields_ == rhs.valid_fields_ &&
00097 ( !is_valid(ValidFieldTypes::TIME) || (this->time_ == rhs.time_) ) &&
00098 ( !is_valid(ValidFieldTypes::POSITION) || (this->positions_ == rhs.positions_) ) &&
00099 ( !is_valid(ValidFieldTypes::VELOCITY) || (this->velocities_ == rhs.velocities_) ) &&
00100 ( !is_valid(ValidFieldTypes::ACCELERATION) || (this->accelerations_ == rhs.accelerations_) );
00101 }
00102
00103 bool JointFeedback::load(industrial::byte_array::ByteArray *buffer)
00104 {
00105 LOG_COMM("Executing joint feedback load");
00106
00107 if (!buffer->load(this->robot_id_))
00108 {
00109 LOG_ERROR("Failed to load joint feedback robot_id");
00110 return false;
00111 }
00112
00113 if (!buffer->load(this->valid_fields_))
00114 {
00115 LOG_ERROR("Failed to load joint feedback valid fields");
00116 return false;
00117 }
00118
00119 if (!buffer->load(this->time_))
00120 {
00121 LOG_ERROR("Failed to load joint feedback time");
00122 return false;
00123 }
00124
00125 if (!this->positions_.load(buffer))
00126 {
00127 LOG_ERROR("Failed to load joint feedback positions");
00128 return false;
00129 }
00130
00131 if (!this->velocities_.load(buffer))
00132 {
00133 LOG_ERROR("Failed to load joint feedback velocities");
00134 return false;
00135 }
00136
00137 if (!this->accelerations_.load(buffer))
00138 {
00139 LOG_ERROR("Failed to load joint feedback accelerations");
00140 return false;
00141 }
00142
00143 LOG_COMM("Joint feedback successfully loaded");
00144 return true;
00145 }
00146
00147 bool JointFeedback::unload(industrial::byte_array::ByteArray *buffer)
00148 {
00149 LOG_COMM("Executing joint feedback unload");
00150
00151 if (!this->accelerations_.unload(buffer))
00152 {
00153 LOG_ERROR("Failed to unload joint feedback accelerations");
00154 return false;
00155 }
00156
00157 if (!this->velocities_.unload(buffer))
00158 {
00159 LOG_ERROR("Failed to unload joint feedback velocities");
00160 return false;
00161 }
00162
00163 if (!this->positions_.unload(buffer))
00164 {
00165 LOG_ERROR("Failed to unload joint feedback positions");
00166 return false;
00167 }
00168
00169 if (!buffer->unload(this->time_))
00170 {
00171 LOG_ERROR("Failed to unload joint feedback time");
00172 return false;
00173 }
00174
00175 if (!buffer->unload(this->valid_fields_))
00176 {
00177 LOG_ERROR("Failed to unload joint feedback valid fields");
00178 return false;
00179 }
00180
00181 if (!buffer->unload(this->robot_id_))
00182 {
00183 LOG_ERROR("Faild to unload joint feedback robot_id");
00184 return false;
00185 }
00186
00187 LOG_COMM("Joint feedback successfully unloaded");
00188 return true;
00189 }
00190
00191 }
00192 }
00193