提交 ad3880a9 编写于 作者: fengqikai1414's avatar fengqikai1414 提交者: Liangliang Zhang

camera: use cybertron sleep for

上级 c6b57163
......@@ -22,6 +22,6 @@ bytes_per_pixel: 2
trigger_internal: 0
trigger_fps: 20
channel_name: "/apollo/sensor/camera/obstacle/front_6mm"
device_wait: 2.0
device_wait_ms: 2000
spin_rate: 0.005
output_type: RGB
......@@ -22,6 +22,6 @@ bytes_per_pixel: 2
trigger_internal: 0
trigger_fps: 20
channel_name: "/apollo/sensor/camera/traffic/image_long"
device_wait: 2.0
device_wait_ms: 2000
spin_rate: 0.005
output_type: RGB
......@@ -22,6 +22,6 @@ bytes_per_pixel: 2
trigger_internal: 0
trigger_fps: 20
channel_name: "/apollo/sensor/camera/traffic/image_short"
device_wait: 2.0
device_wait_ms: 2000
spin_rate: 0.005
output_type: RGB
......@@ -43,7 +43,7 @@ message Config {
required uint32 trigger_fps = 22 [default = 30];
optional string channel_name = 23 [default = ""];
// wait time when camera select timeout
optional float device_wait = 24 [default = 2.0];
optional uint32 device_wait_ms = 24 [default = 2000];
// camera select spin time
optional float spin_rate = 25 [default = 0.005];
required OutputType output_type = 26;
......
......@@ -37,7 +37,7 @@ bool UsbCamComponent::Init() {
raw_image_->height = camera_config_->height();
raw_image_->bytes_per_pixel = camera_config_->bytes_per_pixel();
device_wait_ = camera_config_->device_wait();
device_wait_ = camera_config_->device_wait_ms();
spin_rate_ = camera_config_->spin_rate();
if (camera_config_->output_type() == YUYV) {
......@@ -67,8 +67,8 @@ bool UsbCamComponent::Init() {
void UsbCamComponent::run() {
while (!cybertron::IsShutdown()) {
if (!camera_device_->wait_for_device()) {
// sleep 2s for next check
sleep(device_wait_);
// sleep for next check
cybertron::SleepFor(std::chrono::milliseconds(device_wait_));
continue;
}
......
......@@ -48,7 +48,7 @@ class UsbCamComponent : public Component<> {
CameraImagePtr raw_image_ = nullptr;
std::shared_ptr<Image> pb_image_ = nullptr;
float spin_rate_ = 0.005;
float device_wait_ = 2.0;
uint32_t device_wait_ = 2000;
};
CYBERTRON_REGISTER_COMPONENT(UsbCamComponent)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册