Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            Context ctx = new Context();

            Rclcs.Init(ctx);
            INode node = Rclcs.CreateNode("talker", ctx);
            IPublisher <std_msgs.msg.String> chatter_pub = node.CreatePublisher <std_msgs.msg.String>("chatter");

            std_msgs.msg.String msg = new std_msgs.msg.String();
            int i = 1;

            while (Rclcs.Ok(ctx))
            {
                // adamdbrw - if no at least small sleep is made before
                // the first published message, it doesn't reach subscribers
                // Needs investigation for how to put a valid check here
                // TODO (adam) replace with a proper check
                Thread.Sleep(500);
                msg.Data = "Hello World: " + i;
                i++;
                Console.WriteLine("Publishing: \"" + msg.Data + "\"");
                chatter_pub.Publish(msg);
                Thread.Sleep(500);
            }
            Rclcs.Shutdown(ctx);
        }
Ejemplo n.º 2
0
        public void CreateNodeWithInvalidName()
        {
            string nodeName = "create_node_test_invaild_name?";

            Assert.That(() => { Rclcs.CreateNode(nodeName, context).DestroyNode(); },
                        Throws.TypeOf <InvalidNodeNameException>());
        }
Ejemplo n.º 3
0
        public void CreateNodeWithInvalidRelativeNamespace()
        {
            string nodeName      = "create_node_test_invalid_namespace";
            string nodeNamespace = "invalid_namespace?";

            Assert.That(() => { Rclcs.CreateNode(nodeName, context, nodeNamespace: nodeNamespace).DestroyNode(); },
                        Throws.TypeOf <InvalidNamespaceException>());
        }
Ejemplo n.º 4
0
        public void CreateNodeWithRelativeNamespace()
        {
            string nodeName      = "create_node_test";
            string nodeNamespace = "ns";
            Node   node          = Rclcs.CreateNode(nodeName, context, nodeNamespace: nodeNamespace);

            Assert.That(node.Namespace, Is.EqualTo("/ns"));
            node.Dispose();
        }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            Context ctx = new Context();

            Rclcs.Init(ctx);
            INode node = Rclcs.CreateNode("listener", ctx);

            ISubscription <std_msgs.msg.String> chatter_sub = node.CreateSubscription <std_msgs.msg.String>(
                "chatter", msg => Console.WriteLine("I heard: [" + msg.Data + "]"));

            Rclcs.Spin(node, ctx);
            Rclcs.Shutdown(ctx);
        }
Ejemplo n.º 6
0
 public void SetUp()
 {
     context = new Context();
     Rclcs.Init(context);
     node = Rclcs.CreateNode(TEST_NODE, nodeNamespace: TEST_NAMESPACE, context: context);
 }
Ejemplo n.º 7
0
        public void CreateNodeWithoutInit()
        {
            Context context = new Context();

            Assert.That(() => { Rclcs.CreateNode("foo", context); }, Throws.TypeOf <NotInitializedException>());
        }
Ejemplo n.º 8
0
        public void CreateNode()
        {
            string nodeName = "create_node_test";

            Rclcs.CreateNode(nodeName, context).Dispose();
        }