mirror of
https://github.com/CopterExpress/clover.git
synced 2026-06-03 08:29:32 +00:00
optical_flow: Use correct signs for gyro calculations
This commit is contained in:
@@ -219,16 +219,16 @@ private:
|
||||
{
|
||||
tf2::Quaternion prev_rot, curr_rot;
|
||||
tf2::fromMsg(tf_buffer_.lookupTransform(frame_id, local_frame_id_, prev).transform.rotation, prev_rot);
|
||||
tf2::fromMsg(tf_buffer_.lookupTransform(frame_id, local_frame_id_, curr).transform.rotation, curr_rot);
|
||||
tf2::fromMsg(tf_buffer_.lookupTransform(frame_id, local_frame_id_, curr, ros::Duration(0.1)).transform.rotation, curr_rot);
|
||||
|
||||
geometry_msgs::Vector3Stamped flow;
|
||||
flow.header.frame_id = frame_id;
|
||||
flow.header.stamp = curr;
|
||||
// https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions#Quaternion_↔_angular_velocities
|
||||
auto diff = ((curr_rot - prev_rot) * prev_rot.inverse()) * 2.0f;
|
||||
flow.vector.x = diff.x();
|
||||
flow.vector.y = diff.y();
|
||||
flow.vector.z = diff.z();
|
||||
flow.vector.x = -diff.x();
|
||||
flow.vector.y = -diff.y();
|
||||
flow.vector.z = -diff.z();
|
||||
|
||||
return flow;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user