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 }
00066
00067 void JointTrajPt::init(shared_int sequence, JointData & position, shared_real velocity)
00068 {
00069 this->setJointPosition(position);
00070 this->setSequence(sequence);
00071 this->setVelocity(velocity);
00072 }
00073
00074
00075 void JointTrajPt::copyFrom(JointTrajPt &src)
00076 {
00077 this->setSequence(src.getSequence());
00078 src.getJointPosition(this->joint_position_);
00079 this->setVelocity(src.getVelocity());
00080 }
00081
00082 bool JointTrajPt::operator==(JointTrajPt &rhs)
00083 {
00084 return this->joint_position_ == rhs.joint_position_ &&
00085 this->sequence_ == rhs.sequence_ &&
00086 this->velocity_ == rhs.velocity_;
00087
00088 }
00089
00090 bool JointTrajPt::load(industrial::byte_array::ByteArray *buffer)
00091 {
00092 bool rtn = false;
00093
00094 LOG_COMM("Executing joint trajectory point load");
00095
00096 if (buffer->load(this->sequence_))
00097 {
00098 if (this->joint_position_.load(buffer))
00099 {
00100 if (buffer->load(this->velocity_))
00101 {
00102 LOG_COMM("Trajectory point successfully loaded");
00103 rtn = true;
00104 }
00105 else
00106 {
00107 rtn = false;
00108 LOG_ERROR("Failed to load joint traj pt. velocity");
00109 }
00110
00111 }
00112 else
00113 {
00114 rtn = false;
00115 LOG_ERROR("Failed to load joint traj. pt. position data");
00116 }
00117 }
00118 else
00119 {
00120 rtn = false;
00121 LOG_ERROR("Failed to load joint traj. pt. sequence number");
00122 }
00123
00124 return rtn;
00125 }
00126
00127 bool JointTrajPt::unload(industrial::byte_array::ByteArray *buffer)
00128 {
00129 bool rtn = false;
00130
00131 LOG_COMM("Executing joint traj. pt. unload");
00132 if (buffer->unload(this->velocity_))
00133 {
00134 if(this->joint_position_.unload(buffer))
00135 {
00136 if (buffer->unload(this->sequence_))
00137 {
00138 rtn = true;
00139 LOG_COMM("Joint traj. pt successfully unloaded");
00140 }
00141 else
00142 {
00143 LOG_ERROR("Failed to unload joint traj. pt. sequence number");
00144 rtn = false;
00145 }
00146 }
00147 else
00148 {
00149 LOG_ERROR("Failed to unload joint traj. pt. position data");
00150 rtn = false;
00151 }
00152
00153 }
00154 else
00155 {
00156 LOG_ERROR("Failed to unload joint traj. pt. velocity");
00157 rtn = false;
00158 }
00159
00160 return rtn;
00161 }
00162
00163 }
00164 }
00165