Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/integration' into percep-second-cam
Browse files Browse the repository at this point in the history
  • Loading branch information
qhdwight committed Apr 29, 2024
2 parents b68fa60 + 032f3b7 commit 4f948ef
Show file tree
Hide file tree
Showing 270 changed files with 29,885 additions and 7,919 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,8 @@ jobs:
lfs: "true"
# This makes sure that $GITHUB_WORKSPACE is the catkin workspace path
path: "src/mrover"
- name: Ensure Python Requirements
run: . /home/mrover/catkin_ws/src/mrover/venv/bin/activate && pip install --no-cache-dir -e "$GITHUB_WORKSPACE/src/mrover[dev]"
- name: Style Check
run: . /home/mrover/catkin_ws/src/mrover/venv/bin/activate && cd $GITHUB_WORKSPACE/src/mrover/ && ./style.sh
- name: Update ROS APT
if: github.event.pull_request.draft == false
run: runuser -u mrover -- rosdep update
- name: Ensure ROS APT Requirements
if: github.event.pull_request.draft == false
run: runuser -u mrover -- rosdep install --from-paths "$GITHUB_WORKSPACE/src" --ignore-src -r -y --rosdistro noetic
- name: Copy Catkin Profiles
if: github.event.pull_request.draft == false
run: rsync -r $GITHUB_WORKSPACE/src/mrover/ansible/roles/build/files/profiles $GITHUB_WORKSPACE/.catkin_tools
Expand All @@ -42,7 +34,7 @@ jobs:
if: github.event.pull_request.draft == false && github.event.pull_request.base.ref != 'refs/heads/master'
run: . /opt/ros/noetic/setup.sh && . /home/mrover/catkin_ws/src/mrover/venv/bin/activate && catkin build
- name: Build With Clang Tidy
if : github.event_name == 'push' && github.event.pull_request.base.ref == 'refs/heads/master'
if: github.event_name == 'push' && github.event.pull_request.base.ref == 'refs/heads/master'
run: . /opt/ros/noetic/setup.sh && . /home/mrover/catkin_ws/src/mrover/venv/bin/activate && catkin build -DCMAKE_CXX_CLANG_TIDY=clang-tidy-16
- name: Test
if: github.event.pull_request.draft == false
Expand Down
14 changes: 2 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
[submodule "deps/libde265"]
path = deps/libde265
url = https://github.com/strukturag/libde265.git
shallow = true
branch = v1.0.15
[submodule "deps/dawn"]
path = deps/dawn
url = https://dawn.googlesource.com/dawn
shallow = true
branch = chromium/6108
[submodule "deps/emsdk"]
path = deps/emsdk
url = [email protected]:emscripten-core/emsdk.git
shallow = true
branch = 3.1.53
branch = chromium/6376
[submodule "deps/manif"]
path = deps/manif
url = https://github.com/artivis/manif.git
shallow = true
branch = master
branch = devel
139 changes: 78 additions & 61 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
cmake_minimum_required(VERSION 3.16)
project(mrover VERSION 2024.0.0 LANGUAGES CXX)

option(MROVER_IS_CI "Build for CI" OFF)
option(MROVER_RUN_CLANG_TIDY "Run clang-tidy" OFF)
option(MROVER_IS_JETSON "Build for the Jetson" OFF)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Generate compile_commands.json for clangd

### ============= ###
### OS & Compiler ###
### ============= ###

if (APPLE)
# Ensures that homebrew packages are never used over miniforge packages
set(CMAKE_IGNORE_PATH /opt/homebrew)
Expand All @@ -15,23 +27,30 @@ if (APPLE)
link_libraries(fmt::fmt)
else ()
# TODO(quintin): Fix this
find_package(TBB REQUIRED)
link_libraries(TBB::tbb)
find_package(TBB QUIET)
if (TBB_FOUND)
link_libraries(TBB::tbb)
endif ()
endif ()

include_directories(BEFORE SYSTEM src/preload)
if (NOT APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # Link with LLVM lld instead of GNU ld when using Clang on Linux, it is faster
add_link_options(-fuse-ld=lld)
endif ()

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Generate compile_commands.json for clangd
if (NOT APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_link_options(-fuse-ld=lld) # LLVM lld is faster than GNU ld
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(MROVER_CPP_COMPILE_OPTIONS -Wall -Wextra -pedantic -Wno-missing-field-initializers)
if (MROVER_IS_CI) # Make warnings errors in CI
list(APPEND MROVER_CPP_COMPILE_OPTIONS -Werror)
endif ()
endif ()
set(MROVER_CPP_COMPILE_OPTIONS -Wall -Wextra -pedantic -Wno-missing-field-initializers)
if (MROVER_CI)
list(APPEND MROVER_CPP_COMPILE_OPTIONS -Werror)

if (MROVER_IS_JETSON)
add_definitions(-DMROVER_IS_JETSON)
endif ()

# Inject header files that get included before anything else, including system headers
include_directories(BEFORE SYSTEM src/preload)

include(cmake/macros.cmake)

# ROS packages list
Expand All @@ -48,15 +67,19 @@ set(MROVER_ROS_DEPENDENCIES
tf2
tf2_ros
tf2_geometry_msgs
actionlib_msgs
)

extract_filenames(msg/*.msg MROVER_MESSAGE_FILES)

extract_filenames(srv/*.srv MROVER_SERVICE_FILES)

extract_filenames(action/*.action MROVER_ACTION_FILES)

set(MROVER_MESSAGE_DEPENDENCIES
std_msgs
sensor_msgs
actionlib_msgs
)

set(MROVER_PARAMETERS
Expand All @@ -79,7 +102,7 @@ if (ZED_FOUND)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
set(CMAKE_CUDA_FLAGS "--diag-suppress 108,68")
set(CMAKE_CUDA_FLAGS "--diag-suppress 20012")
# Jetson Xavier NX/AGX has Volta 7.2 architecture
# Perception Laptop (A4000, Quadro version of RTX 3080) has Ampere 8.6 architecture
set(CMAKE_CUDA_ARCHITECTURES 72 86)
Expand All @@ -104,6 +127,8 @@ add_message_files(FILES ${MROVER_MESSAGE_FILES})

add_service_files(FILES ${MROVER_SERVICE_FILES})

add_action_files(DIRECTORY action FILES ${MROVER_ACTION_FILES})

generate_messages(DEPENDENCIES ${MROVER_MESSAGE_DEPENDENCIES})

generate_dynamic_reconfigure_options(${MROVER_PARAMETERS})
Expand All @@ -124,48 +149,44 @@ target_link_libraries(lie PUBLIC MANIF::manif)

## ESW

if (NOT APPLE)
mrover_add_vendor_header_only_library(moteus src/esw/mjbots)
mrover_add_header_only_library(can_device src/esw/can_device)
mrover_add_library(motor_library src/esw/motor_library/*.cpp src/esw/motor_library)
target_link_libraries(motor_library PUBLIC can_device moteus)

if (NetLink_FOUND AND NetLinkRoute_FOUND)
mrover_add_nodelet(can_driver src/esw/can_driver/*.cpp src/esw/can_driver src/esw/can_driver/pch.hpp)
mrover_nodelet_link_libraries(can_driver nl-3 nl-route-3)
# TODO(quintin): Fix this CMake hard coding
#mrover_nodelet_link_libraries(can ${NetLink_LIBRARIES} ${NetLinkRoute_LIBRARIES}})
mrover_nodelet_include_directories(can_driver /usr/include/libnl3)
endif ()
mrover_add_vendor_header_only_library(moteus deps/mjbots)
mrover_add_header_only_library(can_device src/esw/can_device)
mrover_add_library(motor_library src/esw/motor_library/*.cpp src/esw/motor_library)
target_link_libraries(motor_library PUBLIC can_device moteus)

macro(mrover_add_esw_bridge_node name sources)
mrover_add_node(${name} ${sources})
target_link_libraries(${name} PRIVATE can_device motor_library)
endmacro()

mrover_add_esw_bridge_node(arm_hw_bridge src/esw/arm_hw_bridge/*.cpp)
mrover_add_esw_bridge_node(arm_translator_bridge src/esw/arm_translator_bridge/*.cpp src/esw/arm_translator_bridge/*.hpp)
mrover_add_esw_bridge_node(cache_bridge src/esw/cache_bridge/*.cpp)
mrover_add_esw_bridge_node(drive_bridge src/esw/drive_bridge/*.cpp)
mrover_add_esw_bridge_node(led_hw_bridge src/esw/led_hw_bridge/*.cpp)
mrover_add_esw_bridge_node(led src/esw/led/*.cpp)
mrover_add_esw_bridge_node(mast_gimbal_bridge src/esw/mast_gimbal_bridge/*.cpp)
mrover_add_esw_bridge_node(pdb_bridge src/esw/pdb_bridge/*.cpp)
mrover_add_esw_bridge_node(sa_hw_bridge src/esw/sa_hw_bridge/*.cpp)
mrover_add_esw_bridge_node(sa_translator_bridge src/esw/sa_translator_bridge/*.cpp)
mrover_add_esw_bridge_node(science_bridge src/esw/science_bridge/*.cpp)
mrover_add_esw_bridge_node(brushless_test_bridge src/esw/brushless_test_bridge/*.cpp motor_library)
mrover_add_esw_bridge_node(brushed_test_bridge src/esw/brushed_test_bridge/*.cpp)
mrover_add_esw_bridge_node(test_arm_bridge src/esw/test_arm_bridge/*.cpp)
mrover_add_esw_bridge_node(pdb_test_bridge src/esw/pdb_test_bridge/*.cpp)
mrover_add_esw_bridge_node(arm_position_test_bridge src/esw/arm_position_test_bridge/*.cpp)
# mrover_add_esw_bridge_node(sa_sensor src/esw/fw/dirt_sensor/dirt_sensor_ros/dirt_sensor_ros.ino)
if (NetLink_FOUND AND NetLinkRoute_FOUND)
mrover_add_nodelet(can_driver src/esw/can_driver/*.cpp src/esw/can_driver src/esw/can_driver/pch.hpp)
mrover_nodelet_link_libraries(can_driver ${NetLink_LIBRARIES} ${NetLinkRoute_LIBRARIES})
mrover_nodelet_include_directories(can_driver ${NetLink_INCLUDE_DIRS} ${NetLinkRoute_INCLUDE_DIRS})
endif ()

macro(mrover_add_esw_bridge_node name sources)
mrover_add_node(${name} ${sources})
target_link_libraries(${name} PRIVATE can_device motor_library)
endmacro()

mrover_add_esw_bridge_node(arm_hw_bridge src/esw/arm_hw_bridge/*.cpp)
mrover_add_esw_bridge_node(arm_translator_bridge src/esw/arm_translator_bridge/*.cpp src/esw/arm_translator_bridge/*.hpp)
mrover_add_esw_bridge_node(cache_bridge src/esw/cache_bridge/*.cpp)
mrover_add_esw_bridge_node(drive_bridge src/esw/drive_bridge/*.cpp)
mrover_add_esw_bridge_node(led_hw_bridge src/esw/led_hw_bridge/*.cpp)
mrover_add_esw_bridge_node(led src/esw/led/*.cpp)
mrover_add_esw_bridge_node(mast_gimbal_bridge src/esw/mast_gimbal_bridge/*.cpp)
mrover_add_esw_bridge_node(pdb_bridge src/esw/pdb_bridge/*.cpp)
mrover_add_esw_bridge_node(sa_bridge src/esw/sa_bridge/*.cpp)
mrover_add_esw_bridge_node(science_bridge src/esw/science_bridge/*.cpp)
mrover_add_esw_bridge_node(brushless_test_bridge src/esw/brushless_test_bridge/*.cpp)
mrover_add_esw_bridge_node(brushed_test_bridge src/esw/brushed_test_bridge/*.cpp)
mrover_add_esw_bridge_node(science_test_bridge src/esw/science_test_bridge/*.cpp)
mrover_add_esw_bridge_node(test_arm_bridge src/esw/test_arm_bridge/*.cpp)
mrover_add_esw_bridge_node(pdb_test_bridge src/esw/pdb_test_bridge/*.cpp)
# mrover_add_esw_bridge_node(arm_position_test_bridge src/esw/arm_position_test_bridge/*.cpp)
# mrover_add_esw_bridge_node(sa_sensor src/esw/fw/dirt_sensor/dirt_sensor_ros/dirt_sensor_ros.ino)

## Perception

mrover_add_library(streaming src/esw/streaming/*.cpp src/esw/streaming)
target_compile_definitions(streaming PUBLIC BOOST_ASIO_NO_DEPRECATED)
mrover_add_library(websocket_server src/esw/websocket_server/*.cpp src/esw/websocket_server)
target_compile_definitions(websocket_server PUBLIC BOOST_ASIO_NO_DEPRECATED)

mrover_add_nodelet(zed_tag_detector src/perception/tag_detector/zed/*.cpp src/perception/tag_detector/zed src/perception/tag_detector/zed/pch.hpp)
mrover_nodelet_link_libraries(zed_tag_detector opencv_core opencv_objdetect opencv_aruco opencv_imgproc lie)
Expand All @@ -177,19 +198,16 @@ mrover_add_nodelet(usb_camera src/perception/usb_camera/*.cpp src/perception/usb
mrover_nodelet_link_libraries(usb_camera opencv_core opencv_objdetect opencv_aruco opencv_imgproc opencv_highgui)

if (CUDA_FOUND)
# mrover_add_node(nv_vid_codec_h265_enc src/esw/nv_vid_codec_h265_enc/*.c*)
# target_link_libraries(nv_vid_codec_h265_enc PUBLIC cuda nvidia-encode opencv_core opencv_imgproc streaming)
# target_include_directories(nv_vid_codec_h265_enc SYSTEM PUBLIC deps/nvenc)
# mrover_add_node(nv_vid_codec_h265_enc src/esw/nv_vid_codec_h265_enc/*.c*)
# target_link_libraries(nv_vid_codec_h265_enc PUBLIC cuda nvidia-encode opencv_core opencv_imgproc streaming)
# target_include_directories(nv_vid_codec_h265_enc SYSTEM PUBLIC deps/nvenc)
endif ()

mrover_add_nodelet(nv_gst_h265_enc src/esw/nv_gst_h265_enc/*.c* src/esw/nv_gst_h265_enc src/esw/nv_gst_h265_enc/pch.hpp)
mrover_nodelet_link_libraries(nv_gst_h265_enc PRIVATE streaming gstreamer-1.0 gstapp-1.0 glib-2.0 gobject-2.0)
if (MROVER_IS_JETSON)
mrover_nodelet_defines(nv_gst_h265_enc MROVER_IS_JETSON)
mrover_nodelet_include_directories(nv_gst_h265_enc /usr/lib/aarch64-linux-gnu/glib-2.0/include)
if (Gst_FOUND AND GstApp_FOUND AND LibUsb_FOUND AND LibUdev_FOUND)
mrover_add_nodelet(gst_websocket_streamer src/esw/gst_websocket_streamer/*.c* src/esw/gst_websocket_streamer src/esw/gst_websocket_streamer/pch.hpp)
mrover_nodelet_link_libraries(gst_websocket_streamer PRIVATE websocket_server ${Gst_LIBRARIES} ${GstApp_LIBRARIES} ${LibUsb_LIBRARIES} ${LibUdev_LIBRARIES} opencv_core opencv_imgproc)
mrover_nodelet_include_directories(gst_websocket_streamer ${Gst_INCLUDE_DIRS} ${GstApp_INCLUDE_DIRS} ${LibUsb_INCLUDE_DIRS} ${LibUdev_INCLUDE_DIRS})
endif ()
# TODO(quintin): Fix this CMake hard coding
mrover_nodelet_include_directories(nv_gst_h265_enc /usr/include/gstreamer-1.0 /usr/include/glib-2.0 /usr/lib/x86_64-linux-gnu/glib-2.0/include)

if (ZED_FOUND)
mrover_add_nodelet(object_detector src/perception/object_detector/*.c* src/perception/object_detector src/perception/object_detector/pch.hpp)
Expand All @@ -214,6 +232,7 @@ endif ()
## Teleoperation

mrover_add_node(arm_controller src/teleoperation/arm_controller/*.cpp)
target_link_libraries(arm_controller PRIVATE lie)

## Simulator

Expand All @@ -224,8 +243,6 @@ if (MROVER_BUILD_SIM)
mrover_nodelet_defines(simulator BOOST_THREAD_PROVIDES_FUTURE)
endif ()

# TODO

### ======= ###
### Testing ###
### ======= ###
Expand Down
3 changes: 3 additions & 0 deletions action/ArmAction.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
string name
---
---
6 changes: 3 additions & 3 deletions ansible/roles/build/files/profiles/ci/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ catkin_make_args: [ ]
cmake_args:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_C_COMPILER=clang-16
- -DCMAKE_CXX_FLAGS=-pipe
- -DCMAKE_CXX_FLAGS=-pipe -fgnuc-version=13.1.0
- -DCMAKE_CXX_COMPILER=clang++-16
- -DCMAKE_CUDA_HOST_COMPILER=clang++-16
- -DMROVER_CI=ON
- -DCMAKE_CUDA_HOST_COMPILER=g++-9
- -DMROVER_IS_CI=ON
- -Wno-dev
devel_layout: linked
devel_space: devel
Expand Down
4 changes: 2 additions & 2 deletions ansible/roles/build/files/profiles/debug/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ catkin_make_args: [ ]
cmake_args:
- -DCMAKE_BUILD_TYPE=Debug
- -DCMAKE_C_COMPILER=clang-16
- -DCMAKE_CXX_FLAGS=-pipe
- -DCMAKE_CXX_FLAGS=-pipe -fgnuc-version=13.1.0
- -DCMAKE_CXX_COMPILER=clang++-16
- -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache
- -DCMAKE_CUDA_HOST_COMPILER=clang++-16
- -DCMAKE_CUDA_HOST_COMPILER=g++-9
- -Wno-dev
devel_layout: linked
devel_space: devel
Expand Down
4 changes: 2 additions & 2 deletions ansible/roles/build/files/profiles/release/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ catkin_make_args: [ ]
cmake_args:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_C_COMPILER=clang-16
- -DCMAKE_CXX_FLAGS=-march=native -pipe
- -DCMAKE_CXX_FLAGS=-march=native -pipe -fgnuc-version=13.1.0
- -DCMAKE_CXX_COMPILER=clang++-16
- -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache
- -DCMAKE_CUDA_HOST_COMPILER=clang++-16
- -DCMAKE_CUDA_HOST_COMPILER=g++-9
- -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
- -Wno-dev
devel_layout: linked
Expand Down
15 changes: 15 additions & 0 deletions ansible/roles/build/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
- libopencv-dev
- libgstreamer1.0-dev
- libgstreamer-plugins-base1.0-dev
- vainfo
- x264

- name: Install Local APT Packages
become: True
Expand Down Expand Up @@ -190,10 +192,23 @@
link: /usr/bin/lld
priority: 160

- name: Set clang-tidy 16 as Default
become: True
alternatives:
name: clang-tidy
path: /usr/bin/clang-tidy-16
link: /usr/bin/clang-tidy
priority: 160

- name: Setup Python Virtual Environment
pip:
name:
# Installs from pyproject.toml
- "{{ catkin_workspace }}/src/mrover[dev]"
virtualenv: "{{ catkin_workspace }}/src/mrover/venv"
virtualenv_command: /usr/bin/python3.10 -m venv

- name: Install Chromium
become: True
snap:
name: chromium
10 changes: 10 additions & 0 deletions ansible/roles/ci/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
- libnl-route-3-dev
- libtbb-dev
- libopencv-dev
- libgstreamer1.0-dev
- libgstreamer-plugins-base1.0-dev

- name: Install Local APT Packages
become: True
Expand Down Expand Up @@ -173,6 +175,14 @@
link: /usr/bin/lld
priority: 160

- name: Set clang-tidy 16 as Default
become: True
alternatives:
name: clang-tidy
path: /usr/bin/clang-tidy-16
link: /usr/bin/clang-tidy
priority: 160

- name: Setup Python Virtual Environment
pip:
name:
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/dev/files/home/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ZSH_THEME="mrover"
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git virtualenvwrapper fzf)
plugins=(git virtualenvwrapper fzf zsh-autosuggestions zsh-syntax-highlighting)

source $ZSH/oh-my-zsh.sh

Expand Down
Loading

0 comments on commit 4f948ef

Please sign in to comment.