Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I've marked Pete's answers as correct because it put me on the right path. My actual solution was a little different. First I created a transform listener in my main and passed this a tf2_buffer. Within my class as part of my callback method I used the buffer to look up the transform from second to final link to the base link. I then multiplied the inverse of this by my IMU output, giving me the IMU output in terms of roll only. e.g.

tf2::Quaternion all_joints_to_nozzle;      
geometry_msgs::TransformStamped transform_stamped;
transform_stamped = tf_buffer_.lookupTransform("base_link", "tilt_assembly", ros::Time(0));
tf2::convert(transform_stamped.transform.rotation, all_joints_to_nozzle);
tf2::Quaternion nozzle_offset;
nozzle_offset.setEuler(0.0, 0.07, 0.0);
//This results in an accurate position of the roll of the nozzle exclusively
transformed_quaternion = (all_joints_to_nozzle * nozzle_offset).inverse() * imu_quaternion; 
double roll, pitch, yaw;
tf2::Matrix3x3(transformed_quaternion).getEulerYPR(yaw, pitch, roll, 1);
set_position(index, roll);

As long as the IMU isn't powered on in the vertical position (X axis aligned to gravity), I can correctly and consistently measure the position of my end effector now.