private void button1_Click(object sender, EventArgs e) { uri = "ws://" + textBox1.Text + ":" + textBox2.Text; try { Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); s.Connect(textBox1.Text, Convert.ToInt32(textBox2.Text)); rosSocket = new RosSocket(new RosSharp.RosBridgeClient.Protocols.WebSocketNetProtocol(uri)); zm_robot_pose = rosSocket.Subscribe <geometry.Pose2D>("/zm_robot_position", SubscriptionPositionHandler); zm_robot_vel = rosSocket.Subscribe <geometry.Twist>("/cmd_vel", SubscriptionCmdVelHandler); zm_robot_vel_pub = rosSocket.Advertise <geometry.Twist>("cmd_vel"); thr_subscriber = new Thread(LoopExecute_subscriber); thr_publisher = new Thread(LoopExecute_publisher); thr_subscriber.Start(); thr_publisher.Start(); label20.Text = "Success."; button14.Enabled = true; } catch (SocketException ex) { label20.Text = "Failed."; MessageBox.Show("Connnect failed, please check IP Address."); } catch (System.FormatException error) { label20.Text = "Failed."; MessageBox.Show("Input IP incorrect, please input correct IP Address."); } }
public static void Main(string[] args) { //RosSocket rosSocket = new RosSocket(new RosBridgeClient.Protocols.WebSocketSharpProtocol(uri)); RosSocket rosSocket = new RosSocket(new RosBridgeClient.Protocols.WebSocketNetProtocol(uri)); // Publication: std_msgs.String message = new std_msgs.String("publication test message data"); string publication_id = rosSocket.Advertise <std_msgs.String>("publication_test"); rosSocket.Publish(publication_id, message); // Subscription: string subscription_id = rosSocket.Subscribe <std_msgs.String>("/subscription_test", SubscriptionHandler); subscription_id = rosSocket.Subscribe <std_msgs.String>("/subscription_test", SubscriptionHandler); // Service Call: rosSocket.CallService <rosapi.GetParamRequest, rosapi.GetParamResponse>("/rosapi/get_param", ServiceCallHandler, new rosapi.GetParamRequest("/rosdistro", "default")); rosSocket.CallService <rosapi.GetParamRequest, rosapi.GetParamResponse>("/rosapi/get_param", ServiceCallHandler, new rosapi.GetParamRequest("/rosdistro", "default")); // Service Response: string service_id = rosSocket.AdvertiseService <std_srvs.TriggerRequest, std_srvs.TriggerResponse>("/service_response_test", ServiceResponseHandler); Console.WriteLine("Press any key to unsubscribe..."); Console.ReadKey(true); rosSocket.Unadvertise(publication_id); rosSocket.Unsubscribe(subscription_id); rosSocket.UnadvertiseService(service_id); Console.WriteLine("Press any key to close..."); Console.ReadKey(true); rosSocket.Close(); }
public void Initialize() { cancelPublicationID = rosSocket.Advertise <GoalID>(actionName + "/cancel"); goalPublicationID = rosSocket.Advertise <TActionGoal>(actionName + "/goal"); statusSubscriptionID = rosSocket.Subscribe <GoalStatusArray>(actionName + "/status", StatusCallback, (int)(timeStep * 1000)); feedbackSubscriptionID = rosSocket.Subscribe <TActionFeedback>(actionName + "/feedback", FeedbackCallback, (int)(timeStep * 1000)); resultSubscriptionID = rosSocket.Subscribe <TActionResult>(actionName + "/result", ResultCallback, (int)(timeStep * 1000)); }
public void Start() { cancelPublicationID = socket.Advertise <GoalID>(actionName + "/cancel"); goalPublicationID = socket.Advertise <TActionGoal>(actionName + "/goal"); statusSubscriptionID = socket.Subscribe <GoalStatusArray>(actionName + "/status", StatusCallback, millisecondsTimestep); feedbackSubscriptionID = socket.Subscribe <TActionFeedback>(actionName + "/feedback", FeedbackCallback, millisecondsTimestep); resultSubscriptionID = socket.Subscribe <TActionResult>(actionName + "/result", ResultCallback, millisecondsTimestep); }
public void Initialize() { statusPublicationID = rosSocket.Advertise <GoalStatusArray>(actionName + "/status"); feedbackPublicationID = rosSocket.Advertise <TActionFeedback>(actionName + "/feedback"); resultPublicationID = rosSocket.Advertise <TActionResult>(actionName + "/result"); cancelSubscriptionID = rosSocket.Subscribe <GoalID>(actionName + "/cancel", CancelCallback, (int)(timeStep * 1000)); goalSubscriptionID = rosSocket.Subscribe <TActionGoal>(actionName + "/goal", GoalCallback, (int)(timeStep * 1000)); UpdateAndPublishStatus(ActionStatus.NO_GOAL); }
public void connection(RosSocket rosSocket) { this.rosSocket = rosSocket; int subscription_multirulestoserver = rosSocket.Subscribe("/multirulestoserver", "std_msgs/String", multirulestoserverHandler); paramsRosSocket.publication_servertoMultirules = rosSocket.Advertise("/servertoMultirules", "std_msgs/String"); int subscription_trafficInfoResponse = rosSocket.Subscribe("/trafficInfoResponse", "std_msgs/String", trafficInfoResponseHandler); paramsRosSocket.publication_trafficInfoRequest = rosSocket.Advertise("/trafficInfoRequest", "std_msgs/String"); }
public void Start() { statusPublicationID = socket.Advertise <GoalStatusArray>(actionName + "/status"); feedbackPublicationID = socket.Advertise <TActionFeedback>(actionName + "/feedback"); resultPublicationID = socket.Advertise <TActionResult>(actionName + "/result"); cancelSubscriptionID = socket.Subscribe <GoalID>(actionName + "/cancel", CancelCallback, millisecondsTimestep); goalSubscriptionID = socket.Subscribe <TActionGoal>(actionName + "/goal", GoalCallback, millisecondsTimestep); UpdateAndPublishStatus(ActionStatus.NO_GOAL); }
public void Init() { #if UNITY_IOS //iOS doesn't connect to ros-sharp #else rosSocket = GetComponent <HSR_Connector>().RosSocket; rosSocket.Subscribe("/tf", "tf2_msgs/TFMessage", UpdateTF, UpdateTime); rosSocket.Subscribe("/global_pose", "geometry_msgs/PoseStamped", UpdatePosition, UpdateTime); rosSocket.Subscribe("/current/hand_pose", "geometry_msgs/Pose", Buy_item, UpdateTime); Topic_EventHandler?.Invoke(this, EventArgs.Empty); #endif }
void InitTopics() { var forwardCommandSubscriber = socket.Subscribe <Float32>("/sparki/forward_command", ForwardCommand); var turnCommandSubscriber = socket.Subscribe <Float32>("/sparki/turn_command", TurnCommand); var turnSetServoSubscriber = socket.Subscribe <Int16>("/sparki/set_servo", SetServo); addObstaclePublisher = socket.Advertise <String>("/game/add_obstacle"); removeObstaclePublisher = socket.Advertise <String>("/game/remove_obstacle"); Debug.Log("Topics initialized."); }
public void Init() { rosSocket = GetComponent <RosConnector>().RosSocket; //Topicを受け取ったら関数NoResが呼び出される rosSocket.Subscribe("/countNo", "std_msgs/String", NoRes, UpdateTime); }
public void Init() { rosSocket = GetComponent <RosConnector>().RosSocket; Debug.Log("/myinfo" + MyInfoPub.ButtonNo); //Topicを受け取ったら関数YourInfoが呼び出される rosSocket.Subscribe("/myinfo" + MyInfoPub.ButtonNo, "detect_object/TransformInfo", Yourinfo, UpdateTime); }
void Start() { GameObject Connector = GameObject.FindWithTag("Connector"); socket = Connector.GetComponent <RosConnector>()?.RosSocket; string subscription_id = socket.Subscribe <msgs.DiagnosticArray>("/diagnostics", SubscriptionHandler); }
public void Init() { rosSocket = GetComponent <RosConnector>().RosSocket; //Topicを受け取ったら関数NumResが呼び出される rosSocket.Subscribe("/shelfDB_" + idstr, "detect_object/DBinfo", NumRes, UpdateTime); }
public void Init() { #if UNITY_IOS //iOS doesn't connect to ros-sharp #else rosSocket = GetComponent <HSR_Connector>().RosSocket; rosSocket.Subscribe("/move_base/move/goal", "move_base_msgs/MoveBaseActionGoal", GetGoal, UpdateTime); #endif }
public void Config(RosSocket socket, Drone drone) { this.socket = socket; this.drone = drone; MeshHelper = new MeshHelper(); socket.Subscribe <TriangleMeshStamped>("/mesh_publisher/mesh_out", MeshHelper.GetSubscriptionHandler(), 1000); }
// Start is called before the first frame update void Start() { // WebSocket Connection: rosSocket = new RosSocket(new RosSharp.RosBridgeClient.Protocols.WebSocketNetProtocol("ws://localhost:9090")); // Subscription: string subscription_id = rosSocket.Subscribe <std_msgs.String>("/subscription_test", SubscriptionHandler); }
public void Init() { #if UNITY_IOS //iOS doesn't connect to ros-sharp #else rosSocket = GetComponent <HSR_Connector>().RosSocket; rosSocket.Subscribe("/nrp_rosbridge_hsr_out", "std_msgs/String", UpdateState, UpdateTime); #endif }
void Init() { #if UNITY_IOS //iOS doesn't connect to ros-sharp #else rosSocket = GetComponent <HSR_Connector>().RosSocket; rosSocket.Subscribe("/em/draw_position/array", "visualization_msgs/MarkerArray", GetSpaceName, UpdateTime); #endif }
public void Init() { Mynumber = CreateUsersButton.MyNo; rosSocket = GetComponent <RosConnector>().RosSocket; //Topicを受け取ったら関数YurInfoが呼び出される rosSocket.Subscribe("/yourinfo" + Mynumber, "std_msgs/String", YourInfo, UpdateTime); }
public void Init() { #if UNITY_IOS //iOS doesn't connect to ros-sharp #else //PathPlanをSubscribeする rosSocket = GetComponent <HSR_Connector>().RosSocket; rosSocket.Subscribe("/base_local_path", "nav_msgs/Path", GetPath, UpdateTime); #endif }
private void Start() { rosSocket = transform.GetComponent <RosConnector>().RosSocket; rosSocket.Subscribe("/joint_states", "sensor_msgs/JointState", updateJointStates, UpdateTime); jointStateManagers = FindObjectsOfType <JointStateManager>(); numberOfJoints = jointStateManagers.Length; JointPositions = new float[numberOfJoints]; JointVelocities = new float[numberOfJoints]; }
public void SubscriptionTest() { string id = RosSocket.Subscribe <std_msgs.String>("/subscription_test", SubscriptionHandler); OnMessageReceived.WaitOne(); OnMessageReceived.Reset(); RosSocket.Unsubscribe(id); Thread.Sleep(100); Assert.IsTrue(true); }
// Start is called before the first frame update void Start() { uiM = uIManagerGO.GetComponent <UIManager>(); rosSocket = new RosSocket(new RosSharp.RosBridgeClient.Protocols.WebSocketNetProtocol("ws://192.168.189.130:9090")); rosBMSizeFit_Id = rosSocket.Advertise <bm_sfmsgs>("/bm_SizeFitChatter"); string rosBMMeasurements_Id = rosSocket.Subscribe <bm_msgs>("/bm_MeasurementsChatter", MeasurementsSubscriptionHandler); //rosBMMeasurements_Id = rosSocket.Subscribe<bm_msgs>("/bm_MeasurementsChatter", MeasurementsSubscriptionHandler); string rosBMImage_Id = rosSocket.Subscribe <bm_imsgs.Image>("/bm_ImagesChatter", ImageSubscriptionHandler); //rosBMImage_Id = rosSocket.Subscribe<bm_imsgs.Image>("/bm_ImagesChatter", ImageSubscriptionHandler); string rosBMFits_Id = rosSocket.Subscribe <bm_fmsgs>("/bm_FitsChatter", FitsSubscriptionHandler); //change Pinda's chest color for test //pindaChest.GetComponent<MeshRenderer>().material = blueMaterial; changePindaColor(3, 3, 3); }
/// <summary> /// Sets up the publishers and subscribers for the state and position commanding /// </summary> /// <param name="rosSocket"></param> private void SetupPublisherAndSubscribers(RosSocket rosSocket) { if (rosSocket == null) { return; } SubscriptionHandler <Odometry> subscriptionHandler = new SubscriptionHandler <Odometry>((o) => ExecuteOnUpdate(() => ReportNewAsaRelPose(o))); rosSocket.Subscribe <Odometry>("/odometry/filtered/asa_relative", subscriptionHandler); anchored_goal_publishing_id = rosSocket.Advertise <AsaRelPoseStamped>("/anchored_goal"); }
/// <summary> /// Adds a subscriber to the map /// </summary> /// <param name="name"></param> /// <param name="topic"></param> public void AddSubscriber <T>(string name, string topic, RosSocket socket, Action <T> callback) where T : Message, new() { SubscriptionHandler <T> handler = new SubscriptionHandler <T>(callback); if (NameToTopicMap.ContainsKey(name) == false) { NameToTopicMap[name] = topic; } string subscriptionId = socket.Subscribe <T>(GetTopic(name), handler); NameToSubscribeId[name] = subscriptionId; }
IEnumerator Init(float delay = 0.0f) { if (delay != 0) { yield return(new WaitForSeconds(delay)); } check_topic = false; rosSocket = GameObject.Find(rosConnectorGameObjectName).GetComponent <RosConnector>().RosSocket; if (rosSocket != null) { rosSocket.Subscribe <MarkerArray>(topic, SubscriptionHandler); } }
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); //}); }
internal void connect() { if (rosSocket != null) { rosSocket.Close(); rosSocket = null; } rosWebSocketProtocol = new RosSharp.RosBridgeClient.Protocols.WebSocketUWPProtocol(uri); // Todo refactor the async connector. rosSocket = new RosSocket(rosWebSocketProtocol); imageSubId = rosSocket.Subscribe <sensor_msgs.Image>("/tracked_objects/image", SubscriptionHandler); logSubId = rosSocket.Subscribe <rosgraph.Log>("/rosout", LogSubscriptionHandler); trackedSubId = rosSocket.Subscribe <DetectedObjectPose>("/detected_object", DetectedSubscriptionHandler); commandPubId = rosSocket.Advertise <std_msgs.RosInt32>("/goto"); dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 3); dispatcherTimer.Start(); UpdateCurrentTask("Connected", ""); }
private void timerConnectRosSocket_Tick(object sender, EventArgs e) { rosSocket.seturl("ws://" + props.cam.ip + ":" + props.cam.port); if (rosSocket.isConnected) { int subscription_id = rosSocket.Subscribe("/pallet_status_" + props.cam.id, "std_msgs/String", subscriptionHandler); timerConnectRosSocket.Stop(); timerCheckConnection.Start(); } else { rosSocket.connect(); } }
private void listen() { RosSocket rosSocket = new RosSocket("ws://192.168.1.125:9090"); //string subscription_id = rosSocket.Subscribe("odom", "nav_msgs/Odometry", subscriptionHandler); string subscription_id = rosSocket.Subscribe("/amcl_pose", "geometry_msgs/PoseWithCovarianceStamped", subscriptionHandler); Console.WriteLine("Press any key to close..."); while (true) { Thread.Sleep(10); } // rosSocket.Close(); }