Beispiel #1
0
        /// <summary>
        /// This function starts the XmlRpcServer used to handle inbound calls on this node
        /// </summary>
        /// <param name="port">The optional argument is used to force ROS to try to bind to a specific port.
        /// Doing so should only be done when acting as the RosMaster.</param>
        public void Start(int port = 0)
        {
            shuttingDown = false;

            Bind("getPid", getPid);

            // if port is 0, then we need to get our hostname from ROS' network init,
            // and we don't know our port until we're bound and listening
            bool bound = server.BindAndListen(port);

            if (!bound)
            {
                throw new Exception("RPCServer bind failed");
            }

            if (port == 0)
            {
                this.port = server.Port; // get bind result
                this.uri  = $"http://{Network.host}:{this.port}/";
            }
            else
            {
                this.port = port;
                this.uri  = ROS.ROS_MASTER_URI; // if port is not 0 we are be the master
            }

            //ROS.Info()( $"[{ThisNode.Name}] XmlRpc Server listening at " + uri );
            serverThread = new Thread(ServerThreadFunc)
            {
                IsBackground = true
            };
            serverThread.Start();
        }
Beispiel #2
0
        /// <summary>
        /// This function starts the XmlRpcServer used to handle inbound calls on this node
        /// </summary>
        /// <param name="port">The optional argument is used to force ROS to try to bind to a specific port.
        /// Doing so should only be done when acting as the RosMaster.</param>
        public void Start(int port = 0)
        {
            disposed = false;

            Bind("getPid", getPid);

            // if port is 0, then we need to get our hostname from ROS' network init,
            // and we don't know our port until we're bound and listening
            bool bound = server.BindAndListen(port);

            if (!bound)
            {
                throw new Exception("RPCServer bind failed");
            }

            if (port == 0)
            {
                this.port = server.Port;     // get bind result
                this.uri  = "http://" + Network.Host + ":" + this.port + "/";
            }
            else
            {
                this.port = port;
                this.uri  = ROS.ROS_MASTER_URI;      // if port is non-zero we are the master
            }

            logger.LogInformation("XmlRpc Server listening at " + uri);
            serverThread = new Thread(ServerThreadFunc)
            {
                IsBackground = true
            };
            serverThread.Start();
        }
        public void Start(String hostname)
        {
            int what = int.Parse(hostname.Split(':')[2].TrimEnd('/'));

            shutting_down = false;
            port          = 0;

            bind("getPublications", getPublications);
            bind("getSubscriptions", getSubscriptions);

            bind("publisherUpdate", pubUpdate);

            bind("requestTopic", requestTopic);
            bind("getSystemState", getSystemState);


            bind("getPublishedTopics", getPublishedTopics);

            bind("registerPublisher", registerPublisher);
            bind("unregisterPublisher", unregisterPublisher);

            bind("registerSubscriber", registerSubscriber);
            bind("unregisterSubscriber", unregisterSubscriber);

            bind("hasParam", hasParam);
            bind("setParam", setParam);
            bind("getParam", getParam);
            bind("deleteParam", deleteParam);
            bind("paramUpdate", paramUpdate);
            bind("subscribeParam", subscribeParam);
            bind("getParamNames", getParamNames);

            bind("getPid", getPid);
            bind("getBusStats", getBusStatus);
            bind("getBusInfo", getBusInfo);

            bind("Time", getTime);

            bind("Duration", getTime);

            bind("get_rostime", getTime);

            bind("get_time", getTime);
            bind("lookupNode", lookupNode);

            bind("getTopicTypes", getTopicTypes);


            //SERVICE??

            bool bound = server.BindAndListen(what); //use any port available

            if (!bound)
            {
                throw new Exception("RPCServer bind failed");
            }
            port = server.Port;
            if (port == 0)
            {
                throw new Exception("RPCServer's port is invalid");
            }
            uri = hostname;

            Console.WriteLine("XmlRpc IN THE HIZI (" + uri + ") FOR SHIZI");
            server_thread = new Thread(serverThreadFunc);
            server_thread.IsBackground = true;
            server_thread.Start();
        }