コード例 #1
0
    void Start()
    {
        m_meshfilter = GetComponent <MeshFilter>();

        m_data = new LidarData[720];

        m_ind  = new List <int>();
        m_vert = new List <Vector3>();
        for (int i = 0; i < 720; i++)
        {
            m_ind.Add(i);
        }
        m_mesh = new Mesh();
        m_mesh.MarkDynamic();

        RplidarBinding.OnConnect(COM);
        RplidarBinding.StartMotor();
        m_onscan = RplidarBinding.StartScan();


        if (m_onscan)
        {
            m_thread = new Thread(GenMesh);
            m_thread.Start();
        }
    }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     RplidarBinding.OnConnect(port);
     RplidarBinding.StartMotor();
     RplidarBinding.StartScan();
     getAllData();
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Keum0912/lidar
        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();
        }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        getAllData();
        if (Input.GetKeyDown(KeyCode.S))
        {
            print("Begin");
            if (string.IsNullOrEmpty(port))
            {
                return;
            }

            RplidarBinding.OnConnect(port);
            RplidarBinding.StartMotor();
            RplidarBinding.StartScan();
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            print("Disconnect");
            RplidarBinding.OnDisconnect();
        }
    }
コード例 #5
0
    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);
                }
            }
        });
    }