-
Notifications
You must be signed in to change notification settings - Fork 1
/
sim_vision_sensor.m
130 lines (99 loc) · 3.63 KB
/
sim_vision_sensor.m
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
%% sim_vision_sensor
%
% A base class for V-REP vision sensors. This includes sensors used for
% fast "laser" sensors, which are simulated as vision sensors. Inherits
% from sim_entity.
%
% Methods
%
% get_data % Returns [dataPackets, dataIndex], raw sensor data.
% The contents of dataPackets will depend entirely
% on which filters are active. dataIndex is a
% vector containing the starting indicies of each
% packet in dataPackets.
%
% resolution % Retrieves scan resolution of sensor.
% fov % Retrieves the fov, field of view, of
% the sensor.
%
% set_resolution % Sets the sensor's resolution.
% set_fov % Sets the sensor's fov.
%
classdef sim_vision_sensor < sim_entity
properties
end
methods
function obj = sim_vision_sensor(sim,ident)
obj = obj@sim_entity(sim,ident);
end
function [dataPackets, dataIndex] = get_data(obj)
% sim_vision_sensor.get_data
%
% Retrieves packets of data from the sensor. The first packet,
% containing 15 entries, is always the min, max and average of:
% Intensity, red, green, blue, and depth.
%
% The data that follows is entirely dependant on the filter
% components active. These filters can be found in a vision sensor
% object's properties dialog. See the following V-REP documentation
% page for more information.
% http://www.coppeliarobotics.com/helpFiles/en/visionSensorFilterComposition.htm
%
% Returns:
%
% dataPackets % The data returned by the vision
% sensor.
% dataIndex % A list of indicies that represent the
% beginning of each packet.
%
[dataPackets, dataIndex] = obj.sim.readPointVisionSensor(obj.id);
end
function res = resolution(obj)
% sim_vision_sensor.resolution
%
% Gets the current resolution of the sensor.
%
% Returns:
%
% res % A 2-vector containing the sensor's resolution in
% the form [width, height]
%
res(1) = obj.get_IntParam(1002);
res(2) = obj.get_IntParam(1003);
end
function f = fov(obj)
% sim_sensor.fov
%
% Gets the FOV of the sensor.
%
% Returns:
%
% f % The sensor's FOV in radians.
%
f = obj.get_FloatParam(1004);
end
function set_resolution(obj,new)
% sim_sensor.set_resolution(new)
%
% Sets the resolution of the sensor to 'new'
%
% Arguments:
% new % A 2-vector that contains the sensor's new resolution
% in the form [width, height].
%
obj.set_IntParam(1002,new(1));
obj.set_IntParam(1003,new(2));
end
function set_fov(obj,new)
% sim_sensor.set_resolution(new)
%
% Sets the resolution of the sensor to 'new'
%
% Arguments:
%
% new % An angle in radians.
%
obj.set_FloatParam(1004,new);
end
end
end