14 if (std::isnan(rotation.getAngle()))
19 auto rotationAxis = rotation.
getAxis();
25 return (!std::isnan(vector.x()) && !std::isnan(vector.y()) && !std::isnan(vector.z()));
28 bool isValid(geometry_msgs::Transform
const& pose)
38 if (node.path.find(
"ViewPose") == std::string::npos)
47 node[itmTranslation][0] = origin.x() * 1000;
50 node[itmTranslation][1] = origin.y() * 1000;
51 node[itmTranslation][2] = origin.z() * 1000;
54 node[itmRotation][itmAngle] = rotation.
getAngle();
56 auto rotationAxis = rotation.getAxis();
57 node[itmRotation][itmAxis][0] = rotationAxis.x();
58 node[itmRotation][itmAxis][1] = rotationAxis.y();
59 node[itmRotation][itmAxis][2] = rotationAxis.z();
63 ROS_ERROR(
"Given is pose is not valid for writing to the NxLib. Using identity transform");
65 node[itmTranslation][0] = 0;
66 node[itmTranslation][1] = 0;
67 node[itmTranslation][2] = 0;
69 node[itmRotation][itmAngle] = 0;
70 node[itmRotation][itmAxis][0] = 1;
71 node[itmRotation][itmAxis][1] = 0;
72 node[itmRotation][itmAxis][2] = 0;
80 origin.setX(node[itmTranslation][0].asDouble() / 1000);
85 origin.setY(node[itmTranslation][1].asDouble() / 1000);
86 origin.setZ(node[itmTranslation][2].asDouble() / 1000);
89 tf2::Vector3 rotationAxis(node[itmRotation][itmAxis][0].asDouble(), node[itmRotation][itmAxis][1].asDouble(),
90 node[itmRotation][itmAxis][2].asDouble());
91 tf2::Quaternion rotation(rotationAxis, node[itmRotation][itmAngle].asDouble());
97 geometry_msgs::TransformStamped
poseFromNxLib(NxLibItem
const& node, std::string
const& parentFrame,
98 std::string
const& childFrame)
100 geometry_msgs::TransformStamped stampedTransform;
102 stampedTransform.header.frame_id = parentFrame;
103 stampedTransform.child_frame_id = childFrame;
107 return stampedTransform;
110 geometry_msgs::TransformStamped
transformFromPose(geometry_msgs::PoseStamped
const& pose, std::string
const& childFrame)
112 geometry_msgs::TransformStamped transform;
114 transform.transform.translation.x = pose.pose.position.x;
115 transform.transform.translation.y = pose.pose.position.y;
116 transform.transform.translation.z = pose.pose.position.z;
117 transform.transform.rotation = pose.pose.orientation;
119 transform.header.stamp = pose.header.stamp;
120 transform.header.frame_id = pose.header.frame_id;
121 transform.child_frame_id = childFrame;
128 geometry_msgs::PoseStamped pose;
130 pose.pose.position.x = transform.transform.translation.x;
131 pose.pose.position.y = transform.transform.translation.y;
132 pose.pose.position.z = transform.transform.translation.z;
133 pose.pose.orientation = transform.transform.rotation;
135 pose.header.stamp = transform.header.stamp;
136 pose.header.frame_id = transform.header.frame_id;
195 geometry_msgs::Pose pose;
197 pose.position.x = transform.
getOrigin().x();
198 pose.position.y = transform.
getOrigin().y();
199 pose.position.z = transform.
getOrigin().z();
205 std::string childFrame)
207 geometry_msgs::TransformStamped tStamped;
210 tStamped.header.frame_id = std::move(parentFrame);
211 tStamped.child_frame_id = std::move(childFrame);
218 std::string
const& targetFrame)
223 geometry_msgs::TransformStamped stTransform;
226 transform =
fromMsg(stTransform.transform);
tf2::Transform fromStampedMessage(geometry_msgs::TransformStamped const &tStamped)
geometry_msgs::Pose poseFromTransform(tf2::Transform const &transform)
tf2::Transform getLatestTransform(tf2_ros::Buffer const &tfBuffer, std::string const &cameraFrame, std::string const &targetFrame)
virtual geometry_msgs::TransformStamped lookupTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration timeout) const
geometry_msgs::TransformStamped fromTfTransform(tf2::Transform const &transform, std::string parentFrame, std::string childFrame)
geometry_msgs::TransformStamped transformFromPose(geometry_msgs::PoseStamped const &pose, std::string const &childFrame)
tf2::Transform fromMsg(geometry_msgs::Transform const &t)
tf2Scalar getAngle() const
geometry_msgs::PoseStamped stampedPoseFromTransform(geometry_msgs::TransformStamped const &transform)
bool isValid(tf2::Transform const &pose)
void writePoseToNxLib(tf2::Transform const &pose, NxLibItem const &node)
void convert(const A &a, B &b)
tf2::Transform poseFromNxLib(NxLibItem const &node)