14 #include <boost/make_shared.hpp> 20 return ros::Time(time.sec(), time.nsec());
23 sensor_msgs::ImuPtr
toRosImu(
const roboception::msgs::Imu& imu)
25 auto rosImu = boost::make_shared<sensor_msgs::Imu>();
26 rosImu->header.frame_id =
"imu";
27 rosImu->header.stamp =
toRosTime(imu.timestamp());
28 rosImu->orientation_covariance[0] = -1;
29 rosImu->angular_velocity.x = imu.angular_velocity().x();
30 rosImu->angular_velocity.y = imu.angular_velocity().y();
31 rosImu->angular_velocity.z = imu.angular_velocity().z();
32 rosImu->linear_acceleration.x = imu.linear_acceleration().x();
33 rosImu->linear_acceleration.y = imu.linear_acceleration().y();
34 rosImu->linear_acceleration.z = imu.linear_acceleration().z();
39 geometry_msgs::PosePtr
toRosPose(
const roboception::msgs::Pose& pose)
41 auto rosPose = boost::make_shared<geometry_msgs::Pose>();
42 rosPose->position.x = pose.position().x();
43 rosPose->position.y = pose.position().y();
44 rosPose->position.z = pose.position().z();
45 rosPose->orientation.x = pose.orientation().x();
46 rosPose->orientation.y = pose.orientation().y();
47 rosPose->orientation.z = pose.orientation().z();
48 rosPose->orientation.w = pose.orientation().w();
54 auto protoPoseStamped = frame.pose();
55 auto protoPosePose = protoPoseStamped.pose();
57 auto rosPose = boost::make_shared<geometry_msgs::PoseStamped>();
58 rosPose->header.frame_id = frame.parent();
59 rosPose->header.stamp =
toRosTime(protoPoseStamped.timestamp());
60 rosPose->pose.position.x = protoPosePose.position().x();
61 rosPose->pose.position.y = protoPosePose.position().y();
62 rosPose->pose.position.z = protoPosePose.position().z();
63 rosPose->pose.orientation.x = protoPosePose.orientation().x();
64 rosPose->pose.orientation.y = protoPosePose.orientation().y();
65 rosPose->pose.orientation.z = protoPosePose.orientation().z();
66 rosPose->pose.orientation.w = protoPosePose.orientation().w();
70 geometry_msgs::PoseStampedPtr
toRosPoseStamped(
const roboception::msgs::Pose& pose,
const roboception::msgs::Time& time,
71 const std::string& frame_id)
73 auto rosPose = boost::make_shared<geometry_msgs::PoseStamped>();
74 rosPose->header.frame_id = frame_id;
76 rosPose->pose.position.x = pose.position().x();
77 rosPose->pose.position.y = pose.position().y();
78 rosPose->pose.position.z = pose.position().z();
79 rosPose->pose.orientation.x = pose.orientation().x();
80 rosPose->pose.orientation.y = pose.orientation().y();
81 rosPose->pose.orientation.z = pose.orientation().z();
82 rosPose->pose.orientation.w = pose.orientation().w();
88 auto protoPoseStamped = frame.pose();
89 auto protoPosePose = protoPoseStamped.pose();
90 auto protoCov = protoPosePose.covariance();
92 auto rosPose = boost::make_shared<geometry_msgs::PoseWithCovarianceStamped>();
93 rosPose->header.frame_id = frame.parent();
94 rosPose->header.stamp =
toRosTime(protoPoseStamped.timestamp());
95 rosPose->pose.pose.position.x = protoPosePose.position().x();
96 rosPose->pose.pose.position.y = protoPosePose.position().y();
97 rosPose->pose.pose.position.z = protoPosePose.position().z();
98 rosPose->pose.pose.orientation.x = protoPosePose.orientation().x();
99 rosPose->pose.pose.orientation.y = protoPosePose.orientation().y();
100 rosPose->pose.pose.orientation.z = protoPosePose.orientation().z();
101 rosPose->pose.pose.orientation.w = protoPosePose.orientation().w();
102 for (
int i = 0; i < protoCov.size(); i++)
104 rosPose->pose.covariance[i] = protoCov.Get(i);
112 transform.
setOrigin(
tf::Vector3(pose.position().x(), pose.position().y(), pose.position().z()));
114 tf::Quaternion(pose.orientation().x(), pose.orientation().y(), pose.orientation().z(), pose.orientation().w()));
121 frame.parent(), frame.name());
geometry_msgs::PoseStampedPtr toRosPoseStamped(const roboception::msgs::Frame &frame)
tf::Transform toRosTfTransform(const roboception::msgs::Pose &pose)
sensor_msgs::ImuPtr toRosImu(const roboception::msgs::Imu &imu)
geometry_msgs::PosePtr toRosPose(const roboception::msgs::Pose &pose)
ros::Time toRosTime(const roboception::msgs::Time &time)
geometry_msgs::PoseWithCovarianceStampedPtr toRosPoseWithCovarianceStamped(const roboception::msgs::Frame &frame)
tf::StampedTransform toRosTfStampedTransform(const roboception::msgs::Frame &frame)