Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualize Hydroelastic and Point Contacts (continued from #25) #133

Merged
merged 91 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
52224a3
Copy files from example
Nov 2, 2021
d5ab342
Matching adjusted drake-ros
Nov 2, 2021
ffb3a67
Update changes to drake geometry API
Nov 4, 2021
44a8942
Format with clang
Nov 9, 2021
1551696
.cpp/.hpp -> .cc/.h
sloretz Sep 13, 2022
2864252
Ressurect hydroelastic collisions demo
sloretz Sep 13, 2022
f9f8d74
Move to drake_ros_examples
sloretz Sep 13, 2022
103df6e
Hydroelastic collisions separate from rviz visualizer
sloretz Sep 13, 2022
26857cd
Remove unneeded variable
sloretz Sep 13, 2022
816c6bc
tf2_eigen dep is solely in drake_ros_viz
sloretz Sep 13, 2022
7ac93ba
Strip drake visualizer stuff for now
sloretz Sep 13, 2022
df88c37
Example is now a ball rolling down a hill
sloretz Sep 14, 2022
cd86ac0
Follow rolling sphere
sloretz Sep 14, 2022
057c0ca
Marker namespace from body names
sloretz Sep 14, 2022
93175c0
ConnectContactResultsToRviz and demo is now a slow super big ball
sloretz Sep 14, 2022
8e254e8
Namespace cleanup
sloretz Sep 15, 2022
bb48322
Tweak resolution and timestep for faster demo
sloretz Sep 15, 2022
9f14505
Misc cleanup
sloretz Sep 15, 2022
fa4f4be
Get contact results from plant instead of scene graph
sloretz Sep 15, 2022
1457c5f
Add missing CMakeLists.txt
sloretz Sep 15, 2022
743d1bc
Two balls and Hydroelastic with fallback
sloretz Sep 15, 2022
26740cd
Return of the body_names_
sloretz Sep 15, 2022
cbebca1
Don't need Shapereifier interface
sloretz Sep 16, 2022
0fcc152
Visualize point contacts in RViz too
sloretz Sep 16, 2022
b8cd8a4
Make example about collisions, not just hydroelastic ones
sloretz Sep 16, 2022
17d5d59
General collisions example
sloretz Sep 16, 2022
b5be1d9
Generic example for both point and hydroelastic contacts
sloretz Sep 16, 2022
217326a
Clang-format
sloretz Sep 16, 2022
0793768
drake_ros_viz linters pass
sloretz Sep 16, 2022
aed55b8
drake_ros_examples linters pass
sloretz Sep 16, 2022
adfcb83
Move lodpng.h
sloretz Sep 16, 2022
7455a20
Depend on libgflags-dev
sloretz Sep 16, 2022
8703f9d
Set timestamp on markers and drop Pt| prefix
sloretz Sep 19, 2022
3fcb67f
Default publish rate of 32Hz
sloretz Sep 19, 2022
a59042c
Change view to avoid https://github.com/ros2/rviz/issues/906
sloretz Sep 20, 2022
e046551
Lifetime changes, file naming, drake-visualizer use
sloretz Sep 22, 2022
ad256b2
Separate function for color conversion
sloretz Sep 22, 2022
0b48adb
Clearer code creating line segment for visualizing point contacts
sloretz Sep 22, 2022
9ce6d87
Misc fixes
sloretz Dec 29, 2022
41ba081
Use drake_ros_core geometry conversions
sloretz Dec 29, 2022
9efe3b2
lint fixes
sloretz Dec 29, 2022
0b5e77e
get_graph_query_port -> get_graph_query_input_port
sloretz Dec 30, 2022
2d0b371
Fix code style
sloretz Dec 30, 2022
93c45c5
Use Geometry conversions
sloretz Jan 3, 2023
71d33cb
Fix linter
sloretz Jan 3, 2023
eb19433
Merge branch 'main' into sloretz__gbalke__drake_ros_viz_hydroelastic
sloretz Mar 8, 2023
4f151aa
build and tests pass
sloretz Mar 8, 2023
7a58697
Hash to tag
sloretz Mar 8, 2023
7e4dc19
Examples builds and passes tests
sloretz Mar 9, 2023
e1e033d
Rename to hydroelastic
sloretz Mar 9, 2023
bae1efa
Bazelize hydroelastic example
sloretz Mar 9, 2023
52cdc4d
Add bazel hydroelastic test
sloretz Mar 9, 2023
aadb2f4
Remove copyright notice
sloretz Mar 9, 2023
c41c4d6
Use sdformat file for defining scene (works with Bazel, untested with…
sloretz Mar 9, 2023
427fdd2
Remove unused resolution_hint flag
sloretz Mar 9, 2023
c987c70
Fix CMake build
sloretz Mar 10, 2023
e2e07fa
Put code into a namespace
sloretz Mar 10, 2023
61519dc
drake-visualizer -> meshcat
sloretz Mar 10, 2023
955bf31
Document how to enable meshcat
sloretz Mar 10, 2023
34ec277
Add TODO to make convert_color a public API
sloretz Mar 10, 2023
93c2c08
Add LeafSystem doxygen tags
sloretz Mar 10, 2023
e1d8dc4
Linting
sloretz Mar 10, 2023
d7cdbcc
Remove copyright notice and lint
sloretz Mar 10, 2023
503f276
Remove copyright notice
sloretz Mar 10, 2023
d794320
Fix copy/paste error in comment
sloretz Mar 10, 2023
3fbc1e4
Remove unnecessary public visibility
sloretz Mar 10, 2023
f170fe0
Add TODO for Python example
sloretz Mar 10, 2023
0d29436
Removed copy/pasted parameters
sloretz Mar 10, 2023
2d4e4cd
Don't set maximum step size
sloretz Mar 10, 2023
4e3fde4
Remove newline
sloretz Mar 10, 2023
2362cc1
xmllint --pretty 1
sloretz Mar 10, 2023
e48da9a
Added TODO for making all geometries compliant
sloretz Mar 10, 2023
b550b08
Use SimulatorConfig
sloretz Mar 10, 2023
ce81a8d
Remove unused stuff
sloretz Mar 10, 2023
219c34a
VTK instead of lodepng
sloretz Mar 11, 2023
0fc0eb8
GenerateHeatmapPng()
sloretz Mar 11, 2023
0300fa1
VisualizationConfig
sloretz Mar 11, 2023
a5df348
Linter
sloretz Mar 11, 2023
64fc65c
depend on libvtk
sloretz Mar 11, 2023
b57dadc
libvtk9-dev
sloretz Mar 16, 2023
31d0076
Merge branch 'main' into sloretz__gbalke__drake_ros_viz_hydroelastic
sloretz Mar 16, 2023
12e1361
Update drake_ros namespace usage
sloretz Mar 16, 2023
c9c6bb2
Fix linters
sloretz Mar 16, 2023
8734143
Add ament_index_share_files
sloretz Mar 17, 2023
09dd72c
lint
sloretz Mar 17, 2023
b226b00
clang-format
sloretz Mar 17, 2023
2f7a3f9
Clarify note about runfiles_manifest
sloretz Mar 23, 2023
e41e15d
Comment why using ament_index_share_files
sloretz Mar 23, 2023
44f8be5
Add note about overriding
sloretz Mar 23, 2023
2b74a07
Merge branch 'main' into sloretz__gbalke__drake_ros_viz_hydroelastic
sloretz Apr 12, 2023
ae15ae4
Update comment
sloretz Apr 12, 2023
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
107 changes: 107 additions & 0 deletions bazel_ros2_rules/ros2/ament_index.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# -*- python -*-

"""
Provides bazel rules for working with an ament resource index.

See this for more information:
https://github.com/ament/ament_cmake/
blob/master/ament_cmake_core/doc/resource_index.md
"""

load("@bazel_skylib//lib:paths.bzl", "paths")
load("//tools:ament_index.bzl", "AmentIndex")

def _ament_index_share_files_impl(ctx):
# declare that a "package" with the given name exists
package_marker_path = paths.join(
ctx.attr.prefix,
"share/ament_index/resource_index/packages/",
ctx.attr.package_name,
)
package_marker_out = ctx.actions.declare_file(package_marker_path)
ctx.actions.write(
output = package_marker_out,
content = "",
)

# Symlink sources into the share directory
runfiles_symlinks = {
package_marker_path: package_marker_out,
}

for src in ctx.attr.srcs:
# src is a target that could have multiple files
for file in src.files.to_list():
sp = file.short_path
if sp.startswith(ctx.attr.strip_prefix):
sp = sp[len(ctx.attr.strip_prefix):]
symlink_path = paths.join(
ctx.attr.prefix,
"share",
ctx.attr.package_name,
sp,
)
runfiles_symlinks[symlink_path] = file

return [
AmentIndex(prefix = ctx.attr.prefix),
DefaultInfo(
runfiles = ctx.runfiles(root_symlinks = runfiles_symlinks),
),
]

ament_index_share_files = rule(
attrs = dict(
package_name = attr.string(mandatory = True),
srcs = attr.label_list(
mandatory = True,
allow_empty = False,
allow_files = True,
),
# A prefix is required because the shim can't prepend the runfiles
# root to AMENT_PREFIX_PATH
prefix = attr.string(default = "ament_index_share_files"),
strip_prefix = attr.string(default = ""),
),
implementation = _ament_index_share_files_impl,
output_to_genfiles = True,
provides = [AmentIndex],
)
"""
Creates an ament resource index and share/ directory for a single package.

This creates both a package marker for a package, and a share directory
for that package.
Files in `srcs` will be added to `share/package_name`.
A target depending on this one will be able to access the files in the
share directory using the package's share directory joined with the
files they expect.

d = ament_index_cpp::get_package_share_directory("package_name")
file = join(d, "short_path of file")

Note that this works only when bazel creates runfiles links,
and not just a *.runfiles_manifest (which it might do on an unsupported
platform like Windows, or with `--nobuild_runfile_links`).

Note that the same package_name should never be used in two different
calls to `ament_index_share_files` given to the same target.
This is called "overriding", and it's not currently supported.
Currently if the two calls to `ament_index_share_files` also have
the same value for "prefix", then a target depending on both may
be able to find resources from both rules, but that behavior is not
guaranteed.
TODO(sloretz) detect and error when a target is given two ament indexes
with the same package.

Args:
package_name: name of a ROS 2 package to which these share files belong
srcs: files to put into the share directory
prefix: optional prefix to give to the generated runfiles.
strip_prefix: optional prefix to strip from the short_path of the files

Provides:
AmentIndex: a prefix path where the ament resource index was generated.
DefaultInfo: folders and symlinked files to add to the runfiles of a
dependent target.
"""
1 change: 1 addition & 0 deletions bazel_ros2_rules/ros2/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch", "update_attrs")
load("//tools:execute.bzl", "execute_or_fail")

COMMON_FILES_MANIFEST = [
"ament_index.bzl",
"ros_cc.bzl",
"ros_py.bzl",
"rosidl.bzl",
Expand Down
4 changes: 3 additions & 1 deletion bazel_ros2_rules/ros2/rosidl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ rosidl_generate_ament_index_entry = rule(
allow_empty = False,
allow_files = True,
),
prefix = attr.string(default = "."),
# A prefix is required because the shim can't prepend the runfiles
# root to AMENT_PREFIX_PATH
prefix = attr.string(default = "rosidl_generate_ament_index_entry"),
),
implementation = _rosidl_generate_ament_index_entry_impl,
output_to_genfiles = True,
Expand Down
3 changes: 3 additions & 0 deletions bazel_ros2_rules/ros2/tools/dload_shim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ void ApplyEnvironmentActions(
std::abort();
}
for (size_t j = 1; j < actions[i].size(); ++j) {
// Not seeing explicitly set values in your environment variable?
// Rlocation returns an empty string if the path cannot be found,
// or contains "./", "../", etc.
value_stream << runfiles->Rlocation(actions[i][j]) << ":";
}

Expand Down
2 changes: 2 additions & 0 deletions drake_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ ament_export_dependencies(geometry_msgs)
ament_export_dependencies(rclcpp)
ament_export_dependencies(rosidl_runtime_c)
ament_export_dependencies(rosidl_typesupport_cpp)
ament_export_dependencies(tf2_eigen)
ament_export_dependencies(tf2_ros)
ament_export_dependencies(visualization_msgs)
ament_export_dependencies(VTK)

ament_package()
2 changes: 2 additions & 0 deletions drake_ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
<buildtool_depend>eigen3_cmake_module</buildtool_depend>
<build_depend>eigen</build_depend>

<depend>libvtk9-dev</depend>
<depend>rclcpp</depend>
<depend>rclpy</depend>
<depend>rosidl_runtime_c</depend>
<depend>rosidl_typesupport_cpp</depend>
<depend>geometry_msgs</depend>
<depend>tf2_eigen</depend>
<depend>visualization_msgs</depend>

<test_depend>ament_cmake_clang_format</test_depend>
Expand Down
1 change: 1 addition & 0 deletions drake_ros/required_packages.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ DRAKE_ROS_REQUIRED_PACKAGES = [
"rclcpp",
"rosidl_runtime_c",
"rosidl_typesupport_cpp",
"tf2_eigen",
"tf2_ros",
"visualization_msgs",
]
Expand Down
2 changes: 2 additions & 0 deletions drake_ros/viz/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ cc_library(
"//tf2:odr_safe_deps",
"@ros2//:geometry_msgs_cc",
"@ros2//:rclcpp_cc",
"@ros2//:tf2_eigen_cc",
"@ros2//:visualization_msgs_cc",
"@vtk//:vtkIOImage",
],
)

Expand Down
8 changes: 8 additions & 0 deletions drake_ros/viz/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
find_package(geometry_msgs REQUIRED)
find_package(rclcpp REQUIRED)
find_package(tf2_eigen REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(VTK REQUIRED)

set(HEADERS
"contact_markers_system.h"
"defaults.h"
"name_conventions.h"
"rviz_visualizer.h"
"scene_markers_system.h"
Expand All @@ -19,16 +23,20 @@ add_library(drake_ros_viz
name_conventions.cc
rviz_visualizer.cc
scene_markers_system.cc
contact_markers_system.cc
)

target_link_libraries(drake_ros_viz PUBLIC
drake::drake
drake_ros_core
drake_ros_tf2
rclcpp::rclcpp
tf2_eigen::tf2_eigen
${geometry_msgs_TARGETS}
${visualization_msgs_TARGETS}
)
target_link_libraries(drake_ros_viz PRIVATE
VTK::IOImage)

target_include_directories(drake_ros_viz
PUBLIC
Expand Down
Loading