Hello.
Below is my mission planner csharp plugin code.
this code add waypoint on planner screen well as I intended.
but, I wonder why there is always “you must have home altitude” screen.
I’m programmatically updating home point of my aircraft. could that be the reason?
I enter home altitude value as “0” and it worked in SITL, but I’m worrying about something I don’t know happen inside the program :
public void minuteToDigitWaypoints()
{
try
{
string input = "";
InputBox.Show("Minutes -> Digits", "Input Format : 35-29.33333'S;129-35.99999'W", ref input);
if (string.IsNullOrEmpty(input))
{
MessageBox.Show("Nothing Entered");
return; // Exit if the input is empty or canceled
}
// Define the regular expression pattern to match the input format
string pattern = @"^(\d{1,3})-(\d{1,2}\.\d+)'([NSns]);(\d{1,3})-(\d{1,2}\.\d+)'([EWew])$";
Match match = Regex.Match(input, pattern);
if (match.Success)
{
double latitude = double.Parse(match.Groups[1].Value) + double.Parse(match.Groups[2].Value) / 60;
if ((match.Groups[3].Value == "S") || (match.Groups[3].Value == "s"))
latitude *= -1;
double longitude = double.Parse(match.Groups[4].Value) + double.Parse(match.Groups[5].Value) / 60;
if ((match.Groups[6].Value == "W") || (match.Groups[6].Value == "w"))
longitude *= -1;
string result = $"Original input: {input}\n\n" +
$"Converted coordinates:\nLatitude: {latitude}, Longitude: {longitude}";
Clipboard.SetText(result);
// Display the result in a new dialog box
MessageBox.Show(result + "\n\nabove contents was copied to clipboard.", "Conversion Results");
SaveResultToNotepad(result, " Minutes To Digits");
Host.AddWPtoList(MAVLink.MAV_CMD.WAYPOINT, 0, 0, 0, 0, longitude, latitude, 300);
}
else
{
MessageBox.Show("Wrong Input. Input format : 35-29.33333'S;129-35.99999'W",
"Wrong Input format", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
MessageBox.Show($"An error occurred: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}