noelex / rclnet

Modern ROS 2 client library for .NET.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to see node from ROS2 CLI

carsonloyaltrimble opened this issue · comments

Hi there,

First this is a great library and thanks for the hard work here.

I am able to create a new .NET 7 application and create context, node and publisher to publish async while my app is running. My issue is that I am not able to see the node listed in the command line ros2 interface using the command: ros2 node list

For the examples, the topic and data do show up as expected.

Is this intended behavior? I do not think it causes a huge issue more that it is very difficult to debug the system with large amounts of nodes running. Would love to help dig into this if needed and thanks again!

Code:

 private async void SpinNode()
 {
     await using var ctx = new RclContext();
     using var node = ctx.CreateNode("turtle_circling");
     using var pub = node.CreatePublisher<Twist>("/turtle1/cmd_vel");

     var twist = new Twist(
         linear: new(x: 3.0f),
         angular: new(z: 1.8f)
     );

     while (!cts.IsCancellationRequested)
     {
         Debug.WriteLine("Publishing! ros2 publisher");
         await pub.PublishAsync(twist);
         await Task.Delay(1000, cts.Token);
     }
 }

image

Could you please try running the graph_monitor example first and then start your node and see if graph_monitor can receive node online events?

For what it's worth...this example does seem to work fine in linux. Only edits I made were async Task rather than async void because I needed something to await in Main.

I'm using .NET 8 though. If that matters.

I have had problems similar to this when the executable is being run as root instead of a user. I'm not sure if there is a similar thing in Windows or not.

Could you please try running the graph_monitor example first and then start your node and see if graph_monitor can receive node online events?

Will do this and report back! Also will try running as user instead.

I have had problems similar to this when the executable is being run as root instead of a user. I'm not sure if there is a similar thing in Windows or not.

I am on windows and it appears there is a similar-ish behavior. When I build and run the project from Visual Studio 2022 in Windows then I am not able to see the node using ros2 node list in other terminals. If I manually run the build executable in a fresh command prompt then I am able to see it as normal. Any thoughts on this @noelex

If I manually run the build executable in a fresh command prompt then I am able to see it as normal.

Looks like an environment issue. Does removing launchSettings.json and launching Visual Studio from a command prompt with setup.bat sourced work for you?

I will try this and post an update shortly. Thanks for the support here!

It looks like this is related to the env config in Visual Studio. It does not seem to cause any issues so I am happy to close this for now since that seems to be the root cause. Thanks everyone! @noelex great repo!