Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the reference frame configurable #4

Open
wants to merge 1 commit into
base: ros2_0_galactic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions param/xsens_mti_node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

# TF transform frame_id (default: imu_link), you may want to change it if you use multiple devices
frame_id: "imu_link"
reference_frame_id: "world"

# Message publishers
pub_imu: true
Expand Down
1 change: 1 addition & 0 deletions src/messagepublishers/packetcallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include <xstypes/xsdatapacket.h>

const char* DEFAULT_FRAME_ID = "imu_link";
const char* DEFAULT_REFERENCE_FRAME_ID = "world";

class PacketCallback
{
Expand Down
4 changes: 3 additions & 1 deletion src/messagepublishers/transformpublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ struct TransformPublisher : public PacketCallback
{
tf2_ros::TransformBroadcaster tf_broadcaster;
std::string frame_id = DEFAULT_FRAME_ID;
std::string reference_frame_id = DEFAULT_REFERENCE_FRAME_ID;

TransformPublisher(rclcpp::Node &node) : tf_broadcaster(node)
{
node.get_parameter("frame_id", frame_id);
node.get_parameter("reference_frame_id", reference_frame_id);
}

void operator()(const XsDataPacket &packet, rclcpp::Time timestamp)
Expand All @@ -85,7 +87,7 @@ struct TransformPublisher : public PacketCallback
XsQuaternion q = packet.orientationQuaternion();

tf.header.stamp = timestamp;
tf.header.frame_id = "world";
tf.header.frame_id = reference_frame_id;
tf.child_frame_id = frame_id;
tf.transform.translation.x = 0.0;
tf.transform.translation.y = 0.0;
Expand Down