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); }
public void CreateNodeWithInvalidName() { string nodeName = "create_node_test_invaild_name?"; Assert.That(() => { Rclcs.CreateNode(nodeName, context).DestroyNode(); }, Throws.TypeOf <InvalidNodeNameException>()); }
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>()); }
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(); }
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); }
public void SetUp() { context = new Context(); Rclcs.Init(context); node = Rclcs.CreateNode(TEST_NODE, nodeNamespace: TEST_NAMESPACE, context: context); }
public void CreateNodeWithoutInit() { Context context = new Context(); Assert.That(() => { Rclcs.CreateNode("foo", context); }, Throws.TypeOf <NotInitializedException>()); }
public void CreateNode() { string nodeName = "create_node_test"; Rclcs.CreateNode(nodeName, context).Dispose(); }