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.h"
00033 #include "simple_message/shared_types.h"
00034 #include "simple_message/log_wrapper.h"
00035 #else
00036 #include "joint_traj_pt.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
00047 {
00048
00049 JointTrajPt::JointTrajPt(void)
00050 {
00051 this->init();
00052 }
00053 JointTrajPt::~JointTrajPt(void)
00054 {
00055
00056 }
00057
00058 void JointTrajPt::init()
00059 {
00060 this->joint_position_.init();
00061 this->sequence_ = 0;
00062 this->velocity_ = 0.0;
00063 this->duration_ = 0.0;
00064 }
00065
00066 void JointTrajPt::init(shared_int sequence, JointData & position, shared_real velocity, shared_real duration)
00067 {
00068 this->setJointPosition(position);
00069 this->setSequence(sequence);
00070 this->setVelocity(velocity);
00071 this->setDuration(duration);
00072 }
00073
00074 void JointTrajPt::copyFrom(JointTrajPt &src)
00075 {
00076 this->setSequence(src.getSequence());
00077 src.getJointPosition(this->joint_position_);
00078 this->setVelocity(src.getVelocity());
00079 this->setDuration(src.getDuration());
00080 }
00081
00082 bool JointTrajPt::operator==(JointTrajPt &rhs)
00083 {
00084 return this->joint_position_ == rhs.joint_position_ && this->sequence_ == rhs.sequence_
00085 && this->velocity_ == rhs.velocity_ && this->duration_ == rhs.duration_;
00086
00087 }
00088
00089 bool JointTrajPt::load(industrial::byte_array::ByteArray *buffer)
00090 {
00091 bool rtn = false;
00092
00093 LOG_COMM("Executing joint trajectory point load");
00094
00095 if (buffer->load(this->sequence_))
00096 {
00097 if (this->joint_position_.load(buffer))
00098 {
00099 if (buffer->load(this->velocity_))
00100 {
00101 if (buffer->load(this->duration_))
00102 {
00103 LOG_COMM("Trajectory point successfully loaded");
00104 rtn = true;
00105 }
00106 else
00107 {
00108 rtn = false;
00109 LOG_ERROR("Failed to load joint traj pt. duration");
00110 }
00111 rtn = true;
00112 }
00113 else
00114 {
00115 rtn = false;
00116 LOG_ERROR("Failed to load joint traj pt. velocity");
00117 }
00118
00119 }
00120 else
00121 {
00122 rtn = false;
00123 LOG_ERROR("Failed to load joint traj. pt. position data");
00124 }
00125 }
00126 else
00127 {
00128 rtn = false;
00129 LOG_ERROR("Failed to load joint traj. pt. sequence number");
00130 }
00131
00132 return rtn;
00133 }
00134
00135 bool JointTrajPt::unload(industrial::byte_array::ByteArray *buffer)
00136 {
00137 bool rtn = false;
00138
00139 LOG_COMM("Executing joint traj. pt. unload");
00140 if (buffer->unload(this->duration_))
00141 {
00142 if (buffer->unload(this->velocity_))
00143 {
00144 if (this->joint_position_.unload(buffer))
00145 {
00146 if (buffer->unload(this->sequence_))
00147 {
00148 rtn = true;
00149 LOG_COMM("Joint traj. pt successfully unloaded");
00150 }
00151 else
00152 {
00153 LOG_ERROR("Failed to unload joint traj. pt. sequence number");
00154 rtn = false;
00155 }
00156 }
00157 else
00158 {
00159 LOG_ERROR("Failed to unload joint traj. pt. position data");
00160 rtn = false;
00161 }
00162
00163 }
00164 else
00165 {
00166 LOG_ERROR("Failed to unload joint traj. pt. velocity");
00167 rtn = false;
00168 }
00169 }
00170 else
00171 {
00172 LOG_ERROR("Failed to unload joint traj. pt. duration");
00173 rtn = false;
00174 }
00175
00176 return rtn;
00177 }
00178
00179 }
00180 }
00181