Open muralimanohar0212 opened 3 months ago
Hello, The advice is a bit delayed, but here is a short answer:
You should be able to run the example program async_listener
, included in the ros2-client
source codes. Download the sources from GitHub, and use the command cargo run --example=async_listener
. Then run (in another terminal) ros2 topic pub /topic std_msgs/msg/String "data: 'Hello, world'"
like you suggest.
Expected results:
$ ros2 topic pub /topic std_msgs/msg/String "data: 'Hello, world'"
publisher: beginning loop
publishing #1: std_msgs.msg.String(data='Hello, world')
publishing #2: std_msgs.msg.String(data='Hello, world')
publishing #3: std_msgs.msg.String(data='Hello, world')
publishing #4: std_msgs.msg.String(data='Hello, world')
publishing #5: std_msgs.msg.String(data='Hello, world')
and
$ cargo run --example=async_listener
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.13s
Running `target/debug/examples/async_listener`
I heard: Hello, world
I heard: Hello, world
I heard: Hello, world
I heard: Hello, world
I heard: Hello, world
You obviously need to have ROS2 installed to be able to run ros2
command-line tool, but there is no need to create any packages. ROS2 distrbutions Foxy, Galactic, and Humble should work.
Thank you for your patience in waiting for answer.
Hello,
This is my first time trying to setup ros2-client in rust. I want to thank you for your patience in advance.
As mentioned, I am trying to get a simple publisher in place. I first started by creating a new rust project using
cargo new <project_name
. In this I have put a simple basic subscriber as below`use ros2_client::{Context, NodeOptions, NodeName, Name, MessageTypeName, Subscription, DEFAULT_SUBSCRIPTION_QOS}; use futures::stream::StreamExt; fn main() { smol::block_on(async { // Create a new ROS 2 context let context = Context::new().unwrap();
}); }
`
Now, when I run the commands
cargo build
andcargo run
, I do not see the listeners on the terminal when runningros2 node list
. Even when runningros2 topic pub /topic std_msgs/msg/String "data: 'Hello, world'"
on a separate terminal, I don't see the library listening and printing these messages.Is there something wrong that I am doing, or am I supposed to create a package using
ros2 pkg create
? Is there anything I need to check or do before creating the project? The node created using rust cannot be seen. I am currently using humble version of ROS2.Any help is appreciated. Many thanks in advance