Skip to content

Commit

Permalink
Flightdata, Payload Control tab fixes (#3153)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 authored Aug 3, 2023
1 parent 734c2ca commit bd6d475
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 74 deletions.
22 changes: 6 additions & 16 deletions ExtLibs/ArduPilot/Mavlink/MAVLinkInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4491,28 +4491,18 @@ public void setMountControl(double pa, double pb, double pc, bool islatlng)

public void setMountControl(byte sysid, byte compid, double pa, double pb, double pc, bool islatlng)
{
mavlink_mount_control_t req = new mavlink_mount_control_t
{
target_system = sysid,
target_component = compid
};

if (!islatlng)
{
req.input_a = (int) pa;
req.input_b = (int) pb;
req.input_c = (int) pc;
// pa is pitch, pb is roll, pc is yaw in centi-degrees. convert to degrees
doCommand(sysid, compid, MAV_CMD.DO_MOUNT_CONTROL, (float)(pa * 0.01), (float)(pb * 0.01), (float)(pc * 0.01), 0, 0, 0, (float)MAV_MOUNT_MODE.MAVLINK_TARGETING, false);
}
else
{
req.input_a = (int) (pa * 10000000.0);
req.input_b = (int) (pb * 10000000.0);
req.input_c = (int) (pc * 100.0);
// pa is lat in degrees, placed in param5 in deg * 10e7
// pb is lon in degrees, placed in param6 in deg * 10e7
// pc is alt in meters, placed in param5 in meters
doCommand(sysid, compid, MAV_CMD.DO_MOUNT_CONTROL, 0, 0, 0, (float)pc, (float)(pa * 10000000.0f), (float)(pb * 10000000.0f), (float)MAV_MOUNT_MODE.MAVLINK_TARGETING, false);
}

generatePacket((byte) MAVLINK_MSG_ID.MOUNT_CONTROL, req);
Thread.Sleep(20);
generatePacket((byte) MAVLINK_MSG_ID.MOUNT_CONTROL, req);
}

[Obsolete]
Expand Down
29 changes: 0 additions & 29 deletions GCSViews/FlightData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,35 +703,6 @@ public void loadTabControlActions()
ThemeManager.ApplyThemeTo(tabControlactions);
}

//Updates the visibility of the payload control tab based on whether the payload target is available or not
public void updatePayloadTabVisible()
{
bool gimbalPresent = false;

//if the currently connected target is a flight controller check if there is an associated mavlink gimbal
if (MainV2.comPort.compidcurrent == 1)
{
foreach (var mav in MainV2.comPort.MAVlist)
{
if (mav.sysid == MainV2.comPort.sysidcurrent &&
mav.compid == (int) MAVLink.MAV_COMPONENT.MAV_COMP_ID_GIMBAL)
{
gimbalPresent = true;
break;
}
}
}

if (tabControlactions.TabPages.Contains(tabPayload) == true && gimbalPresent == false)
{
tabControlactions.TabPages.Remove(tabPayload);
}
else if (tabControlactions.TabPages.Contains(tabPayload) == false && gimbalPresent == true)
{
tabControlactions.TabPages.Add(tabPayload);
}
}

internal void BUT_run_script_Click(object sender, EventArgs e)
{
if (File.Exists(selectedscript))
Expand Down
2 changes: 1 addition & 1 deletion GCSViews/FlightData.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3983,7 +3983,7 @@
<value>63, 19</value>
</data>
<data name="trackBarRoll.RightToLeft" type="System.Windows.Forms.RightToLeft, System.Windows.Forms">
<value>Yes</value>
<value>No</value>
</data>
<data name="trackBarRoll.RightToLeftLayout" type="System.Boolean, mscorlib">
<value>True</value>
Expand Down
28 changes: 0 additions & 28 deletions MainV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,34 +1179,6 @@ void comPort_MavChanged(object sender, EventArgs e)
return;
}
}

if (this.InvokeRequired)
{
this.BeginInvoke((MethodInvoker) delegate
{
//enable the payload control page if a mavlink gimbal is detected
if (instance.FlightData != null)
{
instance.FlightData.updatePayloadTabVisible();
}

instance.MyView.Reload();

_connectionControl.UpdateSysIDS();
});
}
else
{
//enable the payload control page if a mavlink gimbal is detected
if (instance.FlightData != null)
{
instance.FlightData.updatePayloadTabVisible();
}

instance.MyView.Reload();

_connectionControl.UpdateSysIDS();
}
}
#if !NETSTANDARD2_0
#if !NETCOREAPP2_0
Expand Down

0 comments on commit bd6d475

Please sign in to comment.