osrf / vrx

Virtual RobotX (VRX) resources.
Apache License 2.0
421 stars 189 forks source link

Bearing calculation for acoustic pinger does not seem to be correct #426

Open andrew-aj opened 2 years ago

andrew-aj commented 2 years ago

For the acoustic pinger the calculation for the bearing does not seem to be correct. For example, with a bearing value of 0.22 when we yaw our boat right 0.22 radians the new bearing value is 0.44 whereas it should be 0. It seems like the bearing calculation is reversed and is counter-clockwise when bearing normally is calculated with positive being clockwise.

acxz commented 2 years ago

I fully agree with @andrew-aj here, bearing is calculated clockwise from north.

From wikipedia:

In nautical navigation the absolute bearing is the clockwise angle between north and an object observed from the vessel.

j-herman commented 2 years ago

VRX defines the pinger bearing in the body frame of the WAMV, documented in the wiki: https://github.com/osrf/vrx/wiki/frame_conventions

acxz commented 2 years ago

Thank you for taking a look at this issue! I don't think we have a disagreement on what frame the bearing is computed with respect to, but rather how VRX defines bearing.

Typically, it is considered a clockwise angle in the body frame. Would it be possible to update the documentation to clarify that the bearing is defined as counterclockwise in the body frame?

Edit: it looks the REP that VRX follows, does mention the following:

By the right hand rule, the yaw component of orientation increases as the child frame rotates counter-clockwise, and for geographic poses, yaw is zero when pointing east.

This requires special mention only because it differs from a traditional compass bearing, which is zero when pointing north and increments clockwise. Hardware drivers should make the appropriate transformations before publishing standard ROS messages.

An addition like this at the end of the first paragraph under https://github.com/osrf/vrx/wiki/frame_conventions#acoustic-pinger would go a long ways: Note following [REP 103](https://www.ros.org/reps/rep-0103.html), the bearing is computed counterclockwise from the body frame x-axis.

I think that would be sufficient to close this issue and to prevent confusion for future users familiar with the clockwise definition of the bearing.

j-herman commented 2 years ago

@acxz Thanks for the comment! There was a lot of discussion when this issue first came up as to whether we should make the change. When we decided to stay with the REP, we added the wiki page to try to help with just that confusion - sounds like a good recommendation to make this easier to interpret for everyone. Leaving the issue open as we were using it to track the computation error in elevation.