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