Skip to content

Commit 2ca3e47

Browse files
author
hanjun
committed
add read_cfg
1 parent 7c18da3 commit 2ca3e47

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

human_detector/src/module/hal_camera_module/hal_camera_module.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ bool HalCameraModule::Initialize(aimrt::CoreRef core) {
1111

1212
try {
1313
// Write your other initialization logic here ...
14+
// Read cfg
15+
auto file_path = core_.GetConfigurator().GetConfigFilePath();
16+
if (!file_path.empty()) {
17+
YAML::Node cfg_node = YAML::LoadFile(std::string(file_path));
18+
freq_ = cfg_node["freq"].as<double>();
19+
}
1420
// Get executor handle
1521
executor_ = core_.GetExecutorManager().GetExecutor("work_executor");
1622
AIMRT_CHECK_ERROR_THROW(executor_, "Get executor 'work_executor' failed.");
@@ -74,6 +80,8 @@ void HalCameraModule::MainLoop() {
7480

7581
// publish event
7682
aimrt::channel::Publish(publisher_, msg);
83+
84+
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(1000 / freq_)));
7785
}
7886

7987
} catch (const std::exception& e) {

human_detector/src/module/hal_camera_module/hal_camera_module.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ class HalCameraModule : public aimrt::ModuleBase {
3333
aimrt::executor::ExecutorRef executor_;
3434

3535
std::unique_ptr<cv::VideoCapture> camera_ptr_;
36+
37+
double freq_ = 10;
3638
};

0 commit comments

Comments
 (0)