joint_traj_pt_full.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  * Copyright (c) 2013, Southwest Research Institute
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are met:
00009  *
00010  *      * Redistributions of source code must retain the above copyright
00011  *      notice, this list of conditions and the following disclaimer.
00012  *      * Redistributions in binary form must reproduce the above copyright
00013  *      notice, this list of conditions and the following disclaimer in the
00014  *      documentation and/or other materials provided with the distribution.
00015  *      * Neither the name of the Southwest Research Institute, nor the names
00016  *      of its contributors may be used to endorse or promote products derived
00017  *      from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00023  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029  * POSSIBILITY OF SUCH DAMAGE.
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;  // must happen after others are set
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 


simple_message
Author(s): Shaun Edwards
autogenerated on Fri Aug 28 2015 11:11:56