File tree 4 files changed +54
-44
lines changed
4 files changed +54
-44
lines changed Original file line number Diff line number Diff line change @@ -86,12 +86,12 @@ if(BUILD_TESTING)
86
86
test /test_pixel_formats.cpp)
87
87
target_link_libraries (test_pixel_formats
88
88
${PROJECT_NAME} )
89
- # TODO(flynneva): rewrite this test in another PR
90
- # Integration tests
91
- # ament_add_gtest( test_usb_cam_lib
92
- # test/ test_usb_cam_lib.cpp)
93
- # target_link_libraries(test_usb_cam_lib
94
- # ${PROJECT_NAME} )
89
+ if (INTEGRATION_TESTS)
90
+ ament_add_gtest(test_usb_cam_lib
91
+ test / test_usb_cam_lib.cpp)
92
+ target_link_libraries ( test_usb_cam_lib
93
+ ${PROJECT_NAME} )
94
+ endif ( )
95
95
endif ()
96
96
97
97
install (
Original file line number Diff line number Diff line change @@ -154,7 +154,25 @@ Unfortunately `rviz2` and `show_image.py` do not support visualizing the compres
154
154
ros2 run image_transport republish compressed raw --ros-args --remap in/compressed:=image_raw/compressed --remap out:=image_raw/uncompressed
155
155
```
156
156
157
- ## Address and leak sanitizing
157
+ ## Testing
158
+
159
+ To run the basic unit tests for this repository:
160
+
161
+ ``` shell
162
+ colcon build --packages-select usb_cam
163
+ colcon test --pacakges-select usb_cam
164
+ ```
165
+
166
+ ### Integration tests
167
+
168
+ To run integration tests for this repository:
169
+
170
+ ``` shell
171
+ colcon build --packages-select usb_cam --cmake-args -DINTEGRATION_TESTS=1
172
+ colcon test --pacakges-select usb_cam
173
+ ```
174
+
175
+ ### Address and leak sanitizing
158
176
159
177
Incorporated into the ` CMakelists.txt ` file to assist with memory leak and address sanitizing
160
178
is a flag to add these compile commands to the targets.
Original file line number Diff line number Diff line change @@ -104,32 +104,27 @@ typedef struct
104
104
105
105
typedef struct
106
106
{
107
- std::string camera_name; // can be anything
108
- std::string device_name; // usually /dev/video0 or something similiar
109
- std::string frame_id;
110
- std::string io_method_name;
111
- std::string camera_info_url;
112
- // these parameters all have to be a combination supported by the device
113
- // Use
114
- // v4l2-ctl --device=0 --list-formats-ext
115
- // to discover them,
116
- // or guvcview
117
- std::string pixel_format_name;
118
- std::string av_device_format;
119
- int image_width;
120
- int image_height;
121
- int framerate;
122
- int brightness;
123
- int contrast;
124
- int saturation;
125
- int sharpness;
126
- int gain;
127
- int white_balance;
128
- int exposure;
129
- int focus;
130
- bool auto_white_balance;
131
- bool autoexposure;
132
- bool autofocus;
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 ;
133
128
} parameters_t ;
134
129
135
130
typedef struct
Original file line number Diff line number Diff line change 38
38
TEST (test_usb_cam_lib, test_usb_cam_class) {
39
39
usb_cam::UsbCam test_usb_cam;
40
40
41
+ usb_cam::parameters_t parameters;
42
+ test_usb_cam.configure (parameters, usb_cam::utils::IO_METHOD_MMAP);
43
+
44
+ test_usb_cam.start ();
45
+
41
46
auto supported_fmts = test_usb_cam.get_supported_formats ();
42
47
43
48
// TODO(flynneva): iterate over availble formats with test_usb_cam obj
44
49
for (auto fmt : supported_fmts) {
45
50
std::cerr << " format: " << fmt.format .type << std::endl;
46
51
}
47
52
48
- // TODO(flynneva): rework these tests in another MR
49
- {
50
- // test_usb_cam.configure(
51
- // "/dev/video0",
52
- // usb_cam::utils::IO_METHOD_MMAP,
53
- // "yuyv2rgb", 640, 480, 30);
54
- // test_usb_cam.start();
55
- // TODO(flynneva): uncomment once /dev/video0 can be simulated in CI
56
- // EXPECT_TRUE(test_usb_cam.is_capturing());
57
- // test_usb_cam.shutdown();
58
- }
53
+ // TODO(flynneva): uncomment once /dev/video0 can be simulated in CI
54
+ EXPECT_TRUE (test_usb_cam.is_capturing ());
55
+ test_usb_cam.shutdown ();
59
56
}
You can’t perform that action at this time.
0 commit comments