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_traj_pt_full.h"
00033 #include "simple_message/shared_types.h"
00034 #include "simple_message/log_wrapper.h"
00035 #else
00036 #include "joint_traj_pt_full.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_traj_pt_full
00047 {
00048
00049 JointTrajPtFull::JointTrajPtFull(void)
00050 {
00051 this->init();
00052 }
00053 JointTrajPtFull::~JointTrajPtFull(void)
00054 {
00055
00056 }
00057
00058 void JointTrajPtFull::init()
00059 {
00060 this->robot_id_ = 0;
00061 this->sequence_ = 0;
00062 this->valid_fields_ = 0;
00063 this->time_ = 0.0;
00064 this->positions_.init();
00065 this->velocities_.init();
00066 this->accelerations_.init();
00067 }
00068
00069 void JointTrajPtFull::init(industrial::shared_types::shared_int robot_id,
00070 industrial::shared_types::shared_int sequence,
00071 industrial::shared_types::shared_int valid_fields,
00072 industrial::shared_types::shared_real time,
00073 industrial::joint_data::JointData & positions,
00074 industrial::joint_data::JointData & velocities,
00075 industrial::joint_data::JointData & accelerations)
00076 {
00077 this->setRobotID(robot_id);
00078 this->setSequence(sequence);
00079 this->setTime(time);
00080 this->setPositions(positions);
00081 this->setVelocities(velocities);
00082 this->setAccelerations(accelerations);
00083 this->valid_fields_ = valid_fields;
00084 }
00085
00086 void JointTrajPtFull::copyFrom(JointTrajPtFull &src)
00087 {
00088 this->setRobotID(src.getRobotID());
00089 this->setSequence(src.getSequence());
00090 src.getTime(this->time_);
00091 src.getPositions(this->positions_);
00092 src.getVelocities(this->velocities_);
00093 src.getAccelerations(this->accelerations_);
00094 this->valid_fields_ = src.valid_fields_;
00095 }
00096
00097 bool JointTrajPtFull::operator==(JointTrajPtFull &rhs)
00098 {
00099 return this->robot_id_ == rhs.robot_id_ &&
00100 this->sequence_ == rhs.sequence_ &&
00101 this->valid_fields_ == rhs.valid_fields_ &&
00102 ( !is_valid(ValidFieldTypes::TIME) || (this->time_ == rhs.time_) ) &&
00103 ( !is_valid(ValidFieldTypes::POSITION) || (this->positions_ == rhs.positions_) ) &&
00104 ( !is_valid(ValidFieldTypes::VELOCITY) || (this->velocities_ == rhs.velocities_) ) &&
00105 ( !is_valid(ValidFieldTypes::ACCELERATION) || (this->accelerations_ == rhs.accelerations_) );
00106 }
00107
00108 bool JointTrajPtFull::load(industrial::byte_array::ByteArray *buffer)
00109 {
00110 LOG_COMM("Executing joint trajectory point load");
00111
00112 if (!buffer->load(this->robot_id_))
00113 {
00114 LOG_ERROR("Failed to load joint traj pt. robot_id");
00115 return false;
00116 }
00117
00118 if (!buffer->load(this->sequence_))
00119 {
00120 LOG_ERROR("Failed to load joint traj. pt. sequence number");
00121 return false;
00122 }
00123
00124 if (!buffer->load(this->valid_fields_))
00125 {
00126 LOG_ERROR("Failed to load joint traj. pt. valid fields");
00127 return false;
00128 }
00129
00130 if (!buffer->load(this->time_))
00131 {
00132 LOG_ERROR("Failed to load joint traj. pt. time");
00133 return false;
00134 }
00135
00136 if (!this->positions_.load(buffer))
00137 {
00138 LOG_ERROR("Failed to load joint traj. pt. positions");
00139 return false;
00140 }
00141
00142 if (!this->velocities_.load(buffer))
00143 {
00144 LOG_ERROR("Failed to load joint traj. pt. velocities");
00145 return false;
00146 }
00147
00148 if (!this->accelerations_.load(buffer))
00149 {
00150 LOG_ERROR("Failed to load joint traj. pt. accelerations");
00151 return false;
00152 }
00153
00154 LOG_COMM("Trajectory point successfully loaded");
00155 return true;
00156 }
00157
00158 bool JointTrajPtFull::unload(industrial::byte_array::ByteArray *buffer)
00159 {
00160 LOG_COMM("Executing joint traj. pt. unload");
00161
00162 if (!this->accelerations_.unload(buffer))
00163 {
00164 LOG_ERROR("Failed to unload joint traj. pt. accelerations");
00165 return false;
00166 }
00167
00168 if (!this->velocities_.unload(buffer))
00169 {
00170 LOG_ERROR("Failed to unload joint traj. pt. velocities");
00171 return false;
00172 }
00173
00174 if (!this->positions_.unload(buffer))
00175 {
00176 LOG_ERROR("Failed to unload joint traj. pt. positions");
00177 return false;
00178 }
00179
00180 if (!buffer->unload(this->time_))
00181 {
00182 LOG_ERROR("Failed to unload joint traj. pt. time");
00183 return false;
00184 }
00185
00186 if (!buffer->unload(this->valid_fields_))
00187 {
00188 LOG_ERROR("Failed to unload joint traj. pt. valid fields");
00189 return false;
00190 }
00191
00192 if (!buffer->unload(this->sequence_))
00193 {
00194 LOG_ERROR("Failed to unload joint traj. pt. sequence number");
00195 return false;
00196 }
00197
00198 if (!buffer->unload(this->robot_id_))
00199 {
00200 LOG_ERROR("Faild to unload joint traj. pt. robot_id");
00201 return false;
00202 }
00203
00204 LOG_COMM("Joint traj. pt successfully unloaded");
00205 return true;
00206 }
00207
00208 }
00209 }
00210