Skip to content

Commit

Permalink
CurrentState: correct unit handling for radius (#3262)
Browse files Browse the repository at this point in the history
This fixes the turn radius display on the map when using other speed units
  • Loading branch information
robertlong13 authored Jan 12, 2024
1 parent fb6af04 commit 75c40eb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static GMapMarker getMAVMarker(MAVState MAV, GMapOverlay overlay = null)
itemp.Cog = MAV.cs.groundcourse;
itemp.Target = MAV.cs.target_bearing;
itemp.Nav_bearing = MAV.cs.nav_bearing;
itemp.Radius = MAV.cs.radius * CurrentState.multiplierdist;
itemp.Radius = (float)CurrentState.fromDistDisplayUnit(MAV.cs.radius);
return null;
}
else if (item is GMapMarkerQuad)
Expand Down Expand Up @@ -76,7 +76,7 @@ public static GMapMarker getMAVMarker(MAVState MAV, GMapOverlay overlay = null)
{
return (new GMapMarkerPlane(MAV.sysid - 1, portlocation, MAV.cs.yaw,
MAV.cs.groundcourse, MAV.cs.nav_bearing, MAV.cs.target_bearing,
MAV.cs.radius * CurrentState.multiplierdist)
(float)CurrentState.toDistDisplayUnit(MAV.cs.radius))
{
ToolTipText = ArduPilot.Common.speechConversion(MAV, "" + Settings.Instance["mapicondesc"]),
ToolTipMode = String.IsNullOrEmpty(Settings.Instance["mapicondesc"]) ? MarkerTooltipMode.Never : MarkerTooltipMode.Always,
Expand Down
2 changes: 1 addition & 1 deletion ExtLibs/ArduPilot/CurrentState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ public float radius
get
{
if (_groundspeed <= 1) return 0;
return (float)(groundspeed * groundspeed / (9.80665 * Math.Tan(roll * MathHelper.deg2rad)));
return (float)toDistDisplayUnit(_groundspeed * _groundspeed / (9.80665 * Math.Tan(roll * MathHelper.deg2rad)));
}
}
[GroupText("Position")]
Expand Down
2 changes: 1 addition & 1 deletion Swarm/Formation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public override void SendCommand()

if (true)
{
var leaderturnrad = Leader.cs.radius;
var leaderturnrad = CurrentState.fromDistDisplayUnit(Leader.cs.radius);
var mavturnradius = leaderturnrad - x;

{
Expand Down

0 comments on commit 75c40eb

Please sign in to comment.