joint_traj_pt_full.h
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 
00032 #ifndef JOINT_TRAJ_PT_FULL_H
00033 #define JOINT_TRAJ_PT_FULL_H
00034 
00035 #ifndef FLATHEADERS
00036 #include "simple_message/joint_data.h"
00037 #include "simple_message/simple_message.h"
00038 #include "simple_message/simple_serialize.h"
00039 #include "simple_message/shared_types.h"
00040 #else
00041 #include "joint_data.h"
00042 #include "simple_message.h"
00043 #include "simple_serialize.h"
00044 #include "shared_types.h"
00045 #endif
00046 
00047 namespace industrial
00048 {
00049 namespace joint_traj_pt_full
00050 {
00051 
00052 namespace SpecialSeqValues
00053 {
00054 enum SpecialSeqValue
00055 {
00056   START_TRAJECTORY_DOWNLOAD = -1, START_TRAJECOTRY_STREAMING = -2, END_TRAJECTORY = -3, STOP_TRAJECTORY = -4
00057 };
00058 }
00059 typedef SpecialSeqValues::SpecialSeqValue SpecialSeqValue;
00060 
00061 namespace ValidFieldTypes
00062 {
00063 enum ValidFieldType
00064 {
00065   TIME = 0x01, POSITION = 0x02, VELOCITY = 0x04, ACCELERATION = 0x08
00066 };
00067 }
00068 typedef ValidFieldTypes::ValidFieldType ValidFieldType;
00069 
00096 class JointTrajPtFull : public industrial::simple_serialize::SimpleSerialize
00097 {
00098 public:
00099 
00106   JointTrajPtFull(void);
00111   ~JointTrajPtFull(void);
00112 
00117   void init();
00118 
00123   void init(industrial::shared_types::shared_int robot_id,
00124             industrial::shared_types::shared_int sequence,
00125             industrial::shared_types::shared_int valid_fields,
00126             industrial::shared_types::shared_real time,
00127             industrial::joint_data::JointData & positions,
00128             industrial::joint_data::JointData & velocities,
00129             industrial::joint_data::JointData & accelerations);
00130 
00137   void setRobotID(industrial::shared_types::shared_int robot_id)
00138   {
00139     this->robot_id_ = robot_id;
00140   }
00141 
00148   industrial::shared_types::shared_int getRobotID()
00149   {
00150     return this->robot_id_;
00151   }
00152 
00158   void setSequence(industrial::shared_types::shared_int sequence)
00159   {
00160     this->sequence_ = sequence;
00161   }
00162 
00168   industrial::shared_types::shared_int getSequence()
00169   {
00170     return this->sequence_;
00171   }
00172 
00178   void setTime(industrial::shared_types::shared_real time)
00179   {
00180     this->time_ = time;
00181     this->valid_fields_ |= ValidFieldTypes::TIME;  // set the bit
00182   }
00183 
00190   bool getTime(industrial::shared_types::shared_real & time)
00191   {
00192     time = this->time_;
00193     return is_valid(ValidFieldTypes::TIME);
00194   }
00195 
00199   void clearTime()
00200   {
00201     this->time_ = 0;
00202     this->valid_fields_ &= ~ValidFieldTypes::TIME;  // clear the bit
00203   }
00204 
00210   void setPositions(industrial::joint_data::JointData &positions)
00211   {
00212     this->positions_.copyFrom(positions);
00213     this->valid_fields_ |= ValidFieldTypes::POSITION;  // set the bit
00214   }
00215 
00222   bool getPositions(industrial::joint_data::JointData &dest)
00223   {
00224     dest.copyFrom(this->positions_);
00225     return is_valid(ValidFieldTypes::POSITION);
00226   }
00227 
00231   void clearPositions()
00232   {
00233     this->positions_.init();
00234     this->valid_fields_ &= ~ValidFieldTypes::POSITION;  // clear the bit
00235   }
00236 
00242   void setVelocities(industrial::joint_data::JointData &velocities)
00243   {
00244     this->velocities_.copyFrom(velocities);
00245     this->valid_fields_ |= ValidFieldTypes::VELOCITY;  // set the bit
00246   }
00247 
00254   bool getVelocities(industrial::joint_data::JointData &dest)
00255   {
00256     dest.copyFrom(this->velocities_);
00257     return is_valid(ValidFieldTypes::VELOCITY);
00258   }
00259 
00263   void clearVelocities()
00264   {
00265     this->velocities_.init();
00266     this->valid_fields_ &= ~ValidFieldTypes::VELOCITY;  // clear the bit
00267   }
00273   void setAccelerations(industrial::joint_data::JointData &accelerations)
00274   {
00275     this->accelerations_.copyFrom(accelerations);
00276     this->valid_fields_ |= ValidFieldTypes::ACCELERATION;  // set the bit
00277   }
00278 
00285   bool getAccelerations(industrial::joint_data::JointData &dest)
00286   {
00287     dest.copyFrom(this->accelerations_);
00288     return is_valid(ValidFieldTypes::ACCELERATION);
00289   }
00290 
00294   void clearAccelerations()
00295   {
00296     this->accelerations_.init();
00297     this->valid_fields_ &= ~ValidFieldTypes::ACCELERATION;  // clear the bit
00298   }
00299 
00300 
00306   void copyFrom(JointTrajPtFull &src);
00307 
00313   bool operator==(JointTrajPtFull &rhs);
00314 
00320   bool is_valid(ValidFieldType field)
00321   {
00322     return valid_fields_ & field;
00323   }
00324 
00325   // Overrides - SimpleSerialize
00326   bool load(industrial::byte_array::ByteArray *buffer);
00327   bool unload(industrial::byte_array::ByteArray *buffer);
00328   unsigned int byteLength()
00329   {
00330     return 3*sizeof(industrial::shared_types::shared_int) + sizeof(industrial::shared_types::shared_real)
00331         + 3*this->positions_.byteLength();
00332   }
00333 
00334 private:
00335 
00339   industrial::shared_types::shared_int robot_id_;
00343   industrial::shared_types::shared_int sequence_;
00348   industrial::shared_types::shared_int valid_fields_;
00353   industrial::shared_types::shared_real time_;
00354 
00358   industrial::joint_data::JointData positions_;
00362   industrial::joint_data::JointData velocities_;  
00365   industrial::joint_data::JointData accelerations_;
00366 
00367 };
00368 
00369 }
00370 }
00371 
00372 #endif /* JOINT_TRAJ_PT_FULL_H */


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