Skip to content

Commit 227d504

Browse files
authored
Fix circular dependency, update cruft (#8)
1 parent 33fb35a commit 227d504

6 files changed

Lines changed: 162 additions & 21 deletions

File tree

.cruft.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/UrbanMachine/create-ros-app.git",
3-
"commit": "6a85fd934e7c6297d5fd717c545fad443cc4dfcf",
3+
"commit": "5d14b64b8a4c2ac85f57a19dd962216de9c7a28a",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {

docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ RUN --mount=type=cache,target="${APT_CACHE}" \
4545
# Build tools
4646
build-essential \
4747
git \
48+
git-lfs \
4849
# Complementary ROS2 Python tools
4950
python3-colcon-common-extensions \
5051
python3-colcon-mixin \
Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,69 @@
11
"""Launch nodes for this launch profile."""
22

3+
from pathlib import Path
4+
35
from launch import LaunchDescription
46
from launch_ros.actions import Node
57

8+
# Import the forklift URDF module so it register itself with the URDFConstants
9+
from node_helpers import launching
10+
from node_helpers.parameters import ParameterLoader
11+
from pydantic import BaseModel
12+
13+
14+
class MetaParameters(BaseModel):
15+
"""This is a great place to put parameters that affect the generation of the launch
16+
file. Don't put node specific configuration in here, rather, put configuration for
17+
what nodes you want to be created in the first place.
18+
19+
Read more about this functionality under docs/parameters.rst
20+
"""
21+
22+
urdf_modules_to_load: list[launching.URDFModuleNodeFactory.Parameters]
23+
"""This is an example of dynamically loading an arbitrary number of URDFs.
24+
25+
This is set in the `/robot/launch-profile/parameters.yaml` under `meta_parameters`.
26+
"""
27+
628

729
def generate_launch_description() -> LaunchDescription:
8-
rviz_config = "/robot/launch-profile/rviz-config.rviz"
30+
# Create a parameter loader to parse all yaml files in the launch-profile/parameters
31+
# directory, and then apply overrides from the override file, if one exists.
32+
param_loader: ParameterLoader[MetaParameters] = ParameterLoader(
33+
parameters_directory=Path("/robot/launch-profile/parameters/"),
34+
override_file=Path("/robot/launch-profile/parameters.override.yaml"),
35+
meta_parameters_schema=MetaParameters,
36+
)
37+
38+
rviz_config = launching.required_file("/robot/launch-profile/rviz-config.rviz")
39+
40+
urdf_node_factories = (
41+
launching.URDFModuleNodeFactory(parameters=node_factory_params)
42+
for node_factory_params in param_loader.meta_parameters.urdf_modules_to_load
43+
)
44+
urdf_nodes = []
45+
for urdf_node_factory in urdf_node_factories:
46+
urdf_nodes += urdf_node_factory.create_nodes()
47+
948
launch_description = [
10-
Node(package="rviz2", executable="rviz2", arguments=["-d", [rviz_config]]),
49+
*urdf_nodes,
50+
Node(
51+
package="node_helpers",
52+
executable="run_ExampleNode",
53+
name="ExampleNode",
54+
parameters=[param_loader.ros_parameters_file],
55+
namespace="example_node_namespace",
56+
),
57+
Node(
58+
package="rviz2",
59+
executable="rviz2",
60+
arguments=["-d", [str(rviz_config)]],
61+
),
62+
Node(
63+
namespace="urdf_arrangement",
64+
package="node_helpers",
65+
executable="interactive_transform_publisher",
66+
parameters=[param_loader.ros_parameters_file],
67+
),
1168
]
1269
return LaunchDescription(launch_description)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
meta_parameters:
2+
urdf_modules_to_load:
3+
# URDF's are attached to base_link down below in the
4+
- namespace: "example_node_namespace"
5+
urdf_constant_name: "forklift"
6+
7+
8+
example_node_namespace:
9+
ExampleNode:
10+
ros__parameters:
11+
root_config:
12+
publish_value: "hello"
13+
publish_hz: 10.0
14+
15+
urdf_arrangement:
16+
interactive_transform_publisher:
17+
ros__parameters:
18+
static_transforms_file: /robot/persistent/interactive_transforms.json
19+
scale_factor: 1.0
20+
tf_publish_frequency: 1.0
21+
transforms:
22+
# Mounts the forklift urdf to the base_link so it can be visualized in rviz
23+
- "base_link:example_node_namespace.forklift_body"

launch-profiles/node_helpers_showcase/rviz-config.rviz

Lines changed: 74 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Panels:
44
Name: Displays
55
Property Tree Widget:
66
Expanded:
7-
- /Global Options1
8-
- /Status1
7+
- /InteractiveMarkers1
8+
- /InteractiveTransforms1
99
Splitter Ratio: 0.5
10-
Tree Height: 1064
10+
Tree Height: 1108
1111
- Class: rviz_common/Selection
1212
Name: Selection
1313
- Class: rviz_common/Tool Properties
@@ -47,10 +47,69 @@ Visualization Manager:
4747
Plane Cell Count: 10
4848
Reference Frame: <Fixed Frame>
4949
Value: true
50+
- Alpha: 1
51+
Class: rviz_default_plugins/RobotModel
52+
Collision Enabled: false
53+
Description File: ""
54+
Description Source: Topic
55+
Description Topic:
56+
Depth: 5
57+
Durability Policy: Volatile
58+
History Policy: Keep Last
59+
Reliability Policy: Reliable
60+
Value: /example_node_namespace/urdf_0/robot_description
61+
Enabled: true
62+
Links:
63+
All Links Enabled: true
64+
Expand Joint Details: false
65+
Expand Link Details: false
66+
Expand Tree: false
67+
Link Tree Style: Links in Alphabetic Order
68+
example_node_namespace.forklift_body:
69+
Alpha: 1
70+
Show Axes: false
71+
Show Trail: false
72+
Value: true
73+
example_node_namespace.forks:
74+
Alpha: 1
75+
Show Axes: false
76+
Show Trail: false
77+
Value: true
78+
example_node_namespace.forks_origin:
79+
Alpha: 1
80+
Show Axes: false
81+
Show Trail: false
82+
Value: true
83+
Mass Properties:
84+
Inertia: false
85+
Mass: false
86+
Name: ExampleURDF
87+
TF Prefix: ""
88+
Update Interval: 0
89+
Value: true
90+
Visual Enabled: true
91+
- Class: rviz_default_plugins/InteractiveMarkers
92+
Enable Transparency: true
93+
Enabled: true
94+
Interactive Markers Namespace: ""
95+
Name: InteractiveMarkers
96+
Show Axes: false
97+
Show Descriptions: true
98+
Show Visual Aids: false
99+
Value: true
100+
- Class: rviz_default_plugins/InteractiveMarkers
101+
Enable Transparency: true
102+
Enabled: true
103+
Interactive Markers Namespace: /urdf_arrangement
104+
Name: InteractiveTransforms
105+
Show Axes: false
106+
Show Descriptions: true
107+
Show Visual Aids: false
108+
Value: true
50109
Enabled: true
51110
Global Options:
52111
Background Color: 48; 48; 48
53-
Fixed Frame: map
112+
Fixed Frame: base_link
54113
Frame Rate: 30
55114
Name: root
56115
Tools:
@@ -93,33 +152,33 @@ Visualization Manager:
93152
Views:
94153
Current:
95154
Class: rviz_default_plugins/Orbit
96-
Distance: 10
155+
Distance: 8.649819374084473
97156
Enable Stereo Rendering:
98157
Stereo Eye Separation: 0.05999999865889549
99158
Stereo Focal Distance: 1
100159
Swap Stereo Eyes: false
101160
Value: false
102161
Focal Point:
103-
X: 0
104-
Y: 0
105-
Z: 0
162+
X: -0.4261273145675659
163+
Y: -0.3684071898460388
164+
Z: 0.5727261900901794
106165
Focal Shape Fixed Size: true
107166
Focal Shape Size: 0.05000000074505806
108167
Invert Z Axis: false
109168
Name: Current View
110169
Near Clip Distance: 0.009999999776482582
111-
Pitch: 0.785398006439209
170+
Pitch: 0.5403984189033508
112171
Target Frame: <Fixed Frame>
113172
Value: Orbit (rviz)
114-
Yaw: 0.785398006439209
173+
Yaw: 1.0753980875015259
115174
Saved: ~
116175
Window Geometry:
117176
Displays:
118177
collapsed: false
119-
Height: 1355
178+
Height: 1331
120179
Hide Left Dock: false
121180
Hide Right Dock: false
122-
QMainWindow State: 000000ff00000000fd000000040000000000000156000004b1fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b000004b1000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000004b1fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003b000004b1000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004f60000003efc0100000002fb0000000800540069006d00650100000000000004f60000025300fffffffb0000000800540069006d0065010000000000000450000000000000000000000285000004b100000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
181+
QMainWindow State: 000000ff00000000fd0000000400000000000001c5000004ddfc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b000004dd000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000499fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003b00000499000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000009f40000003efc0100000002fb0000000800540069006d00650000000000000009f40000025300fffffffb0000000800540069006d0065010000000000000450000000000000000000000829000004dd00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
123182
Selection:
124183
collapsed: false
125184
Time:
@@ -128,6 +187,6 @@ Window Geometry:
128187
collapsed: false
129188
Views:
130189
collapsed: false
131-
Width: 1270
132-
X: 3842
133-
Y: 40
190+
Width: 2548
191+
X: 8
192+
Y: 64

pkgs/node_helpers/node_helpers/urdfs/loading.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
from ament_index_python import get_package_share_directory
66

7-
from node_helpers.launching.files import required_file
8-
97
NAMESPACE_FMT = "{namespace}.{name}"
108
_JOINT_TAG = "joint"
119
_LINK_TAG = "link"
@@ -20,7 +18,10 @@ def load_urdf(package: str, relative_urdf_path: Path | str) -> str:
2018

2119
relative_urdf_path = Path(relative_urdf_path)
2220
package_root = get_package_share_directory(package)
23-
urdf_file = required_file(package_root, relative_urdf_path)
21+
urdf_file = Path(package_root, relative_urdf_path)
22+
23+
if not urdf_file.is_file():
24+
raise FileNotFoundError(f"URDF file '{urdf_file!s}' not found")
2425
return urdf_file.read_text()
2526

2627

0 commit comments

Comments
 (0)