Skip to content

Commit 1091c5b

Browse files
authored
Merge pull request #361 from ros-drivers/add-additional-compilers
Add compiler versions to CI matrix
2 parents 614c8e3 + 0ca285f commit 1091c5b

File tree

5 files changed

+103
-53
lines changed

5 files changed

+103
-53
lines changed

.github/workflows/build_test.yml

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,38 @@ jobs:
7070
strategy:
7171
fail-fast: false
7272
matrix:
73+
cxx_compiler:
74+
- g++-12
75+
- g++-14
76+
- clang-14
77+
- clang-16
78+
- clang-18
7379
ros_distro: ${{ fromJson(needs.get_ros_distros.outputs.series) }}
7480
include:
75-
${{ fromJson(needs.get_ros_distros.outputs.matrix) }}
81+
- ${{ fromJson(needs.get_ros_distros.outputs.matrix) }}
82+
- cxx_compiler: g++-12
83+
cc_compiler: gcc-12
84+
- cxx_compiler: g++-14
85+
cc_compiler: gcc-14
86+
- cxx_compiler: clang-14
87+
cc_compiler: clang-14
88+
- cxx_compiler: clang-16
89+
cc_compiler: clang-16
90+
- cxx_compiler: clang-18
91+
cc_compiler: clang-18
92+
exclude:
93+
- { ros_distro: humble, cxx_compiler: g++-14 }
94+
- { ros_distro: humble, cxx_compiler: clang-16 }
95+
- { ros_distro: humble, cxx_compiler: clang-18 }
96+
7697
container:
7798
image: rostooling/setup-ros-docker:${{ matrix.docker_image }}
7899
steps:
79100
- name: Install dependencies
80101
run: |
81102
sudo apt-get update
82103
sudo apt-get -y install policykit-1 libgtk2.0-common screen uml-utilities libc6-dev libicu-dev gcc python3 python3-pip
104+
sudo apt-get -y install ${{ matrix.cc_compiler }} ${{ matrix.cxx_compiler }}
83105
mkdir renode_portable
84106
wget https://builds.renode.io/renode-latest.linux-portable.tar.gz
85107
tar xf renode-latest.linux-portable.tar.gz -C renode_portable --strip-components=1
@@ -96,15 +118,15 @@ jobs:
96118
package-name: usb_cam
97119
target-ros2-distro: ${{ matrix.ros_distro }}
98120
vcs-repo-file-url: ""
99-
colcon-defaults: |
100-
{
101-
"build": {
102-
"mixin": ["coverage-gcc"]
103-
}
104-
}
105-
# If possible, pin the repository in the workflow to a specific commit to avoid
106-
# changes in colcon-mixin-repository from breaking your tests.
107-
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/1ddb69bedfd1f04c2f000e95452f7c24a4d6176b/index.yaml
121+
extra-cmake-args: -DCMAKE_C_COMPILER=${{ matrix.cc_compiler }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} # -DLLVM_ENABLE_RUNTIMES=compiler-rt
122+
# TODO(flynneva): re-enable once code coverage works with differet compilers
123+
# colcon-defaults: |
124+
# {
125+
# "build": {
126+
# "mixin": ["coverage-gcc"]
127+
# }
128+
# }
129+
# colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/b8436aa16c0bdbc01081b12caa253cbf16e0fb82/index.yaml
108130
# Compile again, this time enabling integration tests
109131
- name: Build integration tests
110132
shell: bash
@@ -118,13 +140,14 @@ jobs:
118140
renode_portable/renode --disable-gui --version
119141
- uses: actions/upload-artifact@v4
120142
with:
121-
name: colcon-logs-${{ matrix.ros_distro }}
143+
name: colcon-logs-${{ matrix.ros_distro }}-${{ matrix.cxx_compiler }}
122144
path: ${{ steps.build_and_test_step.outputs.ros-workspace-directory-name }}/log
123145
if: always()
124146
continue-on-error: true
125-
- uses: actions/upload-artifact@v4
126-
with:
127-
name: lcov-logs-${{ matrix.ros_distro }}
128-
path: ${{ steps.build_and_test_step.outputs.ros-workspace-directory-name }}/lcov
129-
if: always()
130-
continue-on-error: true
147+
# TODO(flynneva): re-enable once code coverage works with differet compilers
148+
# - uses: actions/upload-artifact@v4
149+
# with:
150+
# name: lcov-logs-${{ matrix.ros_distro }}-${{ matrix.cxx_compiler }}
151+
# path: ${{ steps.build_and_test_step.outputs.ros-workspace-directory-name }}/lcov
152+
# if: always()
153+
# continue-on-error: true

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ rclcpp_components_register_node(${PROJECT_NAME}_node
6565
EXECUTABLE ${PROJECT_NAME}_node_exe
6666
)
6767

68+
# To fix `DSO missing from command line` error with clang
69+
target_link_libraries(${PROJECT_NAME}_node_exe stdc++)
70+
6871
if(SANITIZE)
6972
target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=address -fsanitize=leak)
7073
target_link_libraries(${PROJECT_NAME} -fsanitize=address -fsanitize=leak)
@@ -81,11 +84,11 @@ if(BUILD_TESTING)
8184
ament_add_gtest(test_usb_cam_utils
8285
test/test_usb_cam_utils.cpp)
8386
target_link_libraries(test_usb_cam_utils
84-
${PROJECT_NAME})
87+
${PROJECT_NAME} m stdc++)
8588
ament_add_gtest(test_pixel_formats
8689
test/test_pixel_formats.cpp)
8790
target_link_libraries(test_pixel_formats
88-
${PROJECT_NAME})
91+
${PROJECT_NAME} m stdc++)
8992
if(INTEGRATION_TESTS)
9093
ament_add_gtest(test_usb_cam_lib
9194
test/test_usb_cam_lib.cpp)

include/usb_cam/formats/mjpeg.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ class MJPEG2RGB : public pixel_format_base
243243
size_t m_avframe_rgb_size;
244244
char * m_averror_str;
245245
int m_result = 0;
246-
int m_counter = 0;
247-
const int * m_linesize;
248246

249247
const int m_align = 32;
250248
};

include/usb_cam/formats/pixel_format_base.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ namespace formats
5050
/// arguments for future pixel format(s) that are added.
5151
typedef struct
5252
{
53-
std::string name = "";
54-
int width = 640;
55-
int height = 480;
56-
size_t pixels = 640 * 480;
57-
std::string av_device_format_str = "AV_PIX_FMT_YUV422P";
53+
std::string name;
54+
int width;
55+
int height;
56+
size_t pixels;
57+
std::string av_device_format_str;
5858
} format_arguments_t;
5959

6060

@@ -74,6 +74,8 @@ class pixel_format_base
7474
m_requires_conversion(requires_conversion)
7575
{}
7676

77+
virtual ~pixel_format_base() {}
78+
7779
/// @brief Name of pixel format. Used in the parameters file to select this format
7880
/// @return
7981
inline std::string name() {return m_name;}

include/usb_cam/usb_cam.hpp

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,65 @@ std::vector<std::shared_ptr<pixel_format_base>> driver_supported_formats(
9696
return fmts;
9797
}
9898

99-
typedef struct
99+
typedef struct capture_format_t
100100
{
101101
struct v4l2_fmtdesc format;
102102
struct v4l2_frmivalenum v4l2_fmt;
103103
} capture_format_t;
104104

105-
typedef struct
105+
typedef struct parameters_t
106106
{
107-
std::string camera_name = "usb_cam"; // can be anything
108-
std::string device_name = "/dev/video0"; // usually /dev/video0 or something similiar
109-
std::string frame_id = "camera";
110-
std::string io_method_name = "mmap";
111-
std::string camera_info_url = "package://usb_cam/config/camera_info.yaml";
112-
std::string pixel_format_name = "yuyv2rgb";
113-
std::string av_device_format = "YUV422P";
114-
int image_width = 600;
115-
int image_height = 400;
116-
int framerate = 30.0;
117-
int brightness = -1;
118-
int contrast = -1;
119-
int saturation = -1;
120-
int sharpness = -1;
121-
int gain = -1;
122-
int white_balance = -1;
123-
int exposure = -1;
124-
int focus = -1;
125-
bool auto_white_balance = true;
126-
bool autoexposure = true;
127-
bool autofocus = false;
107+
std::string camera_name;
108+
std::string device_name;
109+
std::string frame_id;
110+
std::string io_method_name;
111+
std::string camera_info_url;
112+
std::string pixel_format_name;
113+
std::string av_device_format;
114+
int image_width;
115+
int image_height;
116+
int framerate;
117+
int brightness;
118+
int contrast;
119+
int saturation;
120+
int sharpness;
121+
int gain;
122+
int white_balance;
123+
int exposure;
124+
int focus;
125+
bool auto_white_balance;
126+
bool autoexposure;
127+
bool autofocus;
128+
129+
parameters_t()
130+
// *INDENT-OFF*
131+
: camera_name("usb_cam"),
132+
device_name("/dev/video0"),
133+
frame_id("camera"),
134+
io_method_name("mmap"),
135+
camera_info_url("package://usb_cam/config/camera_info.yaml"),
136+
pixel_format_name("yuyv2rgb"),
137+
av_device_format("YUV422P"),
138+
image_width(600),
139+
image_height(480),
140+
framerate(30.0),
141+
brightness(-1),
142+
contrast(-1),
143+
saturation(-1),
144+
sharpness(-1),
145+
gain(-1),
146+
white_balance(-1),
147+
exposure(-1),
148+
focus(-1),
149+
auto_white_balance(true),
150+
autoexposure(true),
151+
autofocus(false)
152+
{
153+
}
154+
// *INDENT-ON*
128155
} parameters_t;
129156

130-
typedef struct
157+
typedef struct image_t
131158
{
132159
char * data;
133160
size_t width;
@@ -396,13 +423,10 @@ class UsbCam
396423
image_t m_image;
397424

398425
AVFrame * m_avframe;
399-
int m_avframe_size;
400426
AVCodec * m_avcodec;
401-
AVCodecID m_codec_id;
402427
AVDictionary * m_avoptions;
403428
AVCodecContext * m_avcodec_context;
404429

405-
int64_t m_buffer_time_us;
406430
bool m_is_capturing;
407431
int m_framerate;
408432
const time_t m_epoch_time_shift_us;

0 commit comments

Comments
 (0)