[ros-users] [Discourse.ros.org] [ROS Projects] ROS# on gith…

Forside
Vedhæftede filer:
Indlæg som e-mail
+ (text/plain)
Slet denne besked
Besvar denne besked
Skribent: Martin Bischoff via ros-users
Dato:  
Til: ros-users
CC: Martin Bischoff
Emne: [ros-users] [Discourse.ros.org] [ROS Projects] ROS# on github.com/siemens/ros-sharp


## Code Example ##
A simple Publisher/Subscriber Example:

```cs
using System;
using RosSharp.RosBridgeClient;

// commands on ROS system:
// roscore
// rostopic echo /talker
// rostopic pub /listener std_msgs/String "World!"
// roslaunch rosbridge_server rosrbridge_websocket.launch

public class HelloWorld
{
    public static void Main(string[] args)
    {
        RosSocket rosSocket = new RosSocket("ws://192.168.0.101:9090");


        // Publication:
        int publication_id = rosSocket.Advertize("/talker", "std_msgs/String");


        StandardString message = new StandardString();
        message.data = "Hello!";
        rosSocket.Publish(publication_id, message);


        // Subscription Example:
        int subscription_id = rosSocket.Subscribe("/listener", "std_msgs/String", subscriptionHandler);


        Console.WriteLine("Press any key to close...");
        Console.ReadKey(true);
        rosSocket.Close();
    }
    private static void subscriptionHandler(Message message)
    {
        StandardString standardString = (StandardString)message;
        Console.WriteLine(standardString.data);
    }
}



```





---
[Visit Topic](https://discourse.ros.org/t/ros-on-github-com-siemens-ros-sharp/3405/2) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list

http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>