public static Hokuyo CreateHokuyo(String portCom, LidarID id) { bool forceUart = false; bool forceUsb = false; if (forceUart) return new HokuyoUart(id); else if (forceUsb) return new HokuyoUsb(portCom, id); Hokuyo hok; try { hok = new HokuyoUsb(portCom, id); return hok; } catch (Exception) { hok = new HokuyoUart(id); return hok; } }
private void btnHokuyoUart_Click(object sender, EventArgs e) { ////String mess = "MS000072500001"; //String mess = "VV\n00P\n"; //byte[] b = new Byte[mess.Length]; //for (int i = 0; i < mess.Length; i++) //{ // b[i] = (byte)mess[i]; //} //Trame trameUart = new Trame(b); //Trame trameUdp = TrameFactory.EnvoyerUart(Carte.RecIO, trameUart); //Connexions.ConnexionIO.SendMessage(trameUdp); HokuyoUart lidar = new HokuyoUart(LidarID.LidarSol); List<PointReel> pts = lidar.GetMesure(); Plateau.ObstaclesPlateau = new List<IForme>(); foreach (PointReel p in pts) { Plateau.ObstaclesPlateau.Add(new Cercle(p, 4)); } MessageBox.Show(pts.Count + " points"); }