本文整理汇总了C#中MissionPlanner.Utilities.Locationwp类的典型用法代码示例。如果您正苦于以下问题:C# Locationwp类的具体用法?C# Locationwp怎么用?C# Locationwp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Locationwp类属于MissionPlanner.Utilities命名空间,在下文中一共展示了Locationwp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Convert
static object Convert(Locationwp cmd, bool isint = false)
{
if (isint)
{
var temp = new MAVLink.mavlink_mission_item_int_t()
{
command = cmd.id,
param1 = cmd.p1,
param2 = cmd.p2,
param3 = cmd.p3,
param4 = cmd.p4,
x = (int)(cmd.lat * 1.0e7),
y = (int)(cmd.lng * 1.0e7),
z = (float) cmd.alt
};
return temp;
}
else
{
var temp = new MAVLink.mavlink_mission_item_t()
{
command = cmd.id,
param1 = cmd.p1,
param2 = cmd.p2,
param3 = cmd.p3,
param4 = cmd.p4,
x = (float) cmd.lat,
y = (float) cmd.lng,
z = (float) cmd.alt
};
return temp;
}
}
开发者ID:jmachuca77,项目名称:MissionPlanner,代码行数:35,代码来源:locationwp.cs
示例2: lookahead
/*
calculate lookahead rise in terrain. This returns extra altitude
needed to clear upcoming terrain in meters
*/
float lookahead(Locationwp loc, float bearing, float distance, float climb_ratio)
{
if (!enable || grid_spacing <= 0)
{
return 0;
}
//Locationwp loc;
//if (!ahrs.get_position(loc))
{
// we don't know where we are
//return 0;
}
float base_height = 0;
if (!height_amsl(loc, ref base_height))
{
// we don't know our current terrain height
return 0;
}
float climb = 0;
float lookahead_estimate = 0;
// check for terrain at grid spacing intervals
while (distance > 0)
{
location_update(loc, bearing, grid_spacing);
climb += climb_ratio*grid_spacing;
distance -= grid_spacing;
float height = 0;
if (height_amsl(loc, ref height))
{
float rise = (height - base_height) - climb;
if (rise > lookahead_estimate)
{
lookahead_estimate = rise;
}
}
}
return lookahead_estimate;
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:47,代码来源:AP_Terrain.cs
示例3: updateLocationLabel
private void updateLocationLabel(Locationwp plla)
{
if (!Instance.IsDisposed)
{
Instance.BeginInvoke((MethodInvoker)delegate
{
Instance.LBL_location.Text = gotolocation.Lat + " " + gotolocation.Lng + " " + gotolocation.Alt + " " + gotolocation.Tag;
}
);
}
}
开发者ID:jackmaynard,项目名称:MissionPlanner,代码行数:12,代码来源:MovingBase.cs
示例4: updateLocationLabel
private void updateLocationLabel(Locationwp plla)
{
this.BeginInvoke((MethodInvoker)delegate
{
LBL_location.Text = gotolocation.Lat + " " + gotolocation.Lng + " " + gotolocation.Alt +" "+ gotolocation.Tag;
}
);
}
开发者ID:tinashanica,项目名称:MissionPlanner,代码行数:8,代码来源:FollowMe.cs
示例5: setGuidedModeWP
public void setGuidedModeWP(Locationwp gotohere)
{
if (gotohere.alt == 0 || gotohere.lat == 0 || gotohere.lng == 0)
return;
giveComport = true;
try
{
gotohere.id = (byte) MAV_CMD.WAYPOINT;
// fix for followme change
if (MAV.cs.mode.ToUpper() != "GUIDED")
setMode("GUIDED");
MAV_MISSION_RESULT ans = setWP(gotohere, 0, MAVLink.MAV_FRAME.GLOBAL_RELATIVE_ALT, (byte) 2);
if (ans != MAV_MISSION_RESULT.MAV_MISSION_ACCEPTED)
throw new Exception("Guided Mode Failed");
}
catch (Exception ex)
{
log.Error(ex);
}
giveComport = false;
}
开发者ID:ChukRhodes,项目名称:MissionPlanner,代码行数:27,代码来源:MAVLinkInterface.cs
示例6: getWP
/// <summary>
/// Gets specfied WP
/// </summary>
/// <param name="index"></param>
/// <returns>WP</returns>
public Locationwp getWP(ushort index)
{
while (giveComport)
System.Threading.Thread.Sleep(100);
bool use_int = (MAV.cs.capabilities & MAV_PROTOCOL_CAPABILITY.MISSION_INT) > 0;
object req;
if (use_int)
{
mavlink_mission_request_int_t reqi = new mavlink_mission_request_int_t();
reqi.target_system = MAV.sysid;
reqi.target_component = MAV.compid;
reqi.seq = index;
// request
generatePacket((byte)MAVLINK_MSG_ID.MISSION_REQUEST_INT, reqi);
req = reqi;
}
else
{
mavlink_mission_request_t reqf = new mavlink_mission_request_t();
reqf.target_system = MAV.sysid;
reqf.target_component = MAV.compid;
reqf.seq = index;
// request
generatePacket((byte)MAVLINK_MSG_ID.MISSION_REQUEST, reqf);
req = reqf;
}
giveComport = true;
Locationwp loc = new Locationwp();
DateTime start = DateTime.Now;
int retrys = 5;
while (true)
{
if (!(start.AddMilliseconds(3500) > DateTime.Now)) // apm times out after 5000ms
{
if (retrys > 0)
{
log.Info("getWP Retry " + retrys);
if (use_int)
generatePacket((byte)MAVLINK_MSG_ID.MISSION_REQUEST_INT, req);
else
generatePacket((byte)MAVLINK_MSG_ID.MISSION_REQUEST, req);
start = DateTime.Now;
retrys--;
continue;
}
giveComport = false;
throw new TimeoutException("Timeout on read - getWP");
}
//Console.WriteLine("getwp read " + DateTime.Now.Millisecond);
MAVLinkMessage buffer = readPacket();
//Console.WriteLine("getwp readend " + DateTime.Now.Millisecond);
if (buffer.Length > 5)
{
if (buffer.msgid == (byte) MAVLINK_MSG_ID.MISSION_ITEM)
{
//Console.WriteLine("getwp ans " + DateTime.Now.Millisecond);
var wp = buffer.ToStructure<mavlink_mission_item_t>();
// received a packet, but not what we requested
if (index != wp.seq)
{
generatePacket((byte) MAVLINK_MSG_ID.MISSION_REQUEST, req);
continue;
}
loc.options = (byte) (wp.frame);
loc.id = (byte) (wp.command);
loc.p1 = (wp.param1);
loc.p2 = (wp.param2);
loc.p3 = (wp.param3);
loc.p4 = (wp.param4);
loc.alt = ((wp.z));
loc.lat = ((wp.x));
loc.lng = ((wp.y));
log.InfoFormat("getWP {0} {1} {2} {3} {4} opt {5}", loc.id, loc.p1, loc.alt, loc.lat, loc.lng,
loc.options);
break;
//.........这里部分代码省略.........
开发者ID:ChukRhodes,项目名称:MissionPlanner,代码行数:101,代码来源:MAVLinkInterface.cs
示例7: goHereToolStripMenuItem_Click
private void goHereToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!MainV2.comPort.BaseStream.IsOpen)
{
CustomMessageBox.Show(Strings.PleaseConnect, Strings.ERROR);
return;
}
if (MainV2.comPort.MAV.GuidedMode.z == 0)
{
flyToHereAltToolStripMenuItem_Click(null, null);
if (MainV2.comPort.MAV.GuidedMode.z == 0)
return;
}
if (MouseDownStart.Lat == 0 || MouseDownStart.Lng == 0)
{
CustomMessageBox.Show(Strings.BadCoords, Strings.ERROR);
return;
}
Locationwp gotohere = new Locationwp();
gotohere.id = (byte) MAVLink.MAV_CMD.WAYPOINT;
gotohere.alt = MainV2.comPort.MAV.GuidedMode.z; // back to m
gotohere.lat = (MouseDownStart.Lat);
gotohere.lng = (MouseDownStart.Lng);
try
{
MainV2.comPort.setGuidedModeWP(gotohere);
}
catch (Exception ex)
{
MainV2.comPort.giveComport = false;
CustomMessageBox.Show(Strings.CommandFailed + ex.Message, Strings.ERROR);
}
}
开发者ID:Viousa,项目名称:MissionPlanner,代码行数:39,代码来源:FlightData.cs
示例8: goHereToolStripMenuItem_Click
private void goHereToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!MainV2.comPort.BaseStream.IsOpen)
{
CustomMessageBox.Show("Please Connect First");
return;
}
if (MainV2.comPort.MAV.GuidedMode.z == 0)
{
flyToHereAltToolStripMenuItem_Click(null, null);
if (MainV2.comPort.MAV.GuidedMode.z == 0)
return;
}
if (gotolocation.Lat == 0 || gotolocation.Lng == 0)
{
CustomMessageBox.Show("Bad Lat/Long");
return;
}
Locationwp gotohere = new Locationwp();
gotohere.id = (byte)MAVLink.MAV_CMD.WAYPOINT;
gotohere.alt = (float)(MainV2.comPort.MAV.GuidedMode.z); // back to m
gotohere.lat = (gotolocation.Lat);
gotohere.lng = (gotolocation.Lng);
try
{
MainV2.comPort.setGuidedModeWP(gotohere);
}
catch (Exception ex) { MainV2.comPort.giveComport = false; CustomMessageBox.Show("Error sending command : " + ex.Message); }
}
开发者ID:neolu,项目名称:MissionPlanner,代码行数:35,代码来源:Simple.cs
示例9: getWP
/// <summary>
/// Gets specfied WP
/// </summary>
/// <param name="index"></param>
/// <returns>WP</returns>
public Locationwp getWP(ushort index)
{
while (giveComport)
System.Threading.Thread.Sleep(100);
giveComport = true;
Locationwp loc = new Locationwp();
mavlink_mission_request_t req = new mavlink_mission_request_t();
req.target_system = MAV.sysid;
req.target_component = MAV.compid;
req.seq = index;
//Console.WriteLine("getwp req "+ DateTime.Now.Millisecond);
// request
generatePacket((byte)MAVLINK_MSG_ID.MISSION_REQUEST, req);
DateTime start = DateTime.Now;
int retrys = 5;
while (true)
{
if (!(start.AddMilliseconds(800) > DateTime.Now)) // apm times out after 1000ms
{
if (retrys > 0)
{
log.Info("getWP Retry " + retrys);
generatePacket((byte)MAVLINK_MSG_ID.MISSION_REQUEST, req);
start = DateTime.Now;
retrys--;
continue;
}
giveComport = false;
throw new Exception("Timeout on read - getWP");
}
//Console.WriteLine("getwp read " + DateTime.Now.Millisecond);
byte[] buffer = readPacket();
//Console.WriteLine("getwp readend " + DateTime.Now.Millisecond);
if (buffer.Length > 5)
{
if (buffer[5] == (byte)MAVLINK_MSG_ID.MISSION_ITEM)
{
//Console.WriteLine("getwp ans " + DateTime.Now.Millisecond);
var wp = buffer.ByteArrayToStructure<mavlink_mission_item_t>(6);
// received a packet, but not what we requested
if (req.seq != wp.seq)
{
generatePacket((byte)MAVLINK_MSG_ID.MISSION_REQUEST, req);
continue;
}
loc.options = (byte)(wp.frame);
loc.id = (byte)(wp.command);
loc.p1 = (wp.param1);
loc.p2 = (wp.param2);
loc.p3 = (wp.param3);
loc.p4 = (wp.param4);
loc.alt = ((wp.z));
loc.lat = ((wp.x));
loc.lng = ((wp.y));
log.InfoFormat("getWP {0} {1} {2} {3} {4} opt {5}", loc.id, loc.p1, loc.alt, loc.lat, loc.lng, loc.options);
break;
}
else
{
log.Info(DateTime.Now + " PC getwp " + buffer[5]);
}
}
}
giveComport = false;
return loc;
}
开发者ID:munaclaw,项目名称:MissionPlanner,代码行数:84,代码来源:MAVLinkInterface.cs
示例10: mainloop
void mainloop()
{
DateTime nextsend = DateTime.Now;
StreamWriter sw = new StreamWriter(File.OpenWrite("followmeraw.txt"));
threadrun = true;
while (threadrun)
{
try
{
string line = comPort.ReadLine();
sw.WriteLine(line);
//string line = string.Format("$GP{0},{1:HHmmss},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},", "GGA", DateTime.Now.ToUniversalTime(), Math.Abs(lat * 100), MainV2.comPort.MAV.cs.lat < 0 ? "S" : "N", Math.Abs(lng * 100), MainV2.comPort.MAV.cs.lng < 0 ? "W" : "E", MainV2.comPort.MAV.cs.gpsstatus, MainV2.comPort.MAV.cs.satcount, MainV2.comPort.MAV.cs.gpshdop, MainV2.comPort.MAV.cs.alt, "M", 0, "M", "");
if (line.StartsWith("$GPGGA")) //
{
string[] items = line.Trim().Split(',', '*');
if (items[15] != GetChecksum(line.Trim()))
{
Console.WriteLine("Bad Nmea line " + items[15] + " vs " + GetChecksum(line.Trim()));
continue;
}
if (items[6] == "0")
{
Console.WriteLine("No Fix");
continue;
}
gotolocation.Lat = double.Parse(items[2], CultureInfo.InvariantCulture)/100.0;
gotolocation.Lat = (int) gotolocation.Lat + ((gotolocation.Lat - (int) gotolocation.Lat)/0.60);
if (items[3] == "S")
gotolocation.Lat *= -1;
gotolocation.Lng = double.Parse(items[4], CultureInfo.InvariantCulture)/100.0;
gotolocation.Lng = (int) gotolocation.Lng + ((gotolocation.Lng - (int) gotolocation.Lng)/0.60);
if (items[5] == "W")
gotolocation.Lng *= -1;
gotolocation.Alt = intalt;
gotolocation.Tag = "Sats " + items[7] + " hdop " + items[8];
}
if (DateTime.Now > nextsend && gotolocation.Lat != 0 && gotolocation.Lng != 0 &&
gotolocation.Alt != 0) // 200 * 10 = 2 sec /// lastgotolocation != gotolocation &&
{
nextsend = DateTime.Now.AddMilliseconds(1000/updaterate);
Console.WriteLine("Sending follow wp " + DateTime.Now.ToString("h:MM:ss") + " " +
gotolocation.Lat + " " + gotolocation.Lng + " " + gotolocation.Alt);
lastgotolocation = new PointLatLngAlt(gotolocation);
Locationwp gotohere = new Locationwp();
gotohere.id = (byte) MAVLink.MAV_CMD.WAYPOINT;
gotohere.alt = (float) (gotolocation.Alt);
gotohere.lat = (gotolocation.Lat);
gotohere.lng = (gotolocation.Lng);
try
{
updateLocationLabel(gotohere);
}
catch
{
}
if (MainV2.comPort.BaseStream.IsOpen && MainV2.comPort.giveComport == false)
{
try
{
MainV2.comPort.giveComport = true;
MainV2.comPort.setGuidedModeWP(gotohere);
MainV2.comPort.giveComport = false;
}
catch
{
MainV2.comPort.giveComport = false;
}
}
}
}
catch
{
System.Threading.Thread.Sleep((int) (1000/updaterate));
}
}
sw.Close();
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:100,代码来源:FollowMe.cs
示例11: location_offset
/*
* extrapolate latitude/longitude given distances north and east
* This function costs about 80 usec on an AVR2560
*/
void location_offset(Locationwp loc, float ofs_north, float ofs_east)
{
if (!is_zero(ofs_north) || !is_zero(ofs_east))
{
int32_t dlat = (int32_t) (ofs_north*LOCATION_SCALING_FACTOR_INV);
int32_t dlng = (int32_t) ((ofs_east*LOCATION_SCALING_FACTOR_INV)/longitude_scale(loc));
loc.lat += dlat;
loc.lng += dlng;
}
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:15,代码来源:AP_Terrain.cs
示例12: location_update
/*
* extrapolate latitude/longitude given bearing and distance
* Note that this function is accurate to about 1mm at a distance of
* 100m. This function has the advantage that it works in relative
* positions, so it keeps the accuracy even when dealing with small
* distances and floating point numbers
*/
void location_update(Locationwp loc, float bearing, float distance)
{
float ofs_north = cosf(radians(bearing))*distance;
float ofs_east = sinf(radians(bearing))*distance;
location_offset(loc, ofs_north, ofs_east);
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:14,代码来源:AP_Terrain.cs
示例13: level
/*
return terrain height in meters above average sea level (WGS84) for
a given position
This is the base function that other height calculations are derived
from. The functions below are more convenient for most uses
This function costs about 20 microseconds on Pixhawk
*/
bool height_amsl(Locationwp loc, ref float height)
{
height = (float) srtm.getAltitude(loc.lat, loc.lng).alt;
return true;
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:15,代码来源:AP_Terrain.cs
示例14: longitude_scale
float longitude_scale(Locationwp loc)
{
int32_t last_lat = -999999999;
float scale = 1.0f;
if (labs(last_lat - loc.lat) < 100000)
{
// we are within 0.01 degrees (about 1km) of the
// same latitude. We can avoid the cos() and return
// the same scale factor.
return scale;
}
scale = cosf(loc.lat*1.0e-7f*DEG_TO_RAD);
scale = constrain_float(scale, 0.01f, 1.0f);
last_lat = (int32_t) loc.lat;
return scale;
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:16,代码来源:AP_Terrain.cs
示例15: mainloop
void mainloop()
{
DateTime nextsend = DateTime.Now;
DateTime nextrallypntupdate = DateTime.Now;
StreamWriter sw = new StreamWriter(File.OpenWrite("MovingBase.txt"));
threadrun = true;
while (threadrun)
{
try
{
string line = comPort.ReadLine();
sw.WriteLine(line);
//string line = string.Format("$GP{0},{1:HHmmss},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},", "GGA", DateTime.Now.ToUniversalTime(), Math.Abs(lat * 100), MainV2.comPort.MAV.cs.lat < 0 ? "S" : "N", Math.Abs(lng * 100), MainV2.comPort.MAV.cs.lng < 0 ? "W" : "E", MainV2.comPort.MAV.cs.gpsstatus, MainV2.comPort.MAV.cs.satcount, MainV2.comPort.MAV.cs.gpshdop, MainV2.comPort.MAV.cs.alt, "M", 0, "M", "");
if (line.StartsWith("$GPGGA")) //
{
string[] items = line.Trim().Split(',','*');
if (items[15] != GetChecksum(line.Trim()))
{
Console.WriteLine("Bad Nmea line " + items[15] + " vs " + GetChecksum(line.Trim()));
continue;
}
if (items[6] == "0")
{
Console.WriteLine("No Fix");
continue;
}
gotolocation.Lat = double.Parse(items[2], CultureInfo.InvariantCulture) / 100.0;
gotolocation.Lat = (int)gotolocation.Lat + ((gotolocation.Lat - (int)gotolocation.Lat) / 0.60);
if (items[3] == "S")
gotolocation.Lat *= -1;
gotolocation.Lng = double.Parse(items[4], CultureInfo.InvariantCulture) / 100.0;
gotolocation.Lng = (int)gotolocation.Lng + ((gotolocation.Lng - (int)gotolocation.Lng) / 0.60);
if (items[5] == "W")
gotolocation.Lng *= -1;
gotolocation.Alt = double.Parse(items[9], CultureInfo.InvariantCulture);
gotolocation.Tag = "Sats "+ items[7] + " hdop " + items[8] ;
}
if (DateTime.Now > nextsend && gotolocation.Lat != 0 && gotolocation.Lng != 0 && gotolocation.Alt != 0) // 200 * 10 = 2 sec /// lastgotolocation != gotolocation &&
{
nextsend = DateTime.Now.AddMilliseconds(1000/updaterate);
Console.WriteLine("new home wp " +DateTime.Now.ToString("h:MM:ss")+" "+ gotolocation.Lat + " " + gotolocation.Lng + " " +gotolocation.Alt);
lastgotolocation = new PointLatLngAlt(gotolocation);
Locationwp gotohere = new Locationwp();
gotohere.id = (byte)MAVLink.MAV_CMD.WAYPOINT;
gotohere.alt = (float)(gotolocation.Alt);
gotohere.lat = (gotolocation.Lat);
gotohere.lng = (gotolocation.Lng);
try
{
updateLocationLabel(gotohere);
}
catch { }
MainV2.comPort.MAV.cs.MovingBase = gotolocation;
// plane only
if (updaterallypnt && DateTime.Now > nextrallypntupdate)
{
nextrallypntupdate = DateTime.Now.AddSeconds(5);
try
{
MainV2.comPort.setParam("RALLY_TOTAL", 1);
MainV2.comPort.setRallyPoint(0, new PointLatLngAlt(gotolocation) { Alt = gotolocation.Alt + double.Parse(MainV2.config["TXT_DefaultAlt"].ToString()) }, 0, 0, 0, (byte)(float)MainV2.comPort.MAV.param["RALLY_TOTAL"]);
MainV2.comPort.setParam("RALLY_TOTAL", 1);
}
catch (Exception ex) { Console.WriteLine(ex.ToString()); }
}
}
}
catch { System.Threading.Thread.Sleep((int)(1000 / updaterate)); }
}
sw.Close();
}
开发者ID:jackmaynard,项目名称:MissionPlanner,代码行数:97,代码来源:MovingBase.cs
示例16: saveWPs
void saveWPs(object sender, ProgressWorkerEventArgs e, object passdata = null)
{
try
{
MAVLinkInterface port = comPort;
if (!port.BaseStream.IsOpen)
{
//throw new Exception("Please connect first!");
throw new Exception("请先连接无人机!");
}
comPort.giveComport = true;
int a = 0;
// define the home point
Locationwp home = new Locationwp();
try
{
home.id = (byte)MAVLink.MAV_CMD.WAYPOINT;
home.lat = (double.Parse(TXT_homelat.Text));
home.lng = (double.Parse(TXT_homelng.Text));
home.alt = (float.Parse(TXT_homealt.Text) / CurrentState.multiplierdist); // use saved home
}
catch { throw new Exception("Your home location is invalid"); }
// log
//log.Info("wps values " + comPort.MAV.wps.Values.Count);
//log.Info("cmd rows " + (Commands.Rows.Count + 1)); // + home
// check for changes / future mod to send just changed wp's
if (comPort.MAV.wps.Values.Count == (Commands.Rows.Count + 1))
{
Hashtable wpstoupload = new Hashtable();
a = -1;
foreach (var item in comPort.MAV.wps.Values)
{
// skip home
if (a == -1)
{
a++;
continue;
}
MAVLink.mavlink_mission_item_t temp = DataViewtoLocationwp(a);
if (temp.command == item.command &&
temp.x == item.x &&
temp.y == item.y &&
temp.z == item.z &&
temp.param1 == item.param1 &&
temp.param2 == item.param2 &&
temp.param3 == item.param3 &&
temp.param4 == item.param4
)
{
//log.Info("wp match " + (a + 1));
}
else
{
//log.Info("wp no match" + (a + 1));
wpstoupload[a] = "";
}
a++;
}
}
// set wp total
((ProgressReporterDialogue)sender).UpdateProgressAndStatus(0, "上传航点数量");
ushort totalwpcountforupload = (ushort)(Commands.Rows.Count + 1);
port.setWPTotal(totalwpcountforupload); // + home
// set home location - overwritten/ignored depending on firmware.
((ProgressReporterDialogue)sender).UpdateProgressAndStatus(0, "上传回家点");
var homeans = port.setWP(home, 0, MAVLink.MAV_FRAME.GLOBAL, 0);
if (homeans != MAVLink.MAV_MISSION_RESULT.MAV_MISSION_ACCEPTED)
{
CustomMessageBox.Show(Strings.ErrorRejectedByMAV, Strings.ERROR);
return;
}
// define the default frame.
MAVLink.MAV_FRAME frame = MAVLink.MAV_FRAME.GLOBAL_RELATIVE_ALT;
// get the command list from the datagrid
var commandlist = GetCommandList();
// upload from wp1, as home is alreadey sent
a = 1;
// process commandlist to the mav
foreach (var temp in commandlist)
{
// this code below fails
//a = commandlist.IndexOf(temp) + 1;
//.........这里部分代码省略.........
开发者ID:kkouer,项目名称:PcGcs,代码行数:101,代码来源:GCS.cs
示例17: setWP
/// <summary>
/// Save wp to eeprom
/// </summary>
/// <param name="loc">location struct</param>
/// <param name="index">wp no</param>
/// <param name="frame">global or relative</param>
/// <param name="current">0 = no , 2 = guided mode</param>
public MAV_MISSION_RESULT setWP(Locationwp loc, ushort index, MAV_FRAME frame, byte current = 0, byte autocontinue = 1)
{
giveComport = true;
mavlink_mission_item_t req = new mavlink_mission_item_t();
req.target_system = MAV.sysid;
req.target_component = MAV.compid; // MSG_NAMES.MISSION_ITEM
req.command = loc.id;
req.current = current;
req.autocontinue = autocontinue;
req.frame = (byte)frame;
req.y = (float)(loc.lng);
req.x = (float)(loc.lat);
req.z = (float)(loc.alt);
req.param1 = loc.p1;
req.param2 = loc.p2;
req.param3 = loc.p3;
req.param4 = loc.p4;
req.seq = index;
log.InfoFormat("setWP {6} frame {0} cmd {1} p1 {2} x {3} y {4} z {5}", req.frame, req.command, req.param1, req.x, req.y, req.z, index);
// request
generatePacket((byte)MAVLINK_MSG_ID.MISSION_ITEM, req);
DateTime start = DateTime.Now;
int retrys = 10;
while (true)
{
if (!(start.AddMilliseconds(400) > DateTime.Now))
{
if (retrys > 0)
{
log.Info("setWP Retry " + retrys);
generatePacket((byte)MAVLINK_MSG_ID.MISSION_ITEM, req);
start = DateTime.Now;
retrys--;
continue;
}
giveComport = false;
throw new Exception("Timeout on read - setWP");
}
byte[] buffer = readPacket();
if (buffer.Length > 5)
{
if (buffer[5] == (byte)MAVLINK_MSG_ID.MISSION_ACK)
{
var ans = buffer.ByteArrayToStructure<mavlink_mission_ack_t>(6);
log.Info("set wp " + index + " ACK 47 : " + buffer[5] + " ans " + Enum.Parse(typeof(MAV_MISSION_RESULT), ans.type.ToString()));
if (req.current == 2)
{
MAV.GuidedMode = req;
}
else if (req.current == 3)
{
}
else
{
MAV.wps[req.seq] = req;
}
return (MAV_MISSION_RESULT)ans.type;
}
else if (buffer[5] == (byte)MAVLINK_MSG_ID.MISSION_REQUEST)
{
var ans = buffer.ByteArrayToStructure<mavlink_mission_request_t>(6);
if (ans.seq == (index + 1))
{
log.Info("set wp doing " + index + " req " + ans.seq + " REQ 40 : " + buffer[5]);
giveComport = false;
if (req.current == 2)
{
MAV.GuidedMode = req;
}
else if (req.current == 3)
{
}
else
{
MAV.wps[req.seq] = req;
}
//.........这里部分代码省略.........
开发者ID:pandagxnu,项目名称:MissionPlanner,代码行数:101,代码来源:MAVLink.cs
示例18: writeKML
//.........这里部分代码省略.........
// cycle through reps
for (int repno = repeat; repno > 0; repno--)
{
// cycle through wps
for (int no = wpno; no <= a; no++)
{
if (pointlist[no] != null)
list.Add(pointlist[no]);
}
}
fullpointlist.AddRange(list);
}
else
{
pointlist.Add(null);
}
}
catch (Exception e)
{
log.Info("writekml - bad wp data " + e);
}
}
if (usable > 0)
{
avglat = avglat / usable;
avglong = avglong / usable;
double latdiff = maxlat - minlat;
double longdiff = maxlong - minlong;
float range = 4000;
Locationwp loc1 = new Locationwp();
loc1.lat = (minlat);
loc1.lng = (minlong);
Locationwp loc2 = new Locationwp();
loc2.lat = (maxlat);
loc2.lng = (maxlong);
//double distance = getDistance(loc1, loc2); // same code as ardupilot
double distance = 2000;
if (usable > 1)
{
range = (float)(distance * 2);
}
else
{
range = 4000;
}
if (avglong != 0 && usable < 3)
{
// no autozoom
lookat = "<LookAt> <longitude>" + (minlong + longdiff / 2).ToString(new CultureInfo("en-US")) + "</longitude> <latitude>" + (minlat + latdiff / 2).ToString(new CultureInfo("en-US")) + "</latitude> <range>" + range + "</range> </LookAt>";
//MainMap.ZoomAndCenterMarkers("objects");
//MainMap.Zoom -= 1;
//MainMap_OnMapZoomChanged();
}
}
else if (home.Length > 5 && usable == 0)
{
lookat = "<LookAt> <longitude>" + TXT_homelng.Text.ToString(new CultureInfo("en-US")) + "</longitude> <latitude>" + TXT_homelat.Text.ToString(new CultureInfo("en-US")) + "</latitude> <range>4000</range> </LookAt>";
RectLatLng? rect = gMapControl1.GetRectOfAllMarkers("objects");
开发者ID:kkouer,项目名称:PcGcs,代码行数:67,代码来源:GCS.cs
示例19: DoAcceptTcpClientCallback
//.........这里部分代码省略.........
MemoryStream streamjpg = new MemoryStream();
imgout.Save(streamjpg, System.Drawing.Imaging.ImageFormat.Jpeg);
data = streamjpg.ToArray();
}
header = "Content-Type: image/jpeg\r\nContent-Length: " + data.Length + "\r\n\r\n";
temp = asciiEncoding.GetBytes(header);
stream.Write(temp, 0, temp.Length);
stream.Write(data, 0, data.Length);
header = "\r\n--APMPLANNER\r\n";
temp = asciiEncoding.GetBytes(header);
stream.Write(temp, 0, temp.Length);
}
GCSViews.FlightData.mymap.streamjpgenable = false;
GCSViews.FlightData.myhud.streamjpgenable = false;
stream.Close();
}
else if (url.Contains("/guided?"))
{
//http://127.0.0.1:56781/guided?lat=-34&lng=117.8&alt=30
Regex rex = new Regex(@"lat=([\-\.0-9]+)&lng=([\-\.0-9]+)&alt=([\.0-9]+)", RegexOptions.IgnoreCase);
Match match = rex.Match(url);
if (match.Success)
{
|
请发表评论