-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera_sensor.cpp
More file actions
68 lines (52 loc) · 1.58 KB
/
camera_sensor.cpp
File metadata and controls
68 lines (52 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <example/CameraSensor.h>
#include <vnx/Config.h>
#include <vnx/Process.h>
#include <vnx/Terminal.h>
#include <vnx/Server.h>
int main(int argc, char** argv) {
std::map<std::string, std::string> options;
options["n"] = "node"; // we declare -n is the same as --node
options["node"] = "server url"; // we declare --node means "server url"
vnx::init("camera_sensor", argc, argv, options);
/*
* By default we create a local UNIX node for this example.
*/
std::string node = "camera_sensor.sock";
vnx::read_config("node", node);
{
/*
* Start a Terminal to display log messages for us.
*/
vnx::Handle<vnx::Terminal> terminal = new vnx::Terminal("Terminal");
terminal.start_detached();
}
{
/*
* The Server will listen on and accept client connections to this process,
* depending on the type of Endpoint either on a TCP port or on a UNIX domain socket.
*/
vnx::Handle<vnx::Server> server = new vnx::Server("Server", vnx::Endpoint::from_url(node));
server.start_detached();
}
{
/*
* Create and start our sensor module.
*/
vnx::Handle<example::CameraSensor> module = new example::CameraSensor("Camera");
// Set configuration variables
if(!module->output) {
module->output = "sensors.raw_data.camera"; // set default output topic
}
// Start module in the background
module.start_detached();
/*
* After the module has been started any attempt to access it will cause an exception.
*
* For example: module->output = "something.else"; // throws exception
*/
}
/*
* Wait until shutdown.
*/
vnx::wait();
}