Skip to content

Commit

Permalink
GimbalVideoControl: add click-to-pan
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlong13 committed Sep 22, 2024
1 parent 5e7f027 commit 786315f
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions Controls/GimbalVideoControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,38 @@ private void VideoBox_Click(object sender, EventArgs e)
{
MouseEventArgs me = (MouseEventArgs)e;
var point = getMousePosition(me.X, me.Y);
if (!point.HasValue) { return; }
if (!point.HasValue)
{
return;
}

var loc = selectedCamera?.CalculateImagePointLocation(point.Value.x, point.Value.y);
if (loc != null)
// Check currently held modifier keys
if (Control.ModifierKeys == preferences.MoveCameraToMouseLocationModifier)
{
var attitude = selectedGimbalManager?.GetAttitude(selectedGimbalID);
if (attitude == null)
{
return;
}
var q = selectedCamera?.CalculateImagePointRotation(point.Value.x, point.Value.y);
if (q == null)
{
return;
}
q = attitude * q;
Console.WriteLine("Attitude: {0:0.0} {1:0.0} {2:0.0}", attitude.get_euler_yaw() * MathHelper.rad2deg, attitude.get_euler_pitch() * MathHelper.rad2deg, attitude.get_euler_roll() * MathHelper.rad2deg);
Console.WriteLine("New: {0:0.0} {1:0.0} {2:0.0}", q.get_euler_yaw() * MathHelper.rad2deg, q.get_euler_pitch() * MathHelper.rad2deg, q.get_euler_roll() * MathHelper.rad2deg);

selectedGimbalManager?.SetAttitudeAsync(q, yaw_lock, selectedGimbalID);

}
else if (Control.ModifierKeys == preferences.MoveCameraPOIToMouseLocationModifier)
{
var loc = selectedCamera?.CalculateImagePointLocation(point.Value.x, point.Value.y);
if (loc == null)
{
return;
}
selectedGimbalManager?.SetROILocationAsync(loc.Lat, loc.Lng, loc.Alt, frame: MAV_FRAME.GLOBAL);
}
}
Expand Down Expand Up @@ -659,9 +686,9 @@ public GimbalControlPreferences()
TrackObjectUnderMouse = MouseButton.Left;

MoveCameraToMouseLocationModifier = Keys.None;
MoveCameraPOIToMouseLocationModifier = Keys.Shift;
MoveCameraPOIToMouseLocationModifier = Keys.Control;
SlewCameraBasedOnMouseModifier = Keys.Alt;
TrackObjectUnderMouseModifier = Keys.Control;
TrackObjectUnderMouseModifier = Keys.Control | Keys.Alt;

// Default speed settings
SlewSpeedSlow = 1m; // deg/sec
Expand Down

0 comments on commit 786315f

Please sign in to comment.