ros2_rust: `self.node.get_clock().now().to_ros_msg().unwrap()` doesn't work anymore
Some errors have detailed explanations: E0433, E0560.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `lanelet_rs` (bin "lanelet_publisher") due to 3 previous errors; 1 warning emitted
error[E0308]: mismatched types
--> src/lanelet_subscriber.rs:73:28
|
73 | stamp: self.node.get_clock().now().to_ros_msg().unwrap()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `builtin_interfaces::msg::Time`, found `Time`
|
= note: `Time` and `builtin_interfaces::msg::Time` have similar names, but are actually distinct types
note: `Time` is defined in crate `rclrs`
--> /ros_ws/install/rclrs/share/rclrs/rust/src/vendor/builtin_interfaces/msg.rs:223:1
|
223 | pub struct Time {
| ^^^^^^^^^^^^^^^
note: `builtin_interfaces::msg::Time` is defined in crate `builtin_interfaces`
--> /ros_ws/install/builtin_interfaces/share/builtin_interfaces/rust/src/msg.rs:185:1
|
185 | pub struct Time {
| ^^^^^^^^^^^^^^^
error[E0599]: no method named `sec` found for struct `Time` in the current scope
--> src/lanelet_path_cross_product.rs:78:34
|
78 | sec: now.sec(),
| ^^^ method not found in `Time`
error[E0599]: no method named `nanosec` found for struct `Time` in the current scope
--> src/lanelet_path_cross_product.rs:79:38
How do you imagine how the timestamp should be filled properly and why does this error first occur today? What have you done?
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 2
- Comments: 18 (9 by maintainers)
@Guelakais the infrastruture for generating code for messages is rather complex, hence why it’s not as streamlined with
ros2-rustas with other projects that just use existing message packages in other languages. We know about this issue and the ROS team as well, we’ve been talking with them on how to improve the user experience since we both believe that Rust will play an important role in robotics in the short future.However, you’d still need to declare dependencies in Cargo.toml so that both
colconandcargocan find them. C++ doesn’t have that problem because there’s no packaging system for C++, but given that Rust comes with its own toolchain, the dependencies need to be duplicated. Eventually, we might be able to infer the ROS dependencies from Cargo.toml, but not sure if that’s entirely feasible.