NDEVR
API Documentation
Scanner3D.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Hardware
28File: Scanner3D
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#if NDEVR_SCAN
35#include <NDEVR/Device.h>
36#include <NDEVR/PointScannerOptions.h>
37#include <NDEVR/MaterialRaster.h>
38#include <NDEVR/SnapLocation.h>
39#include <NDEVR/Scan.h>
40#include <NDEVR/Matrix.h>
41#include <NDEVR/UUID.h>
42#include <NDEVR/Time.h>
43#include <NDEVR/Plane.h>
44#include <NDEVR/Pointer.h>
45#include <NDEVR/Vector.h>
46class ScannerDriver;
47namespace NDEVR
48{
49 struct FileRequest;
50 class Scanner3D;
53 class Log;
54 class Camera;
56 class Battery;
57 class PositionSensor;
58 class Light;
59 class Winch;
60 class BasicThread;
61 class RangeSensor;
62 class Connection;
63 class Motor;
64 class RotationBounds;
65 class DistanceEncoder;
69 enum ScannerState
70 {
71 e_scan_ready
72 , e_scanning
73 , e_movement
74 , e_manual_mode
75 , e_remote_mode
76 , e_motor_control
77 , e_measure
78 , e_maintenance_mode
79 , e_disconnected
80 , e_error
81 };
82
86 enum class ScanPointType
87 {
89 , e_calibrate_circle_a
90 , e_calibrate_circle_b
91 , e_calibrate_circle_c
92 };
96 struct ScanSpeedProfile
97 {
98 ScanSpeedProfile();
99 ScanSpeedProfile(TranslatedString title, fltp04 speed)
100 : title(title)
101 , speed(speed)
102 {}
103 TranslatedString title;
104 fltp04 speed;
105 };
109 struct PolarScanResolutionInfo
110 {
111 Bounds<2, Angle<fltp08>> bounds;
112 Vector<2, Angle<fltp08>> step = Vector<2, Angle<fltp08>>(Angle<fltp08>(DEGREES, 2.0));
113 uint01 primary_angle = ROLL;
114 };
118 struct CartesianScanResolutionInfo
119 {
120 Bounds<3, fltp08> bounds = Bounds<3, fltp08>(-100.0, 100.0);
121 Vector<2, fltp08> step = Vector<2, fltp08>(0.01);
122 };
123
127 enum ScanResolutionType
128 {
129 e_polar
130 , e_cartesian
131 };
136 struct ScanProfile
137 {
138 UUID id = Constant<UUID>::Invalid;
139 TranslatedString title;
140 TranslatedString description;
141 String icon;
142 Buffer<ScanSpeedProfile> scan_speed_profiles;
143 ScanResolutionType scan_resolution_type = ScanResolutionType::e_polar;
144 CartesianScanResolutionInfo cartesian_scan_info;
145 PolarScanResolutionInfo polar_scan_info;
146 bool editable_bounds = true;
147 bool editable_step = true;
148 bool supports_raster = false;
149 bool editable_raster = false;
150 bool is_deployment_scan = false;
151 bool is_stationary_scan = true;
152 bool force_camera_visible = false;
153 bool request_custom_camera_profile = false;
154 bool force_video_record = false;
155 bool no_point_collection = false;
156 bool is_global_bounds = false;
157 bool prefer_large_scanner_camera = false;
158 };
163 struct POINT_SCANNER_API Scanner3DScanSettings
164 {
165 UUID scan_profile_id;
166 ScanProfile profile;
167 fltp04 speed = 1.0f;
168 RasterInfo raster_info;
169 CartesianScanResolutionInfo cartesian_scan_info;
170 PolarScanResolutionInfo polar_scan_info;
171 bool is_child_of_station = true;
172 void logInfo(LogPtr log) const;
173 };
177 struct ActiveScanStatus
178 {
179 TranslatedString status_message;
180 String status_icon;
181 TimeSpan time_remaining = Constant<TimeSpan>::Invalid;
182 Time start_time = Constant<Time>::Invalid;
183 RGBColor status_color = Constant<RGBColor>::Invalid;
184 fltp04 percent = Constant<fltp04>::Invalid;
185 bool show_status = false;
186 };
195 class POINT_SCANNER_API Scanner3D : public Device
196 {
197 Q_OBJECT
198 public:
199 Scanner3D(DesignObjectLookup* lookup, const Model& model, LogPtr log, QObject* parent = nullptr);
200 ~Scanner3D();
201
202 virtual void createScanner() = 0;
203 virtual void parkDevice() {}
204 [[nodiscard]] virtual Matrix<fltp08> scanModelFileTransform() const = 0;
205 [[nodiscard]] virtual Matrix<fltp08> prismModelFileTransform() const;
206 [[nodiscard]] virtual bool supportsState(ScannerState state) const;
207 virtual void startScan(const Scanner3DScanSettings& settings) = 0;
208 [[nodiscard]] virtual Buffer<ScanProfile> availableScanProfiles() const = 0;
209 [[nodiscard]] virtual ScanProfile scanProfile(UUID id) const;
210 [[nodiscard]] virtual Plane<3, fltp08> scanPlane(const ScanProfile& profile, uint01 dimension) const;
211 [[nodiscard]] virtual Vertex<3, fltp08> scanOrigin(const ScanProfile& profile, uint01 dimension) const;
212
213 virtual void addImageToRaster(const ImageData& data, const Vector<2, Angle<sint04>>& fov, const Matrix<fltp08>& camera_matrix);
214 virtual void addCameraDrapeFunction(const StringView& id, std::function<void()> function);
215 virtual void removeCameraDrapeFunction(const StringView& id);
216 [[nodiscard]] ActiveScanStatus scanStatus() const { return m_scan_status; };
217 [[nodiscard]] virtual RasterInfo defaultRasterInfo(const UUID& profile) const;
218 [[nodiscard]] virtual bool supportsScanImageRaster() const { return false; }
219
220 [[nodiscard]] virtual bool rollLocked() const { return false; }
221 virtual bool requestRollLock(bool) { return false; }
222
223 [[nodiscard]] virtual bool isScanning() const { return m_is_scanning; }
224 [[nodiscard]] virtual bool isPaused() const { return m_is_paused; };
225 [[nodiscard]] virtual ScannerState scannerState() const { return m_scanner_state; }
226 [[nodiscard]] virtual Vector<3, Angle<fltp08>> headAngle() const;
227 [[nodiscard]] virtual Vector<3, Angle<fltp08>> pointToHeadAngle(Vertex<3, fltp08> point) const;
228
229 [[nodiscard]] virtual Motor* headMotor(uint01 axis) const;
230 virtual void orientHead(const Vector<3, Angle<fltp08>>& head_orientation);
231 [[nodiscard]] virtual RangeSensor* createRangeSensor();
232 virtual void setCameraPointTarget(const Vector<3, fltp08>& target);
233 virtual void clearCameraTarget();
234 virtual void updateCameraTarget();
235 virtual void deployStabalizer(bool stabalizer);
236 virtual bool supportsStabalizer() const { return false; }
237 Vertex<3, fltp08> cameraTarget() const;
238 virtual void endUpdates() { };
239 [[nodiscard]] virtual UUID camera() const { return m_camera; }
240 [[nodiscard]] virtual Matrix<fltp08> cameraTransform() const { return Matrix<fltp08>(1.0); }
241 [[nodiscard]] virtual bool useCalibratedScan() const { return false; };
242 [[nodiscard]] virtual TranslatedString scannerInfo() const;
243 [[nodiscard]] virtual Matrix<fltp08> scannerMatrix() const;
244 virtual bool snapViewportToScanner() const;
245
246 [[nodiscard]] PointScannerOptions& options();
247 [[nodiscard]] const PointScannerOptions& options() const;
248
249 [[nodiscard]] virtual TimeSpan getScanTime(const Scanner3DScanSettings&) const { return Constant<TimeSpan>::Invalid; };
250 [[nodiscard]] bool pauseRequested() const { return m_request_pause_scan; }
251 [[nodiscard]] bool startRequested() const { return m_request_start_scan; }
252 [[nodiscard]] bool stopRequested() const { return m_request_stop_scan; }
253
254 virtual bool executeManualCommand(const String& command) { UNUSED(command); return false; };
255 virtual void recordPoint(bool record_to_cloud = true, bool record_to_mesh = true);
256 virtual void recordPoint(const PolarScanRecord<fltp04>& record);
257 virtual void setScannerState(ScannerState scanner_state);
258 virtual void requestConnect();
259 virtual void requestDisconnect();
260 virtual void requestStopScan();
261 virtual void requestResumeScan();
262 virtual void requestPauseScan();
263 virtual uint04 meshBlendFactor() const { return 3U; }
264 [[nodiscard]] virtual DynamicPointer<Scan> scan();
265 [[nodiscard]] virtual Buffer<Battery*> batteries() const { return Buffer<Battery*>(); }
266 [[nodiscard]] virtual Buffer<TemperatureSensor*> temperatureSensors() const { return Buffer<TemperatureSensor*>(); };
267 [[nodiscard]] virtual OrientationSensor* orientationSensor() const { return nullptr; };
268 [[nodiscard]] virtual PositionSensor* positionSensor() const { return nullptr; };
269 [[nodiscard]] virtual Winch* deploymentWinch() const { return nullptr; }
270 [[nodiscard]] virtual RotationBounds* rotationalBounds() const { return nullptr; };
271 [[nodiscard]] virtual Light* light() const { return nullptr; }
272 [[nodiscard]] virtual Light* redDot() const { return nullptr; }
273 [[nodiscard]] virtual DistanceEncoder* distanceEncoder() const { return nullptr; }
274 [[nodiscard]] virtual Connection* connection() const { return nullptr; }
275 [[nodiscard]] virtual RangeSensor* rangeSensor() const { return m_range_sensor; };
276
277 [[nodiscard]] virtual TimeSpan scanTime() const;
278 [[nodiscard]] virtual bool usingPrism() const { return false; };
279 [[nodiscard]] virtual Log* maintenanceLog() const { return nullptr; };
280 [[nodiscard]] virtual const ScanSetupSettings& scanSettings() const { return m_scan_settings; }
281 [[nodiscard]] virtual Matrix<fltp08> initialScanTransform() const;
282 virtual void updateModel();
283 virtual void clearScanStateRequests();
284 [[nodiscard]] virtual bool isConnected() const;
285 signals:
286 void scanStatusChangedSignal();
287 void scanStartedSignal();
288 void scanFinishedSignal(UUID id);
289 void connectionChangedSignal(bool is_connected);
290 protected:
291 virtual void setConnected(bool is_connected);
292 virtual void createPrismModel();
293 virtual void createScannerModel();
294 [[nodiscard]] virtual Bounds<2, Angle<fltp08>> scanBounds() const = 0;
295 virtual void stopScan() = 0;
296 virtual void resumeScan() = 0;
297 virtual void pauseScan() = 0;
298 [[nodiscard]] virtual FileRequest scanModelFile() const;
299 [[nodiscard]] virtual FileRequest prismModelFile() const;
300 virtual void updateScanModel(bool scan_ended, bool force_calculate_mesh);
301 virtual void finishUpdatingScanModel();
302 virtual void calibrateScanModel();
303 virtual void createScanObject();
304 [[nodiscard]] virtual Matrix<fltp08> laserTransform(const Vector<3, Angle<fltp08>>& head_angle) const = 0;
305 [[nodiscard]] virtual Matrix<fltp08> scanTransform() const { return Matrix<fltp08>(1.0); }
306 protected:
307 Model m_camera_point_target;
308 Angle<sint04> m_anti_jitter_angle = Angle<sint04>(DEGREES, 0.3);
309 fltp08 m_anti_jitter_offset = 0.005;
310 Dictionary<String, std::function<void()>> m_camera_drape_functions;
311 DesignObjectLookup* m_manager;
312
313 ScannerState m_scanner_state;
314 ActiveScanStatus m_scan_status;
315 Vector<3, Motor*> m_head_motors;
316 RangeSensor* m_range_sensor;
317 //Scanner ID's
318 UUID m_prism_model = Constant<UUID>::Invalid;
319 UUID m_camera = Constant<UUID>::Invalid;
320
321 ScanPointType m_scan_point_type;
322
323 Time m_scan_start_time;
324 Time m_start_pause_time;
325 TimeSpan m_pause_time;
326
327 //Scan Information
328 ScanSetupSettings m_scan_settings;
329 bool m_is_scanning = false;
330 bool m_is_paused = false;
331 DynamicPointer<Scan> m_scan;
332 DynamicPointer<PointScannerOptions> m_options;
333 bool m_request_start_scan = false;
334 bool m_request_pause_scan = false;
335 bool m_request_stop_scan = false;
336 bool m_request_disconnect = false;
337 bool m_request_connect = false;
338 bool m_file_loaded = false;
339 bool m_mesh_with_head_angle = false;
340 bool m_is_connected = false;
341 };
342}
343#endif
A thread that executes a user-provided callback function concurrently.
Definition BasicThread.h:47
A device which has an associated voltage or percent that changes.
Definition Battery.h:106
A core object representing a user view as well as convenience functions for moving this view through ...
Definition Camera.h:95
A standard interface for all types of connections that allow transmitting and receiving of data betwe...
Definition Connection.h:316
A core class where all Design Objects including models, materials, and geometries are stored.
A root class which describes some physical object, such as a Motor, Sensor, or Connection.
Definition Device.h:54
A distance encoder is a device that measures distance by generating pulses in response to an object's...
A Device responsible for turning on and off a light source.
Definition Light.h:44
Serves as the primary program interface for processes to report issues and allows any number of LogSt...
Definition Log.h:50
A motor is a device which produces rotational spin.
Definition Motor.h:46
Forward declaration for design object lookup service.
Forward declaration for distance encoder device.
A RangeSensor is a Device that determines the distance of a target at a certain orientation.
Definition RangeSensor.h:52
A Device responsible for determining the temperature of either the environment or a specific componen...
The primary namespace for the NDEVR SDK.
@ ROLL
Rotation about the forward axis (X).
Definition Angle.h:45
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ description
The description text of the object.
@ icon
Icon identifier for the object.
@ start_time
The time at which the effect begins.
Definition Effect.h:52
@ e_normal
Normal map channel for per-pixel lighting.
A FileRequest bundles format data as well as a particular file.
Definition FileFormat.h:101