概述
JointTrajPt类封装了机器人关节轨迹数据,功能是作为一条trajectory上的某一个中间点,旨在模仿ROS中的JointTrajectoryPoint类型的消息,不同之处在于:关节velocity数据是一个单独的值,而ROS中是一个float64类型的数组,duration参数代表的是本轨迹点运动所持续的时间,而ROS中指的是从轨迹开始后计算的时间。
namespace industrial
{
namespace joint_traj_pt
{
namespace SpecialSeqValues
{
enum SpecialSeqValue
{
START_TRAJECTORY_DOWNLOAD = -1, //Downloading模式的轨迹开始信号
START_TRAJECOTRY_STREAMING = -2, //deprecated
START_TRAJECTORY_STREAMING = -2, //Streaming模式的轨迹开始信号
END_TRAJECTORY = -3, //Downloading模式的轨迹结束信号
STOP_TRAJECTORY = -4 //要求控制器尽快停止运动
};
}
typedef SpecialSeqValues::SpecialSeqValue SpecialSeqValue;
class JointTrajPt : public industrial::simple_serialize::SimpleSerialize
{
public:
JointTrajPt(void);
~JointTrajPt(void);
void init();
//初始化,创建完整的轨迹点
void init(industrial::shared_types::shared_int sequence, industrial::joint_data::JointData & position,
industrial::shared_types::shared_real velocity, industrial::shared_types::shared_real duration);
void setJointPosition(industrial::joint_data::JointData &position)
{
this->joint_position_.copyFrom(position);
}
void getJointPosition(industrial::joint_data::JointData &dest)
{
dest.copyFrom(this->joint_position_);
}
void setSequence(industrial::shared_types::shared_int sequence)
{
this->sequence_ = sequence;
}
industrial::shared_types::shared_int getSequence()
{
return this->sequence_;
}
void setVelocity(industrial::shared_types::shared_real velocity)
{
this->velocity_ = velocity;
}
industrial::shared_types::shared_real getVelocity()
{
return this->velocity_;
}
void setDuration(industrial::shared_types::shared_real duration)
{
this->duration_ = duration;
}
industrial::shared_types::shared_real getDuration()
{
return this->duration_;
}
void copyFrom(JointTrajPt &src);
bool operator==(JointTrajPt &rhs);
// Overrides - SimpleSerialize
bool load(industrial::byte_array::ByteArray *buffer);
bool unload(industrial::byte_array::ByteArray *buffer);
unsigned int byteLength()
{
return sizeof(industrial::shared_types::shared_real) + sizeof(industrial::shared_types::shared_int)
+ this->joint_position_.byteLength();
}
private:
//关节位置
industrial::joint_data::JointData joint_position_;
//关节速度
industrial::shared_types::shared_real velocity_;
//轨迹序号
industrial::shared_types::shared_int sequence_;
//本路径点所需的时间
industrial::shared_types::shared_real duration_;
};
}
}
里面的各个方法和上一篇中的JointData是类似的,不再列举说明。