本文整理汇总了C#中MissionPlanner.MAVLinkInterface类的典型用法代码示例。如果您正苦于以下问题:C# MAVLinkInterface类的具体用法?C# MAVLinkInterface怎么用?C# MAVLinkInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MAVLinkInterface类属于MissionPlanner命名空间,在下文中一共展示了MAVLinkInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: getOffsetFromLeader
public HIL.Vector3 getOffsetFromLeader(MAVLinkInterface leader, MAVLinkInterface mav)
{
//convert Wgs84ConversionInfo to utm
CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
GeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;
int utmzone = (int)((leader.MAV.cs.lng - -186.0) / 6.0);
IProjectedCoordinateSystem utm = ProjectedCoordinateSystem.WGS84_UTM(utmzone, leader.MAV.cs.lat < 0 ? false : true);
ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84, utm);
double[] masterpll = { leader.MAV.cs.lng, leader.MAV.cs.lat };
// get leader utm coords
double[] masterutm = trans.MathTransform.Transform(masterpll);
double[] mavpll = { mav.MAV.cs.lng, mav.MAV.cs.lat };
//getLeader follower utm coords
double[] mavutm = trans.MathTransform.Transform(mavpll);
return new HIL.Vector3(masterutm[1] - mavutm[1], masterutm[0] - mavutm[0], 0);
}
开发者ID:jmkirsch,项目名称:MissionPlanner,代码行数:25,代码来源:FormationControl.cs
示例2: UpdateIcon
public void UpdateIcon(MAVLinkInterface mav, float x, float y, float z, bool movable)
{
foreach (var icon in icons)
{
if (icon.interf == mav)
{
icon.Movable = movable;
if (!movable)
{
icon.x = 0;
icon.y = 0;
icon.z = 0;
icon.Color = Color.Blue;
}
else
{
icon.x = x;
icon.y = y;
icon.z = z;
icon.Color = Color.Red;
}
this.Invalidate();
return;
}
}
Console.WriteLine("ADD MAV {0} {1} {2}",x,y,z);
icons.Add(new icon() { interf = mav, y=y, z = z,x = x, Movable = movable, Name = mav.ToString() });
}
开发者ID:ECain,项目名称:MissionPlanner,代码行数:29,代码来源:Grid.cs
示例3: MAVState
public MAVState(MAVLinkInterface mavLinkInterface)
{
this.parent = mavLinkInterface;
this.packetspersecond = new double[0x100];
this.packetspersecondbuild = new DateTime[0x100];
this.lastvalidpacket = DateTime.MinValue;
this.sysid = 0;
this.compid = 0;
sendlinkid = (byte)(new Random().Next(256));
signing = false;
this.param = new MAVLinkParamList();
this.packets = new Dictionary<uint, MAVLinkMessage>();
this.aptype = 0;
this.apname = 0;
this.recvpacketcount = 0;
this.VersionString = "";
this.SoftwareVersions = "";
this.SerialString = "";
this.FrameString = "";
camerapoints.Clear();
GMapMarkerOverlapCount.Clear();
this.packetslost = 0f;
this.packetsnotlost = 0f;
this.packetlosttimer = DateTime.MinValue;
cs.parent = this;
}
开发者ID:nitbot,项目名称:MissionPlanner,代码行数:29,代码来源:MAVState.cs
示例4: ConfigPanel
public ConfigPanel(string XMLFile, MAVLinkInterface mavinterface)
{
_mavinterface = mavinterface;
InitializeComponent();
LoadXML(XMLFile);
}
开发者ID:LeoTosti,项目名称:x-drone,代码行数:8,代码来源:ConfigPanel.cs
示例5: getOffsets
public HIL.Vector3 getOffsets(MAVLinkInterface mav)
{
if (offsets.ContainsKey(mav))
{
return offsets[mav];
}
return new HIL.Vector3(offsets.Count, 0, 0);
}
开发者ID:AndersonRayner,项目名称:MissionPlanner,代码行数:9,代码来源:Formation.cs
示例6: tlogToCSV
public static string tlogToCSV(string filepath)
{
CurrentState.SpeedUnit = "m/s";
CurrentState.DistanceUnit = "m";
MAVLinkInterface proto = new MAVLinkInterface();
OpenFileDialog openFileDialog1 = new OpenFileDialog();
string LogFilePath;
openFileDialog1.FileName = filepath;
foreach (string logfile in openFileDialog1.FileNames)
{
using (MAVLinkInterface mine = new MAVLinkInterface())
{
try
{
mine.logplaybackfile = new BinaryReader(File.Open(logfile, FileMode.Open, FileAccess.Read, FileShare.Read));
}
catch (Exception ex) { log.Debug(ex.ToString()); }
mine.logreadmode = true;
mine.MAV.packets.Initialize(); // clear
StreamWriter sw = new StreamWriter(Path.GetDirectoryName(logfile) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(logfile) + ".csv");
while (mine.logplaybackfile.BaseStream.Position < mine.logplaybackfile.BaseStream.Length)
{
byte[] packet = mine.readPacket();
string text = "";
mine.DebugPacket(packet, ref text, true, ",");
sw.Write(mine.lastlogread.ToString("yyyy-MM-ddTHH:mm:ss.fff") + "," + text);
}
sw.Close();
mine.logreadmode = false;
mine.logplaybackfile.Close();
mine.logplaybackfile = null;
LogFilePath = (Path.GetDirectoryName(logfile) + Path.DirectorySeparatorChar + (Path.GetFileNameWithoutExtension(logfile) + ".csv"));
return LogFilePath;
}
}
return null;
}
开发者ID:mwrightevent38,项目名称:tlogconvertor,代码行数:50,代码来源:ImageUtility.cs
示例7: BUT_connect_Click
private void BUT_connect_Click(object sender, EventArgs e)
{
var mav = new MAVLinkInterface();
try
{
MainV2.instance.doConnect(mav, CMB_serialport.Text, CMB_baudrate.Text);
MainV2.Comports.Add(mav);
}
catch (Exception ex)
{
}
}
开发者ID:hmchen1,项目名称:MissionPlanner,代码行数:14,代码来源:ConnectionOptions.cs
示例8: magfit
public static string magfit(string logfile)
{
//'''find best magnetometer rotation fit to a log file'''
// print("Processing log %s" % filename);
// mlog = mavutil.mavlink_connection(filename, notimestamps=opts.notimestamps);
MAVLinkInterface mavint = new MAVLinkInterface();
try
{
mavint.BaseStream = new Comms.CommsFile();
mavint.BaseStream.PortName = logfile;
mavint.BaseStream.Open();
}
catch (Exception ex) { return ""; }
mavint.logreadmode = true;
return process(mavint);
}
开发者ID:tinashanica,项目名称:MissionPlanner,代码行数:21,代码来源:Magfitrotation.cs
示例9: UpdateCurrentSettings
public void UpdateCurrentSettings(System.Windows.Forms.BindingSource bs, bool updatenow,
MAVLinkInterface mavinterface, MAVState MAV)
{
lock (this)
{
if (DateTime.Now > lastupdate.AddMilliseconds(50) || updatenow) // 20 hz
{
lastupdate = DateTime.Now;
//check if valid mavinterface
if (parent != null && parent.packetsnotlost != 0)
{
if ((DateTime.Now - MAV.lastvalidpacket).TotalSeconds > 10)
{
linkqualitygcs = 0;
}
else
{
linkqualitygcs =
(ushort) ((parent.packetsnotlost/(parent.packetsnotlost + parent.packetslost))*100.0);
}
if (linkqualitygcs > 100)
linkqualitygcs = 100;
}
if (datetime.Second != lastsecondcounter.Second)
{
lastsecondcounter = datetime;
if (lastpos.Lat != 0 && lastpos.Lng != 0 && armed)
{
if (!mavinterface.BaseStream.IsOpen && !mavinterface.logreadmode)
distTraveled = 0;
distTraveled += (float) lastpos.GetDistance(new PointLatLngAlt(lat, lng, 0, ""))*
multiplierdist;
lastpos = new PointLatLngAlt(lat, lng, 0, "");
}
else
{
lastpos = new PointLatLngAlt(lat, lng, 0, "");
}
// throttle is up, or groundspeed is > 3 m/s
if (ch3percent > 12 || _groundspeed > 3.0)
timeInAir++;
if (!gotwind)
dowindcalc();
}
// re-request streams
if (!(lastdata.AddSeconds(8) > DateTime.Now) && mavinterface.BaseStream.IsOpen)
{
try
{
mavinterface.requestDatastream(MAVLink.MAV_DATA_STREAM.EXTENDED_STATUS, MAV.cs.ratestatus,
MAV.sysid); // mode
mavinterface.requestDatastream(MAVLink.MAV_DATA_STREAM.POSITION, MAV.cs.rateposition,
MAV.sysid); // request gps
mavinterface.requestDatastream(MAVLink.MAV_DATA_STREAM.EXTRA1, MAV.cs.rateattitude,
MAV.sysid); // request attitude
mavinterface.requestDatastream(MAVLink.MAV_DATA_STREAM.EXTRA2, MAV.cs.rateattitude,
MAV.sysid); // request vfr
mavinterface.requestDatastream(MAVLink.MAV_DATA_STREAM.EXTRA3, MAV.cs.ratesensors, MAV.sysid);
// request extra stuff - tridge
mavinterface.requestDatastream(MAVLink.MAV_DATA_STREAM.RAW_SENSORS, MAV.cs.ratesensors,
MAV.sysid); // request raw sensor
mavinterface.requestDatastream(MAVLink.MAV_DATA_STREAM.RC_CHANNELS, MAV.cs.raterc, MAV.sysid);
// request rc info
}
catch
{
log.Error("Failed to request rates");
}
lastdata = DateTime.Now.AddSeconds(30); // prevent flooding
}
byte[] bytearray = MAV.packets[(byte) MAVLink.MAVLINK_MSG_ID.RC_CHANNELS_SCALED];
if (bytearray != null) // hil mavlink 0.9
{
var hil = bytearray.ByteArrayToStructure<MAVLink.mavlink_rc_channels_scaled_t>(6);
hilch1 = hil.chan1_scaled;
hilch2 = hil.chan2_scaled;
hilch3 = hil.chan3_scaled;
hilch4 = hil.chan4_scaled;
hilch5 = hil.chan5_scaled;
hilch6 = hil.chan6_scaled;
hilch7 = hil.chan7_scaled;
hilch8 = hil.chan8_scaled;
// Console.WriteLine("RC_CHANNELS_SCALED Packet");
MAV.packets[(byte) MAVLink.MAVLINK_MSG_ID.RC_CHANNELS_SCALED] = null;
}
bytearray = MAV.packets[(byte) MAVLink.MAVLINK_MSG_ID.AUTOPILOT_VERSION];
//.........这里部分代码省略.........
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:101,代码来源:CurrentState.cs
示例10: getOffsets
/// <summary>
/// Processes a tlog to get the offsets - creates dxf of data
/// </summary>
/// <param name="fn">Filename</param>
/// <returns>Offsets</returns>
public static double[] getOffsets(string fn, int throttleThreshold = 0)
{
// based off tridge's work
string logfile = fn;
// old method
float minx = 0;
float maxx = 0;
float miny = 0;
float maxy = 0;
float minz = 0;
float maxz = 0;
// this is for a dxf
Polyline3dVertex vertex;
List<Polyline3dVertex> vertexes = new List<Polyline3dVertex>();
// data storage
Tuple<float, float, float> offset = new Tuple<float, float, float>(0, 0, 0);
List<Tuple<float, float, float>> data = new List<Tuple<float, float, float>>();
Hashtable filter = new Hashtable();
// track data to use
bool useData = false;
if (throttleThreshold <= 0)
useData = true;
log.Info("Start log: " + DateTime.Now);
using (MAVLinkInterface mine = new MAVLinkInterface())
{
try
{
mine.logplaybackfile =
new BinaryReader(File.Open(logfile, FileMode.Open, FileAccess.Read, FileShare.Read));
}
catch (Exception ex)
{
log.Debug(ex.ToString());
CustomMessageBox.Show("Log Can not be opened. Are you still connected?");
return new double[] {0};
}
mine.logreadmode = true;
mine.MAV.packets.Initialize(); // clear
// gather data
while (mine.logplaybackfile.BaseStream.Position < mine.logplaybackfile.BaseStream.Length)
{
byte[] packetraw = mine.readPacket();
var packet = mine.DebugPacket(packetraw, false);
// this is for packets we dont know about
if (packet == null)
continue;
if (packet.GetType() == typeof (MAVLink.mavlink_vfr_hud_t))
{
if (((MAVLink.mavlink_vfr_hud_t) packet).throttle >= throttleThreshold)
{
useData = true;
}
else
{
useData = false;
}
}
if (packet.GetType() == typeof (MAVLink.mavlink_sensor_offsets_t))
{
offset = new Tuple<float, float, float>(
((MAVLink.mavlink_sensor_offsets_t) packet).mag_ofs_x,
((MAVLink.mavlink_sensor_offsets_t) packet).mag_ofs_y,
((MAVLink.mavlink_sensor_offsets_t) packet).mag_ofs_z);
}
else if (packet.GetType() == typeof (MAVLink.mavlink_raw_imu_t) && useData)
{
int div = 20;
// fox dxf
vertex = new Polyline3dVertex(new Vector3f(
((MAVLink.mavlink_raw_imu_t) packet).xmag - offset.Item1,
((MAVLink.mavlink_raw_imu_t) packet).ymag - offset.Item2,
((MAVLink.mavlink_raw_imu_t) packet).zmag - offset.Item3)
);
vertexes.Add(vertex);
// for old method
setMinorMax(((MAVLink.mavlink_raw_imu_t) packet).xmag - offset.Item1, ref minx, ref maxx);
setMinorMax(((MAVLink.mavlink_raw_imu_t) packet).ymag - offset.Item2, ref miny, ref maxy);
//.........这里部分代码省略.........
开发者ID:ans10528,项目名称:MissionPlanner-MissionPlanner1.3.34,代码行数:101,代码来源:MagCalib.cs
示例11: setLeader
public void setLeader(MAVLinkInterface lead)
{
Leader = lead;
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:4,代码来源:Swarm.cs
示例12: setOffsets
public void setOffsets(MAVLinkInterface mav, double x, double y, double z)
{
offsets[mav] = new HIL.Vector3(x, y, z);
//log.Info(mav.ToString() + " " + offsets[mav].ToString());
}
开发者ID:AndersonRayner,项目名称:MissionPlanner,代码行数:5,代码来源:Formation.cs
示例13: doConnect
public void doConnect(MAVLinkInterface comPort, string port, string baud)
{
bool skipconnectcheck = true;
comPort.BaseStream = new MissionPlanner.Comms.SerialPort();
comPort.BaseStream.PortName = port;
try
{
comPort.BaseStream.BaudRate = int.Parse(baud);
}
catch { };
// 记录tlog文件
try
{
Directory.CreateDirectory("D://LogFiles");
//Directory.CreateDirectory(MainV2.LogDir);
comPort.logfile =
new BufferedStream(
File.Open(
"D://LogFiles" + Path.DirectorySeparatorChar +
DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".tlog", FileMode.CreateNew,
FileAccess.ReadWrite, FileShare.None));
}
catch (Exception exp2)
{
log.Error(exp2);
CustomMessageBox.Show(Strings.Failclog);
} // soft fail
comPort.Open(false, skipconnectcheck);
// create a copy
int[] list = comPort.sysidseen.ToArray();
comPort.GetParam("MIS_TOTAL");
}
开发者ID:kkouer,项目名称:PcGcs,代码行数:39,代码来源:GCS.cs
示例14: doConnect
public void doConnect(MAVLinkInterface comPort, string portname, string baud)
{
bool skipconnectcheck = false;
log.Info("We are connecting");
switch (portname)
{
case "preset":
skipconnectcheck = true;
break;
case "TCP":
comPort.BaseStream = new TcpSerial();
_connectionControl.CMB_serialport.Text = "TCP";
break;
case "UDP":
comPort.BaseStream = new UdpSerial();
_connectionControl.CMB_serialport.Text = "UDP";
break;
case "UDPCl":
comPort.BaseStream = new UdpSerialConnect();
_connectionControl.CMB_serialport.Text = "UDPCl";
break;
case "AUTO":
default:
comPort.BaseStream = new SerialPort();
break;
}
// Tell the connection UI that we are now connected.
_connectionControl.IsConnected(true);
// Here we want to reset the connection stats counter etc.
this.ResetConnectionStats();
comPort.MAV.cs.ResetInternals();
//cleanup any log being played
comPort.logreadmode = false;
if (comPort.logplaybackfile != null)
comPort.logplaybackfile.Close();
comPort.logplaybackfile = null;
try
{
// do autoscan
if (portname == "AUTO")
{
Comms.CommsSerialScan.Scan(false);
DateTime deadline = DateTime.Now.AddSeconds(50);
while (Comms.CommsSerialScan.foundport == false)
{
System.Threading.Thread.Sleep(100);
if (DateTime.Now > deadline)
{
CustomMessageBox.Show(Strings.Timeout);
_connectionControl.IsConnected(false);
return;
}
}
_connectionControl.CMB_serialport.Text = portname = Comms.CommsSerialScan.portinterface.PortName;
_connectionControl.CMB_baudrate.Text = baud = Comms.CommsSerialScan.portinterface.BaudRate.ToString();
}
log.Info("Set Portname");
// set port, then options
comPort.BaseStream.PortName = portname;
log.Info("Set Baudrate");
try
{
comPort.BaseStream.BaudRate = int.Parse(baud);
}
catch (Exception exp)
{
log.Error(exp);
}
// prevent serialreader from doing anything
comPort.giveComport = true;
log.Info("About to do dtr if needed");
// reset on connect logic.
if (config["CHK_resetapmonconnect"] == null || bool.Parse(config["CHK_resetapmonconnect"].ToString()) == true)
{
log.Info("set dtr rts to false");
comPort.BaseStream.DtrEnable = false;
comPort.BaseStream.RtsEnable = false;
comPort.BaseStream.toggleDTR();
}
comPort.giveComport = false;
// setup to record new logs
try
{
Directory.CreateDirectory(MainV2.LogDir);
//.........这里部分代码省略.........
开发者ID:rrvenki,项目名称:MissionPlanner,代码行数:101,代码来源:MainV2.cs
示例15: but_multimav_Click
private void but_multimav_Click(object sender, EventArgs e)
{
Comms.CommsSerialScan.Scan(false);
DateTime deadline = DateTime.Now.AddSeconds(50);
while (Comms.CommsSerialScan.foundport == false)
{
System.Threading.Thread.Sleep(100);
if (DateTime.Now > deadline)
{
CustomMessageBox.Show("Timeout waiting for autoscan/no mavlink device connected");
return;
}
}
MAVLinkInterface com2 = new MAVLinkInterface();
com2.BaseStream.PortName = Comms.CommsSerialScan.portinterface.PortName;
com2.BaseStream.BaudRate = Comms.CommsSerialScan.portinterface.BaudRate;
com2.Open(true);
MainV2.Comports.Add(com2);
CMB_mavs.DataSource = MainV2.Comports;
}
开发者ID:RealTadango,项目名称:MissionPlanner,代码行数:28,代码来源:temp.cs
示例16: readLog
List<string[]> readLog(string fn)
{
if (logcache.Count > 0)
return logcache;
List<string[]> list = new List<string[]>();
if (fn.ToLower().EndsWith("tlog"))
{
MAVLinkInterface mine = new MAVLinkInterface();
mine.logplaybackfile = new BinaryReader(File.Open(fn, FileMode.Open, FileAccess.Read, FileShare.Read));
mine.logreadmode = true;
mine.MAV.packets.Initialize(); // clear
CurrentState cs = new CurrentState();
string[] oldvalues = {""};
while (mine.logplaybackfile.BaseStream.Position < mine.logplaybackfile.BaseStream.Length)
{
byte[] packet = mine.readPacket();
cs.datetime = mine.lastlogread;
cs.UpdateCurrentSettings(null, true, mine);
// old
// line "GPS: 82686250, 1, 8, -34.1406480, 118.5441900, 0.0000, 309.1900, 315.9500, 0.0000, 279.1200" string
//Status,Time,NSats,HDop,Lat,Lng,RelAlt,Alt,Spd,GCrs
//GPS, 3, 122732, 10, 0.00, -35.3628880, 149.1621961, 808.90, 810.30, 23.30, 94.04
string[] vals = new string[] { "GPS", "3", (cs.datetime.ToUniversalTime() - new DateTime(cs.datetime.Year,cs.datetime.Month,cs.datetime.Day,0,0,0,DateTimeKind.Utc)).TotalMilliseconds.ToString(),
cs.satcount.ToString(),cs.gpshdop.ToString(),cs.lat.ToString(),cs.lng.ToString(),cs.altasl.ToString(),cs.altasl.ToString(),cs.groundspeed.ToString(),cs.yaw.ToString()};
if (oldvalues.Length > 2 && oldvalues[latpos] == vals[latpos]
&& oldvalues[lngpos] == vals[lngpos]
&& oldvalues[altpos] == vals[altpos])
continue;
oldvalues = vals;
list.Add(vals);
// 4 5 7
Console.Write((mine.logplaybackfile.BaseStream.Position * 100 / mine.logplaybackfile.BaseStream.Length) + " \r");
}
mine.logplaybackfile.Close();
logcache = list;
return list;
}
StreamReader sr = new StreamReader(fn);
string lasttime = "0";
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
if (line.ToLower().StartsWith("gps"))
{
if (!sr.EndOfStream)
{
string line2 = sr.ReadLine();
if (line2.ToLower().StartsWith("att"))
{
line = string.Concat(line, ",", line2);
}
}
string[] vals = line.Split(new char[] {',',':'});
if (lasttime == vals[timepos])
continue;
lasttime = vals[timepos];
list.Add(vals);
}
}
sr.Close();
logcache = list;
return list;
}
开发者ID:LeoTosti,项目名称:x-drone,代码行数:93,代码来源:georefimage.cs
示例17: process
static string process(MAVLinkInterface mavint)
{
DateTime Deadline = DateTime.Now.AddSeconds(60);
Vector3 last_mag = null;
double last_usec = 0;
double count = 0;
double[] total_error = new double[rotations.Length];
float AHRS_ORIENTATION = 0;
float COMPASS_ORIENT = 0;
float COMPASS_EXTERNAL = 0;
//# now gather all the data
while (DateTime.Now < Deadline || mavint.BaseStream.BytesToRead > 0)
{
MAVLink.MAVLinkMessage packetbytes = mavint.readPacket();
if (packetbytes.Length < 5)
continue;
object packet = packetbytes.data;
if (packet == null)
continue;
if (packet is MAVLink.mavlink_param_value_t)
{
MAVLink.mavlink_param_value_t m = (MAVLink.mavlink_param_value_t) packet;
if (str(m.param_id) == "AHRS_ORIENTATION")
AHRS_ORIENTATION = (int) (m.param_value);
if (str(m.param_id) == "COMPASS_ORIENT")
COMPASS_ORIENT = (int) (m.param_value);
if (str(m.param_id) == "COMPASS_EXTERNAL")
COMPASS_EXTERNAL = (int) (m.param_value);
}
if (packet is MAVLink.mavlink_raw_imu_t)
{
MAVLink.mavlink_raw_imu_t m = (MAVLink.mavlink_raw_imu_t) packet;
Vector3 mag = new Vector3(m.xmag, m.ymag, m.zmag);
mag = mag_fixup(mag, AHRS_ORIENTATION, COMPASS_ORIENT, COMPASS_EXTERNAL);
Vector3 gyr = new Vector3(m.xgyro, m.ygyro, m.zgyro)*0.001;
double usec = m.time_usec;
if (last_mag != null && gyr.length() > radians(5.0))
{
add_errors(mag, gyr, last_mag, (usec - last_usec)*1.0e-6, total_error, rotations);
count += 1;
}
last_mag = mag;
last_usec = usec;
}
}
int best_i = 0;
double best_err = total_error[0];
foreach (var i in range(len(rotations)))
{
Rotation r = rotations[i];
// if (!r.is_90_degrees())
// continue;
//if ( opts.verbose) {
// print("%s err=%.2f" % (r, total_error[i]/count));}
if (total_error[i] < best_err)
{
best_i = i;
best_err = total_error[i];
}
}
Rotation rans = rotations[best_i];
Console.WriteLine("Best rotation is {0} err={1} from {2} points", rans, best_err/count, count);
//print("Best rotation is %s err=%.2f from %u points" % (r, best_err/count, count));
return rans.name;
}
开发者ID:ChukRhodes,项目名称:MissionPlanner,代码行数:71,代码来源:Magfitrotation.cs
示例18: but_droneapi_Click
private void but_droneapi_Click(object sender, EventArgs e)
{
string droneshareusername = MainV2.getConfig("droneshareusername");
InputBox.Show("Username", "Username", ref droneshareusername);
MainV2.config["droneshareusername"] = droneshareusername;
string dronesharepassword = MainV2.getConfig("dronesharepassword");
if (dronesharepassword != "")
{
try
{
// fail on bad entry
var crypto = new Crypto();
dronesharepassword = crypto.DecryptString(dronesharepassword);
}
catch
{
}
}
InputBox.Show("Password", "Password", ref dronesharepassword, true);
var crypto2 = new Crypto();
string encryptedpw = crypto2.EncryptString(dronesharepassword);
MainV2.config["dronesharepassword"] = encryptedpw;
DroneProto dp = new DroneProto();
if (dp.connect())
{
if (dp.loginUser(droneshareusername, dronesharepassword))
{
MAVLinkInterface mine = new MAVLinkInterface();
var comfile = new CommsFile();
mine.BaseStream = comfile;
mine.BaseStream.PortName = @"C:\Users\hog\Documents\apm logs\iris 6-4-14\2014-04-06 09-07-32.tlog";
mine.BaseStream.Open();
comfile.bps = 4000;
mine.getHeartBeat();
dp.setVechileId(mine.MAV.Guid, 0, mine.MAV.sysid);
dp.startMission();
while (true)
{
byte[] packet = mine.readPacket();
dp.SendMavlink(packet, 0);
}
// dp.close();
// mine.Close();
}
}
}
开发者ID:ans10528,项目名称:MissionPlanner-MissionPlanner1.3.34,代码行数:64,代码来源:temp.cs
示例19: doDisconnect
public void doDisconnect(MAVLinkInterface comPort)
{
try
{
comPort.BaseStream.DtrEnable = false;
comPort.Close();
}
catch
{
}
}
开发者ID:kkouer,项目名称:PcGcs,代码行数:11,代码来源:GCS.cs
示例20: start_Terminal
private void start_Terminal(bool px4)
{
setcomport();
try
{
if (MainV2.comPort != null && MainV2.comPort.BaseStream != null && MainV2.comPort.BaseStream.IsOpen)
MainV2.comPort.BaseStream.Close();
if (comPort.IsOpen)
{
Console.WriteLine("Terminal Start - Close Port");
threadrun = false;
// if (DialogResult.Cancel == CustomMessageBox.Show("The port is open\n Continue?", "Continue", MessageBoxButtons.YesNo))
{
// return;
}
comPort.Close();
// allow things to cleanup
System.Threading.Thread.Sleep(400);
}
comPort.ReadBufferSize = 1024 * 1024 * 4;
comPort.PortName = MainV2.comPortName;
// test moving baud rate line
comPort.BaudRate = int.Parse(MainV2._connectionControl.CMB_baudrate.Text);
if (px4)
{
TXT_terminal.AppendText("Rebooting\n");
// keep it local
MAVLinkInterface mine = new MAVLinkInterface();
mine.BaseStream.PortName = MainV2.comPortName;
mine.BaseStream.BaudRate = comPort.BaudRate;
mine.giveComport = true;
mine.BaseStream.Open();
// check if we are a mavlink stream
byte[] buffer = mine.readPacket();
if (buffer.Length > 0)
{
log.Info("got packet - sending reboot via mavlink");
TXT_terminal.AppendText("Via Mavlink\n");
mine.doReboot(false);
try
{
mine.BaseStream.Close();
}
catch { }
}
else
{
log.Info("no packet - sending reboot via console");
TXT_terminal.AppendText("Via Console\n");
MainV2.comPort.BaseStream.Write("exit\rreboot\r");
try
{
MainV2.comPort.BaseStream.Close();
}
catch { }
}
TXT_terminal.AppendText("Waiting for reboot\n");
// wait 7 seconds for px4 reboot
log.Info("waiting for reboot");
DateTime deadline = DateTime.Now.AddSeconds(8);
while (DateTime.Now < deadline)
{
System.Threading.Thread.Sleep(500);
Application.DoEvents();
}
int a = 0;
while (a < 5)
{
try
{
if (!comPort.IsOpen)
comPort.Open();
}
catch { }
System.Threading.Thread.Sleep(200);
a++;
}
}
else
{
//.........这里部分代码省略.........
开发者ID:RealTadango,项目名称:MissionPlanner,代码行数:101,代码来源:Terminal.cs
注:本文中的MissionPlanner.MAVLinkInterface类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论