コード例 #1
0
    /// <summary>
    /// Initializes ROS
    /// </summary>
    public void InitROS()
    {
        if (!ROS.initialized)
        {
            if (string.IsNullOrEmpty(rosUri))
            {
                UnityEngine.Debug.LogError("ROS Master URI is empty. This must be populated with the Master address of your target roscore instance.");
                return;
            }

            ROS.Init(new string[] { "__master:=" + rosUri }, primaryNodeName);
            NodeHandle nodeHandle = new NodeHandle();

            // Setup publishers
            pubVector3 = nodeHandle.advertise <Messages.geometry_msgs.Vector3>(pubVector3Topic, 1, false);


            // Setup subscribers
            subVector3    = nodeHandle.subscribe <Messages.geometry_msgs.Vector3>(pubVector3Topic, 1, OnReceiveVector3);
            subCustomNode = nodeHandle.subscribe <Messages.stanford_msgs.ExampleCustom>(subCustomNodeTopic, 1, OnReceiveCustomNodeData);
        }
        else
        {
            Debug.LogError("ROS can only be initialized once per application launch. To re-initialize ROS you must close and re-launch the application.");
        }
    }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: cephdon/ROS.NET
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ROS.ROS_MASTER_URI = "http://10.0.2.88:11311";
            ROS.ROS_HOSTNAME   = "10.0.2.152";
            ROS.Init(new string[0], NODE_NAME);

            nodeHandle = new NodeHandle();

            //server = nodeHandle.advertiseService<Messages.roscpp_tutorials.TwoInts, Messages.roscpp_tutorials.TwoInts.Request, Messages.roscpp_tutorials.TwoInts.Response>("/add_two_ints", addition);
            client = nodeHandle.serviceClient <Messages.roscpp_tutorials.TwoInts.Request, Messages.roscpp_tutorials.TwoInts.Response>("/add_two_ints");

            new Thread(new ThreadStart(() =>
            {
                Random r = new Random();
                while (!ROS.shutting_down)
                {
                    TwoInts.Request req = new TwoInts.Request()
                    {
                        a = r.Next(100), b = r.Next(100)
                    };
                    TwoInts.Response resp = new TwoInts.Response();
                    if (client.call(req, ref resp))
                    {
                        Dispatcher.Invoke(new Action(() =>
                        {
                            math.Content = "" + req.a + " + " + req.b + " = " + resp.sum;
                        }));
                    }
                    Thread.Sleep(500);
                }
            })).Start();
        }
コード例 #3
0
        public MainWindow()
        {
            InitializeComponent();
            string[] sParam = new string[1];
            //sParam[0] = "__hostname:=192.168.0.8";
            sParam[0] = "__master:=http://192.168.1.108:11311";

            ROS.Init(sParam, "wpf_talker");
            nh = new NodeHandle();

            pub = nh.advertise <Messages.std_msgs.String>("/chatter", 1, true);

            pubthread = new Thread(() =>
            {
                int i = 0;
                Messages.std_msgs.String msg;
                while (ROS.ok && !closing)
                {
                    msg = new Messages.std_msgs.String("foo " + (i++));
                    pub.publish(msg);
                    Dispatcher.Invoke(new Action(() =>
                    {
                        l.Content = "Sending: " + msg.data;
                    }), new TimeSpan(0, 0, 1));
                    Thread.Sleep(100);
                }
            });
            pubthread.Start();
        }
コード例 #4
0
        public MainWindow()
        {
            InitializeComponent();

            ROS.Init(new string[0], "simplePublisher");
            nh = new NodeHandle();

            pub = nh.advertise <Messages.tf.tfMessage>("/tf_test", 1000, true);

            new Thread(() =>
            {
                int i = 0;
                while (ROS.ok)
                {
                    Messages.tf.tfMessage msg    = new Messages.tf.tfMessage();
                    msg.transforms               = new Messages.geometry_msgs.TransformStamped[1];
                    msg.transforms[0]            = new Messages.geometry_msgs.TransformStamped();
                    msg.transforms[0].header.seq = (uint)i++;
                    pub.publish(msg);
                    Thread.Sleep(100);
                    Dispatcher.Invoke(new Action(() =>
                    {
                        l.Content = "Sending: " + msg.transforms[0].header.seq;
                    }));
                }
            }).Start();
        }
コード例 #5
0
 public RosFixture()
 {
     Console.WriteLine("Init ROS");
     ROS.ROS_MASTER_URI = "http://localhost:11311";
     ROS.ROS_IP         = "127.0.0.1";
     ROS.Init(new string[0], "RosFixture");
 }
コード例 #6
0
        public MainWindow()
        {
            InitializeComponent();

            ROS.Init(new string[0], "wpf_talker");
            nh = new NodeHandle();

            pub = nh.advertise <Messages.std_msgs.String>("/chatter", 1, false);

            pubthread = new Thread(() =>
            {
                int i = 0;
                Messages.std_msgs.String msg;
                while (ROS.ok && !closing)
                {
                    msg = new Messages.std_msgs.String("foo " + (i++));
                    pub.publish(msg);
                    Dispatcher.Invoke(new Action(() =>
                    {
                        l.Content = "Sending: " + msg.data;
                    }), new TimeSpan(0, 0, 1));
                    Thread.Sleep(100);
                }
            });
            pubthread.Start();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: MagicHYD/Windows-Robot
        private static void Main(string[] args)
        {
            ROS.Init(args, "Listener");
            NodeHandle            node       = new NodeHandle();
            Subscriber <m.String> Subscriber = node.subscribe <m.String>("/chatter", 1, chatterCallback);

            ROS.waitForShutdown();
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: nivir/UnityROS
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     ROS.Init(args, "xna_game");
     using (TheGame game = new TheGame())
     {
         game.Run();
     }
 }
コード例 #9
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ROS.Init(new string[0], NODE_NAME);

            nodeHandle = new NodeHandle();

            server = nodeHandle.advertiseService <TwoInts.Request, TwoInts.Response>("/add_two_ints", addition);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: wiwing/ROS.NET
 private void StartRos(int runNumber)
 {
     Logger.LogInformation($"Start ROS #{runNumber}");
     ROS.Init(new string[] { }, "PubSubTestbed");
     spinner = new AsyncSpinner();
     spinner.Start();
     Logger.LogInformation("Started");
 }
コード例 #11
0
        void doConnect()
        {
            //开启键盘控制节点
            ROS.Init(new string[0], "tele_key");
            nh = new NodeHandle();

            pub = nh.advertise <Messages.geometry_msgs.Twist>("/cmd_vel", 1, false);
        }
コード例 #12
0
 private void StartRos(int runNumber)
 {
     ROS.Info()($"Start ROS #{runNumber}");
     ROS.Init(new string[] { }, "PubSubTestbed");
     spinner = new AsyncSpinner();
     spinner.Start();
     ROS.Info()("Started");
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: jr-robotics/ROS.NET
 private void StartRos(int runNumber)
 {
     Logger.LogInformation($"Start ROS #{runNumber}");
     ROS.ROS_MASTER_URI = "http://localhost:11311";
     ROS.Init(new string[] { }, "PubSubTestbed");
     spinner = new AsyncSpinner();
     spinner.Start();
     Logger.LogInformation("Started");
 }
コード例 #14
0
ファイル: MainWindow.xaml.cs プロジェクト: nivir/UnityROS
        public MainWindow()
        {
            InitializeComponent();

            ROS.Init(new string[0], "wpf_listener");
            nh = new NodeHandle();

            sub = nh.subscribe <Messages.std_msgs.String>("/chatter", 10, subCallback);
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: wijanarko-sukma/ROS.NET
        static void Main(string[] args)
        {
            string NODE_NAME = "ServiceClientTest";

            try
            {
                ROS.Init(ref args, NODE_NAME + DateTime.Now.Ticks);
                var spinner = new AsyncSpinner();
                spinner.Start();
            }
            catch (RosException e)
            {
                ROS.Critical()("ROS.Init failed, shutting down: {0}", e.Message);
                ROS.shutdown();
                ROS.waitForShutdown();
                return;
            }

            try
            {
                var nodeHandle = new NodeHandle();
                while (ROS.ok)
                {
                    Random          r   = new Random();
                    TwoInts.Request req = new TwoInts.Request()
                    {
                        a = r.Next(100), b = r.Next(100)
                    };
                    TwoInts.Response resp   = new TwoInts.Response();
                    DateTime         before = DateTime.Now;
                    bool             res    = nodeHandle.serviceClient <TwoInts.Request, TwoInts.Response>("/add_two_ints").call(req, ref resp);
                    TimeSpan         dif    = DateTime.Now.Subtract(before);

                    string str = "";
                    if (res)
                    {
                        str = "" + req.a + " + " + req.b + " = " + resp.sum + "\n";
                    }
                    else
                    {
                        str = "call failed after ";
                    }

                    str += Math.Round(dif.TotalMilliseconds, 2) + " ms";
                    ROS.Info()(str);
                    Thread.Sleep(1000);
                }
            }
            catch (RosException e)
            {
                ROS.Critical()("Shutting down: {0}", e.Message);
            }

            ROS.shutdown();
            ROS.waitForShutdown();
        }
コード例 #16
0
ファイル: MainWindow.xaml.cs プロジェクト: cephdon/ROS.NET
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     new Thread(() =>
     {
         // ROS stuff
         ROS.ROS_MASTER_URI = "http://10.0.3.5:11311";
         ROS.Init(new string[0], "The_IMU_Tester_" + System.Environment.MachineName.Replace("-", "__"));
         nh = new NodeHandle();
     }).Start();
 }
コード例 #17
0
        public RosoutDebug(int verboseLevel, string[] args)
        {
            this.verboseLevel = verboseLevel;
            ROS.Init(args, "RosoutDebug");
            var asyncSpinner = new AsyncSpinner();

            asyncSpinner.Start();
            nodeHandle = new NodeHandle();
            Init();
        }
コード例 #18
0
        static void Main(string[] args)
        {
            ROS.Init(args, "MoveitTest");
            NodeHandle node = new NodeHandle();

            gm.PoseStamped result = SetPose(-0.1, 0.1, 0.2, 0.0, 180.0, 0.0, "");
            Console.WriteLine("result");
            Console.WriteLine(result);
            GetIK(node, result, "endeffector");
            ROS.waitForShutdown();
        }
コード例 #19
0
    // Use this for initialization
    void Start()
    {
        setROS_HOST();
        string[] dummy = { "" };
        ROS.Init(dummy, "unity");                                 //TODO:set your own node name
        n      = new NodeHandle();
        tf     = new Transformer(false /* do Interprate ?*/);     /* for TF lookup*/
        tf_pub = n.advertise <Messages.tf.tfMessage>("/tf", 100); /* for TF broad cast */

        Debug.LogError("ROS my HostIP  :" + ROS.ROS_IP + "\nMASTER_URI" + ROS.ROS_MASTER_URI);
    }
コード例 #20
0
ファイル: Program.cs プロジェクト: wijanarko-sukma/ROS.NET
        private static void Main(string[] args)
        {
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
            ROS.Init(args, "Listener");
            var spinner = new AsyncSpinner();

            spinner.Start();
            NodeHandle node       = new NodeHandle();
            Subscriber Subscriber = node.subscribe <std_msgs.String>("/chatter", 1, chatterCallback);

            ROS.waitForShutdown();
        }
コード例 #21
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string[] sParam = new string[1];
            //sParam[0] = "__hostname:=192.168.0.8";
            sParam[0] = "__master:=http://192.168.1.108:11311";

            ROS.Init(sParam, "Image_Test2");
            nh = new NodeHandle();


            VoicePlay.EasyPlayer_Init();
        }
コード例 #22
0
    // Use this for initialization
    void Start()
    {
        ROS.ROS_MASTER_URI = "http://127.0.0.1:11311/";
        string[] args = new string[0];
        ROS.Init(args, "Talker");
        node   = new NodeHandle();
        Talker = node.advertise <m.String>("/chatter", 1000);

        sub = node.subscribe <Messages.std_msgs.String>("/chatter_to_unity", 10, subCallback);

        StartCoroutine(Coro());
    }
コード例 #23
0
        public MainWindow()
        {
            before = DateTime.Now;
            InitializeComponent();

            ROS.ROS_MASTER_URI = "http://10.0.2.226:11311";
            ROS.ROS_HOSTNAME   = "10.0.2.226";
            ROS.Init(new string[0], "simpleSubscriber");
            nh = new NodeHandle();

            sub = nh.subscribe <Messages.std_msgs.String>("/my_topic", 10, subCallback);
        }
コード例 #24
0
ファイル: Program.cs プロジェクト: wijanarko-sukma/ROS.NET
        static void Main(string[] args)
        {
#if (DEBUG)
            Environment.SetEnvironmentVariable("ROS_MASTER_URI", "http://localhost:11311/");
#endif
            Console.WriteLine("Start ROS");
            ROS.Init(ref args, "ActionServerClientSlowDummy");

            ICallbackQueue callbackQueue = new CallbackQueue();

            var asyncSpinner = new AsyncSpinner(callbackQueue);
            asyncSpinner.Start();

            NodeHandle nodeHandle = new NodeHandle(callbackQueue);

            ActionClient <Messages.actionlib.TestGoal, Messages.actionlib.TestResult,
                          Messages.actionlib.TestFeedback> actionClient = null;

            // setup action server start
            Console.WriteLine("Create server");
            var actionServer = new ActionServer <Messages.actionlib.TestGoal, Messages.actionlib.TestResult,
                                                 Messages.actionlib.TestFeedback>(nodeHandle, "test_action");
            Param.Set("status_list_timeout", 999.9);
            actionServer.RegisterGoalCallback((sgoalHandle) =>
            {
                Thread thread = new Thread(() => serverGoalCallback(sgoalHandle, actionServer, actionClient));
                thread.Start();
            });
            Console.WriteLine("Start Server");
            actionServer.Start();
            Console.WriteLine("Server Started");
            // setup action server finish


            // setup client
            actionClient = new ActionClient <Messages.actionlib.TestGoal, Messages.actionlib.TestResult,
                                             Messages.actionlib.TestFeedback>("test_action_slow", nodeHandle);
            // send action request to serverslowdummy
            Console.WriteLine("Wait for client and server to negotiate connection");
            bool started = actionClient.WaitForActionServerToStart(new TimeSpan(0, 0, 3));

            if (!started)
            {
                Console.WriteLine("Negotiation with server failed!");
            }

            Console.ReadLine();

            actionServer.Shutdown();
            nodeHandle.shutdown();
            ROS.shutdown();
        }
コード例 #25
0
 private static void _startROS()
 {
     if (!ROS.isStarted() && roslock.WaitOne())
     {
         // Make sure we are still the first caller to initialize ros, in case we blocked waiting for the lock
         if (!ROS.isStarted())
         {
             ROS.Init(new string[0], "unity_test_" + DateTime.Now.Ticks);
             tf.net.Transformer.LateInit();
         }
         roslock.Set();
     }
 }
コード例 #26
0
 public CROS()
 {
     ROS.ROS_HOSTNAME   = "inin-lab2";
     ROS.ROS_MASTER_URI = "http://192.168.0.103:11311";
     //ROS.ROS_MASTER_URI = "http://127.0.0.1:11311";
     ROS.Init(new string[0], "gis_node_2");
     nh      = new NodeHandle();
     ins_sub = nh.subscribe <Messages.common.InsInfo>("/InsInfo", 10, subCallback);
     vec_sub = nh.subscribe <Messages.common.TcpGeneral>("/TREK", 10, veh_subCallback);
     // gis_pub = nh.advertise<Messages.common.GisInfo>("/gis_info", 1);
     //gis_pub = nh.advertise<Messages.std_msgs.String>("/GIS_TEST", 1);
     msg_veh.data = new int[256];
 }
コード例 #27
0
        public MainWindow()
        {
            string[] sParam = new string[2];
            sParam[0] = "__hostname:=" + GetLocalIP();
            sParam[1] = "__master:=http://192.168.1.108:11311";
            ROS.Init(sParam, "wpf_listener3");

            InitializeComponent();


            nh = new NodeHandle();

            sub = nh.subscribe <Messages.std_msgs.String>("/chatter", 10, subCallback);
        }
コード例 #28
0
ファイル: RosOut.cs プロジェクト: MagicHYD/Windows-Robot
        public static void start()
        {
            ROS.Init(new string[0], "rosout");

            nh  = new NodeHandle();
            sub = nh.subscribe <Messages.rosgraph_msgs.Log>("/rosout", 10, rosoutCallback);
            pub = nh.advertise <Messages.rosgraph_msgs.Log>("/rosout_agg", 1000, true);

            new Thread(() =>
            {
                while (!ROS.ok)
                {
                    Thread.Sleep(10);
                }
            }).Start();
        }
コード例 #29
0
 public void StartROS(String master_uri, String hostname, String nodename = "UnityProject")
 {
     if (!IsROSStarted)
     {
         ROS.ROS_HOSTNAME   = hostname;
         ROS.ROS_MASTER_URI = master_uri;
         ROS.Init(new String[0], nodename);
         nh           = new NodeHandle();
         IsROSStarted = true;
         Debug.Log("ROS Started, Master: " + master_uri + " Hostname: " + hostname + " Node Name: " + nodename);
     }
     else
     {
         Debug.LogWarning("Can't start ROS, it is already started");
     }
 }
コード例 #30
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start roscore and ActionServerTesbed.lua and press any key");
            while (!Console.KeyAvailable)
            {
                Thread.Sleep(1);
            }

            Console.WriteLine("Start ROS");

            ROS.Init(ref args, "ActionClient");

            //(new Program()).Start(1);
            (new TestActionServerKill()).Start(5);
            ROS.shutdown();
        }