/* * Uses Factory pattern and polymorphism to return the desired * Sensor type. */ public static Sensors GetInstance(int sensorType, GameObject gObj) { Cube = gObj; Sensors _sensor; switch (sensorType) { case 1: _sensor = new ProximitySensor(); break; case 2: _sensor = new RangeSensor(); break; case 3: _sensor = new LidarSensor(); break; case 4: _sensor = new RadarSensor(); break; case 5: _sensor = new BumperSensor(); break; default: Debug.Log("The chosen sensor doesn't exist!"); _sensor = new ProximitySensor(); break; } sensors = _sensor; return(sensors); }
// Use this for initialization void Start() { pointCloudBaseGameObject = GameObject.FindGameObjectWithTag("PointCloudBase"); pointCloud = pointCloudBaseGameObject.GetComponent <PointCloud>(); lidarGameObject = GameObject.FindGameObjectWithTag("Lidar"); lidarSensor = lidarGameObject.GetComponent <LidarSensor>(); }
// Use this for initialization void Start() { Debug.Log(isTraining); topSpeed = carController.MaxSpeed; recording = false; RecordingPause.SetActive(false); if (LidarSettingPanel != null) { SettingShown = false; LidarSettingPanel.SetActive(SettingShown); // 配置 // do something } LidarSensor.PauseSensor(!isTraining); RecordStatus_Text.text = "RECORD"; DriveStatus_Text.text = ""; SaveStatus_Text.text = ""; SetAngleValue(0); SetMPHValue(0); if (!isTraining) { DriveStatus_Text.text = "Mode: Autonomous"; RecordDisabled.SetActive(true); RecordStatus_Text.text = ""; } }
void Awake() { Bridge = new Comm.Ros.RosBridge(); ls = new LidarSensor(); if (Bridge.Status == Comm.BridgeStatus.Disconnected) { Bridge.Connect(Address, Port, 1); ls.OnBridgeAvailable(Bridge); } }
void Start() { string urlPath = Application.persistentDataPath + "/simunity.txt"; Debug.Log($"Reading websocket URL from {urlPath}"); if (!File.Exists(urlPath)) { using (StreamWriter writer = File.CreateText(urlPath)) { writer.Write("ws://localhost:9090"); } } string url = File.ReadAllText(urlPath); m_RosConnector = new RosConnector { Protocol = RosConnector.Protocols.WebSocketNET, RosBridgeServerUrl = url }; m_RosConnector.Awake(); while (m_RosConnector.RosSocket == null) { } m_Socket = m_RosConnector.RosSocket; m_Socket.Subscribe <ArmMotorCommand>("/arm_control_data", msg => { for (int i = 0; i < 6; i++) { Debug.Log($"Velocity output of motor #{i} is {msg.MotorVel[i]}"); } }); lidarSensor = GameObject.Find("Lidar").GetComponent <LidarSensor>(); m_Socket.Advertise <LidarData>("/LidarData"); //m_Socket.Advertise<ProcessedControllerInput>("/processed_arm_controller_input"); //m_Socket.Advertise<WheelSpeed>("/WheelSpeed"); //m_Socket.Advertise<WheelSpeed>("/TestTopic"); //m_Socket.Subscribe<WheelSpeed>("/WheelSpeed", speed => //{ // Debug.Log(speed.Wheel_Speed[0]); // Debug.Log(speed.Wheel_Speed[1]); //}); //m_Socket.Subscribe<Int32>("/TestTopic", num => //{ // //Debug.Log(num.Wheel_Speed); //}); }