void Start() { // Where the rosbridge instance is running, could be localhost, or some external IP ros = new ROSBridgeLib.ROSBridgeWebSocketConnection("ws://" + IP, 9090); ros.AddSubscriber(typeof(TestSubscriber)); ros.Connect(); }
void Start() { ROSHost = "ws://" + ROSHost; ros = new ROSBridgeLib.ROSBridgeWebSocketConnection(ROSHost, ROSPort); pose_sub = ros.Subscribe <SimplePoseArray>("/unity/simple_bot/pose", OnNewPoseMsg); hand_sub = ros.Subscribe <ROSBridgeLib.simple_unity_bot.HandState>("/unity/simple_bot/hands", OnNewHandMsg); pose_pub = ros.Advertise <SimplePoseArray>("/unity/simple_bot/target_pose"); hand_pub = ros.Advertise <ROSBridgeLib.simple_unity_bot.HandState>("/unity/simple_bot/hand_targets"); ros.Connect(); }
/// <summary> /// Obtain the unique ROSBridgeWebSocketConnection object for a given address and port. /// </summary> /// <param name="address">The network or web address of the rosbridge server.</param> /// <param name="port">The port that the rosbridge server uses on the remote machine.</param> /// <returns></returns> public ROSBridgeWebSocketConnection GetConnection(string address, int port) { string full_address = string.Format("ws://{0}:{1}", address, port); ROSBridgeWebSocketConnection conn; lock (connection_lock) { // Check whether a connection has already been established for this address/port pair. if (!connections.TryGetValue(full_address, out conn)) { Debug.Log("Starting submap connection to " + full_address); conn = new ROSBridgeWebSocketConnection("ws://" + address, port); conn.Connect(); connections[full_address] = conn; } } return(conn); }