Initial bump to 🦊y. Note that this breaks eloquent compability!
Also see note about the package liblibstatistics_collector in common/src/lib.rs.
This commit is contained in:
parent
a124c21e6d
commit
827f97d07a
13
README.md
13
README.md
|
|
@ -5,14 +5,15 @@ Minimal bindings for ROS2 that do *not* require hooking in to the ROS2 build inf
|
||||||
|
|
||||||
How to use
|
How to use
|
||||||
--------------------
|
--------------------
|
||||||
1. Depend on this package: r2r = { git = "https://github.com/sequenceplanner/r2r" }.
|
1. Make sure you have libclang installed. (e.g. libclang-dev on ubuntu)
|
||||||
2. You need to source your ROS2 installation before building/running.
|
2. Depend on this package: r2r = { git = "https://github.com/sequenceplanner/r2r" }.
|
||||||
3. The bindings will rebuild automatically if/when you source your workspace(s).
|
3. You need to source your ROS2 installation before building/running.
|
||||||
4. If you make changes to existing message types, run cargo clean -p msg_gen to force recompilation of the rust message types on the next build.
|
4. The bindings will rebuild automatically if/when you source your workspace(s).
|
||||||
|
5. If you make changes to existing message types, run cargo clean -p msg_gen to force recompilation of the rust message types on the next build.
|
||||||
|
|
||||||
A couple of examples are included in examples/
|
A couple of examples are included in examples/
|
||||||
```
|
```
|
||||||
. /opt/ros/eloquent/setup.sh
|
. /opt/ros/foxy/setup.sh
|
||||||
cargo build
|
cargo build
|
||||||
cargo run --example subscriber_with_thread
|
cargo run --example subscriber_with_thread
|
||||||
```
|
```
|
||||||
|
|
@ -20,7 +21,7 @@ An example application can be found here <https://github.com/sequenceplanner/r2r
|
||||||
|
|
||||||
What works?
|
What works?
|
||||||
--------------------
|
--------------------
|
||||||
- Up to date with ROS2 ~Dashing~ Eloquent
|
- Up to date with ROS2 ~Dashing~ ~Eloquent~ Foxy
|
||||||
- Building Rust types
|
- Building Rust types
|
||||||
- Publish/subscribe
|
- Publish/subscribe
|
||||||
- Services (servers, not clients yet)
|
- Services (servers, not clients yet)
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ pub fn get_all_ros_msgs() -> Vec<String> {
|
||||||
if let Some(file_name_str) = file_name.to_str() {
|
if let Some(file_name_str) = file_name.to_str() {
|
||||||
let substr = &l[4..l.len()-4];
|
let substr = &l[4..l.len()-4];
|
||||||
let srv_name = format!("{}/srv/{}", file_name_str, substr);
|
let srv_name = format!("{}/srv/{}", file_name_str, substr);
|
||||||
println!("srv_name: {}", srv_name);
|
|
||||||
msgs.push(srv_name);
|
msgs.push(srv_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,9 +84,15 @@ fn test_msg_list() {
|
||||||
|
|
||||||
pub fn parse_msgs(msgs: &Vec<String>) -> Vec<RosMsg> {
|
pub fn parse_msgs(msgs: &Vec<String>) -> Vec<RosMsg> {
|
||||||
let v: Vec<Vec<&str>> = msgs.iter().map(|l| l.split("/").into_iter().take(3).collect()).collect();
|
let v: Vec<Vec<&str>> = msgs.iter().map(|l| l.split("/").into_iter().take(3).collect()).collect();
|
||||||
v.iter().filter(|v|v.len() == 3).
|
let v: Vec<_> = v.iter().filter(|v|v.len() == 3).
|
||||||
map(|v| RosMsg { module: v[0].into(), prefix: v[1].into(), name: v[2].into()}).collect()
|
map(|v| RosMsg { module: v[0].into(), prefix: v[1].into(), name: v[2].into()}).collect();
|
||||||
|
|
||||||
|
// hack because I don't have time to find out the root cause of this at the moment.
|
||||||
|
// for some reason the library files generated to this are called
|
||||||
|
// liblibstatistics_collector_test_msgs__..., but I don't know where test_msgs come from.
|
||||||
|
// (this seems to be a useless package anyway)
|
||||||
|
// also affects message generation below.
|
||||||
|
v.into_iter().filter(|v| v.module != "libstatistics_collector").collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_map(included_msgs: &[RosMsg]) -> HashMap<&str, HashMap<&str, Vec<&str>>> {
|
pub fn as_map(included_msgs: &[RosMsg]) -> HashMap<&str, HashMap<&str, Vec<&str>>> {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ fn main() {
|
||||||
&msg.module, &msg.prefix, &include_filename
|
&msg.module, &msg.prefix, &include_filename
|
||||||
));
|
));
|
||||||
includes.push_str(&format!(
|
includes.push_str(&format!(
|
||||||
"#include <{}/{}/{}__rosidl_typesupport_introspection_c.h>\n",
|
"#include <{}/{}/detail/{}__rosidl_typesupport_introspection_c.h>\n",
|
||||||
&msg.module, &msg.prefix, &include_filename
|
&msg.module, &msg.prefix, &include_filename
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
@ -78,27 +78,27 @@ fn main() {
|
||||||
// blacklist types that are handled by rcl bindings
|
// blacklist types that are handled by rcl bindings
|
||||||
.blacklist_type("rosidl_message_type_support_t")
|
.blacklist_type("rosidl_message_type_support_t")
|
||||||
.blacklist_type("rosidl_service_type_support_t")
|
.blacklist_type("rosidl_service_type_support_t")
|
||||||
.blacklist_type("rosidl_generator_c__String")
|
.blacklist_type("rosidl_runtime_c__String")
|
||||||
.blacklist_type("rosidl_generator_c__String__Sequence")
|
.blacklist_type("rosidl_runtime_c__String__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__U16String")
|
.blacklist_type("rosidl_runtime_c__U16String")
|
||||||
.blacklist_type("rosidl_generator_c__U16String__Sequence")
|
.blacklist_type("rosidl_runtime_c__U16String__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__float32__Sequence")
|
.blacklist_type("rosidl_runtime_c__float32__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__float__Sequence")
|
.blacklist_type("rosidl_runtime_c__float__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__float64__Sequence")
|
.blacklist_type("rosidl_runtime_c__float64__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__double__Sequence")
|
.blacklist_type("rosidl_runtime_c__double__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__long_double__Sequence")
|
.blacklist_type("rosidl_runtime_c__long_double__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__char__Sequence")
|
.blacklist_type("rosidl_runtime_c__char__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__wchar__Sequence")
|
.blacklist_type("rosidl_runtime_c__wchar__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__boolean__Sequence")
|
.blacklist_type("rosidl_runtime_c__boolean__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__octet__Sequence")
|
.blacklist_type("rosidl_runtime_c__octet__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__uint8__Sequence")
|
.blacklist_type("rosidl_runtime_c__uint8__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__int8__Sequence")
|
.blacklist_type("rosidl_runtime_c__int8__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__uint16__Sequence")
|
.blacklist_type("rosidl_runtime_c__uint16__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__int16__Sequence")
|
.blacklist_type("rosidl_runtime_c__int16__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__uint32__Sequence")
|
.blacklist_type("rosidl_runtime_c__uint32__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__int32__Sequence")
|
.blacklist_type("rosidl_runtime_c__int32__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__uint64__Sequence")
|
.blacklist_type("rosidl_runtime_c__uint64__Sequence")
|
||||||
.blacklist_type("rosidl_generator_c__int64__Sequence")
|
.blacklist_type("rosidl_runtime_c__int64__Sequence")
|
||||||
.default_enum_style(bindgen::EnumVariation::Rust {
|
.default_enum_style(bindgen::EnumVariation::Rust {
|
||||||
non_exhaustive: false,
|
non_exhaustive: false,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ fn main() {
|
||||||
println!("cargo:rustc-link-lib=dylib=rmw");
|
println!("cargo:rustc-link-lib=dylib=rmw");
|
||||||
println!("cargo:rustc-link-lib=dylib=rmw_implementation");
|
println!("cargo:rustc-link-lib=dylib=rmw_implementation");
|
||||||
println!("cargo:rustc-link-lib=dylib=rosidl_typesupport_c");
|
println!("cargo:rustc-link-lib=dylib=rosidl_typesupport_c");
|
||||||
println!("cargo:rustc-link-lib=dylib=rosidl_generator_c");
|
println!("cargo:rustc-link-lib=dylib=rosidl_runtime_c");
|
||||||
|
|
||||||
let bindings = builder.generate().expect("Unable to generate bindings");
|
let bindings = builder.generate().expect("Unable to generate bindings");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ use std::ffi::CString;
|
||||||
impl Default for rmw_message_info_t {
|
impl Default for rmw_message_info_t {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
rmw_message_info_t {
|
rmw_message_info_t {
|
||||||
|
source_timestamp: 0,
|
||||||
|
received_timestamp: 0,
|
||||||
publisher_gid: rmw_gid_t {
|
publisher_gid: rmw_gid_t {
|
||||||
implementation_identifier: std::ptr::null(),
|
implementation_identifier: std::ptr::null(),
|
||||||
data: [0; 24],
|
data: [0; 24],
|
||||||
|
|
@ -39,7 +41,7 @@ impl Default for rmw_qos_profile_t {
|
||||||
|
|
||||||
// special treatment to convert to/from rust strings.
|
// special treatment to convert to/from rust strings.
|
||||||
// ros strings are owned by ros, assignment is a copy
|
// ros strings are owned by ros, assignment is a copy
|
||||||
impl rosidl_generator_c__String {
|
impl rosidl_runtime_c__String {
|
||||||
pub fn to_str(&self) -> &str {
|
pub fn to_str(&self) -> &str {
|
||||||
let s = unsafe { CStr::from_ptr(self.data as *mut i8) };
|
let s = unsafe { CStr::from_ptr(self.data as *mut i8) };
|
||||||
s.to_str().unwrap_or("")
|
s.to_str().unwrap_or("")
|
||||||
|
|
@ -49,13 +51,13 @@ impl rosidl_generator_c__String {
|
||||||
let q = CString::new(other).unwrap();
|
let q = CString::new(other).unwrap();
|
||||||
let to_send_ptr = q.as_ptr() as *const i8;
|
let to_send_ptr = q.as_ptr() as *const i8;
|
||||||
unsafe {
|
unsafe {
|
||||||
rosidl_generator_c__String__assign(self as *mut _, to_send_ptr);
|
rosidl_runtime_c__String__assign(self as *mut _, to_send_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use widestring::U16String;
|
use widestring::U16String;
|
||||||
impl rosidl_generator_c__U16String {
|
impl rosidl_runtime_c__U16String {
|
||||||
pub fn to_str(&self) -> String {
|
pub fn to_str(&self) -> String {
|
||||||
let s = unsafe { U16String::from_ptr(self.data, self.size) };
|
let s = unsafe { U16String::from_ptr(self.data, self.size) };
|
||||||
// U16Str = U16String::from_ptr(buffer, strlen as usize);
|
// U16Str = U16String::from_ptr(buffer, strlen as usize);
|
||||||
|
|
@ -68,15 +70,15 @@ impl rosidl_generator_c__U16String {
|
||||||
let wstr = U16String::from_str(other);
|
let wstr = U16String::from_str(other);
|
||||||
let to_send_ptr = wstr.as_ptr() as *const uint_least16_t;
|
let to_send_ptr = wstr.as_ptr() as *const uint_least16_t;
|
||||||
unsafe {
|
unsafe {
|
||||||
rosidl_generator_c__U16String__assignn(self as *mut _, to_send_ptr, wstr.len());
|
rosidl_runtime_c__U16String__assignn(self as *mut _, to_send_ptr, wstr.len());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rosidl_generator_c__U16String__Sequence {
|
impl rosidl_runtime_c__U16String__Sequence {
|
||||||
pub fn update(&mut self, values: &[String]) {
|
pub fn update(&mut self, values: &[String]) {
|
||||||
unsafe { rosidl_generator_c__U16String__Sequence__fini(self as *mut _); }
|
unsafe { rosidl_runtime_c__U16String__Sequence__fini(self as *mut _); }
|
||||||
unsafe { rosidl_generator_c__U16String__Sequence__init(self as *mut _, values.len()); }
|
unsafe { rosidl_runtime_c__U16String__Sequence__init(self as *mut _, values.len()); }
|
||||||
let strs = unsafe { std::slice::from_raw_parts_mut(self.data, values.len()) };
|
let strs = unsafe { std::slice::from_raw_parts_mut(self.data, values.len()) };
|
||||||
for (target, source) in strs.iter_mut().zip(values) {
|
for (target, source) in strs.iter_mut().zip(values) {
|
||||||
target.assign(&source);
|
target.assign(&source);
|
||||||
|
|
@ -93,10 +95,10 @@ impl rosidl_generator_c__U16String__Sequence {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rosidl_generator_c__String__Sequence {
|
impl rosidl_runtime_c__String__Sequence {
|
||||||
pub fn update(&mut self, values: &[String]) {
|
pub fn update(&mut self, values: &[String]) {
|
||||||
unsafe { rosidl_generator_c__String__Sequence__fini(self as *mut _); }
|
unsafe { rosidl_runtime_c__String__Sequence__fini(self as *mut _); }
|
||||||
unsafe { rosidl_generator_c__String__Sequence__init(self as *mut _, values.len()); }
|
unsafe { rosidl_runtime_c__String__Sequence__init(self as *mut _, values.len()); }
|
||||||
let strs = unsafe { std::slice::from_raw_parts_mut(self.data, values.len()) };
|
let strs = unsafe { std::slice::from_raw_parts_mut(self.data, values.len()) };
|
||||||
for (target, source) in strs.iter_mut().zip(values) {
|
for (target, source) in strs.iter_mut().zip(values) {
|
||||||
target.assign(&source);
|
target.assign(&source);
|
||||||
|
|
@ -136,18 +138,18 @@ macro_rules! primitive_sequence {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
primitive_sequence!(rosidl_generator_c__float32, f32);
|
primitive_sequence!(rosidl_runtime_c__float32, f32);
|
||||||
primitive_sequence!(rosidl_generator_c__float64, f64);
|
primitive_sequence!(rosidl_runtime_c__float64, f64);
|
||||||
primitive_sequence!(rosidl_generator_c__long_double, u128);
|
primitive_sequence!(rosidl_runtime_c__long_double, u128);
|
||||||
primitive_sequence!(rosidl_generator_c__char, i8);
|
primitive_sequence!(rosidl_runtime_c__char, i8);
|
||||||
primitive_sequence!(rosidl_generator_c__wchar, u16);
|
primitive_sequence!(rosidl_runtime_c__wchar, u16);
|
||||||
primitive_sequence!(rosidl_generator_c__boolean, bool);
|
primitive_sequence!(rosidl_runtime_c__boolean, bool);
|
||||||
primitive_sequence!(rosidl_generator_c__octet, u8);
|
primitive_sequence!(rosidl_runtime_c__octet, u8);
|
||||||
primitive_sequence!(rosidl_generator_c__uint8, u8);
|
primitive_sequence!(rosidl_runtime_c__uint8, u8);
|
||||||
primitive_sequence!(rosidl_generator_c__int8, i8);
|
primitive_sequence!(rosidl_runtime_c__int8, i8);
|
||||||
primitive_sequence!(rosidl_generator_c__uint16, u16);
|
primitive_sequence!(rosidl_runtime_c__uint16, u16);
|
||||||
primitive_sequence!(rosidl_generator_c__int16, i16);
|
primitive_sequence!(rosidl_runtime_c__int16, i16);
|
||||||
primitive_sequence!(rosidl_generator_c__uint32, u32);
|
primitive_sequence!(rosidl_runtime_c__uint32, u32);
|
||||||
primitive_sequence!(rosidl_generator_c__int32, i32);
|
primitive_sequence!(rosidl_runtime_c__int32, i32);
|
||||||
primitive_sequence!(rosidl_generator_c__uint64, u64);
|
primitive_sequence!(rosidl_runtime_c__uint64, u64);
|
||||||
primitive_sequence!(rosidl_generator_c__int64, i64);
|
primitive_sequence!(rosidl_runtime_c__int64, i64);
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,16 @@
|
||||||
#include <rcutils/error_handling.h>
|
#include <rcutils/error_handling.h>
|
||||||
|
|
||||||
// low level msg type handling
|
// low level msg type handling
|
||||||
#include <rosidl_generator_c/string.h>
|
#include <rosidl_runtime_c/string.h>
|
||||||
#include <rosidl_generator_c/string_functions.h>
|
#include <rosidl_runtime_c/string_functions.h>
|
||||||
|
|
||||||
#include <rosidl_generator_c/u16string.h>
|
#include <rosidl_runtime_c/u16string.h>
|
||||||
#include <rosidl_generator_c/u16string_functions.h>
|
#include <rosidl_runtime_c/u16string_functions.h>
|
||||||
|
|
||||||
#include <rosidl_generator_c/primitives_sequence.h>
|
#include <rosidl_runtime_c/primitives_sequence.h>
|
||||||
#include <rosidl_generator_c/primitives_sequence_functions.h>
|
#include <rosidl_runtime_c/primitives_sequence_functions.h>
|
||||||
|
|
||||||
#include <rosidl_generator_c/message_type_support_struct.h>
|
#include <rosidl_runtime_c/message_type_support_struct.h>
|
||||||
#include <rosidl_typesupport_introspection_c/message_introspection.h>
|
#include <rosidl_typesupport_introspection_c/message_introspection.h>
|
||||||
#include <rosidl_typesupport_introspection_c/field_types.h>
|
#include <rosidl_typesupport_introspection_c/field_types.h>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue