9 bool isValid(tf2::Vector3
const& vector)
11 return (!std::isnan(vector.x()) && !std::isnan(vector.y()) && !std::isnan(vector.z()));
14 tf2Scalar fixZeroValue(
double value,
double epsilon = 0.00001)
16 if (std::abs(value) <= epsilon)
23 tf2::Vector3 vector3FromNxLib(NxLibItem
const& node)
25 double x = node[0].asDouble();
26 double y = node[1].asDouble();
27 double z = node[2].asDouble();
41 if (std::isnan(rotation.getAngle()))
46 auto rotationAxis = rotation.
getAxis();
64 tf2::Vector3 origin(fixZeroValue(transform.
getOrigin().getX()), fixZeroValue(transform.
getOrigin().getY()),
65 fixZeroValue(transform.
getOrigin().getZ()));
75 if (node.path.find(
"ViewPose") == std::string::npos)
86 node[itmTranslation][0] = origin.x();
87 node[itmTranslation][1] = origin.y();
88 node[itmTranslation][2] = origin.z();
91 node[itmRotation][itmAngle] = rotation.
getAngle();
93 auto rotationAxis = rotation.getAxis();
94 node[itmRotation][itmAxis][0] = rotationAxis.x();
95 node[itmRotation][itmAxis][1] = rotationAxis.y();
96 node[itmRotation][itmAxis][2] = rotationAxis.z();
100 ENSENSO_ERROR(
"Given transform is not valid for writing to the NxLib, using identity transform instead");
102 node[itmTranslation][0] = 0;
103 node[itmTranslation][1] = 0;
104 node[itmTranslation][2] = 0;
106 node[itmRotation][itmAngle] = 0;
107 node[itmRotation][itmAxis][0] = 1;
108 node[itmRotation][itmAxis][1] = 0;
109 node[itmRotation][itmAxis][2] = 0;
117 pose.orientation = transform.rotation;
118 pose.position.x = transform.translation.x;
119 pose.position.y = transform.translation.y;
120 pose.position.z = transform.translation.z;
125 transform.rotation = pose.orientation;
126 transform.translation.x = pose.position.x;
127 transform.translation.y = pose.position.y;
128 transform.translation.z = pose.position.z;
134 pose.header = transform.header;
140 transform.header = pose.header;
149 tf2::Vector3 origin = vector3FromNxLib(node[itmTranslation]);
153 tf2::Quaternion rotation(vector3FromNxLib(node[itmRotation][itmAxis]), node[itmRotation][itmAngle].asDouble());
167 stampedPose.header.frame_id = parentFrame;
168 stampedPose.header.stamp = timestamp;
177 transform.child_frame_id = childFrame;
244 tStamped.header.stamp = timestamp;
245 tStamped.header.frame_id = std::move(parentFrame);
246 tStamped.child_frame_id = std::move(childFrame);
252 std::string
const& targetFrame)
260 transform =
fromMsg(tStamped.transform);
bool isValid(tf2::Transform const &transform)
void ENSENSO_ERROR(T... args)
static const Matrix3x3 & getIdentity()
tf2::Transform getLatestTransform(tf2_ros::Buffer const &tfBuffer, std::string const &cameraFrame, std::string const &targetFrame)
StampedPoseMsg stampedPoseFromNxLib(NxLibItem const &node, std::string const &parentFrame, ensenso::ros::Time timestamp)
void writeTransformToNxLib(tf2::Transform const &transform, NxLibItem const &node)
geometry_msgs::msg::TransformStamped StampedTransformMsg
tf2::Transform transformFromNxLib(NxLibItem const &node)
bool isIdentity(tf2::Transform const &transform)
StampedPoseMsg poseFromTransform(StampedTransformMsg const &transform)
geometry_msgs::msg::Pose PoseMsg
geometry_msgs::TransformStamped t
tf2Scalar getAngle() const
geometry_msgs::msg::PoseStamped StampedPoseMsg
void convertMsg(TransformMsg const &transform, PoseMsg &pose)
virtual geometry_msgs::TransformStamped lookupTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration timeout) const
StampedTransformMsg fromTf(tf2::Transform const &transform, std::string parentFrame, std::string childFrame, ensenso::ros::Time timestamp)
void fromMsg(const A &, B &b)
TF2SIMD_FORCE_INLINE const Vector3 & getRow(int i) const
void ENSENSO_WARN(T... args)
void convert(const A &a, B &b)
tf2::Transform fromMsg(StampedTransformMsg const &tStamped)
geometry_msgs::msg::Transform TransformMsg
StampedTransformMsg transformFromPose(StampedPoseMsg const &pose, std::string const &childFrame)