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); }
void Start() { rosSocket = new RosSocket(new RosSharp.RosBridgeClient.Protocols.WebSocketNetProtocol(uri)); // 10.189.42.225:9090 rosSocket.Advertise <std_msgs.String>("/chatter"); publication_id = rosSocket.Advertise <sensor_msgs.CompressedImage>("/test_image"); InvokeRepeating("Publish", 0, 1); //Subscribe("/chatter"); }
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 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); }
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 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 AsaUtilities(RosSocket rosSocket) { this.rosSocket = rosSocket; createTfId = rosSocket.Advertise <AsaRelPoseStamped>("/mock_anchor_created"); foundTfId = rosSocket.Advertise <AsaRelPoseStamped>("/mock_anchor_found"); //Subscribe to found anchors SubscriptionHandler <FoundAnchor> handler = new SubscriptionHandler <FoundAnchor>((foundAnchor) => { foundAnchorEvent?.Invoke(this, new AnchorFoundEventArgs(foundAnchor)); }); rosSocket.Subscribe <FoundAnchor>("asa_ros/found_anchor", handler, 1, 5); }
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(); }
void Start() { GameObject Connector = GameObject.FindWithTag("Connector"); socket = Connector.GetComponent <RosConnector>()?.RosSocket; publication_id = socket.Advertise <msgs.Geometry.Twist>("/cmd_vel"); }
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."); } }
void YISubscribe() { for (int i = 0; i < dbsub.cnt; i++) //受け取った座標を更新 { px[i] = newPlane[i].gameObject.transform.localPosition.x; py[i] = newPlane[i].gameObject.transform.localPosition.y; pz[i] = newPlane[i].gameObject.transform.localPosition.z; rx[i] = newPlane[i].gameObject.transform.localEulerAngles.x; ry[i] = newPlane[i].gameObject.transform.localEulerAngles.y; rz[i] = newPlane[i].gameObject.transform.localEulerAngles.z; sx[i] = newPlane[i].gameObject.transform.localScale.x; sy[i] = newPlane[i].gameObject.transform.localScale.y; sz[i] = newPlane[i].gameObject.transform.localScale.z; } transI.image_num = dbsub.cnt; transI.position_x = px; transI.position_y = py; transI.position_z = pz; transI.rotation_x = rx; transI.rotation_y = ry; transI.rotation_z = rz; transI.scale_x = sx; transI.scale_y = sy; transI.scale_z = sz; transI.TimeB = dbsub.TimeB; transI.TimeT = dbsub.TimeT; Debug.Log(Mynumber); //advertise_id = rosSocket.Advertise("/myinfo" + Mynumber, "detect_object/DBinfo"); advertise_id = rosSocket.Advertise("/myinfo" + Mynumber, "detect_object/TransformInfo"); rosSocket.Publish(advertise_id, transI); yourinfo_check_topic = false; }
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: int ImageDataSize = 100; sensor_msgs.CompressedImage image = new sensor_msgs.CompressedImage(); image.header.frame_id = "Test"; string publication_id = rosSocket.Advertise <sensor_msgs.CompressedImage>("/test_image"); Console.WriteLine("Press any key to start publication..."); Console.ReadKey(true); for (int i = 0; i < 100000; i++) { image.header.seq += 1; image.data = Enumerable.Repeat((byte)0x20, ImageDataSize).ToArray(); rosSocket.Publish(publication_id, image); } Console.WriteLine("Press any key to close..."); Console.ReadKey(true); rosSocket.Unadvertise(publication_id); rosSocket.Close(); }
public Spot(RosSocket socket) { rosSocket = socket; publicationIds[topic_cmd_vel] = rosSocket.Advertise <RosSharp.RosBridgeClient.MessageTypes.Geometry.Twist>(topic_cmd_vel); }
public void Init() { GetComponent <Subscribe_semantic_image>().semantic_result += (sender, e) => semantic_result_arrived(); rosSocket = GetComponent <HSR_Connector>().RosSocket; semantic_result_topic = GetComponent <Subscribe_semantic_image>(); advertise_id = rosSocket.Advertise("/image_hololens", "sensor_msgs/CompressedImage"); Debug.Log("ara:ROS Initation Finished"); }
void Start() { GameObject Connector = GameObject.FindWithTag("Connector"); socket = Connector.GetComponent <RosConnector>()?.RosSocket; publication_id = socket.Advertise <std_msgs.String>("/speech"); message = new std_msgs.String(); say("Hallo, ich bin Mino. Du bist erfolgreich verbunden."); }
private void AddCollisionObjects(string _object, float _centerX, float _centerY, float _centerZ, bool _useSpecialBoxGeometry = false) { CollisionObject collisionObjectMsg = CollisionObjectHandler.AddCollisionObject(_object, _centerX, _centerY, _centerZ, _useSpecialBoxGeometry); // Publication: string publicationID = rosSocket.Advertise <CollisionObject>("collision_object"); rosSocket.Publish(publicationID, collisionObjectMsg); }
private void Start() { rosSocket = GetComponent <RosConnector>().RosSocket; publicationIdIIWA = rosSocket.Advertise <jointPos_msg>(TopicIIWA); OldTime = Time.time; Flag = false; c = 0; }
void Start() { UserCountButton = GameObject.Find("UserCountButton"); tapto = UserCountButton.GetComponent <TapToFirst>(); rosSocket = GetComponent <RosConnector>().RosSocket; //トピック名はusercount,型はString advertise_id = rosSocket.Advertise("/usercount", "std_msgs/String"); counter = "whatNo"; message = new StandardString(); }
void Start() { sphere = GameObject.Find("UpdateBoard"); taptrigger = sphere.GetComponent <TapTrigger>(); rosSocket = GetComponent <RosConnector>().RosSocket; advertise_id = rosSocket.Advertise("/chatter", "std_msgs/String"); moji = "true"; message = new StandardString(); }
public void PublicationTest() { string id = RosSocket.Advertise <std_msgs.String>("/publication_test"); std_msgs.String message = new std_msgs.String("publication test message data"); RosSocket.Publish(id, message); RosSocket.Unadvertise(id); Thread.Sleep(100); Assert.IsTrue(true); }
// Update is called once per frame void Update() { rosSocketIsAlive = rosSocket.protocol.IsAlive(); // Publication: string publication_id = rosSocket.Advertise <std_msgs.String>("publication_test"); std_msgs.String message = new std_msgs.String(); message.data = "publication test message data"; rosSocket.Publish(publication_id, message); }
private void btnForward_Click(object sender, EventArgs e) { string id = RosSocket.Advertise <Twist>("/cmd_vel"); Vector3 linear = new Vector3(0.5, 0.0, 0.0); Vector3 angular = new Vector3(0.0, 0.0, 0.0); Twist forward = new Twist(linear, angular); RosSocket.Publish(id, forward); //发布 RosSocket.Unadvertise(id); //取消发布 Thread.Sleep(100); //System.Net.WebSockets.WebSocketException 一方关闭webSocket报错,未完成握手 }
/// <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"); }
// Publish string to ROS public void PublishString(string topic, string msg) { // Create new standard string and set its data to msg std_msgs.String message = new std_msgs.String { data = msg }; string publicationId = rosSocket.Advertise <std_msgs.String>(topic); // Topic must be in "/topic" format rosSocket.Publish(publicationId, message); Debug.Log("Sent:" + msg); }
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); //}); }
// Use this for initialization void Start() { // Grab the original local position //originalPosition = this.transform.localPosition; ros = new RosSocket("ws://192.168.1.140:9090"); publication_id = ros.Advertise("/CHOICE", "std_msgs/String"); while (i > 0.0f) { //publication_id = ros.Advertise("/CHOICE", "std_msgs/String"); i -= Time.deltaTime; //publishn(); } //publishn(); }
private static void DoWork() { string uri = "ws://localhost:9090"; Console.WriteLine($"Trying to connect to RosBridge via {uri}"); RosSharp.RosBridgeClient.Protocols.WebSocketNetProtocol webSocketNetProtocol = new RosSharp.RosBridgeClient.Protocols.WebSocketNetProtocol(uri); var protocol = RosSharp.RosBridgeClient.Protocols.ProtocolInitializer.GetProtocol(RosSharp.RosBridgeClient.Protocols.Protocol.WebSocketNET, uri); protocol.OnConnected += OnConnected; protocol.OnClosed += OnClosed; rosSocket = new RosSocket(protocol, RosSocket.SerializerEnum.Newtonsoft_JSON); rosSocket.Subscribe <Clock>("/clock", ReceiveMessage, 1000); publishId = rosSocket.Advertise <Clock>("/customTopic_clock"); //rosSocket.Subscribe<RosSharp.RosBridgeClient.MessageTypes.Std.String>("/clock", ReceiveMessage); }
public BodyMeasurements() { rosSocket = new RosSocket(new RosSharp.RosBridgeClient.Protocols.WebSocketNetProtocol(uri)); rosBMMeasurements_Id = rosSocket.Advertise <bm_msgs.bm_message>("/bm_MeasurementsChatter"); rosBMImage_Id = rosSocket.Advertise <bm_imsgs.Image>("/bm_ImagesChatter"); rosBMFits_Id = rosSocket.Advertise <bm_msgs.bm_fits>("/bm_FitsChatter"); string rosBMSizeFit_Id = rosSocket.Subscribe <bm_msgs.bm_sizefit>("/bm_SizeFitChatter", SizeFitSubscriptionHandler); //rosBMSizeFit_Id = rosSocket.Subscribe<bm_msgs.bm_sizefit>("/bm_SizeFitChatter", SizeFitSubscriptionHandler); InitializeComponent(); _sensor = KinectSensor.GetDefault(); if (_sensor != null) { _sensor.Open(); _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.BodyIndex | FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body); _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived; } }
void Start() { WorldEditorID = GameObject.Find("WorldEditor"); iddecision = WorldEditorID.GetComponent <IDdecision>(); holoid = iddecision.ids; sphere = GameObject.Find("PressableButtonHoloLens2"); taptrigger = sphere.GetComponent <TapTrigger>(); rosSocket = GetComponent <RosConnector>().RosSocket; //トピック名はchatter,型はString advertise_id = rosSocket.Advertise("/chatter", "std_msgs/String"); moji = "trues"; message = new StandardString(); }