Skip to content

Conversation

lelongg
Copy link
Contributor

@lelongg lelongg commented Feb 9, 2019

This is a pretty big update and unfortunately it might be a bit too hard to review.

It adds :

  • ROS2 Crystal support
  • support for nested messages
  • support for arrays in message
  • generated RCL binding

@lelongg lelongg changed the title Crystal & and more Crystal and more Feb 10, 2019
@esteve
Copy link
Collaborator

esteve commented Feb 11, 2019

@lelongg whoa, this is so great, thank you so much! Do you think you could split this into smaller and more focused pull requests? Given that your changes started in December, I think it's doable. It'll make it much easier for me to review, I'll make a few comments in this PR, though.

Copy link
Collaborator

@esteve esteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it's in the right direction, but I haven't had time to properly review it all, please split up this pull request into smaller ones. I left a few comments, please use this feedback in future contributions.

@lelongg
Copy link
Contributor Author

lelongg commented Feb 22, 2019

Most concerns should have been addressed.
Splitting in separate meaningful PR might be difficult since this repository cannot be built in its current state (due to changes in ROS2 dependencies) and there is not much change I can easily remove from this PR and still making it compile.

A compilation order issue remains.
First compilation fails because messages are built before rosidl_generator_rs.
I don't know how to fix this yet.

Solution was to add rosidl_default to the workspace.

@esteve
Copy link
Collaborator

esteve commented Feb 27, 2019

@lelongg thank you so much for taking the time to address my feedback. Don't worry about splitting up the PR, it'd make it easier sure, but the work you've done is excellent. Let me have a couple of days to review it all and if I don't get back to you, feel free to ping me again. Thanks!

This was referenced Feb 27, 2019
@tprk77 tprk77 mentioned this pull request Mar 2, 2019
@tprk77
Copy link
Contributor

tprk77 commented Mar 3, 2019

Hi @lelongg, I've been trying out your branch. It's very cool and the examples are working great.

But I've run into a pretty serious issue. It seems that iterative builds are using stale source files. I am having to delete the build directory every time I want to compile.

Steps to reproduce:

$ colcon build --packages-up-to rclrs_examples
Starting >>> ament_cmake_export_crates
Finished <<< ament_cmake_export_crates [0.19s]
...
Finished <<< rclrs_examples [39.0s]
colcon build [9/9 done] [0 ongoing]
Summary: 9 packages finished [43.9s]

$ echo "RANDOM JUNK (((((((((((((((((((((" >> src/ros2_rust/rclrs_examples/src/rclrs_publisher.rs

$ colcon build --packages-up-to rclrs_examples
Starting >>> ament_cmake_export_crates
Finished <<< ament_cmake_export_crates [0.20s]
...
Finished <<< rclrs_examples [0.32s]
colcon build [9/9 done] [0 ongoing]
Summary: 9 packages finished [5.07s]

# NOTE This should NOT have succeeded!

$ tail src/ros2_rust/rclrs_examples/src/rclrs_publisher.rs
        message.data = format!("Hello, world! {}", publish_count);
        println!("Publishing: [{}]", message.data);
        publisher.publish(&message)?;
        publish_count += 1;
    }

    Ok(())
}

RANDOM JUNK (((((((((((((((((((((

@lelongg
Copy link
Contributor Author

lelongg commented Mar 3, 2019

@tprk77 Yes I noticed that too and it's very inconvenient but I haven't solved it yet.

@esteve I've found issues in array generation when working on this project today and I expect to find some more. Will it interfere with your review if I keep adding fixes to this PR? Alternatively, I can try to remove changes to the generator from this PR and fix it separately. It might lighten this PR a bit.

@esteve
Copy link
Collaborator

esteve commented Mar 3, 2019

@lelongg I think it'd make this PR easier to review if the generator stuff were in a separate PR, but it's your call, whatever works best for you.

@tprk77
Copy link
Contributor

tprk77 commented Mar 3, 2019

@lelongg Sounds good. I am all for getting this in and fixing the issues later.

I've been trying this out some more, and I have one more comment. It seems there are a few types like Node which contain Rc making them unable to be Send or Sync. I think it might be useful in some situations to move types like Node, Subscription, and Publisher to other threads. It seems like the underlying rcl should(?) be capable of supporting that, but I don't really know. You would know better than me about the feasibility.

Again, maybe something to consider later on. 😁

ruffsl referenced this pull request in ruffsl/ros2_rust Mar 5, 2019
.repos file is pruned other PR, so skipping keys shouldn't be needed
https://github.com/esteve/ros2_rust/pull/3
Copy link
Collaborator

@esteve esteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for removing the generator changes, it's made reviewing this PR easier. This is the feedback I have so far.


let mut publish_count: u32 = 1;

while rclrs::ok() {
while context.ok() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep rclrs:::ok for symmetry with the other client libraries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://index.ros.org//doc/ros2/Releases/Release-Crystal-Clemmys/.

However, you may just continue to offer a single, global init and shutdown in your client library, and just store a single global context object.

As it is optional I was thinking about adding the global context object later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine if the context is not global for the time being, we can address that in the future. What I meant is that all the client libraries have an 'init` function that optionally take a context (or use the global one implicitly) and all functions are attached to the root namespace (e.g. rclcpp::init, rclpy.init, etc.)

Moreover, the concept of the context as defined in ROS2 differs slightly from what's presented in this pull request. It's not the context that calls rcl_init, but the opposite:

https://github.com/ros2/rcl/blob/master/rcl/src/rcl/init.c#L59

so in order to have mimic the other client libraries, we need to have a rclrs::init function that accepts a context and all functions are done at the rclrs level (e.g. spin, ok, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, the concept of the context as defined in ROS2 differs slightly from what's presented in this pull request. It's not the context that calls rcl_init, but the opposite

It looks like rclcpp context calls rcl_init.

https://github.com/ros2/rclcpp/blob/a54a32915313960497bda2d601cdf98e9f2e9bf0/rclcpp/src/rclcpp/context.cpp#L89

in order to have mimic the other client libraries, we need to have a rclrs::init function that accepts a context and all functions are done at the rclrs level

rclpy.init does take an optional context but rclcpp::init does not.

https://github.com/ros2/rclcpp/blob/e32d17980dcf761712cb854b3703336c380a570e/rclcpp/src/rclcpp/utilities.cpp#L28

How much of a requirement do you think it is to mimic another client interface ? I think it is an important question to settle since it can considerably restrain the design space in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much of a requirement do you think it is to mimic another client interface ? I think it is an important question to settle since it can considerably restrain the design space in the future.

I'd say it's pretty important that rclrs follows the other client libraries, if only to help users switch to Rust if they know other ROS2 libraries. There's only a handful of methods common to all the libraries (i.e. init, createX, destroyX), so apart from that, we have enough freedom to implement the API in any way we want.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lelongg did you have time to look into making the rclrs API similar to the other clients'? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't make the change yet. What API do you suggest ? We can mimic the rclcpp API by making rclrs::ok take a context object but rclcpp::init does not and so we cannot add rclrs::init until we get the global context.

fn main() {
rclrs::init().unwrap();
fn main() -> rclrs::RclResult {
let context = rclrs::Context::default();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rclrs::init() like the other examples.

@esteve
Copy link
Collaborator

esteve commented Mar 5, 2019

@tprk77 I'd rather get the pull request fixed or the changes moved to another pull request. This repository works fine right now (albeit only with Bouncy), I'd prefer not to introduce any changes that contain bugs.

@lelongg lelongg mentioned this pull request Mar 5, 2019
@lelongg
Copy link
Contributor Author

lelongg commented Mar 5, 2019

@tprk77 the iterative compilation issue should be addressed by #7.

@esteve esteve mentioned this pull request Mar 18, 2019
@esteve
Copy link
Collaborator

esteve commented May 5, 2019

Let's better merge this now and address anything else later. Thanks @lelongg !

@esteve esteve merged commit 98d431d into ros2-rust:master May 5, 2019
fmrico pushed a commit to fmrico/ros2_rust that referenced this pull request Jan 10, 2024
JesusSilvaUtrera added a commit to JesusSilvaUtrera/ros2_rust that referenced this pull request Nov 29, 2024
* Added timer_period_ns

* Adds Timer::is_ready().

Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>

* Added comments to avoid warnings

* Added the getter for rcl_clock_t

---------

Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Co-authored-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants