Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a16336e
nested messages working
lelongg Dec 22, 2018
52329a3
fix array support
lelongg Dec 22, 2018
0afd8b3
add rcl_sys
lelongg Jan 2, 2019
711e557
add author & fix compilation order
lelongg Jan 2, 2019
7664286
readme
lelongg Jan 3, 2019
ce221b2
format
lelongg Jan 3, 2019
a890b6b
fix clippy warnings
lelongg Jan 3, 2019
811b718
delete patch
lelongg Jan 3, 2019
4212c5d
remove leftover build.rs
lelongg Jan 3, 2019
9d28b9a
fix authors
lelongg Jan 3, 2019
ee61486
add qos support
lelongg Feb 8, 2019
17fb7d0
add spin & change handle handling
lelongg Feb 9, 2019
6805c7e
clippy
lelongg Feb 9, 2019
a4a35a2
edit readme
lelongg Feb 9, 2019
d9af4d3
Update README.md
lelongg Feb 9, 2019
262924e
fix message generation issue
lelongg Feb 20, 2019
9b2b172
remove messages
lelongg Feb 22, 2019
270d344
fix fixed size nested array issue
lelongg Feb 22, 2019
7fe7ce8
delete unused files
lelongg Feb 22, 2019
8e88968
reset authors
lelongg Feb 22, 2019
4e0da9f
remove rcl_sys
lelongg Feb 22, 2019
3ac2be1
remove remaining authors & revert readme
lelongg Feb 22, 2019
b4338cf
fix quickstart
lelongg Feb 22, 2019
0d49823
fix fixed size array warning
lelongg Feb 22, 2019
a13bc91
add rosidl_defaults to repos
lelongg Feb 25, 2019
30c2043
fix warnings with array generation
lelongg Feb 25, 2019
fb3efd8
register the 'rosidl_generator_rs'
christianrauch Feb 28, 2019
0b2ee43
Merge pull request #1 from christianrauch/register_gen
lelongg Mar 2, 2019
4a6683e
revert message generation to its initial state
lelongg Mar 4, 2019
3f3a205
add rcl build dependency to rclrs
lelongg Mar 5, 2019
f657ce1
move spin and spin_once from Node to rclrs
lelongg Mar 5, 2019
c55dd16
move publisher sleep at the end of the loop
lelongg Mar 5, 2019
df7befc
re-add msg to rosidl_generator_rs
lelongg Mar 7, 2019
5589047
add TODO for publisher and subscription lifetime
lelongg Mar 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,31 @@ What's missing?
---------------

Lots of things!
- Nested types
- An ament build type for Cargo. The current examples use CMake to install and build the binaries... and it's really ugly.
- Component nodes
- Clients and services
- Tests
- Documentation

### Limitations

- messages are deep-copied and this can be terribly inefficient for big messages like images; the current solution leverages C typesupport implementations and might benefits from a direct serialization/deserialization
- the current solution for crates export with CMake is not very robust
- `rclrs` interface is very limited for now and might not be so much idiomatic yet, any help and suggestion on the interface would be greatly appreciated
- due to the current ROS2 support of non-default clients, packages containing definitions of messages used in Rust crates must be present in the current workspace; otherwise message crates generation won't be triggered

Sounds great, how can I try this out?
-------------------------------------

The following steps show how to build the examples:

```
mkdir -p ~/ros2_rust_ws/src
cd ~/ros2_rust_ws
wget https://raw.githubusercontent.com/esteve/ros2_rust/master/ros2_rust.repos
vcs import ~/ros2_rust_ws/src < ros2_rust.repos
cd ~/ros2_rust_ws/src/ros2/rosidl_typesupport
patch -p1 < ../../ros2_rust/ros2_rust/rosidl_typesupport_ros2_rust.patch
cd ~/ros2_rust_ws
src/ament/ament_tools/scripts/ament.py build --isolated
mkdir -p ros2_rust_ws/src
cd ros2_rust_ws
git clone https://github.com/esteve/ros2_rust.git src/ros2_rust
vcs import src < ./src/ros2_rust/ros2_rust.repos
source /opt/ros/crystal/setup.sh
colcon build
```

Now you can just run a bunch of examples.
Expand All @@ -49,15 +53,15 @@ Now you can just run a bunch of examples.
Publisher:

```
. ~/ros2_rust_ws/install_isolated/local_setup.sh
. ./install/setup.sh

ros2 run rclrs_examples rclrs_publisher
```

Subscriber:

```
. ~/ros2_rust_ws/install_isolated/local_setup.sh
. ./install/setup.sh

ros2 run rclrs_examples rclrs_subscriber
```
Expand Down
67 changes: 11 additions & 56 deletions rclrs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,72 +1,27 @@
cmake_minimum_required(VERSION 3.5)
project(rclrs NONE)

project(rclrs C)

find_package(ament_cmake_ros REQUIRED)
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_export_crates REQUIRED)
find_package(rcl REQUIRED)
find_package(rcl_interfaces REQUIRED)
find_package(rclrs_common REQUIRED)
find_package(rmw REQUIRED)
find_package(rmw_implementation REQUIRED)
find_package(rmw_implementation_cmake REQUIRED)
find_package(rosidl_generator_c REQUIRED)

set(${PROJECT_NAME}_SRCS
"src/c/rclrs.c"
)

set(CMAKE_C_STANDARD 11)

add_library(${PROJECT_NAME}
${${PROJECT_NAME}_SRCS})
foreach(_crate_dependency ${rclrs_common_CRATES})
set(_crates_dependencies "${_crates_dependencies}\n[dependencies.rclrs_common]\npath = '${_crate_dependency}'\n")
endforeach()

ament_target_dependencies(${PROJECT_NAME}
"builtin_interfaces"
"rcl"
"rosidl_generator_c"
"rosidl_typesupport_c")
file(COPY "${CMAKE_SOURCE_DIR}/Cargo.toml" DESTINATION "${CMAKE_BINARY_DIR}/")
file(APPEND "${CMAKE_BINARY_DIR}/Cargo.toml" "${_crates_dependencies}")

install(
TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

configure_file(
"src/rust/Cargo.toml.in"
"share/${PROJECT_NAME}/rust/Cargo.toml"
@ONLY
)

install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/rust/Cargo.toml"
FILES ${CMAKE_BINARY_DIR}/Cargo.toml build.rs src/rcl_wrapper.h
DESTINATION share/${PROJECT_NAME}/rust/
)

install(
DIRECTORY src/rust/src/
DIRECTORY src/
DESTINATION share/${PROJECT_NAME}/rust/src
)

install(
DIRECTORY src/rust/src/
DESTINATION share/${PROJECT_NAME}/rust/src
)

ament_export_dependencies(ament_cmake_ros)
ament_export_dependencies(builtin_interfaces)
ament_export_dependencies(rcl)
ament_export_dependencies(rosidl_generator_c)
ament_export_dependencies(rosidl_typesupport_c)

ament_export_libraries(${PROJECT_NAME})
ament_export_crates("share/${PROJECT_NAME}/rust/")

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
ament_export_crates("share/${PROJECT_NAME}/rust")

ament_package()
ament_package()
8 changes: 6 additions & 2 deletions rclrs/src/rust/Cargo.toml.in → rclrs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
name = "rclrs"
version = "0.1.0"
authors = ["Esteve Fernandez <esteve@apache.org>"]
edition = "2018"

[dependencies]
libc = "0.2"
rclrs_common = { path = '@rclrs_common_CRATES@' }
libc = "0.2.43"
failure = "0.1.5"

[build-dependencies]
bindgen = "0.45.0"
34 changes: 34 additions & 0 deletions rclrs/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
extern crate bindgen;

use std::env;
use std::path::PathBuf;

fn main() {
let mut builder = bindgen::Builder::default()
.header("src/rcl_wrapper.h")
.derive_copy(false)
.default_enum_style(bindgen::EnumVariation::Rust);

let ament_prefix_var_name = "AMENT_PREFIX_PATH";
let ament_prefix_var = env::var(ament_prefix_var_name);

if let Ok(ament_prefix_paths) = ament_prefix_var {
for ament_prefix_path in ament_prefix_paths.split(":") {
builder = builder.clang_arg(format!("-I{}/include", ament_prefix_path));
println!("cargo:rustc-link-search=native={}/lib", ament_prefix_path);
}
}

println!("cargo:rustc-link-lib=dylib=rcl");
println!("cargo:rustc-link-lib=dylib=rcl_logging_noop");
println!("cargo:rustc-link-lib=dylib=rcutils");
println!("cargo:rustc-link-lib=dylib=rmw");
println!("cargo:rustc-link-lib=dylib=rmw_implementation");

let bindings = builder.generate().expect("Unable to generate bindings");

let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("rcl_bindings.rs"))
.expect("Couldn't write bindings!");
}
42 changes: 4 additions & 38 deletions rclrs/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,15 @@
<maintainer email="esteve@apache.org">Esteve Fernandez</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_ros</buildtool_depend>
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_export_crates</buildtool_depend>
<buildtool_depend>rclrs_common</buildtool_depend>

<buildtool_export_depend>ament_cmake_ros</buildtool_export_depend>
<buildtool_export_depend>ament_cmake_export_crates</buildtool_export_depend>
<buildtool_export_depend>rclrs_common</buildtool_export_depend>

<build_depend>builtin_interfaces</build_depend>
<build_depend>rcl_interfaces</build_depend>
<build_depend>rcl</build_depend>
<build_depend>rmw_implementation_cmake</build_depend>
<build_depend>rmw</build_depend>
<build_depend>rosidl_generator_c</build_depend>
<build_depend>rosidl_typesupport_c</build_depend>
<build_depend>rosidl_typesupport_rs</build_depend>
<build_export_depend>builtin_interfaces</build_export_depend>
<build_export_depend>rcl_interfaces</build_export_depend>
<build_export_depend>rmw</build_export_depend>
<build_export_depend>rosidl_generator_c</build_export_depend>
<build_export_depend>rosidl_generator_rs</build_export_depend>
<build_export_depend>rosidl_typesupport_c</build_export_depend>

<exec_depend>builtin_interfaces</exec_depend>
<exec_depend>rcl_interfaces</exec_depend>
<exec_depend>rcl</exec_depend>
<exec_depend>rmw_implementation_cmake</exec_depend>
<exec_depend>rmw_implementation</exec_depend>
<exec_depend>rosidl_generator_c</exec_depend>
<exec_depend>rosidl_parser</exec_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>builtin_interfaces</test_depend>
<test_depend>rcl_interfaces</test_depend>
<test_depend>rclrs_common</test_depend>
<test_depend>rmw_implementation_cmake</test_depend>
<test_depend>rmw</test_depend>
<test_depend>rosidl_generator_c</test_depend>
<test_depend>rosidl_generator_rs</test_depend>
<test_depend>std_msgs</test_depend>
<build_depend>rcl_interfaces</build_depend>
<build_depend>rclrs_common</build_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
</package>
Loading