Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
67779fa
Add drake_ros_bazel_installed Bazel package.
hidmic May 7, 2021
7867e02
Use native rules in drake_ros_* macros properly
hidmic May 12, 2021
35f3d89
Target @drake_ros repo in ros2 Starlark templates.
hidmic May 12, 2021
e0a011f
Drop rviz_default_plugins workaround.
hidmic May 12, 2021
1bc0567
Use importlib.metadata to find_python_package()
hidmic May 12, 2021
cacf43f
Fix cc_library imports (includes, data)
hidmic May 12, 2021
ab802fe
Drop CMake rosidl pipeline entrypoint
hidmic May 26, 2021
4eda216
Fix dload C++ shim assert.
hidmic Jun 4, 2021
89d3ae3
Add drake_ros_py_executable_import() macro.
hidmic Jun 4, 2021
7bc6c62
Split execute_or_fail() macro for reuse.
hidmic Jun 4, 2021
a68b9cb
Add python_dev repository to support C extension builds.
hidmic Jun 4, 2021
8633186
Implement rosidl pipeline
hidmic Jun 4, 2021
86a1455
Add message generation example packages
hidmic Jun 4, 2021
88cc886
Update ros2 repository configuration
hidmic Jun 4, 2021
a9167a4
Refactor ROS build infrastructure
hidmic Jun 18, 2021
055c005
Configure workspace through .bazelrc
hidmic Jun 18, 2021
668fce1
Fix //apps and //common packages
hidmic Jun 18, 2021
99993c9
Update ROS build infrastructure
hidmic Jun 24, 2021
a088003
Functional oracle and inquirer nodes
hidmic Jun 24, 2021
c32ae73
Fix label in ROS 2 rosidl_tools
hidmic Jun 30, 2021
28bc19d
Updated oracle and inquirer nodes
hidmic Jun 30, 2021
0be49b5
Add fastcdr to ROS 2 repository package whitelist
hidmic Jun 30, 2021
351f065
Use single source as main in ros_py_binary()
hidmic Jul 2, 2021
8b97a60
Fix to_starlark_string_dict() utility
hidmic Jul 2, 2021
361ae64
Pick up buildtool_depends as build dependencies
hidmic Jul 2, 2021
8a0445f
Refactor ROS 2 Python package scrapping
hidmic Jul 2, 2021
be67add
Fix up rosidl_tools for Python interface generation
hidmic Jul 2, 2021
f65feb1
Functional oracle and inquirer nodes in C++ and Python
hidmic Jul 2, 2021
1044771
Sandbox rmw_cyclonedds_cpp, not rmw_fastrtps_cpp
hidmic Jul 16, 2021
fd1e8e4
Update ROS 2 Skylark tools
hidmic Aug 4, 2021
f0ecfe2
Add READMEs to packages
hidmic Sep 22, 2021
055193a
Use explicit QoS settings in Python
hidmic Sep 22, 2021
701fd86
Make dload*.bzl utilities private
hidmic Sep 22, 2021
e567c10
Put Python shim logic in a main() function
hidmic Sep 22, 2021
ed1bcab
Add comments to BUILD.bazel files
hidmic Sep 22, 2021
53c114f
Use ROS 2 Rolling binary installation
hidmic Sep 22, 2021
c1fc00b
Drop nonexistent lint tests
hidmic Sep 22, 2021
91392b5
Fix pure CMake package scrapping
hidmic Sep 22, 2021
6f0f566
Add drake_ros_ prefix to package names
hidmic Sep 30, 2021
2ead16b
Drop use_fastrtps_profile() macro
hidmic Sep 30, 2021
5192b55
Lint Python sources
hidmic Sep 30, 2021
7381bb9
Add support for CycloneDDS network isolation
hidmic Oct 4, 2021
7a87131
Fix typo: replace Q by @
hidmic Oct 4, 2021
c74037c
Update keep_common() macro implementation
hidmic Oct 14, 2021
5fbb60e
Document //tools/ros2:generate_repository_files.py script
hidmic Oct 14, 2021
7789fbd
Rename *_tools.bzl files
hidmic Oct 14, 2021
e113236
Enable native rule overrides
hidmic Oct 14, 2021
dc2280c
Rename AVAILABLE_TYPESUPPORTS to AVAILABLE_TYPESUPPORT_LIST
hidmic Oct 14, 2021
a79e41f
Document ROS 2 C++, Python, and rosidl rules
hidmic Oct 14, 2021
2cf5778
Document and simplify ros2.bzl
hidmic Oct 14, 2021
cf5cc5b
Clarify dload* macro visibility
hidmic Oct 14, 2021
2f866ac
Add debugger fork-follow smoke tests
hidmic Oct 14, 2021
491db1e
Cleanup ROS 2 dependencies
hidmic Oct 14, 2021
c5d349e
Add prerequisites' install script
hidmic Oct 14, 2021
e83151d
Make rmw isolation an explicit runtime choice
hidmic Oct 15, 2021
c6e6f0b
Fix ros_cc_test() kwargs handling
hidmic Oct 25, 2021
fd50e23
Use plain binaries as inner ros_*_test rules' executable.
hidmic Oct 25, 2021
f35b783
Minimize .bzl templates in local ros2 repositories.
hidmic Oct 25, 2021
daad629
Restrict rosidl_*_genrules output to stderr only
hidmic Oct 25, 2021
8c1c2ed
Remove 'manual' tag from RMW isolation tests
hidmic Oct 25, 2021
c35fbb8
Add --batch flag to debugger fork-follow tests.
hidmic Oct 25, 2021
eb7eafe
Improve setup prerequisites script
hidmic Oct 25, 2021
f712156
Add basic Bazel+ROS 2 CI
hidmic Oct 26, 2021
1a6c089
Remove Drake from WORKSPACE
hidmic Oct 26, 2021
678b58c
Use ROS 2 Rolling Docker image for CI
hidmic Oct 26, 2021
73dad8a
No sudo within Docker container
hidmic Oct 26, 2021
4a2b0dd
Complete build prerequisites
hidmic Oct 26, 2021
3f62d27
Complete Python prerequisites
hidmic Oct 26, 2021
5f82eee
Merge and document all ROS 2 tooling.
hidmic Oct 28, 2021
b5f5f43
Update basic Bazel+ROS 2 CI
hidmic Oct 28, 2021
56d7962
Add envsubst to prereqs
hidmic Oct 28, 2021
244adec
Remove 'manual' tags in debugger fork-follow tests
hidmic Nov 8, 2021
d0c020b
Cleanup Bazel ROS CI workflow
hidmic Nov 8, 2021
7c998b8
Clean up trailing whitespace
hidmic Nov 8, 2021
687f618
Rename kwargs.bzl functions
hidmic Nov 8, 2021
fa5ec0d
Improve rmw_isolation API tests
hidmic Nov 8, 2021
d9dcd22
Avoid half upgrades when installing prereqs
hidmic Nov 9, 2021
c9264db
Reduce Bazel ROS CI times
hidmic Nov 9, 2021
d28ae86
Clarify drake_ros_common README.md
hidmic Dec 7, 2021
e40de01
Improve ROS 2 Skylark tools documentation.
hidmic Dec 7, 2021
bb2ec9a
Use transitive instead of transitively
hidmic Dec 7, 2021
98042d4
Improve install prerequisites
hidmic Dec 20, 2021
0bffdc9
Add comment about execv() error handling
hidmic Dec 20, 2021
84c8910
Use scraping, not scrapping
hidmic Dec 20, 2021
ff444cc
Add note on rationale behind forgoing rules_foreign_cc
hidmic Dec 20, 2021
bdaba92
Rename ros_py_import() as ros_import_binary()
hidmic Dec 20, 2021
42469f3
Annotate shimmed targets in ROS C++/Python rules
hidmic Dec 20, 2021
c8336af
Rename build.bazel as package.BUILD.bazel
hidmic Dec 20, 2021
78fb939
Remove lru_cache instance
hidmic Dec 20, 2021
3faa640
Improve ros2bzl.sandboxing module
hidmic Dec 20, 2021
c8c51f0
Improve ros2bzl.scraping.system module
hidmic Dec 20, 2021
93fa595
Fail on /usr/local dependencies
hidmic Dec 20, 2021
24c5c7b
Make all implementation details private
hidmic Dec 20, 2021
499f99b
Revamp ROS 2 rmw_isolation package
hidmic Dec 21, 2021
20fae24
Clarify ament_cmake_CMakeLists.txt.in purpose
hidmic Dec 21, 2021
21718a9
Improve rmw_isolation collision rates
hidmic Dec 21, 2021
b159cbe
Comment on rmw_isolation tests flakiness
hidmic Dec 23, 2021
efc8a6c
Comment on ros2bzl.scraping.system.DEFAULT_* dirs
hidmic Dec 23, 2021
700752a
Tweak scraping of ROS package dependencies
hidmic Dec 23, 2021
674f879
Correct writing in README.md files
hidmic Dec 23, 2021
d6dceee
Lint all C++ and Python code
hidmic Dec 23, 2021
7e44de5
Manage rosidl generated deps properly
hidmic Jan 3, 2022
8d5a489
Simplify cmake_tools members naming
hidmic Jan 5, 2022
efb4d54
Rearrange comments in rmw_isolation BUILD file
hidmic Jan 5, 2022
cae236a
Comment isolated nodes in rmw_isolation tests
hidmic Jan 5, 2022
74e2e58
Update ROS 2 Skylark tools README.md
hidmic Jan 11, 2022
f068da4
Document ros2bzl.scraping.collect_ros_package_metadata()
hidmic Jan 11, 2022
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
29 changes: 29 additions & 0 deletions .github/workflows/bazelized.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Bazel ROS Continuous Integration

on:
pull_request:
branches:
- main
- develop

defaults:
run:
working-directory: drake_ros_bazel_installed

jobs:
build_and_test:
runs-on: ubuntu-latest
container:
image: ros:rolling-ros-base-focal
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: "/home/runner/.cache/bazel"
key: bazel
- name: Install prerequisites
run: yes | ./setup/install_prereqs.sh
- name: Build Bazel workspace
run: bazel build //...
- name: Test Bazel workspace
run: bazel test //... @ros2//...
9 changes: 9 additions & 0 deletions drake_ros_bazel_installed/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Perform optimized builds.
build -c opt

# Use C++17.
build --cxxopt=-std=c++17
build --host_cxxopt=-std=c++17

# Use Python 3.
build --python_path=/usr/bin/python3
1 change: 1 addition & 0 deletions drake_ros_bazel_installed/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Empty build file to mark package root.
33 changes: 33 additions & 0 deletions drake_ros_bazel_installed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Bazel Project with ROS 2 as a Precompiled External

This project pulls in a system installed ROS 2 distribution as a Bazel external repository.

For an introduction to Bazel, refer to [Getting Started with Bazel](https://docs.bazel.build/versions/master/getting-started.html).

## Platform support

This project targets ROS 2 Rolling distributions on Ubuntu Focal 20.04 only.

## Instructions

First, install the required dependencies:

```sh
sudo ./setup/install_prereqs.sh
```

To build all packages:

```sh
bazel build //...
```

To run binaries directly:

```sh
bazel run //drake_ros_apps:oracle_cc
```

```sh
bazel run //drake_ros_apps:inquirer_py
```
9 changes: 9 additions & 0 deletions drake_ros_bazel_installed/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
workspace(name = "drake_ros")

load("//tools/workspace/python:repository.bzl", "python_repository")

python_repository(name = "python_dev")

load("//tools/workspace/ros2:repository.bzl", "ros2_repository")

ros2_repository(name = "ros2")
93 changes: 93 additions & 0 deletions drake_ros_bazel_installed/drake_ros_apps/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# -*- mode: python -*-
# vi: set ft=python :

load("@ros2//:ros_cc.bzl", "ros_cc_binary")
load("@ros2//:ros_py.bzl", "ros_py_binary")
load("@ros2//:rosidl.bzl", "rosidl_interfaces_group")

rosidl_interfaces_group(
name = "drake_ros_apps_msgs",
interfaces = [
"msg/Status.msg",
],
deps = [
"//drake_ros_common:drake_ros_common_msgs",
"@ros2//:builtin_interfaces",
],
)

ros_cc_binary(
name = "oracle_cc",
srcs = ["oracle.cc"],
deps = [
":drake_ros_apps_msgs_cc",
"//drake_ros_common:drake_ros_common_msgs_cc",
"@ros2//:rclcpp_cc",
"@ros2//:rclcpp_action_cc",
],
rmw_implementation = "rmw_cyclonedds_cpp",
tags = ["requires-network"],
)

ros_cc_binary(
name = "inquirer_cc",
srcs = ["inquirer.cc"],
deps = [
":drake_ros_apps_msgs_cc",
"//drake_ros_common:drake_ros_common_msgs_cc",
"@ros2//:rclcpp_cc",
"@ros2//:rclcpp_action_cc",
],
rmw_implementation = "rmw_cyclonedds_cpp",
tags = ["requires-network"],
)

ros_py_binary(
name = "oracle_py",
srcs = ["oracle.py"],
main = "oracle.py",
deps = [
":drake_ros_apps_msgs_py",
"//drake_ros_common:drake_ros_common_msgs_py",
"@ros2//:rclpy_py",
],
rmw_implementation = "rmw_cyclonedds_cpp",
tags = ["requires-network"],
)

ros_py_binary(
name = "inquirer_py",
srcs = ["inquirer.py"],
main = "inquirer.py",
deps = [
":drake_ros_apps_msgs_py",
"//drake_ros_common:drake_ros_common_msgs_py",
"@ros2//:rclpy_py",
],
rmw_implementation = "rmw_cyclonedds_cpp",
tags = ["requires-network"],
)

sh_test(
name = "gdb_oracle_cc_test",
srcs = ["test/exec.sh"],
args = [
"gdb",
"-x", "$(location :test/oracle_cc.gdb)", "--batch", "--args",
"$(location :oracle_cc)", "--ros-args", "--disable-external-lib-logs",
],
data = ["test/oracle_cc.gdb", ":oracle_cc"],
size = "small",
)

sh_test(
name = "lldb_oracle_cc_test",
srcs = ["test/exec.sh"],
args = [
"lldb",
"-s", "$(location :test/oracle_cc.lldb)", "--batch", "--",
"$(location :oracle_cc)", "--ros-args", "--disable-external-lib-logs",
],
data = ["test/oracle_cc.lldb", ":oracle_cc"],
size = "small",
)
18 changes: 18 additions & 0 deletions drake_ros_bazel_installed/drake_ros_apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Demo `drake_ros` apps

This package exercises `rosidl` interface generation and usage in C++ and Python, with cross-package interface dependencies.

To check that the resulting interfaces are functional, it includes a demo applications in C++ and Python. Namely:

- Equivalent `oracle_(cc|py)` applications that publish `drake_ros_apps_msgs/msg/Status` messages, serve a `drake_ros_common_msgs/srv/Query`service, and provide a `drake_ros_common_msgs/action/Do` action.
- Equivalent `inquirer_(cc|py)` applications that subscribe to `drake_ros_apps_msgs/msg/Status` messages, make `drake_ros_common_msgs/srv/Query` service requests, and invoke the `drake_ros_common_msgs/action/Do` action.

You may run a C++ oracle against a Python inquirer, and vice versa:

```sh
bazel run //drake_ros_apps:oracle_py
```

```sh
bazel run //drake_ros_apps:inquirer_cc
```
133 changes: 133 additions & 0 deletions drake_ros_bazel_installed/drake_ros_apps/inquirer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#include <functional>
#include <memory>

#include <rclcpp/rclcpp.hpp>
#include <rclcpp_action/client.hpp>
#include <rclcpp_action/create_client.hpp>

#include "drake_ros_apps_msgs/msg/status.hpp"
#include "drake_ros_common_msgs/action/do.hpp"
#include "drake_ros_common_msgs/srv/query.hpp"

using namespace std::chrono_literals;

namespace drake_ros_apps {

class Inquirer : public rclcpp::Node {
public:
Inquirer() : Node("inquirer") {
using namespace std::placeholders;
status_sub_ = this->create_subscription<drake_ros_apps_msgs::msg::Status>(
"status", rclcpp::QoS(rclcpp::KeepLast(1)),
std::bind(&Inquirer::on_status, this, _1));

query_client_ =
this->create_client<drake_ros_common_msgs::srv::Query>("query");

action_client_ =
rclcpp_action::create_client<drake_ros_common_msgs::action::Do>(this,
"do");

inquire_timer_ =
this->create_wall_timer(5s, std::bind(&Inquirer::inquire, this));
}

private:
using QueryClient = rclcpp::Client<drake_ros_common_msgs::srv::Query>;

void handle_reply(QueryClient::SharedFuture future) const {
RCLCPP_INFO(this->get_logger(), "oracle said: %s",
future.get()->reply.c_str());
}

using ActionGoalHandle =
rclcpp_action::ClientGoalHandle<drake_ros_common_msgs::action::Do>;
void handle_rite_request_response(
const std::shared_ptr<ActionGoalHandle> handle) const {
if (!handle) {
RCLCPP_ERROR(this->get_logger(), "oracle rejected rite request");
} else {
RCLCPP_INFO(this->get_logger(), "oracle rite in progress");
}
}

void handle_rite_feedback(
std::shared_ptr<ActionGoalHandle> handle,
const std::shared_ptr<const ActionGoalHandle::Feedback> feedback) const {
RCLCPP_INFO(this->get_logger(), "oracle is %s", feedback->message.c_str());
}

void handle_rite_result(const ActionGoalHandle::WrappedResult& result) const {
switch (result.code) {
case rclcpp_action::ResultCode::SUCCEEDED:
RCLCPP_INFO(this->get_logger(), "oracle rite is complete");
break;
case rclcpp_action::ResultCode::ABORTED:
RCLCPP_ERROR(this->get_logger(), "oracle rite aborted due to %s",
result.result->reason.c_str());
break;
case rclcpp_action::ResultCode::CANCELED:
RCLCPP_WARN(this->get_logger(), "oracle rite was cancelled");
break;
default:
RCLCPP_ERROR(this->get_logger(), "oracle rite status unknown");
break;
}
}

void inquire() const {
using namespace std::placeholders;

if (query_client_->service_is_ready()) {
auto request =
std::make_shared<drake_ros_common_msgs::srv::Query::Request>();
request->query = "how's it going?";
RCLCPP_INFO(this->get_logger(), "oracle, %s", request->query.c_str());
query_client_->async_send_request(
request, std::bind(&Inquirer::handle_reply, this, _1));
} else {
RCLCPP_WARN(this->get_logger(), "oracle not available for queries");
}

if (action_client_->action_server_is_ready()) {
rclcpp_action::Client<drake_ros_common_msgs::action::Do>::SendGoalOptions
options;
options.goal_response_callback =
std::bind(&Inquirer::handle_rite_request_response, this, _1);
options.feedback_callback =
std::bind(&Inquirer::handle_rite_feedback, this, _1, _2);
options.result_callback =
std::bind(&Inquirer::handle_rite_result, this, _1);
drake_ros_common_msgs::action::Do::Goal goal;
goal.action = "rite";
goal.period = rclcpp::Duration::from_seconds(0.1);
goal.timeout = rclcpp::Duration::from_seconds(1.0);
action_client_->async_send_goal(goal, options);
} else {
RCLCPP_WARN(this->get_logger(), "oracle not available for actions");
}
}

void on_status(const drake_ros_apps_msgs::msg::Status& msg) const {
RCLCPP_INFO(get_logger(), "%s status (%lu): %s", msg.origin.c_str(),
msg.status.sequence_id, msg.status.message.c_str());
}

std::shared_ptr<rclcpp::Subscription<drake_ros_apps_msgs::msg::Status>>
status_sub_;
std::shared_ptr<rclcpp::Client<drake_ros_common_msgs::srv::Query>>
query_client_;
std::shared_ptr<rclcpp_action::Client<drake_ros_common_msgs::action::Do>>
action_client_;
std::shared_ptr<rclcpp::TimerBase> inquire_timer_;
};

} // namespace drake_ros_apps

int main(int argc, char** argv) {
rclcpp::init(argc, argv);

rclcpp::spin(std::make_shared<drake_ros_apps::Inquirer>());

rclcpp::shutdown();
}
Loading