diff --git a/.devcontainer/entrypoint b/.devcontainer/entrypoint index fc613d2..292be6c 100755 --- a/.devcontainer/entrypoint +++ b/.devcontainer/entrypoint @@ -1,9 +1,14 @@ #!/bin/bash +# Build the voraus-ros-interfaces +echo "Building voraus_ros_interfaces with colcon" +. /opt/ros/humble/setup.sh && . ~/ros_deps/install/setup.sh && cd ~/workspace/voraus_ros_interfaces && colcon build +echo "source ~/workspace/voraus_ros_interfaces/install/setup.bash" >> ~/.bashrc + # Build the package mounted in the container echo "Building workspace with colcon" -. /opt/ros/humble/setup.sh && . ~/ros_deps/install/setup.sh && colcon build -echo "source ~/workspace/install/setup.sh" >> ~/.bashrc +. /opt/ros/humble/setup.sh && . ~/ros_deps/install/setup.sh && . ~/workspace/voraus_ros_interfaces/install/setup.sh && cd ~/workspace && colcon build +echo "source ~/workspace/install/setup.bash" >> ~/.bashrc # Run the CMD (either the default from the Dockerfile or the one provided as docker run argument) exec "$@" diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index c29942b..7e3ddc8 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -17,5 +17,5 @@ jobs: uses: devcontainers/ci@v0.3 with: cacheFrom: ghcr.io/vorausrobotik/voraus-ros-bridge-dev - runCmd: cargo build --verbose + runCmd: cargo ament-build --install-base install/voraus_ros_bridge -- --release --verbose push: never diff --git a/Cargo.lock b/Cargo.lock index 42b08ac..faa5618 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,5 +3,1375 @@ version = 3 [[package]] -name = "voraus-ros-bridge" +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.68", + "which", +] + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "builtin_interfaces" +version = "1.2.1" +dependencies = [ + "rosidl_runtime_rs", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets 0.52.5", +] + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "geometry_msgs" +version = "4.2.4" +dependencies = [ + "builtin_interfaces", + "rosidl_runtime_rs", + "std_msgs", +] + +[[package]] +name = "gethostname" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818" +dependencies = [ + "libc", + "windows-targets 0.48.5", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "idna" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libloading" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" +dependencies = [ + "cfg-if", + "windows-targets 0.52.5", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opcua" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6df8d714e27ba497815bf1d41f79b7652804d54ef5132ef1fc553fbd03598c81" +dependencies = [ + "base64", + "bitflags", + "byteorder", + "bytes", + "chrono", + "derivative", + "foreign-types", + "futures", + "gethostname", + "lazy_static", + "libc", + "log", + "openssl", + "openssl-sys", + "parking_lot", + "regex", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "tokio", + "tokio-util", + "url", + "uuid", +] + +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.5", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "percent-encoding" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn 2.0.68", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rclrs" +version = "0.4.1" +dependencies = [ + "bindgen", + "cfg-if", + "futures", + "rosidl_runtime_rs", +] + +[[package]] +name = "redox_syscall" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rosidl_runtime_rs" +version = "0.4.1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sensor_msgs" +version = "4.2.4" +dependencies = [ + "builtin_interfaces", + "geometry_msgs", + "rosidl_runtime_rs", + "std_msgs", +] + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "std_msgs" +version = "4.2.4" +dependencies = [ + "builtin_interfaces", + "rosidl_runtime_rs", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tinyvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + +[[package]] +name = "url" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +dependencies = [ + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" +dependencies = [ + "getrandom", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "voraus_ros_bridge" +version = "0.1.0" +dependencies = [ + "builtin_interfaces", + "opcua", + "rclrs", + "rosidl_runtime_rs", + "sensor_msgs", + "std_msgs", + "voraus_ros_interfaces", +] + +[[package]] +name = "voraus_ros_interfaces" +version = "0.0.1" +dependencies = [ + "rosidl_runtime_rs", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.68", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[patch.unused]] +name = "action_msgs" +version = "1.2.1" + +[[patch.unused]] +name = "actionlib_msgs" +version = "4.2.4" + +[[patch.unused]] +name = "composition_interfaces" +version = "1.2.1" + +[[patch.unused]] +name = "diagnostic_msgs" +version = "4.2.4" + +[[patch.unused]] +name = "example_interfaces" +version = "0.9.3" + +[[patch.unused]] +name = "examples_rclrs_message_demo" +version = "0.4.1" + +[[patch.unused]] +name = "examples_rclrs_minimal_client_service" +version = "0.4.1" + +[[patch.unused]] +name = "examples_rclrs_minimal_pub_sub" +version = "0.4.1" + +[[patch.unused]] +name = "lifecycle_msgs" +version = "1.2.1" + +[[patch.unused]] +name = "nav_msgs" +version = "4.2.4" + +[[patch.unused]] +name = "rcl_interfaces" +version = "1.2.1" + +[[patch.unused]] +name = "rclrs_example_msgs" +version = "0.4.1" + +[[patch.unused]] +name = "rosgraph_msgs" +version = "1.2.1" + +[[patch.unused]] +name = "rust_pubsub" +version = "0.1.0" + +[[patch.unused]] +name = "shape_msgs" +version = "4.2.4" + +[[patch.unused]] +name = "statistics_msgs" +version = "1.2.1" + +[[patch.unused]] +name = "std_srvs" +version = "4.2.4" + +[[patch.unused]] +name = "stereo_msgs" +version = "4.2.4" + +[[patch.unused]] +name = "test_msgs" +version = "1.2.1" + +[[patch.unused]] +name = "trajectory_msgs" +version = "4.2.4" + +[[patch.unused]] +name = "unique_identifier_msgs" +version = "2.2.1" + +[[patch.unused]] +name = "visualization_msgs" +version = "4.2.4" + +[[patch.unused]] +name = "voraus_ros_bridge" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 98f95b1..cb5704e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,8 @@ [package] -name = "voraus-ros-bridge" +name = "voraus_ros_bridge" version = "0.1.0" edition = "2021" +rust-version = "1.74" authors = ["Jan-Niklas Burfeind ", "Philipp Caspers ", "Dwayne Steinke ", "Tobias Brinker "] description = "Enables `voraus.core` integration within the ROS framework." readme = "README.md" @@ -11,5 +12,26 @@ license = "MIT" keywords = ["ros2", "opc-ua", "bridge", "voraus"] categories = ["command-line-utilities"] - [dependencies] +std_msgs = { version = "4.2.4" } +sensor_msgs = { version = "4.2.4" } +builtin_interfaces = "*" +voraus_ros_interfaces = { version = "*" } +rclrs = { version = "0.4.1" } +rosidl_runtime_rs = { version = "*" } +opcua = { version = "0.12.0" } + +[dev-dependencies] +rclrs = { version = "0.4.1" } +std_msgs = { version = "4.2.4" } +sensor_msgs = { version = "4.2.4" } +builtin_interfaces = "*" +opcua = { version = "0.12.0" } + +[[example]] +name = "simple-publisher" +path = "examples/ros2/simple-publisher.rs" + +[[example]] +name = "simple-subscriber" +path = "examples/ros2/simple-subscriber.rs" diff --git a/README.md b/README.md index 1512661..4af5a48 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,36 @@ Run `cargo clippy` Run `cargo test` -### Build the crate +### Build the crates -Run `cargo build` +Run `cargo build --release` + +### Run the voraus_ros_bridge + +Run `cargo run --release` + +## via ROS: + +run `cargo ament-build --install-base install/voraus_ros_bridge -- --release`. +Then `ros2 run voraus_ros_bridge voraus_ros_bridge` + +### Custom message/service files + +Create a separate ros message package just like you would in cpp. +Compile it. +Source the workspace of the message package. ($LD_LIBRARY_PATH has to be updated) +Include it in the cargo.toml and package.xml. +Build the consuming project with colcon the first time (in order to generate the cargo config.toml), after that cargo is fine. + + +### General Notes + +ros2_rust only supports single threaded executors for now. +The ros bridge could benefit from both the multithreaded one and the static single threaded. +Might be a problem in the future but could potentially worked around by spawning multiple node. + +## Ros msgs crates not published to creates.io +It would be nice to not have to manually invoke colcon in order to patch the dependencies etc. +Cargo provides a build.rs for such tasks, but since the dependency resolving happens before build.rs gets executed +it still fails if colcon build was not invoked manually before. This might be solvabe if the msgs crate where published +normally on crates.io. Maybe we should restart the discussion on GitHub about this topic. \ No newline at end of file diff --git a/examples/opc-ua/client.rs b/examples/opc-ua/client.rs new file mode 100644 index 0000000..8783a88 --- /dev/null +++ b/examples/opc-ua/client.rs @@ -0,0 +1,83 @@ +use opcua::client::prelude::*; +use std::sync::Arc; +use opcua::server::session; +use opcua::sync::*; + +fn main() { + // Optional - enable OPC UA logging + // opcua::console_logging::init(); + + // Make the client configuration + let mut client = ClientBuilder::new() + .application_name("Simple Client") + .application_uri("urn:SimpleClient") + .product_uri("urn:SimpleClient") + .trust_server_certs(true) + .create_sample_keypair(true) + .session_retry_limit(3) + .client() + .unwrap(); + + // Create an endpoint. The EndpointDescription can be made from a tuple consisting of + // the endpoint url, security policy, message security mode and user token policy. + let endpoint: EndpointDescription = ( + "opc.tcp://localhost:48401/", + "None", + MessageSecurityMode::None, + UserTokenPolicy::anonymous(), + ) + .into(); + + let session = client + .connect_to_endpoint(endpoint, IdentityToken::Anonymous) + .unwrap(); + + let session = session.write(); + // let nodes_to_read:ReadValueId = (NodeId::new(1, 100007), AttributeId::Value, + // session.read(nodes_to_read, timestamps_to_return, max_age) + // let _ = Session::run(session); +} + +fn subscribe_to_values(session: Arc>) -> Result<(), StatusCode> { + let session = session.write(); + // Create a subscription polling every 2s with a callback + let subscription_id = session.create_subscription( + 2000.0, + 10, + 30, + 0, + 0, + true, + DataChangeCallback::new(|changed_monitored_items| { + println!("Data change from server:"); + changed_monitored_items + .iter() + .for_each(|item| print_value(item)); + }), + )?; + // Create some monitored items + let items_to_create: Vec = ["100007", "100903", "100909"] + .iter() + .map(|v| NodeId::new(1, *v).into()) + .collect(); + let _ = session.create_monitored_items( + subscription_id, + TimestampsToReturn::Both, + &items_to_create, + )?; + Ok(()) +} + +fn print_value(item: &MonitoredItem) { + let node_id = &item.item_to_monitor().node_id; + let data_value = item.last_value(); + if let Some(ref value) = data_value.value { + println!("Item \"{}\", Value = {:?}", node_id, value); + } else { + println!( + "Item \"{}\", Value not found, error: {}", + node_id, + data_value.status.as_ref().unwrap() + ); + } +} diff --git a/examples/opc-ua/server.rs b/examples/opc-ua/server.rs new file mode 100644 index 0000000..b3d7e12 --- /dev/null +++ b/examples/opc-ua/server.rs @@ -0,0 +1,75 @@ +use opcua::server::prelude::*; + +fn main() { + let server: Server = ServerBuilder::new() + .application_name("Demo Server") + .application_uri("urn:server_uri") + .discovery_urls(vec!["opc.tcp://localhost:4855/".to_string()]) + .create_sample_keypair(true) + .trust_client_certs() + .pki_dir("./pki-server") + .discovery_server_url(None) + .host_and_port("localhost", 4855) + .endpoint( + "none", + ServerEndpoint::new( + "/", + SecurityPolicy::None, + MessageSecurityMode::None, + &vec![String::from("ANONYMOUS")], + ), + ) + .server() + .unwrap(); + + let address_space = server.address_space(); + + let folder_id = address_space.write() + .add_folder("Variables", "Variables", &NodeId::objects_folder_id()) + .unwrap(); + + let node_id = NodeId::new(1, "MyVar"); + VariableBuilder::new(&node_id, "MyVar", "MyVar") + .organized_by(&folder_id) + .value(0u8) + .insert(&mut address_space.write()); + + let now = DateTime::now(); + let value = 123.456f64; + let _ = address_space.write().set_variable_value(node_id, value, &now, &now); + + server.run(); + + // println!("0"); + // let ns = { + // let address_space = server.address_space(); + // let mut address_space = address_space.write(); + // address_space.register_namespace("urn:demo-server").unwrap() + // }; + // println!("1"); + // let static_folder_id = { + // let address_space = server.address_space(); + // let mut address_space = address_space.write(); + // address_space + // .add_folder("Static", "Static", &NodeId::objects_folder_id()) + // .unwrap() + // }; + // println!("2"); + // let address_space = server.address_space(); + // let mut address_space = address_space.write(); + + // // Create a folder under static folder + // let folder_id = address_space + // .add_folder("Scalar", "Scalar", &static_folder_id) + // .unwrap(); + + // println!("3"); + // let value = 42; + // VariableBuilder::new(&NodeId::new(ns,"Float".to_string()), "Float", "Float") + // .data_type(DataTypeId::Float) + // .value(value) + // .organized_by(&folder_id) + // .insert(&mut server.address_space().write()); + // println!("Starting OPC UA server."); + // server.run(); +} // diff --git a/examples/ros2/simple-publisher.rs b/examples/ros2/simple-publisher.rs new file mode 100644 index 0000000..7bb9bb6 --- /dev/null +++ b/examples/ros2/simple-publisher.rs @@ -0,0 +1,84 @@ +use builtin_interfaces::msg::Time as TimeMsg; +use rclrs::{create_node, Context, Node, Publisher, RclrsError, QOS_PROFILE_DEFAULT}; +use sensor_msgs::msg::JointState as JointStateMsg; +use std::f64::consts::PI; +use std::{env, sync::Arc, thread, time::Duration, vec}; +use std_msgs::msg::Header; +struct SimplePublisherNode { + node: Arc, + publisher: Arc>, +} + +impl SimplePublisherNode { + fn new(context: &Context) -> Result { + let node = create_node(context, "joint_states").unwrap(); + let publisher = node + .create_publisher("joint_states", QOS_PROFILE_DEFAULT) + .unwrap(); + Ok(Self { node, publisher }) + } + + fn publish_data(&self, data: f64) -> Result { + let time_stamp = self.node.get_clock().now().to_ros_msg().unwrap(); + let time_msgs = TimeMsg { + sec: time_stamp.sec, + nanosec: time_stamp.nanosec, + }; + let msg: JointStateMsg = JointStateMsg { + header: Header { + stamp: time_msgs, + frame_id: "1".to_string(), + }, + name: vec!["Test Joint States".to_string()], + position: vec![data, 3.0], + velocity: vec![2.0, 3.3], + effort: vec![], + }; + self.publisher.publish(msg).unwrap(); + Ok(1) + } +} + +struct SineWave { + amplitude: f64, + frequency: f64, + sample_rate: f64, + current_sample: usize, +} + +impl SineWave { + fn new(amplitude: f64, frequency: f64, sample_rate: f64) -> Self { + SineWave { + amplitude, + frequency, + sample_rate, + current_sample: 0, + } + } +} + +impl Iterator for SineWave { + type Item = f64; + + fn next(&mut self) -> Option { + let t = self.current_sample as f64 / self.sample_rate; + let value = self.amplitude * (2.0 * PI * self.frequency * t).sin(); + self.current_sample += 1; + Some(value) + } +} + +fn main() -> Result<(), RclrsError> { + let context = Context::new(env::args()).unwrap(); + let publisher = Arc::new(SimplePublisherNode::new(&context).unwrap()); + let publisher_other_thread = Arc::clone(&publisher); + let mut sine = SineWave::new(1.0, 10.0, 44100.0); // Amplitude 1.0, Frequency 440 Hz, Sample Rate 44100 Hz + thread::spawn(move || loop { + thread::sleep(Duration::from_nanos(100)); + + publisher_other_thread + .publish_data(sine.next().unwrap()) + .unwrap(); + }); + rclrs::spin(publisher.node.clone()) +} diff --git a/examples/ros2/simple-subscriber.rs b/examples/ros2/simple-subscriber.rs new file mode 100644 index 0000000..ce4717b --- /dev/null +++ b/examples/ros2/simple-subscriber.rs @@ -0,0 +1,58 @@ +use rclrs::{create_node, Context, Node, RclrsError, Subscription, QOS_PROFILE_DEFAULT}; +use sensor_msgs::msg::JointState as JointStateMsg; +use std::{ + env, + sync::{ + atomic::{AtomicU32, Ordering}, + Arc, Mutex, + }, +}; + +struct Subscriber { + num_messages: AtomicU32, + node: Arc, + subscription: Mutex>>>, +} + +impl Subscriber { + pub fn new(name: &str, topic: &str) -> Result, RclrsError> { + let context = Context::new(env::args())?; + let node = create_node(&context, name)?; + let subscriber = Arc::new(Subscriber { + num_messages: 0.into(), + node, + subscription: None.into(), + }); + + let minimal_subscriber_aux = Arc::clone(&subscriber); + let subscription = subscriber.node.create_subscription::( + topic, + QOS_PROFILE_DEFAULT, + move |msg: JointStateMsg| { + minimal_subscriber_aux.callback(msg); + }, + )?; + *subscriber.subscription.lock().unwrap() = Some(subscription); + Ok(subscriber) + } + fn callback(&self, msg: JointStateMsg) { + self.num_messages.fetch_add(1, Ordering::SeqCst); + println!( + "[{}] I heard: '{:?}' with timestamp {}.", + self.node.name(), + msg.position, + msg.header.stamp.nanosec + ); + println!( + "[{}] (Got {} messages so far)", + self.node.name(), + self.num_messages.load(Ordering::SeqCst) + ); + } +} + +fn main() -> Result<(), RclrsError> { + let subscription = + Arc::new(Subscriber::new("joint_states_subscriber", "joint_states").unwrap()); + rclrs::spin(subscription.node.clone()) +} diff --git a/package.xml b/package.xml new file mode 100644 index 0000000..ba26ef8 --- /dev/null +++ b/package.xml @@ -0,0 +1,16 @@ + + voraus_ros_bridge + 0.0.1 + Enables `voraus.core` integration within the ROS framework. + user + MIT + + rclrs + std_msgs + rosidl_runtime_rs + voraus_ros_interfaces + + + ament_cargo + + diff --git a/src/main.rs b/src/main.rs index a37db8b..04c6571 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,33 @@ -fn main() { - println!("Hello, voraus!"); +use rclrs::{create_node, Context, RclrsError}; +use ros_service_server::handle_service; +use std::{env, sync::Arc, thread, time::Duration}; + +mod ros_publisher; +mod ros_service_server; + +use ros_publisher::{create_joint_state_msg, RosPublisher}; + +const FREQUENCY_HZ: u64 = 1000; + +fn main() -> Result<(), RclrsError> { + let context = Context::new(env::args()).unwrap(); + let node = create_node(&context, "voraus_ros_brigde")?; + let node_copy = node.clone(); + let joint_state_publisher = Arc::new(RosPublisher::new(&node, "joint_states").unwrap()); + let publisher_thread_throttle_us = + ((1.0 / FREQUENCY_HZ as f64) * 1000.0 * 1000.0).round() as u64; + let mut increment = 0.0; + thread::spawn(move || loop { + thread::sleep(Duration::from_micros(publisher_thread_throttle_us)); + let joint_state_msg = create_joint_state_msg(&node, increment); + joint_state_publisher + .publish_data(&joint_state_msg) + .unwrap(); + increment += 1.0; + }); + println!("Starting to publish joint states with {} Hz", FREQUENCY_HZ); + + let _server = node_copy + .create_service::("add_two_ints", handle_service)?; + rclrs::spin(node_copy) } diff --git a/src/ros_publisher.rs b/src/ros_publisher.rs new file mode 100644 index 0000000..ef419d1 --- /dev/null +++ b/src/ros_publisher.rs @@ -0,0 +1,43 @@ +use builtin_interfaces::msg::Time as TimeMsg; +use sensor_msgs::msg::JointState as JointStateMsg; +use std::sync::Arc; +use std_msgs::msg::Header; + +use rclrs::{Node, Publisher, RclrsError, QOS_PROFILE_DEFAULT}; +use rosidl_runtime_rs::Message as RosMessage; + +pub struct RosPublisher { + publisher: Arc>, +} + +impl RosPublisher { + pub fn new(node: &Node, topic: &str) -> Result { + let publisher = node.create_publisher(topic, QOS_PROFILE_DEFAULT).unwrap(); + Ok(Self { publisher }) + } + + pub fn publish_data(&self, data: &T) -> Result<(), RclrsError> { + self.publisher.publish(data).unwrap(); + Ok(()) + } +} + +pub fn create_joint_state_msg(node: &Node, data: f64) -> JointStateMsg { + let time = node.get_clock().now().to_ros_msg().unwrap(); + let time_msgs = TimeMsg { + sec: time.sec, + nanosec: time.nanosec, + }; + + let joint_state_msg: JointStateMsg = JointStateMsg { + header: Header { + stamp: time_msgs, + frame_id: "0".to_string(), + }, + name: vec!["Test Joint States".to_string()], + position: vec![data, 3.0], + velocity: vec![2.0, 3.3], + effort: vec![], + }; + joint_state_msg +} diff --git a/src/ros_service_server.rs b/src/ros_service_server.rs new file mode 100644 index 0000000..0afffff --- /dev/null +++ b/src/ros_service_server.rs @@ -0,0 +1,9 @@ +pub fn handle_service( + _request_header: &rclrs::rmw_request_id_t, + request: voraus_ros_interfaces::srv::Voraus_Request, +) -> voraus_ros_interfaces::srv::Voraus_Response { + println!("request: {} + {}", request.a, request.b); + voraus_ros_interfaces::srv::Voraus_Response { + sum: request.a + request.b, + } +} diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs new file mode 100644 index 0000000..5f48b6a --- /dev/null +++ b/tests/helpers/mod.rs @@ -0,0 +1 @@ +pub mod ros_subscriber; diff --git a/tests/helpers/ros_subscriber.rs b/tests/helpers/ros_subscriber.rs new file mode 100644 index 0000000..72ad65d --- /dev/null +++ b/tests/helpers/ros_subscriber.rs @@ -0,0 +1,57 @@ +use rclrs::{create_node, Context, Node, RclrsError, Subscription, QOS_PROFILE_DEFAULT}; +use sensor_msgs::msg::JointState as JointStateMsg; +use std::{ + env, + sync::{ + atomic::{AtomicU32, Ordering}, + Arc, Mutex, + }, +}; + +pub struct Subscriber { + pub num_messages: AtomicU32, + pub data: Arc>>, + pub node: Arc, + subscription: Mutex>>>, +} + +impl Subscriber { + pub fn new(name: &str, topic: &str) -> Result, RclrsError> { + let context = Context::new(env::args())?; + let node = create_node(&context, name)?; + let subscriber = Arc::new(Subscriber { + num_messages: 0.into(), + data: Arc::new(Mutex::new(None)), + node, + subscription: None.into(), + }); + + let minimal_subscriber_aux = Arc::clone(&subscriber); + let subscription = subscriber.node.create_subscription::( + topic, + QOS_PROFILE_DEFAULT, + move |msg: JointStateMsg| { + minimal_subscriber_aux.callback(msg); + }, + )?; + *subscriber.subscription.lock().unwrap() = Some(subscription); + Ok(subscriber) + } + fn callback(&self, msg: JointStateMsg) { + self.num_messages.fetch_add(1, Ordering::SeqCst); + println!("msg {}", msg.clone().position.first().unwrap()); + *self.data.lock().unwrap() = Some(msg); + + println!( + "data {}", + self.data + .lock() + .unwrap() + .as_mut() + .unwrap() + .position + .first() + .unwrap() + ); + } +} diff --git a/tests/test_publisher.rs b/tests/test_publisher.rs new file mode 100644 index 0000000..d976c0e --- /dev/null +++ b/tests/test_publisher.rs @@ -0,0 +1,66 @@ +use std::{ + process::Command, + sync::{atomic::Ordering, Arc}, + time::Duration, +}; + +mod helpers; + +#[test] +fn e2e_opc_ua_var_to_ros_topic() { + println!("Starting ros bridge"); + let mut bridge = Command::new("ros2") + .args(["run"]) + .args(["voraus_ros_bridge"]) + .args(["voraus_ros_bridge"]) + .spawn() + .expect("Failed to run command"); + + // Spawn OPC UA Server with a sample variable + // Spawn ROS Subscriber against the sample topic + println!("Creating Subscription"); + let subscription = Arc::new( + helpers::ros_subscriber::Subscriber::new("joint_states_subscriber", "joint_states") + .unwrap(), + ); + let timeout = Some(Duration::new(5, 0)); + rclrs::spin_once(subscription.node.clone(), timeout).expect("Could not spin"); + + let mut number_of_messages_received = subscription.num_messages.load(Ordering::SeqCst); + let first_sin_value = *subscription + .data + .lock() + .unwrap() + .as_ref() + .unwrap() + .position + .first() + .unwrap(); + assert_eq!(number_of_messages_received, 1); + + rclrs::spin_once(subscription.node.clone(), timeout).expect("Could not spin"); + + number_of_messages_received = subscription.num_messages.load(Ordering::SeqCst); + assert_eq!(number_of_messages_received, 2); + let second_sin_value = *subscription + .data + .lock() + .unwrap() + .as_ref() + .unwrap() + .position + .first() + .unwrap(); + + println!("{}, {}", first_sin_value, second_sin_value); + assert!( + second_sin_value > first_sin_value, + "{} is not greater than {}", + second_sin_value, + first_sin_value + ); + bridge + .kill() + .expect("voraus-ros-bridge process could not be killed."); + println!("done"); +} diff --git a/voraus_ros_interfaces/CMakeLists.txt b/voraus_ros_interfaces/CMakeLists.txt new file mode 100644 index 0000000..80d9ad7 --- /dev/null +++ b/voraus_ros_interfaces/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.5) + +project(voraus_ros_interfaces) + +# Default to C++14 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +find_package(ament_cmake REQUIRED) +find_package(rosidl_default_generators REQUIRED) + +set(msg_files + "msg/Voraus.msg" + "srv/Voraus.srv" +) + +rosidl_generate_interfaces(${PROJECT_NAME} + ${msg_files} +) + +ament_export_dependencies(rosidl_default_runtime) + +ament_package() \ No newline at end of file diff --git a/voraus_ros_interfaces/README.md b/voraus_ros_interfaces/README.md new file mode 100644 index 0000000..dca8085 --- /dev/null +++ b/voraus_ros_interfaces/README.md @@ -0,0 +1,5 @@ +This is a ros package without any rust code for providing the necessary message and service types. +It will probably be autogenerated in the future. It is needed for the compilation of the voraus-ros-bridge and +all its ros consumers. +As this package will be generated from the OPC UA spec it will move to either the voraus components or to the release +such that a preconfigured rosbridge can be shipped. \ No newline at end of file diff --git a/voraus_ros_interfaces/msg/Voraus.msg b/voraus_ros_interfaces/msg/Voraus.msg new file mode 100644 index 0000000..885d5c7 --- /dev/null +++ b/voraus_ros_interfaces/msg/Voraus.msg @@ -0,0 +1,11 @@ +# Primitive types +bool bool_member true +int8 int8_member 1 +uint8 uint8_member 2 +byte byte_member 3 +float32 float32_member 1e-2 + +# Array/sequence of primitive type +float32[3] float_array [1.0, 2.0, 3.0] +float32[<=3] float_seq_bounded [4.0, 5.0] +float32[] float_seq_unbounded [6.0] diff --git a/voraus_ros_interfaces/package.xml b/voraus_ros_interfaces/package.xml new file mode 100644 index 0000000..0cf7d2e --- /dev/null +++ b/voraus_ros_interfaces/package.xml @@ -0,0 +1,20 @@ + + voraus_ros_interfaces + 0.0.1 + Defines custom ros message/service types for the voraus-ros-bridge + user + MIT + + ament_cmake + rosidl_default_generators + + rosidl_default_runtime + + ament_lint_common + + rosidl_interface_packages + + + ament_cmake + + \ No newline at end of file diff --git a/voraus_ros_interfaces/srv/Voraus.srv b/voraus_ros_interfaces/srv/Voraus.srv new file mode 100644 index 0000000..9bf1218 --- /dev/null +++ b/voraus_ros_interfaces/srv/Voraus.srv @@ -0,0 +1,5 @@ +int64 a +int64 b +int64 c +--- +int64 sum \ No newline at end of file