Skip to content

Commit 4ba4a19

Browse files
committed
Update to master
2 parents e5fd68c + 895e2a2 commit 4ba4a19

File tree

22 files changed

+579
-14
lines changed

22 files changed

+579
-14
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ repos:
88
rev: v5.0.0
99
hooks:
1010
- id: check-added-large-files
11+
exclude: "src/robot/yolo_inference/models/yolov8.onnx"
1112
- id: check-ast
1213
- id: check-case-conflict
1314
- id: check-merge-conflict

docker/robot/robot.Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends curl \
1010
&& rm -rf /var/lib/apt/lists/*
1111

1212
# Copy in source code
13+
COPY src/robot/yolo_inference ./yolo_inference
14+
COPY src/robot/object_detection object_detection
1315
COPY src/robot/odometry_spoof odometry_spoof
1416
COPY src/robot/bringup_robot bringup_robot
1517
COPY src/robot/camera_fallback camera_fallback
@@ -48,6 +50,8 @@ RUN apt-get -qq update && \
4850
rm -rf /var/lib/apt/lists/*
4951

5052
# Copy in source code from source stage
53+
WORKDIR ${AMENT_WS}/src
54+
COPY src/robot/object_detection object_detection
5155
WORKDIR ${AMENT_WS}
5256
COPY --from=source ${AMENT_WS}/src src
5357

@@ -69,6 +73,16 @@ RUN apt-get clean && \
6973
rosdep update && \
7074
rm -rf /var/lib/apt/lists/*
7175

76+
RUN apt-get update && apt-get install --no-install-recommends -y \
77+
python3-pip \
78+
python3-dev \
79+
python3-setuptools \
80+
&& rm -rf /var/lib/apt/lists/*
81+
82+
COPY requirements.txt .
83+
RUN pip install --no-cache-dir -r requirements.txt
84+
#RUN pip install --no-cache-dir onnxruntime && pip3 install --no-cache-dir "numpy<2.0"
85+
7286
# Build ROS2 packages
7387
WORKDIR ${AMENT_WS}
7488
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" && \

requirements.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Core ROS 2 Python dependencies
2+
rclpy
3+
ament-index-python
4+
5+
# Launch system dependencies
6+
launch
7+
launch-ros
8+
9+
# Computer Vision and Machine Learning
10+
opencv-python
11+
numpy<2.0
12+
onnxruntime==1.16.3
13+
cv-bridge
14+
15+
# Optional PyTorch support (for .pt model files)
16+
torch ; extra == 'torch'
17+
18+
# Testing and Linting dependencies
19+
pytest
20+
ament-copyright
21+
ament-flake8
22+
ament-pep257
23+
24+
# Build tools
25+
setuptools

scripts/add_robot_package.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ if ! grep -Fq "${pkg}_node = Node(" "$LAUNCH_FILE"; then
4242
block_file=$(mktemp)
4343
printf '%s' "$block" > "$block_file"
4444
awk -v bf="$block_file" '
45-
$0 ~ /##[[:space:]]+LAUNCH[[:space:]]+NODES/ && !done {
46-
print
47-
while ((getline line < bf) > 0) print line
48-
close(bf); done=1; next
49-
}
50-
{ print }
45+
$0 ~ /^[[:space:]]*return[[:space:]]+ld/ && !done {
46+
while ((getline line < bf) > 0) print line
47+
close(bf); done=1
48+
}
49+
{ print }
5150
' "$LAUNCH_FILE" > "$tmp" && mv "$tmp" "$LAUNCH_FILE"
5251
rm -f "$block_file"
5352
echo "✓ Added node block to '$LAUNCH_FILE'"

src/gazebo/launch/mars_env.urdf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
<link name="water_bottle">
3232
<visual>
3333
<geometry>
34-
<mesh filename="https://raw.githubusercontent.com/WATonomous/wato_rover/master/src/gazebo/launch/water_bottle.stl" scale="0.1 0.1 0.1"/>
34+
<mesh filename="https://raw.githubusercontent.com/WATonomous/wato_rover/master/src/gazebo/launch/water_bottle.stl" scale="0.4 0.4 0.4"/>
3535
</geometry>
3636
<material name="water_blue">
3737
<color rgba="0.68 0.85 0.90 1"/>
3838
</material>
3939
</visual>
4040
<collision>
4141
<geometry>
42-
<mesh filename="https://raw.githubusercontent.com/WATonomous/wato_rover/master/src/gazebo/launch/water_bottle.stl" scale="0.1 0.1 0.1"/>
42+
<mesh filename="https://raw.githubusercontent.com/WATonomous/wato_rover/master/src/gazebo/launch/water_bottle.stl" scale="0.4 0.4 0.4"/>
4343
</geometry>
4444
</collision>
4545
</link>
@@ -54,15 +54,15 @@
5454
<link name="mallet">
5555
<visual>
5656
<geometry>
57-
<mesh filename="https://raw.githubusercontent.com/WATonomous/wato_rover/master/src/gazebo/launch/mallet.stl" scale="0.1 0.1 0.1"/>
57+
<mesh filename="https://raw.githubusercontent.com/WATonomous/wato_rover/master/src/gazebo/launch/mallet.stl" scale="0.4 0.4 0.4"/>
5858
</geometry>
5959
<material name="orange">
6060
<color rgba="1 0.4 0.0 1"/>
6161
</material>
6262
</visual>
6363
<collision>
6464
<geometry>
65-
<mesh filename="https://raw.githubusercontent.com/WATonomous/wato_rover/master/src/gazebo/launch/mallet.stl" scale="0.1 0.1 0.1"/>
65+
<mesh filename="https://raw.githubusercontent.com/WATonomous/wato_rover/master/src/gazebo/launch/mallet.stl" scale="0.4 0.4 0.4"/>
6666
</geometry>
6767
</collision>
6868
</link>

src/gazebo/launch/robot_env.sdf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
<geometry>
328328
<mesh>
329329
<uri>water_bottle.stl</uri>
330-
<scale>0.1 0.1 0.1</scale>
330+
<scale>0.4 0.4 0.4</scale>
331331
</mesh>
332332
</geometry>
333333
<material>
@@ -340,7 +340,7 @@
340340
<geometry>
341341
<mesh>
342342
<uri>water_bottle.stl</uri>
343-
<scale>0.1 0.1 0.1</scale>
343+
<scale>0.4 0.4 0.4</scale>
344344
</mesh>
345345
</geometry>
346346
<pose>0 0 0 0 0 3.14159</pose>
@@ -355,7 +355,7 @@
355355
<geometry>
356356
<mesh>
357357
<uri>mallet.stl</uri>
358-
<scale>0.1 0.1 0.1</scale>
358+
<scale>0.4 0.4 0.4</scale>
359359
</mesh>
360360
</geometry>
361361
<material>
@@ -368,7 +368,7 @@
368368
<geometry>
369369
<mesh>
370370
<uri>mallet.stl</uri>
371-
<scale>0.1 0.1 0.1</scale>
371+
<scale>0.4 0.4 0.4</scale>
372372
</mesh>
373373
</geometry>
374374
<pose>0 0 0 0 0 3.14159</pose>

src/gazebo/launch/water_bottle.stl

711 KB
Binary file not shown.

src/robot/bringup_robot/launch/robot.launch.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,25 @@
1616
from launch.actions import IncludeLaunchDescription
1717
from launch_ros.actions import Node
1818
from launch.launch_description_sources import PythonLaunchDescriptionSource
19+
from launch.actions import DeclareLaunchArgument
20+
from launch.substitutions import LaunchConfiguration
1921

2022
import os
2123

2224

2325
def generate_launch_description():
2426
ld = LaunchDescription() # Begin building a launch description
2527

28+
yolo_pkg_share = get_package_share_directory("yolo_inference")
29+
default_model_path = os.path.join(yolo_pkg_share, "models", "yolov8.onnx")
30+
31+
model_path_arg = DeclareLaunchArgument(
32+
"model_path",
33+
default_value=default_model_path,
34+
description="Absolute path to the YOLO ONNX/PT weights file",
35+
)
36+
ld.add_action(model_path_arg)
37+
2638
#################### Odometry Spoof Node #####################
2739
odometry_spoof_node = Node(
2840
package="odometry_spoof",
@@ -65,4 +77,27 @@ def generate_launch_description():
6577
)
6678
ld.add_action(motor_speed_controller_node)
6779

80+
#################### Object_detection Node #####################
81+
object_detection_node = Node(
82+
package="object_detection",
83+
name="object_detection_node",
84+
executable="object_detection_node",
85+
)
86+
ld.add_action(object_detection_node)
87+
88+
ld.add_action(
89+
Node(
90+
package="yolo_inference",
91+
executable="yolo_inference_node",
92+
name="yolo_inference_node",
93+
output="screen",
94+
parameters=[
95+
{
96+
"model_path": LaunchConfiguration("model_path"),
97+
"input_size": 640, # TODO: adjust DEPENDING on model needs 416, 512, etc
98+
}
99+
],
100+
remappings=[("/image", "/sim/realsense1/depth/image")],
101+
)
102+
)
68103
return ld
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright (c) 2025-present WATonomous. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
cmake_minimum_required(VERSION 3.10)
15+
project(object_detection)
16+
17+
# Set compiler to use C++ 17 standard
18+
if(NOT CMAKE_CXX_STANDARD)
19+
set(CMAKE_CXX_STANDARD 17)
20+
endif()
21+
22+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
23+
add_compile_options(-Wall -Wextra -Wpedantic)
24+
endif()
25+
26+
# Search for dependencies required for building this package
27+
find_package(ament_cmake REQUIRED) # ROS2 build tool
28+
find_package(rclcpp REQUIRED) # ROS2 C++ package
29+
30+
# Compiles source files into a library
31+
# A library is not executed, instead other executables can link
32+
# against it to access defined methods and classes.
33+
# We build a library so that the methods defined can be used by
34+
# both the unit test and ROS2 node executables.
35+
add_library(object_detection_lib
36+
src/object_detection_core.cpp)
37+
# Indicate to compiler where to search for header files
38+
target_include_directories(object_detection_lib
39+
PUBLIC include)
40+
# Add ROS2 dependencies required by package
41+
ament_target_dependencies(object_detection_lib
42+
rclcpp
43+
)
44+
45+
# Create ROS2 node executable from source files
46+
add_executable(object_detection_node src/object_detection_node.cpp)
47+
# Link to the previously built library to access object_detection classes and methods
48+
target_link_libraries(object_detection_node object_detection_lib)
49+
50+
# Copy executable to installation location
51+
install(TARGETS
52+
object_detection_node
53+
DESTINATION lib/${PROJECT_NAME})
54+
55+
# Copy launch and config files to installation location
56+
install(DIRECTORY
57+
config
58+
DESTINATION share/${PROJECT_NAME})
59+
60+
61+
ament_package()

src/robot/object_detection/config/params.yaml

Whitespace-only changes.

0 commit comments

Comments
 (0)