void OnDestroy() { m_thread.Abort(); RplidarBinding.EndScan(); RplidarBinding.EndMotor(); RplidarBinding.OnDisconnect(); RplidarBinding.ReleaseDrive(); m_onscan = false; }
static void Main(string[] args) { LidarData[] data = new LidarData[720]; String port; while (true) { Console.WriteLine("input COM port:"); var comport = Console.ReadLine().ToUpper(); int p = 0; if (comport.StartsWith("COM") && comport.Length == 4 && int.TryParse(comport.Substring(3), out p)) { port = comport; break; } } RplidarBinding.OnConnect(port); Console.WriteLine("on conn"); RplidarBinding.StartMotor(); Console.WriteLine("start motor"); RplidarBinding.StartScan(); Console.WriteLine("start scan"); var datalen = RplidarBinding.GetData(ref data); for (var i = 0; i < datalen; i++) { Console.WriteLine($"{data[i].distant} {data[i].theta} {data[i].quality}"); } Console.ReadLine(); Console.WriteLine("end scan"); RplidarBinding.EndScan(); Console.WriteLine("end motor"); RplidarBinding.EndMotor(); Console.ReadLine(); Console.WriteLine("disconnect"); RplidarBinding.OnDisconnect(); }
private void OnGUI() { DrawButton("Connect", () => { if (string.IsNullOrEmpty(port)) { return; } int result = RplidarBinding.OnConnect(port); Debug.Log("Connect on " + port + " result:" + result); }); DrawButton("DisConnect", () => { bool r = RplidarBinding.OnDisconnect(); Debug.Log("Disconnect:" + r); }); DrawButton("StartScan", () => { bool r = RplidarBinding.StartScan(); Debug.Log("StartScan:" + r); }); DrawButton("EndScan", () => { bool r = RplidarBinding.EndScan(); Debug.Log("EndScan:" + r); }); DrawButton("StartMotor", () => { bool r = RplidarBinding.StartMotor(); Debug.Log("StartMotor:" + r); }); DrawButton("EndMotor", () => { bool r = RplidarBinding.EndMotor(); Debug.Log("EndMotor:" + r); }); DrawButton("Release Driver", () => { bool r = RplidarBinding.ReleaseDrive(); Debug.Log("Release Driver:" + r); }); DrawButton("GrabData", () => { int count = RplidarBinding.GetData(ref data); Debug.Log("GrabData:" + count); if (count > 0) { for (int i = 0; i < 20; i++) { Debug.Log("d:" + data[i].distant + " " + data[i].quality + " " + data[i].syncBit + " " + data[i].theta); } } }); }