本文整理汇总了C#中MissionPlanner.MAVLinkInterface.sendPacket方法的典型用法代码示例。如果您正苦于以下问题:C# MAVLinkInterface.sendPacket方法的具体用法?C# MAVLinkInterface.sendPacket怎么用?C# MAVLinkInterface.sendPacket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MissionPlanner.MAVLinkInterface
的用法示例。
在下文中一共展示了MAVLinkInterface.sendPacket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RECVprocess
//.........这里部分代码省略.........
int read = JSBSimSEND.Client.Receive(buffer);
// Console.WriteLine(ASCIIEncoding.ASCII.GetString(buffer,0,read));
}
sitldata.magic = (int)0x4c56414f;
byte[] sendme = StructureToByteArray(sitldata);
SITLSEND.Send(sendme, sendme.Length);
return;
}
if (chkSITL.Checked)
{
sitldata.magic = (int)0x4c56414f;
byte[] sendme = StructureToByteArray(sitldata);
SITLSEND.Send(sendme, sendme.Length);
return;
}
TimeSpan gpsspan = DateTime.Now - lastgpsupdate;
// add gps delay
if (gpsspan.TotalMilliseconds >= GPS_rate)
{
lastgpsupdate = DateTime.Now;
// save current fix = 3
sitl_fdmbuffer[gpsbufferindex % sitl_fdmbuffer.Length] = sitldata;
// Console.WriteLine((gpsbufferindex % gpsbuffer.Length) + " " + ((gpsbufferindex + (gpsbuffer.Length - 1)) % gpsbuffer.Length));
// return buffer index + 5 = (3 + 5) = 8 % 6 = 2
oldgps = sitl_fdmbuffer[(gpsbufferindex + (sitl_fdmbuffer.Length - 1)) % sitl_fdmbuffer.Length];
//comPort.sendPacket(oldgps);
gpsbufferindex++;
}
MAVLink.mavlink_hil_state_t hilstate = new MAVLink.mavlink_hil_state_t();
DateTime epochBegin = new DateTime(1980, 1, 6, 0, 0, 0, DateTimeKind.Utc);
hilstate.time_usec = (UInt64)((DateTime.Now.Ticks - epochBegin.Ticks) / 10); // microsec
hilstate.lat = (int)(oldgps.latitude * 1e7); // * 1E7
hilstate.lon = (int)(oldgps.longitude * 1e7); // * 1E7
hilstate.alt = (int)(oldgps.altitude * 1000); // mm
// Console.WriteLine(hilstate.alt);
// Console.WriteLine("{0} {1} {2}", sitldata.rollDeg.ToString("0.0"), sitldata.pitchDeg.ToString("0.0"), sitldata.yawDeg.ToString("0.0"));
hilstate.pitch = (float)sitldata.pitchDeg * deg2rad; // (rad)
hilstate.pitchspeed = (float)sitldata.pitchRate * deg2rad; // (rad/s)
hilstate.roll = (float)sitldata.rollDeg * deg2rad; // (rad)
hilstate.rollspeed = (float)sitldata.rollRate * deg2rad; // (rad/s)
hilstate.yaw = (float)sitldata.yawDeg * deg2rad; // (rad)
hilstate.yawspeed = (float)sitldata.yawRate * deg2rad; // (rad/s)
hilstate.vx = (short)(sitldata.speedN * 100); // m/s * 100 - lat
hilstate.vy = (short)(sitldata.speedE * 100); // m/s * 100 - long
hilstate.vz = (short)(sitldata.speedD * 100); // m/s * 100 - + speed down
hilstate.xacc = (short)(sitldata.xAccel * 101.957); // (mg)
hilstate.yacc = (short)(sitldata.yAccel * 101.957); // (mg)
hilstate.zacc = (short)(sitldata.zAccel * 101.957); // (mg)
packetcount++;
if (!comPort.BaseStream.IsOpen)
return;
if (comPort.BaseStream.BytesToWrite > 100)
return;
// if (packetcount % 2 == 0)
// return;
comPort.sendPacket(hilstate);
// comPort.sendPacket(oldgps);
//comPort.sendPacket(new MAVLink.mavlink_vfr_hud_t() { airspeed = (float)sitldata.airspeed } );
MAVLink.mavlink_raw_pressure_t pres = new MAVLink.mavlink_raw_pressure_t();
double calc = (101325 * Math.Pow(1 - 2.25577 * Math.Pow(10, -5) * sitldata.altitude, 5.25588)); // updated from valid gps
pres.press_diff1 = (short)(int)(calc - 101325); // 0 alt is 0 pa
// comPort.sendPacket(pres);
}