Apollo
10.0
自动驾驶开放平台
smartereye_device.cc
浏览该文件的文档.
1
/******************************************************************************
2
* Copyright 2020 The Apollo Authors. All Rights Reserved.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*****************************************************************************/
16
17
#include "
modules/drivers/smartereye/smartereye_device.h
"
18
19
#include <
time.h
>
20
21
#include <cmath>
22
#include <string>
23
24
#define CLEAR(x) memset(&(x), 0, sizeof(x))
25
26
namespace
apollo
{
27
namespace
drivers {
28
namespace
smartereye {
29
30
SmartereyeDevice::SmartereyeDevice
() {}
31
32
SmartereyeDevice::~SmartereyeDevice
() {
uninit
(); }
33
34
bool
SmartereyeDevice::init
(
const
std::shared_ptr<Config>& camera_config) {
35
pcamera_ = StereoCamera::connect(
"192.168.1.251"
);
36
pcameraHandler_ =
new
SmartereyeHandler
(
"camera A"
);
37
pcamera_->enableTasks(TaskId::ObstacleTask | TaskId::DisplayTask);
38
inited_ =
true
;
39
40
return
true
;
41
}
42
43
bool
SmartereyeDevice::SetCallback
(
CallbackFunc
ptr) {
44
pcameraHandler_->
SetCallback
(ptr);
45
46
return
true
;
47
}
48
49
int
SmartereyeDevice::poll
() {
50
pcamera_->requestFrame(pcameraHandler_, FrameId::Compound);
51
is_capturing_ =
true
;
52
53
return
1;
54
}
55
56
int
SmartereyeDevice::uninit
() {
57
if
(!inited_) {
58
return
1;
59
}
60
61
pcamera_->disconnectFromServer();
62
is_capturing_ =
false
;
63
inited_ =
false
;
64
65
return
1;
66
}
67
68
bool
SmartereyeDevice::is_capturing
() {
return
is_capturing_; }
69
70
bool
SmartereyeDevice::wait_for_device
() {
71
if
(is_capturing_) {
72
ADEBUG
<<
"is capturing"
;
73
return
true
;
74
}
75
76
return
true
;
77
}
78
79
}
// namespace smartereye
80
}
// namespace drivers
81
}
// namespace apollo
apollo::drivers::smartereye::SmartereyeDevice::SmartereyeDevice
SmartereyeDevice()
Definition
smartereye_device.cc:30
apollo::drivers::smartereye::SmartereyeDevice::init
virtual bool init(const std::shared_ptr< Config > &camera_config)
Definition
smartereye_device.cc:34
apollo::drivers::smartereye::SmartereyeDevice::SetCallback
bool SetCallback(CallbackFunc ptr)
Definition
smartereye_device.cc:43
apollo::drivers::smartereye::SmartereyeDevice::is_capturing
bool is_capturing()
Definition
smartereye_device.cc:68
apollo::drivers::smartereye::SmartereyeDevice::uninit
int uninit()
Definition
smartereye_device.cc:56
apollo::drivers::smartereye::SmartereyeDevice::poll
int poll()
Definition
smartereye_device.cc:49
apollo::drivers::smartereye::SmartereyeDevice::wait_for_device
bool wait_for_device()
Definition
smartereye_device.cc:70
apollo::drivers::smartereye::SmartereyeDevice::~SmartereyeDevice
virtual ~SmartereyeDevice()
Definition
smartereye_device.cc:32
apollo::drivers::smartereye::SmartereyeHandler
Definition
smartereye_handler.h:34
apollo::drivers::smartereye::SmartereyeHandler::SetCallback
bool SetCallback(CallbackFunc ptr)
Definition
smartereye_handler.cc:41
ADEBUG
#define ADEBUG
Definition
log.h:41
apollo::drivers::smartereye::CallbackFunc
std::function< bool(RawImageFrame *rawFrame)> CallbackFunc
Definition
smartereye_handler.h:32
apollo
class register implement
Definition
arena_queue.h:37
smartereye_device.h
time.h
modules
drivers
smartereye
smartereye_device.cc