Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 38 additions & 0 deletions .github/workflows/ros2_code_compiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ros_code_compiles

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch: {}

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v3
- uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: jazzy

- name: Install prerequired packages
# To compile and run the code we require cmake, ninja and opencv
run: sudo apt-get update && sudo apt-get install build-essential cmake ninja-build libopencv-dev

- name: Install dependencies
working-directory: ${{ github.workspace }}
run: |
sudo rosdep init || true
rosdep update
rosdep install --from-paths src -y --ignore-src

- name: Colcon build
working-directory: ${{ github.workspace }}
run: |
source /opt/ros/jazzy/setup.bash
colcon build --packages-select face_detector
12 changes: 0 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,6 @@ if (CLFML_ROS2_PACKAGE_BUILD)
find_package(std_srvs REQUIRED)
find_package(cv_bridge REQUIRED)
target_link_libraries(${PROJECT_NAME} ${cv_bridge_LIBRARIES})
add_executable(camera_node ${CMAKE_CURRENT_LIST_DIR}/bindings/ros2/camera_node.cpp)
ament_target_dependencies(camera_node
rclcpp
sensor_msgs
cv_bridge
std_msgs
geometry_msgs
std_srvs
OpenCV
)
add_executable(face_detector_node ${CMAKE_CURRENT_LIST_DIR}/bindings/ros2/face_detector_node.cpp)
ament_target_dependencies(face_detector_node
rclcpp
Expand All @@ -156,10 +146,8 @@ if (CLFML_ROS2_PACKAGE_BUILD)
std_srvs
OpenCV
)
target_link_libraries(camera_node face_detector)
target_link_libraries(face_detector_node face_detector)
install(TARGETS
camera_node
face_detector_node
DESTINATION lib/${PROJECT_NAME})
endif()
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,31 +153,36 @@ git clone https://github.com/CLFML/Face_Detector.Cpp.git
source /opt/ros/jazzy/setup.bash
```

3. Build the package:
3. Install the dependencies:
```bash
rosdep install --from-paths src -y --ignore-src
```

4. Build the package:

```bash
colcon build --packages-select face_detector
```

4. Set up the environment:
5. Set up the environment:

```bash
source install/setup.bash
```

5. Run the camera node:
6. Run the camera node:

```bash
ros2 run face_detector camera_node
ros2 run v4l2_camera v4l2_camera_node
```

6. In another terminal, run the face detector node (don’t forget to source the setup script):
7. In another terminal, run the face detector node (don’t forget to source the setup script):

```bash
ros2 run face_detector face_detector_node
```

7. In yet another terminal, run the viewer:
8. In yet another terminal, run the viewer:

```bash
ros2 run face_detector face_detector_viewer
Expand All @@ -193,7 +198,6 @@ See our [wiki](https://clfml.github.io/Face_Detector.Cpp/)...
- Add support for MakeFiles and Bazel
- Add Unit-tests
- Add ROS2 package TPU support
- Drop custom ROS2 camera node and use a generic node, such as v4l2_camera or christianrauch/camera_ros
- If needed to crunch ROS2 latency: Do not use nodes, put plugins in a container


Expand Down
98 changes: 0 additions & 98 deletions bindings/ros2/camera_node.cpp

This file was deleted.

7 changes: 2 additions & 5 deletions bindings/ros2/face_detector_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FaceDetectorNode : public rclcpp::Node
private:
void declare_and_get_parameters()
{
declare_parameter("camera_topic", "/camera_node/image_raw");
declare_parameter("camera_topic", "/image_raw");
declare_parameter("face_detected_topic", "/face_detected");
declare_parameter("face_roi_topic", "/face_roi");
declare_parameter("face_landmarks_topic", "/face_landmarks");
Expand Down Expand Up @@ -95,9 +95,6 @@ class FaceDetectorNode : public rclcpp::Node
std_msgs::msg::Int32 face_detected_msg = std_msgs::msg::Int32();
face_detected_msg.data = det_.detected() + 1; // +1 because detector returns -1 for no face and 0 for face detected!
face_detected_pub_->publish(face_detected_msg);

if (face_detected_msg.data)
RCLCPP_INFO(get_logger(), "face detected");
}

void publish_face_roi()
Expand Down Expand Up @@ -154,4 +151,4 @@ int main(int argc, char** argv)
rclcpp::spin(std::make_shared<FaceDetectorNode>());
rclcpp::shutdown();
return 0;
}
}
2 changes: 1 addition & 1 deletion bindings/ros2/set_ld_path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ ! -d "install" ]; then
fi

# Path to the dynamic library
LIB_PATH="install/face_detector/lib/face_detector/libtensorflowlite.so"
LIB_PATH="$(pwd)/install/face_detector/lib/face_detector/libtensorflowlite.so"

# Check if the dynamic library exists
if [ -f "$LIB_PATH" ]; then
Expand Down
27 changes: 16 additions & 11 deletions docs/usage/ros2_build_environment/usage_with_linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,43 @@ git clone https://github.com/CLFML/Face_Detector.Cpp.git

2. Open the cloned repo folder in a terminal

Build the package with more verbose output
3. Source your ROS2 installation:

```bash
colcon build --event-handlers console_direct+ --packages-select face_detector
source /opt/ros/jazzy/setup.bash
```

Note that, whenever build errors occur, and you need to clean the build, use
4. Install the ros2 dependencies:
```bash
rosdep install --from-paths src -y --ignore-src
```

5. Build the package with more verbose output

```bash
rm -rf build install log
rm -rf ~/.ros
colcon build --event-handlers console_direct+ --packages-select face_detector
```

3. Source your ROS2 installation:
Note that, whenever build errors occur, and you need to clean the build, use

```bash
source /opt/ros/jazzy/setup.bash
rm -rf build install log
rm -rf ~/.ros
```

4. Set up the environment
6. Set up the environment

```bash
source install/setup.bash
```

5. With the environment sourced, we can run executables built by colcon. Let’s run the camera node from the examples:
7. With the environment sourced, we can run executables built by colcon. Let’s run the camera node from the examples:

```bash
ros2 run face_detector camera_node
ros2 run v4l2_camera v4l2_camera_node
```

5. In another terminal, let’s run the face detector node (don’t forget to source the setup script):6
8. In another terminal, let’s run the face detector node (don’t forget to source the setup script):6
```bash
ros2 run face_detector face_detector_node
```
Expand Down
2 changes: 1 addition & 1 deletion example/ROS_demo/face_detector_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FaceDetectorViewer : public rclcpp::Node
FaceDetectorViewer() : Node("face_detector_viewer")
{
// Declare parameters for topic names
this->declare_parameter("camera_topic", "/camera_node/image_raw");
this->declare_parameter("camera_topic", "/image_raw");
this->declare_parameter("face_detected_topic", "/face_detected");
this->declare_parameter("face_roi_topic", "/face_roi");
this->declare_parameter("face_landmarks_topic", "/face_landmarks");
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<depend>std_msgs</depend>
<depend>geometry_msgs</depend>
<depend>std_srvs</depend>
<depend>v4l2_camera</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down