Skip to content

Commit

Permalink
CurrentState: add more rangefinders
Browse files Browse the repository at this point in the history
ArduPilot presently supports 10
  • Loading branch information
robertlong13 authored and meee1 committed Oct 26, 2023
1 parent ab05f6e commit ca368f7
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions ExtLibs/ArduPilot/CurrentState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1653,10 +1653,17 @@ public float sonarrange
[DisplayText("Sonar Voltage (Volt)")][GroupText("Sensor")] public float sonarvoltage { get; set; }

[DisplayText("RangeFinder1 (cm)")][GroupText("Sensor")] public uint rangefinder1 { get; set; }

[DisplayText("RangeFinder2 (cm)")][GroupText("Sensor")] public uint rangefinder2 { get; set; }

[DisplayText("RangeFinder3 (cm)")][GroupText("Sensor")] public uint rangefinder3 { get; set; }
[DisplayText("RangeFinder4 (cm)")][GroupText("Sensor")] public uint rangefinder4 { get; set; }
[DisplayText("RangeFinder5 (cm)")][GroupText("Sensor")] public uint rangefinder5 { get; set; }
[DisplayText("RangeFinder6 (cm)")][GroupText("Sensor")] public uint rangefinder6 { get; set; }
[DisplayText("RangeFinder7 (cm)")][GroupText("Sensor")] public uint rangefinder7 { get; set; }
[DisplayText("RangeFinder8 (cm)")][GroupText("Sensor")] public uint rangefinder8 { get; set; }
[DisplayText("RangeFinder9 (cm)")][GroupText("Sensor")] public uint rangefinder9 { get; set; }
[DisplayText("RangeFinder10 (cm)")][GroupText("Sensor")] public uint rangefinder10 { get; set; }


[GroupText("Software")]
public float freemem { get; set; }
[GroupText("Software")] public float load { get; set; }
Expand Down Expand Up @@ -2476,11 +2483,16 @@ private void Parent_OnPacketReceived(object sender, MAVLink.MAVLinkMessage mavLi

{
var sonar = mavLinkMessage.ToStructure<MAVLink.mavlink_distance_sensor_t>();
if (sonar.id == 0)
rangefinder1 = sonar.current_distance;
else if (sonar.id == 1)
rangefinder2 = sonar.current_distance;
if (sonar.id == 0) rangefinder1 = sonar.current_distance;
else if (sonar.id == 1) rangefinder2 = sonar.current_distance;
else if (sonar.id == 2) rangefinder3 = sonar.current_distance;
else if (sonar.id == 3) rangefinder4 = sonar.current_distance;
else if (sonar.id == 4) rangefinder5 = sonar.current_distance;
else if (sonar.id == 5) rangefinder6 = sonar.current_distance;
else if (sonar.id == 6) rangefinder7 = sonar.current_distance;
else if (sonar.id == 7) rangefinder8 = sonar.current_distance;
else if (sonar.id == 8) rangefinder9 = sonar.current_distance;
else if (sonar.id == 9) rangefinder10 = sonar.current_distance;
}

break;
Expand Down

0 comments on commit ca368f7

Please sign in to comment.