30 #ifndef XPP_ROS_CONVERSIONS_H_ 31 #define XPP_ROS_CONVERSIONS_H_ 35 #include <xpp_msgs/StateLin3d.h> 36 #include <xpp_msgs/State6d.h> 37 #include <xpp_msgs/RobotStateCartesian.h> 38 #include <xpp_msgs/RobotStateCartesianTrajectory.h> 54 ToXpp(
const xpp_msgs::StateLin3d& ros)
57 point.
p_.x() = ros.pos.x;
58 point.
p_.y() = ros.pos.y;
59 point.
p_.z() = ros.pos.z;
61 point.
v_.x() = ros.vel.x;
62 point.
v_.y() = ros.vel.y;
63 point.
v_.z() = ros.vel.z;
65 point.
a_.x() = ros.acc.x;
66 point.
a_.y() = ros.acc.y;
67 point.
a_.z() = ros.acc.z;
72 static xpp_msgs::StateLin3d
75 xpp_msgs::StateLin3d ros;
76 ros.pos.x = xpp.
p_.x();
77 ros.pos.y = xpp.
p_.y();
78 ros.pos.z = xpp.
p_.z();
80 ros.vel.x = xpp.
v_.x();
81 ros.vel.y = xpp.
v_.y();
82 ros.vel.z = xpp.
v_.z();
84 ros.acc.x = xpp.
a_.x();
85 ros.acc.y = xpp.
a_.y();
86 ros.acc.z = xpp.
a_.z();
96 vec << ros.x, ros.y, ros.z;
118 for (
auto ee :
xpp.GetEEsOrdered())
125 ToXpp(
const geometry_msgs::Quaternion ros)
136 static geometry_msgs::Quaternion
139 geometry_msgs::Quaternion ros;
148 static xpp_msgs::State6d
151 xpp_msgs::State6d msg;
153 msg.pose.position = ToRos<geometry_msgs::Point>(xpp.
lin.
p_);
154 msg.twist.linear = ToRos<geometry_msgs::Vector3>(xpp.
lin.
v_);
155 msg.accel.linear = ToRos<geometry_msgs::Vector3>(xpp.
lin.
a_);
158 msg.twist.angular = ToRos<geometry_msgs::Vector3>(xpp.
ang.
w);
159 msg.accel.angular = ToRos<geometry_msgs::Vector3>(xpp.
ang.
wd);
180 static xpp_msgs::RobotStateCartesian
183 xpp_msgs::RobotStateCartesian ros;
186 ros.time_from_start = ros::Duration(xpp.
t_global_);
191 ros.ee_forces. push_back(ToRos<geometry_msgs::Vector3>(xpp.
ee_forces_.
at(ee)));
198 ToXpp(
const xpp_msgs::RobotStateCartesian& ros)
201 int n_ee = ros.ee_motion.size();
205 xpp.
t_global_ = ros.time_from_start.toSec();
216 static xpp_msgs::RobotStateCartesianTrajectory
219 xpp_msgs::RobotStateCartesianTrajectory msg;
221 for (
const auto state : xpp) {
222 auto state_msg =
ToRos(state);
223 msg.points.push_back(state_msg);
229 static std::vector<RobotStateCartesian>
230 ToXpp(
const xpp_msgs::RobotStateCartesianTrajectory& ros)
232 std::vector<RobotStateCartesian> xpp_vec;
234 for (
const auto ros_state : ros.points) {
236 xpp_vec.push_back(
xpp);
Quaterniond q
orientation expressed as Quaternion.
static geometry_msgs::Quaternion ToRos(const Eigen::Quaterniond xpp)
static xpp_msgs::StateLin3d ToRos(const StateLin3d &xpp)
T & at(EndeffectorID ee)
Read/write access to the endeffector stored at index ee.
static T ToRos(const Vector3d &xpp)
static std::vector< RobotStateCartesian > ToXpp(const xpp_msgs::RobotStateCartesianTrajectory &ros)
Defines a complete robot state in Cartesian space.
static xpp_msgs::RobotStateCartesianTrajectory ToRos(const std::vector< RobotStateCartesian > &xpp)
EndeffectorsMotion ee_motion_
static xpp_msgs::RobotStateCartesian ToRos(const RobotStateCartesian &xpp)
VectorXd a_
position, velocity and acceleration
StateAng3d ang
Quaternion, velocity and acceleration.
Eigen::Quaterniond Quaterniond
Vector3d w
angular velocity (omega).
6D-State (linear+angular) of an object in 3-dimensional space, where the angular part is expressed by...
StateLin3d lin
linear position, velocity and acceleration
static State3d ToXpp(const xpp_msgs::State6d &ros)
Converts between xpp-states types and xpp-messages.
static RobotStateCartesian ToXpp(const xpp_msgs::RobotStateCartesian &ros)
static xpp_msgs::State6d ToRos(const State3d &xpp)
Vector3d wd
angular acceleration (omega dot).
std::vector< EndeffectorID > GetEEsOrdered() const
static Endeffectors< Vector3d > ToXpp(const std::vector< T > &ros)
static Eigen::Quaterniond ToXpp(const geometry_msgs::Quaternion ros)
Endeffectors< Vector3d > ee_forces_
EndeffectorsContact ee_contact_
static Vector3d ToXpp(const T &ros)
static StateLin3d ToXpp(const xpp_msgs::StateLin3d &ros)