Home > database >  Get the rudder rotation angle of the robot's compass
Get the rudder rotation angle of the robot's compass

Time:05-14

there is an electronic compass with angles of 1-360 degrees (or 0-359, whatever)

https://i.stack.imgur.com/Q7RmH.jpg

there are variables

  • Yaw - compass readings degrees
  • HDG - established direction rudder degrees
  • rudder - the degrees to turn the steering wheel (need to get)

variables to check

HDG:20 Yaw:340 =need to get rudder=40

HDG:50 Yaw:90 =need to get rudder=-40


What is the formula to get the angle by which to rotate?

the problem is to find the shortest turn in the right direction..

it seems simple, but it broke my mind

CodePudding user response:

if (setHDG>=Yaw)

  rudder=360-(360-setHDG Yaw);
  

else rudder=setHDG-Yaw;

CodePudding user response:

Have you thought about using a static variable as a reference point?

  • Related