15 #include <Eigen/Eigen> 25 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
29 : num_joints_(num_joints),
30 base_position_(Eigen::Vector3d::Zero()),
31 joint_positions_(Eigen::VectorXd(num_joints).setZero()),
32 base_orientation_(Eigen::Quaternion<double>::Identity())
36 Eigen::Vector3d& basePosition() {
return base_position_; }
37 Eigen::VectorXd& jointPositions() {
return joint_positions_; }
38 Eigen::Quaternion<double>& baseOrientation() {
return base_orientation_; }
40 const Eigen::Vector3d& basePosition()
const {
return base_position_; }
41 const Eigen::VectorXd& jointPositions()
const {
return joint_positions_; }
42 const Eigen::Quaternion<double>& baseOrientation()
const {
return base_orientation_; }
43 const Eigen::Vector4d pyBaseOrientation()
const {
return Eigen::Vector4d(base_orientation_.x(), base_orientation_.y(), base_orientation_.z(), base_orientation_.w()); }
45 void basePosition(
const Eigen::Vector3d& base_position) { base_position_ = base_position; }
46 void jointPositions(
const Eigen::VectorXd& joint_positions) { joint_positions_ = joint_positions; }
47 void baseOrientation(
const Eigen::Quaternion<double>& base_orientation) { base_orientation_ = base_orientation; }
48 void pyBaseOrientation(
const Eigen::Vector4d base_orientation) { base_orientation_ = Eigen::Quaternion<double>(base_orientation[3], base_orientation[0], base_orientation[1], base_orientation[2]); }
50 Eigen::VectorXd generalizedJointPositions()
const 52 Eigen::VectorXd generalized_joint_positions(num_joints_+7);
53 generalized_joint_positions.head(3) = base_position_;
54 generalized_joint_positions.tail(num_joints_) = joint_positions_;
55 generalized_joint_positions.segment<4>(3) = Eigen::Vector4d(base_orientation_.x(), base_orientation_.y(), base_orientation_.z(), base_orientation_.w());
56 return generalized_joint_positions;
59 std::string toString()
const;
60 friend std::ostream& operator<<(std::ostream &os,
const RobotPosture& obj) {
return os << obj.toString(); }
64 Eigen::Vector3d base_position_;
65 Eigen::VectorXd joint_positions_;
66 Eigen::Quaternion<double> base_orientation_;
73 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
77 : num_joints_(num_joints),
78 generalized_joint_velocities_(Eigen::VectorXd(num_joints+6).setZero())
82 Eigen::VectorXd& generalizedJointVelocities() {
return generalized_joint_velocities_; }
83 Eigen::Ref<Eigen::Vector3d> baseLinearVelocity() {
return generalized_joint_velocities_.segment<3>(0); }
84 Eigen::Ref<Eigen::Vector3d> baseAngularVelocity() {
return generalized_joint_velocities_.segment<3>(3); }
85 Eigen::Ref<Eigen::VectorXd> jointVelocities() {
return generalized_joint_velocities_.tail(num_joints_); }
87 const Eigen::VectorXd& generalizedJointVelocities()
const {
return generalized_joint_velocities_; }
88 const Eigen::Ref<const Eigen::Vector3d> baseLinearVelocity()
const {
return generalized_joint_velocities_.segment<3>(0); }
89 const Eigen::Ref<const Eigen::Vector3d> baseAngularVelocity()
const {
return generalized_joint_velocities_.segment<3>(3); }
90 const Eigen::Ref<const Eigen::VectorXd> jointVelocities()
const {
return generalized_joint_velocities_.tail(num_joints_); }
92 void generalizedJointVelocities(
const Eigen::VectorXd& generalized_joint_velocities) { generalized_joint_velocities_ = generalized_joint_velocities; }
93 void jointVelocities(
const Eigen::Ref<const Eigen::VectorXd> joint_velocities) { generalized_joint_velocities_.tail(num_joints_) = joint_velocities; }
94 void baseLinearVelocity(
const Eigen::Ref< const Eigen::Vector3d> base_linear_velocity) { generalized_joint_velocities_.segment<3>(0) = base_linear_velocity; }
95 void baseAngularVelocity(
const Eigen::Ref<const Eigen::Vector3d> base_angular_velocity) { generalized_joint_velocities_.segment<3>(3) = base_angular_velocity; }
97 std::string toString()
const;
98 friend std::ostream& operator<<(std::ostream &os,
const RobotVelocity& obj) {
return os << obj.toString(); }
102 Eigen::VectorXd generalized_joint_velocities_;
109 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
113 : num_joints_(num_joints),
114 generalized_joint_accelerations_(Eigen::VectorXd(num_joints+6).setZero())
118 Eigen::VectorXd& generalizedJointAccelerations() {
return generalized_joint_accelerations_; }
119 Eigen::Ref<Eigen::Vector3d> baseLinearAcceleration() {
return generalized_joint_accelerations_.segment<3>(0); }
120 Eigen::Ref<Eigen::Vector3d> baseAngularAcceleration() {
return generalized_joint_accelerations_.segment<3>(3); }
121 Eigen::Ref<Eigen::VectorXd> jointAccelerations() {
return generalized_joint_accelerations_.tail(num_joints_); }
123 const Eigen::VectorXd& generalizedJointAccelerations()
const {
return generalized_joint_accelerations_; }
124 const Eigen::Ref<const Eigen::Vector3d> baseLinearAcceleration()
const {
return generalized_joint_accelerations_.segment<3>(0); }
125 const Eigen::Ref<const Eigen::Vector3d> baseAngularAcceleration()
const {
return generalized_joint_accelerations_.segment<3>(3); }
126 const Eigen::Ref<const Eigen::VectorXd> jointAccelerations()
const {
return generalized_joint_accelerations_.tail(num_joints_); }
128 void generalizedJointAccelerations(
const Eigen::VectorXd& generalized_joint_accelerations) { generalized_joint_accelerations_ = generalized_joint_accelerations; }
129 void jointAccelerations(
const Eigen::Ref<const Eigen::VectorXd> joint_accelerations) { generalized_joint_accelerations_.tail(num_joints_) = joint_accelerations; }
130 void baseLinearAcceleration(
const Eigen::Ref< const Eigen::Vector3d> base_linear_acceleration) { generalized_joint_accelerations_.segment<3>(0) = base_linear_acceleration; }
131 void baseAngularAcceleration(
const Eigen::Ref<const Eigen::Vector3d> base_angular_acceleration) { generalized_joint_accelerations_.segment<3>(3) = base_angular_acceleration; }
133 std::string toString()
const;
134 friend std::ostream& operator<<(std::ostream &os,
const RobotAcceleration& obj) {
return os << obj.toString(); }
138 Eigen::VectorXd generalized_joint_accelerations_;
153 Eigen::Vector3d& centerOfMass() {
return com_; }
154 Eigen::Vector3d& linearMomentum() {
return lmom_; }
155 Eigen::Vector3d& angularMomentum() {
return amom_; }
157 const Eigen::Vector3d& centerOfMass()
const {
return com_; }
158 const Eigen::Vector3d& linearMomentum()
const {
return lmom_; }
159 const Eigen::Vector3d& angularMomentum()
const {
return amom_; }
161 void centerOfMass(
const Eigen::Vector3d& com) { com_ = com; }
162 void linearMomentum(
const Eigen::Vector3d& lmom) { lmom_ = lmom; }
163 void angularMomentum(
const Eigen::Vector3d& amom) { amom_ = amom; }
170 const RobotPosture& robotPosture()
const {
return robot_posture_; }
171 const RobotVelocity& robotVelocity()
const {
return robot_velocity_; }
172 const RobotAcceleration& robotAcceleration()
const {
return robot_acceleration_; }
174 void robotPosture(
const RobotPosture& robot_posture) { robot_posture_ = robot_posture; }
175 void robotVelocity(
const RobotVelocity& robot_velocity) { robot_velocity_ = robot_velocity; }
176 void robotAcceleration(
const RobotAcceleration& robot_acceleration) { robot_acceleration_ = robot_acceleration; }
179 Eigen::Vector3d& endeffectorPosition(
int eff_id) {
return eff_positions_[eff_id]; }
180 Eigen::Vector3d& endeffectorVelocity(
int eff_id) {
return eff_velocities_[eff_id]; }
181 Eigen::Vector3d& endeffectorAcceleration(
int eff_id) {
return eff_accelerations_[eff_id]; }
182 Eigen::Quaternion<double>& endeffectorOrientation(
int eff_id) {
return eff_orientations_[eff_id]; }
184 const Eigen::Vector3d& endeffectorPosition(
int eff_id)
const {
return eff_positions_[eff_id]; }
185 const Eigen::Vector3d& endeffectorVelocity(
int eff_id)
const {
return eff_velocities_[eff_id]; }
186 const Eigen::Vector3d& endeffectorAcceleration(
int eff_id)
const {
return eff_accelerations_[eff_id]; }
187 const Eigen::Quaternion<double>& endeffectorOrientation(
int eff_id)
const {
return eff_orientations_[eff_id]; }
189 const std::vector<Eigen::Vector3d>& pyEndeffectorPositions()
const {
return eff_positions_; }
190 void pyEndeffectorPositions(
const std::vector<Eigen::Vector3d>& eff_positions) { eff_positions_ = eff_positions; }
193 std::string toString()
const;
194 const int numJoints()
const {
return num_joints_; }
195 friend std::ostream& operator<<(std::ostream &os,
const KinematicsState& obj) {
return os << obj.toString(); }
203 Eigen::Vector3d com_, lmom_, amom_;
204 std::vector<Eigen::Quaternion<double>> eff_orientations_;
205 std::vector<Eigen::Vector3d> eff_positions_, eff_velocities_, eff_accelerations_;
214 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
220 void clean() { kinematics_sequence_.clear(); }
221 void resize(
int num_timesteps,
int num_joints);
222 int size()
const {
return kinematics_sequence_.size(); }
224 const std::vector<KinematicsState>& kinematicsSequence()
const {
return kinematics_sequence_; }
225 void kinematicsSequence(
const std::vector<KinematicsState>& kinematics_sequence) { kinematics_sequence_ = kinematics_sequence; }
227 KinematicsState& kinematicsState(
int time_id) {
return kinematics_sequence_[time_id]; }
228 const KinematicsState& kinematicsState(
int time_id)
const {
return kinematics_sequence_[time_id]; }
230 std::string toString()
const;
231 friend std::ostream& operator<<(std::ostream &os,
const KinematicsSequence& obj) {
return os << obj.toString(); }
234 std::vector<KinematicsState> kinematics_sequence_;
Definition: KinematicsState.hpp:106
This class is a container for a sequence of kinematic states.
Definition: KinematicsState.hpp:211
Definition: KinematicsState.hpp:22
Definition: KinematicsState.hpp:70
This class is a container for all variables required to define a kinematics state: joint posture...
Definition: KinematicsState.hpp:146