You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

857 lines
20 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
8 years ago
​
5 years ago
8 years ago
​
​
​
8 years ago
​
​
​
​
8 years ago
​
​
8 years ago
​
​
8 years ago
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
8 years ago
​
​
8 years ago
​
​
8 years ago
​
​
​
​
​
​
​
8 years ago
​
8 years ago
​
​
​
​
​
8 years ago
8 years ago
​
​
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
​
8 years ago
8 years ago
8 years ago
​
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
​
​
​
​
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
​
8 years ago
8 years ago
8 years ago
​
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
​
​
​
​
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
​
8 years ago
8 years ago
8 years ago
​
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
8 years ago
8 years ago
8 years ago
8 years ago
​
8 years ago
​
8 years ago
8 years ago
​
8 years ago
​
​
8 years ago
8 years ago
​
​
​
8 years ago
​
8 years ago
​
​
8 years ago
8 years ago
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
8 years ago
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
8 years ago
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
8 years ago
​
  1. #ifndef __3D_LRF_GENERAL_SETTINGS_HEADER__
  2. #define __3D_LRF_GENERAL_SETTINGS_HEADER__
  3. // #define DISABLE_FRENDLY_MESSAGES
  4. typedef enum E_LRF3D_WORK_MODE
  5. {
  6. WM_NONE = 0x00,
  7. WM_INIT = 0x01,
  8. WM_STUDY = 0x02,
  9. WM_DETECTOR = 0x03,
  10. WM_RESET = 0x04,
  11. WM_BORDER = 0x05,
  12. WM_FILE = 0x06,
  13. WM_ERROR = 0xFF
  14. } LRF3D_WORK_MODE;
  15. #ifdef __linux__
  16. #ifndef __GUI__
  17. extern SOFTWARE_INFO gsSOFT_INFO;
  18. #endif
  19. #endif
  20. #define EVENTS_OUTPUT_QUEUE_MAX 2000 // 128
  21. #define SKIP_TARGET_LOG
  22. // #define HIBERNATE_ENABLE
  23. #define THREADED_FLIP
  24. #define TH_JUST_UPDATE_WORKING
  25. #define TH_FORCED_BOOM_CLEAN
  26. // #define TH_PER_MIRROR
  27. #define TH_FULL_PER_LRF
  28. #define TH_NEW_FLIP_FUNC
  29. #define STRONG_STAT
  30. #define TRACKER_INSTANT_TARGET
  31. #define IGNORE_ERROR_ANGLE
  32. // #define ONPC_TOTTAL_SIMULATOR
  33. // #define TRACKER_FULL_COMPARE
  34. // #define SIMULATE_TARGETS
  35. // #define SIMULATE_FLIPS
  36. #define CHECK_SUN_BIT
  37. #define THREADED_MOTORS_START
  38. #define NO_BLACK_TARGETS
  39. #define SHIFT_50 341 // 25m //683 //50m
  40. #define TGD
  41. /* Defined by Makefile of Slave!! */
  42. // #define PRU_SLAVE
  43. #ifdef ONPC_TOTTAL_SIMULATOR
  44. // #define SIMULATE_TARGETS
  45. // #define SIMULATE_DOS_TARGETS
  46. #define NO_MOTORS
  47. #define NO_SOC
  48. #define NO_PRU
  49. #undef TGD
  50. // #define PRU_SLAVE
  51. #endif
  52. #ifdef TGD
  53. #define ENCODER_8192
  54. #define TGD_VERSION_2
  55. #define CHID_TAG_USED
  56. #define PULSE_ALWAYS
  57. // #define ADC_SYMUL_MODE
  58. #endif
  59. #ifdef PULSE_ALWAYS
  60. #define PULSE_PREPULSES 40
  61. #endif
  62. #ifdef SIMULATE_TARGETS
  63. // #define SIMULATE_DOS_TARGETS
  64. #endif
  65. #define MINIMAL_DISTANCE_ADC 400 //~30 meters
  66. // #define NO_MOTORS
  67. #ifndef ENCODER_8192
  68. #define ENCODER_7200
  69. #endif
  70. // #define PRF_KHZ 50000
  71. // #define PRF_KHZ 18000
  72. #define PRF_KHZ 14400
  73. // #define PRF_KHZ 12000
  74. #define B_MINIMAL_PF 2300
  75. #define Q_MINIMAL_PF 32000
  76. // #define Q_WORK_FREQ 48000
  77. #define Q_WORK_FREQ 57600
  78. // #define B_WORK_FREQ 6000
  79. #define B_WORK_FREQ 4000
  80. #define Q_SHIFT_DOWN_FOV 12.5f
  81. #define Q_RADIAN_SHIFT_DOWN_FOV 0.21816615649929119711546134606108f
  82. #define KERNEL_COUNT 8
  83. #ifdef ENCODER_8192_OLD
  84. #define Q_PULSE_START 448
  85. #define Q_PULSE_STOP 1600
  86. #define Q_PULSE_COUNT 1152 // 1152 or 576 or 288 depends on mode
  87. #define Q_MIRROR_COUNT 4
  88. #define Q_SCAN_COUNT 288
  89. #define Q_P_INTERLEAVE 4
  90. #define Q_Q_INTERLEAVE 2048
  91. #define Q_DEGREE_FOV 100.1953125f
  92. #define Q_RADIAN_FOV 1.7487380981896310018786198520208f
  93. #define Q_BLOCK_COUNT 8192
  94. #define M_BLOCK_COUNT 8192
  95. #define B_DEGREE_FOV 360.f
  96. #define B_RADIAN_FOV 6.283185307179586476925286766559f
  97. #define B_TIC_PER_V_SCAN 60
  98. #define B_BLOCK_COUNT 8192 // 94208
  99. #define B_P_INTERLEAVE 1
  100. #define BASE_COUNT 8192 // 94208
  101. #define BASE_SCAN_COUNT 288 // 128 or 64 depends on Mode
  102. #define M_SCAN_POINTS (BASE_SCAN_COUNT * KERNEL_COUNT)
  103. #define B_SCAN_COUNT ((BASE_SCAN_COUNT / Q_MIRROR_COUNT) / B_P_INTERLEAVE) // 128 or 64 depends on Mode
  104. #endif
  105. #ifdef ENCODER_8192
  106. #define Q_PULSE_START 453
  107. #define Q_PULSE_STOP 1605
  108. #define Q_PULSE_COUNT 1152 // 1152 or 576 or 288 depends on mode
  109. #define Q_MIRROR_COUNT 4
  110. #define Q_SCAN_COUNT 288
  111. #define Q_P_INTERLEAVE 4
  112. #define Q_Q_INTERLEAVE 2048
  113. #define Q_DEGREE_FOV 101.25f // 100.1953125f
  114. #define Q_RADIAN_FOV 1.7671458676442586966352369030947f
  115. #define Q_BLOCK_COUNT 8192
  116. #define M_BLOCK_COUNT 8192
  117. #define B_DEGREE_FOV 360.f
  118. #define B_RADIAN_FOV 6.283185307179586476925286766559f
  119. #define B_TIC_PER_V_SCAN 60
  120. #define B_BLOCK_COUNT 8192 // 94208
  121. #define B_P_INTERLEAVE 1
  122. #define BASE_COUNT 8192 // 94208
  123. #define BASE_SCAN_COUNT 288 // 128 or 64 depends on Mode
  124. #define M_SCAN_POINTS (BASE_SCAN_COUNT * KERNEL_COUNT)
  125. #define B_SCAN_COUNT ((BASE_SCAN_COUNT / Q_MIRROR_COUNT) / B_P_INTERLEAVE) // 128 or 64 depends on Mode
  126. #endif
  127. #ifdef ENCODER_7200
  128. #define Q_PULSE_START 324
  129. #define Q_PULSE_STOP 1476
  130. #define Q_PULSE_COUNT 1152 // 1000 or 500 or 250 depends on mode
  131. #define Q_MIRROR_COUNT 4
  132. #define Q_SCAN_COUNT 288
  133. #define Q_P_INTERLEAVE 4
  134. #define Q_Q_INTERLEAVE 1800
  135. #define Q_DEGREE_FOV 115.2f
  136. #define Q_RADIAN_FOV 2.0106192982974676726160917652989f
  137. #define Q_BLOCK_COUNT 7200
  138. #define B_P_INTERLEAVE 5
  139. #define B_DEGREE_FOV 360.f
  140. #define B_RADIAN_FOV 6.283185307179586476925286766559f
  141. #define B_BLOCK_COUNT 7200
  142. #define BASE_SCAN_COUNT 288
  143. #define M_SCAN_POINTS (BASE_SCAN_COUNT * KERNEL_COUNT)
  144. #define B_SCAN_COUNT ((BASE_SCAN_COUNT / Q_MIRROR_COUNT) / B_P_INTERLEAVE) // 128 or 64 depends on Mode
  145. #define B_TIC_PER_V_SCAN 100
  146. inline uint32_t checkInterleavePosibility(uint8_t Inter)
  147. {
  148. // Check Mirror Block Freq
  149. if (PRF_KHZ * Q_P_INTERLEAVE < Q_MINIMAL_PF)
  150. {
  151. return 0;
  152. }
  153. // Check Base Block Freq
  154. if ((B_TIC_PER_V_SCAN * Inter * ((PRF_KHZ * Q_P_INTERLEAVE) / Q_BLOCK_COUNT) /* Scans Per Second */) < B_MINIMAL_PF)
  155. {
  156. return 0;
  157. }
  158. return 1;
  159. }
  160. inline uint32_t findInterleave(void)
  161. {
  162. uint32_t index;
  163. for (index = 1; index < 10; index++)
  164. {
  165. if (checkInterleavePosibility(index))
  166. {
  167. break;
  168. }
  169. }
  170. return index;
  171. }
  172. #endif
  173. #define MAX_Q_PRF (PRF_KHZ * Q_P_INTERLEAVE)
  174. #define MAX_BASE_PRF (B_TIC_PER_V_SCAN * B_P_INTERLEAVE * ((PRF_KHZ * Q_P_INTERLEAVE) / Q_BLOCK_COUNT))
  175. #define P2P_PROPORTION (Q_BLOCK_COUNT / (B_TIC_PER_V_SCAN * B_P_INTERLEAVE)) //( MAX_Q_PRF / MAX_BASE_PRF )
  176. #define LGS_MAX_DETECTOR_ANGLES (BASE_SCAN_COUNT * KERNEL_COUNT * Q_SCAN_COUNT * Q_MIRROR_COUNT)
  177. #define LGS_REAL_DETECTOR_ANGLES LGS_MAX_DETECTOR_ANGLES
  178. #define LGS_MAX_BORDER_ANGLES LGS_REAL_DETECTOR_ANGLES
  179. #define LGS_MAX_DETECTOR_RANGE_INFINITE 4000
  180. #define LGS_MAX_DETECTOR_RANGE_OUTPUT 3999
  181. #define CLK_HZ(X) (200000000u / X)
  182. #define HZ_CLK(X) (200000000u / X)
  183. #define PWM_POLARITY_INVERSE 1
  184. /* V Motor Default setting */
  185. #define VM_WORK_PERIOD 100000 // 1 = 10 nSec
  186. #ifdef PWM_POLARITY_INVERSE
  187. // #define VM_WORK_DUTY_CYCLE 7100 // 7.1%
  188. #define VM_WORK_DUTY_CYCLE 8400 // 8.4%
  189. #else
  190. #define VM_WORK_DUTY_CYCLE 95000 // 95%
  191. #endif
  192. /* V Motor Speeed control settings */
  193. #define VM_FREQ_PER_TICK_M 12 // Motor Pulses
  194. #define VM_FREQ_PER_TICK_C 21 // PRU Clock Ticks
  195. /* H Motor Default setting */
  196. #define HM_WORK_PERIOD 100000 // 1 = 10 nSec
  197. #ifdef PWM_POLARITY_INVERSE
  198. // #define HM_WORK_DUTY_CYCLE 8888 // 8.888%
  199. #define HM_WORK_DUTY_CYCLE 5932 // 5.932%
  200. #else
  201. #define HM_WORK_DUTY_CYCLE 95000 // 95%
  202. #endif
  203. /* H Motor Speeed control settings */
  204. #define HM_FREQ_PER_TICK_M 12 // Motor Pulses
  205. #define HM_FREQ_PER_TICK_C 21 // PRU Clock Ticks
  206. typedef struct S_thresholdHeader
  207. {
  208. uint16_t countNodes;
  209. uint16_t countFlips;
  210. uint32_t sizeBytes;
  211. } thresholdHeader;
  212. typedef union U_thresholdNode
  213. {
  214. uint32_t data;
  215. struct S_values
  216. {
  217. uint32_t min : 12; // 11:0
  218. uint32_t max : 12; // 23:12
  219. #ifdef CHECK_SUN_BIT
  220. uint32_t sbit : 1; // 24:24
  221. uint32_t cnt : 7; // 32:25
  222. #else
  223. uint32_t cnt : 8; // 32:24
  224. #endif
  225. } values;
  226. } thresholdNode;
  227. typedef volatile thresholdNode vThresholdNode;
  228. typedef struct S_targetRecord
  229. {
  230. uint32_t width;
  231. uint32_t begin_id;
  232. uint32_t end_id;
  233. uint16_t range_min;
  234. uint16_t range_max;
  235. union
  236. {
  237. uint32_t status;
  238. struct
  239. {
  240. uint32_t active : 8;
  241. uint32_t lrf : 8;
  242. uint32_t type : 7;
  243. uint32_t w_cnt : 9; // Values 1 - Q_SCAN_COUNT (288)
  244. } flags;
  245. };
  246. } targetRecord;
  247. typedef volatile targetRecord vTargetRecord;
  248. typedef struct S_MO_STATUS
  249. {
  250. uint32_t online : 1;
  251. uint32_t lrf_en : 1;
  252. uint32_t h_motor_ok : 1;
  253. uint32_t v_motor_ok : 1;
  254. uint32_t h_motor_en : 1;
  255. uint32_t v_motor_en : 1;
  256. uint32_t inter_mode : 3;
  257. uint32_t simulate : 1;
  258. uint32_t param_err : 1;
  259. uint32_t sunbit_ena : 1;
  260. uint32_t rsrvd : 20;
  261. } MO_STATUS;
  262. typedef volatile MO_STATUS V_MO_STATUS;
  263. typedef struct
  264. {
  265. union
  266. {
  267. volatile uint32_t status;
  268. V_MO_STATUS flags;
  269. };
  270. volatile uint32_t v_target;
  271. volatile uint32_t h_target;
  272. volatile uint32_t cmd;
  273. } PRSS0_PRU0_IO;
  274. typedef struct
  275. {
  276. union
  277. {
  278. volatile uint32_t status;
  279. volatile struct
  280. {
  281. uint32_t online : 1;
  282. uint32_t work_en : 1;
  283. uint32_t h_motor_ok : 1;
  284. uint32_t v_motor_ok : 1;
  285. uint32_t h_motor_en : 1;
  286. uint32_t v_motor_en : 1;
  287. uint32_t rsrvd : 26;
  288. } flags;
  289. };
  290. volatile uint32_t cmd;
  291. } PRSS0_PRU1_IO;
  292. typedef struct
  293. {
  294. union
  295. {
  296. volatile uint32_t status;
  297. volatile struct
  298. {
  299. uint32_t online : 1;
  300. uint32_t work_en : 1;
  301. uint32_t mode : 2;
  302. uint32_t q_shift : 9; // 0 - 287
  303. uint32_t b_shift : 12; // 0 - 2303
  304. uint32_t rsrvd : 7;
  305. } flags;
  306. };
  307. volatile uint32_t cmd;
  308. } PRSS1_PRU0_IO;
  309. // Fields to Expose Detector statuses
  310. typedef struct
  311. {
  312. uint32_t online : 1;
  313. uint32_t work_en : 1;
  314. uint32_t mode : 2;
  315. uint32_t req : 1;
  316. uint32_t param_err : 1;
  317. uint32_t v_dencity : 4;
  318. uint32_t h_dencity : 4;
  319. uint32_t spike_th : 2;
  320. uint32_t rsrvd : 16;
  321. } DT_STATUS;
  322. typedef volatile DT_STATUS V_DT_STATUS;
  323. // Fields To Provide Detector Core with settings
  324. typedef struct
  325. {
  326. uint32_t order : 3; // 1 - 7
  327. uint32_t offset : 8; // 1 - 255
  328. uint32_t self_build_ena : 1; // 0 - 1
  329. uint32_t flip_size : 8; // 1 - 255
  330. uint32_t good_points : 4; // 1 - 15
  331. uint32_t delta : 7; // 1 - 127
  332. uint32_t master : 1;
  333. } TH_PARAMS;
  334. typedef volatile TH_PARAMS V_TH_PARAMS;
  335. typedef struct
  336. {
  337. union
  338. {
  339. volatile uint32_t status;
  340. V_DT_STATUS flags;
  341. };
  342. union
  343. {
  344. volatile uint32_t params;
  345. V_TH_PARAMS fields;
  346. };
  347. volatile uint32_t cmd;
  348. volatile uint32_t req;
  349. } PRSS1_PRU1_IO;
  350. enum
  351. {
  352. COREX_CLEAR_CMD = 0x0000,
  353. COREX_HALT = 0x0FFF,
  354. CORE0_LRF_ENABLE = 0x00A1,
  355. CORE0_LRF_DISABLE = 0x00A2,
  356. CORE0_V_CTRL_ENABLE = 0x00A3,
  357. CORE0_V_CTRL_DISABLE = 0x00A4,
  358. CORE0_H_CTRL_ENABLE = 0x00A5,
  359. CORE0_H_CTRL_DISABLE = 0x00A6,
  360. CORE0_START_MOTORS = 0x00A7,
  361. CORE0_STOP_MOTORS = 0x00A8,
  362. CORE0_SET_PARAMS = 0x00A9,
  363. CORE0_SET_ILV_MODE = 0x00AA,
  364. CORE0_SYM_ENABLE = 0x00AB,
  365. CORE0_SYM_DISABLE = 0x00AC,
  366. CORE0_RESET = 0x00FF,
  367. CORE1_WORK_ENABLE = 0x01A1,
  368. CORE1_V_CTRL_ENABLE = 0x01A3,
  369. CORE1_H_CTRL_ENABLE = 0x01A4,
  370. CORE1_RESET = 0x01FF,
  371. CORE2_WORK_ENABLE = 0x02A1,
  372. CORE2_RESET = 0x02FF,
  373. CORE3_WORK_DISABLE = 0x03A0,
  374. CORE3_WORK_ENABLE = 0x03A1,
  375. CORE3_SET_PARAMS = 0x03A2,
  376. CORE3_SRESET = 0x03AA,
  377. CORE3_RESET = 0x03FF,
  378. CORE3_REQ_FLIP_TH = 0xA3A1,
  379. CORE3_REQ_CLEAR_TH = 0xA3A2,
  380. CORE3_REQ_UNLOCK = 0xA3A3
  381. };
  382. #define TH_BASE 0x98000000
  383. #define TH_SIZE_MAX_BYTES 0x8000000
  384. #define TH_SIZE_MAX_U32B 0x2000000
  385. #define TH_NODE_SIZE 0x04
  386. /*
  387. #define TH_SIZE_NODES 0x288000
  388. #define TH_SIZE_BYTES 0xA20000
  389. #define TH_2ZONES_SIZE_BYTES 0x1440000
  390. */
  391. #ifndef TH_FULL_PER_LRF
  392. #define TH_PER_LRF
  393. #endif
  394. #ifdef TH_PER_MIRROR
  395. #ifdef ENCODER_7200
  396. #define TH_SIZE_NODES 0x288000
  397. #define TH_LINE_NODES 0x900
  398. #define TH_SIZE_BYTES 0xA20000
  399. #define TH_LINE_BYTES 0x2400
  400. #define TH_2ZONES_SIZE_BYTES 0x510000
  401. #define TH_16ZONES_SIZE_BYTES 0x2881000
  402. // #ifdef ROLLING_THRESHOLD
  403. // #define TH_24ZONES_SIZE_BYTES 0x3CC0000
  404. // #endif
  405. #else
  406. #define TH_SIZE_NODES (M_SCAN_POINTS * Q_SCAN_COUNT) // 0xA2000
  407. #define TH_LINE_NODES M_SCAN_POINTS // 0x900
  408. #define TH_SIZE_BYTES (TH_SIZE_NODES << 2) // 0x288000
  409. #define TH_LINE_BYTES (TH_LINE_NODES << 2) // 0x2400
  410. #define TH_2ZONES_SIZE_BYTES (TH_SIZE_BYTES << 1) // 0x510000
  411. #define TH_16ZONES_SIZE_BYTES (TH_SIZE_BYTES << 4) // 0x2881000
  412. // #ifdef ROLLING_THRESHOLD
  413. // #define TH_24ZONES_SIZE_BYTES ( TH_SIZE_BYTES << 4 + TH_SIZE_BYTES << 3 )
  414. // #endif
  415. #endif
  416. #ifdef TH_PER_LRF
  417. #define TH_KERNEL_SIZE_NODES 0x14400
  418. #define TH_KERNEL_LINE_NODES 0x120
  419. #endif
  420. #define TARGET_BASE 0x9A880000 // TH_BASE + 0x2880000
  421. #define MAX_TARGETS_COUNT 32
  422. #define TARGET_ZONE_SIZE 0x4000 //( sizeof(targetRecord) * MAX_TARGETS_COUNT )
  423. #else // !TH_PER_MIRROR
  424. #ifdef ENCODER_7200
  425. #define TH_SIZE_NODES 0xA2000
  426. #define TH_LINE_NODES 0x900
  427. #define TH_SIZE_BYTES 0x288000
  428. #define TH_LINE_BYTES 0x2400
  429. #define TH_2ZONES_SIZE_BYTES 0x510000
  430. #define TH_16ZONES_SIZE_BYTES 0x2881000
  431. // #ifdef ROLLING_THRESHOLD
  432. // #define TH_24ZONES_SIZE_BYTES 0x3CC0000
  433. // #endif
  434. #else
  435. #define TH_SIZE_NODES (M_SCAN_POINTS * Q_SCAN_COUNT) // 0xA2000
  436. #define TH_LINE_NODES M_SCAN_POINTS // 0x900
  437. #define TH_SIZE_BYTES (TH_SIZE_NODES << 2) // 0x288000
  438. #define TH_LINE_BYTES (TH_LINE_NODES << 2) // 0x2400
  439. #define TH_2ZONES_SIZE_BYTES (TH_SIZE_BYTES << 1) // 0x510000
  440. #define TH_16ZONES_SIZE_BYTES (TH_SIZE_BYTES << 4) // 0x2881000
  441. // #ifdef ROLLING_THRESHOLD
  442. // #define TH_24ZONES_SIZE_BYTES ( TH_SIZE_BYTES << 4 + TH_SIZE_BYTES << 3 )
  443. // #endif
  444. #endif
  445. #ifdef TH_PER_LRF
  446. #define TH_KERNEL_SIZE_NODES 0x14400
  447. #define TH_KERNEL_LINE_NODES 0x120
  448. #endif
  449. #define TARGET_BASE 0x9A880000 // TH_BASE + 0x2880000
  450. #define MAX_TARGETS_COUNT 32
  451. #define TARGET_ZONE_SIZE 0x4000 //( sizeof(targetRecord) * MAX_TARGETS_COUNT )
  452. #endif //! TH_PER_MIRROR
  453. #define SCANS_TO_FLIP 16
  454. #define SIGNAL_OFFSET 32
  455. #define SIGNAL_ORDER 3
  456. #define SIGNAL_DELTA 64
  457. #define TH_POINT_GOOD 8
  458. #define TARGET_WHITE 1
  459. #define TARGET_BLACK 2
  460. #define FLIP_COMPLETE 3
  461. #define SCAN_COMPLETE 4
  462. #define SCAN_FROZEN 5
  463. #define MIRROR_FINISHED 6
  464. #define ERROR_ANGLE 7
  465. #define ADC0_EVENT 53
  466. #define ADC1_EVENT 34
  467. #ifndef am4378
  468. inline void make3Drad(uint32_t sid, float & az, float & el, bool master = true)
  469. {
  470. if (master)
  471. {
  472. el = (float) (sid / TH_LINE_NODES) * (Q_RADIAN_FOV / Q_SCAN_COUNT) - Q_RADIAN_SHIFT_DOWN_FOV;
  473. }
  474. else
  475. {
  476. el = (Q_SCAN_COUNT - (float) (sid / TH_LINE_NODES)) * (Q_RADIAN_FOV / Q_BLOCK_COUNT) - Q_RADIAN_SHIFT_DOWN_FOV;
  477. };
  478. az = ((float) (TH_LINE_NODES - (sid % TH_LINE_NODES))) * (B_RADIAN_FOV / (float) M_SCAN_POINTS);
  479. }
  480. inline void make3Ddeg(uint32_t sid, float & az, float & el, bool master = true)
  481. {
  482. az = ((float) (TH_LINE_NODES - (sid % TH_LINE_NODES))) * (B_DEGREE_FOV / (float) M_SCAN_POINTS);
  483. if (master)
  484. {
  485. el = 90.0f - (float) (sid / TH_LINE_NODES) * (Q_DEGREE_FOV / Q_SCAN_COUNT) - Q_SHIFT_DOWN_FOV;
  486. }
  487. else
  488. {
  489. el = 90.0f - (Q_SCAN_COUNT - (float) (sid / TH_LINE_NODES)) * (Q_DEGREE_FOV / Q_BLOCK_COUNT) - Q_SHIFT_DOWN_FOV;
  490. };
  491. if (el < 0)
  492. {
  493. el *= -1.0f;
  494. az = az + 180.0f;
  495. if (az > 360.0f)
  496. {
  497. az = az - 360.0f;
  498. }
  499. };
  500. }
  501. inline void make3Dmildeg(uint32_t sid, float & az, float & el, bool master = true)
  502. {
  503. if (master)
  504. {
  505. el = 1000.f * (((float) Q_DEGREE_FOV) - (float) (sid / TH_LINE_NODES) * (Q_DEGREE_FOV / Q_SCAN_COUNT) - Q_SHIFT_DOWN_FOV);
  506. }
  507. else
  508. {
  509. el = 1000.f * (((float) Q_DEGREE_FOV) - (Q_SCAN_COUNT - (float) (sid / TH_LINE_NODES)) * (Q_DEGREE_FOV / Q_BLOCK_COUNT) - Q_SHIFT_DOWN_FOV);
  510. };
  511. az = 360000.f - 1000.f * ((float) (TH_LINE_NODES - (sid % TH_LINE_NODES))) * (B_DEGREE_FOV / (float) M_SCAN_POINTS);
  512. if (el < 0)
  513. {
  514. el = -1.f * el;
  515. az = (float) (((int) az + 180000) % 360000);
  516. };
  517. }
  518. inline void makeXY(uint32_t sid, uint16_t & x, uint16_t & y, bool Master = true)
  519. {
  520. if (Master)
  521. {
  522. y = sid / TH_LINE_NODES;
  523. }
  524. else
  525. {
  526. y = Q_SCAN_COUNT - (sid / TH_LINE_NODES);
  527. };
  528. x = sid % TH_LINE_NODES;
  529. }
  530. // inline void makeCds( uint32_t sid, int &x, int &y, bool Master = true ){
  531. // if( Master ){
  532. // y = Q_SCAN_COUNT - ( sid / TH_LINE_NODES );
  533. // } else {
  534. // y = ( sid / TH_LINE_NODES );
  535. // };
  536. // x = sid % TH_LINE_NODES;
  537. // };
  538. inline uint32_t makeIds(int x, int y, bool Master = true)
  539. {
  540. return (Master) ? (Q_SCAN_COUNT - y - 1) * TH_LINE_NODES + x : y * TH_LINE_NODES + x;
  541. }
  542. inline uint32_t interpolate(int color1, int color2, float progress)
  543. {
  544. int a1 = (color1 & 0xff000000) >> 24;
  545. int r1 = (color1 & 0x00ff0000) >> 16;
  546. int g1 = (color1 & 0x0000ff00) >> 8;
  547. int b1 = color1 & 0x000000ff;
  548. int a2 = (color2 & 0xff000000) >> 24;
  549. int r2 = (color2 & 0x00ff0000) >> 16;
  550. int g2 = (color2 & 0x0000ff00) >> 8;
  551. int b2 = color2 & 0x000000ff;
  552. float progress2 = (1 - progress);
  553. int newA = (int) (a1 * progress2 + a2 * progress);
  554. int newR = (int) (r1 * progress2 + r2 * progress);
  555. int newG = (int) (g1 * progress2 + g2 * progress);
  556. int newB = (int) (b1 * progress2 + b2 * progress);
  557. return (newA << 24) + (newR << 16) + (newG << 8) + newB;
  558. }
  559. inline uint32_t makeSID(int kID, int qID, int bID)
  560. {
  561. int cid;
  562. int cqid;
  563. // int mid;
  564. int ccp;
  565. int opp;
  566. cqid = qID % Q_Q_INTERLEAVE;
  567. if (cqid < Q_PULSE_START)
  568. {
  569. cqid = Q_PULSE_START;
  570. }
  571. if (cqid > Q_PULSE_STOP)
  572. {
  573. cqid = Q_PULSE_STOP;
  574. }
  575. bID += (kID * 7) >> 1; // X * 3.5
  576. ccp = bID / (B_BLOCK_COUNT / BASE_SCAN_COUNT);
  577. opp = ccp % B_P_INTERLEAVE;
  578. cid = ccp + 72 * opp + cqid / 4;
  579. // qDebug() << "K_ID:" << kID << " Q_ID:" << qID << " B_ID:" << bID << "\tSpin:" << opp << "Mirror:" << (ccp % 4) << "M-spin:" << ((ccp + 72 * opp) >> 4) << "\tID:" << cid;
  580. return cid;
  581. }
  582. inline bool makeCoords(uint16_t Range, uint32_t sid, int & x, int & y, int & mid, int & seg, bool Master = true)
  583. {
  584. mid = 0;
  585. seg = 0;
  586. if (Master)
  587. {
  588. y = Q_SCAN_COUNT - (sid / TH_LINE_NODES) - 1;
  589. }
  590. else
  591. {
  592. y = (sid / TH_LINE_NODES) - 1;
  593. };
  594. x = sid % TH_LINE_NODES;
  595. if (Range > 4000)
  596. {
  597. return false;
  598. }
  599. return true;
  600. }
  601. inline int makeIdx(int x, int y, bool Master = true)
  602. {
  603. return (Master) ? (288 - y) * TH_LINE_NODES + x : y * TH_LINE_NODES + x;
  604. }
  605. inline bool makeCoords_121(uint16_t Range, uint32_t sid, int & x, int & y, int & mid, int & seg, bool Master = true)
  606. {
  607. int Kernel;
  608. int cMirror;
  609. //int cSpinID;
  610. //int cBaseSpinID;
  611. int cScanID;
  612. int cBaseSegment;
  613. //int cBaseShift;
  614. int cMirrorShift;
  615. int cPulseID;
  616. float fPix = 0;
  617. float fPixStp = (2304.f * 5.f) / 129600.f; // 0.013888888888888888888888888888889f;//0.64222f; //0.64f; //0.16f;
  618. mid = 0;
  619. seg = 0;
  620. Kernel = sid % KERNEL_COUNT; // ok
  621. cPulseID = (int) (sid / KERNEL_COUNT); // ok
  622. cScanID = (int) (cPulseID / Q_SCAN_COUNT); // ok
  623. cMirror = cScanID % 4; // ok
  624. cMirrorShift = cPulseID % Q_SCAN_COUNT; // ok
  625. //cSpinID = (int) (cPulseID / (Q_MIRROR_COUNT * Q_SCAN_COUNT)); // ok
  626. //cBaseSpinID = (int) (cScanID / (BASE_SCAN_COUNT / (B_P_INTERLEAVE * Q_MIRROR_COUNT)));
  627. cBaseSegment = cScanID % (BASE_SCAN_COUNT / (B_P_INTERLEAVE * Q_MIRROR_COUNT));
  628. //cBaseShift = (81 + cMirrorShift) % 450;
  629. mid = cMirror;
  630. seg = cBaseSegment;
  631. if (Master)
  632. {
  633. y = Q_SCAN_COUNT - cMirrorShift - 2;
  634. }
  635. else
  636. {
  637. y = cMirrorShift;
  638. };
  639. // qDebug() << "Pid:" << cPulseID << " ScanID:" << cScanID;
  640. fPix = fPixStp * (float) (81 + cPulseID + cScanID * 162) + 7.0f - (float) Kernel;
  641. x = ((int) fPix) % 2304;
  642. // if( x != (int)fPix ) qDebug() << "Pix:" << fPix << " x:" << x;
  643. if (Range > 4000)
  644. {
  645. return false;
  646. }
  647. return true;
  648. }
  649. inline bool makePixel(uint16_t Range, uint32_t sid, int & x, int & y, int & mid, int & seg, bool Master = true)
  650. {
  651. int Kernel;
  652. mid = 0;
  653. seg = 0;
  654. Kernel = sid % KERNEL_COUNT;
  655. if (B_P_INTERLEAVE > 1)
  656. {
  657. int cMirror;
  658. //int cSpinID;
  659. int cBaseSpinID;
  660. int cScanID;
  661. int cBaseSegment;
  662. //int cBaseShift;
  663. int cMirrorShift;
  664. int cPulseID;
  665. // https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects
  666. cPulseID = (int) (sid / KERNEL_COUNT);
  667. cScanID = (int) (cPulseID / Q_SCAN_COUNT);
  668. cMirror = cScanID % 4;
  669. cMirrorShift = cPulseID % Q_SCAN_COUNT;
  670. //cSpinID = (int) (cPulseID / (Q_MIRROR_COUNT * Q_SCAN_COUNT));
  671. cBaseSpinID = (int) (cScanID / 96);
  672. // cBaseSegment = (int)(cScanID / 96) + cScanID % 96;//((BASE_SCAN_COUNT / Q_MIRROR_COUNT )/ B_P_INTERLEAVE );
  673. cBaseSegment = cScanID % 96;
  674. //cBaseShift = (81 + cMirrorShift) % 450; //((BASE_SCAN_COUNT / Q_MIRROR_COUNT )/ B_P_INTERLEAVE ); //(cPulseID / (Q_MIRROR_COUNT * Q_SCAN_COUNT)) % B_SCAN_COUNT;
  675. mid = cMirror;
  676. seg = cBaseSegment;
  677. if (Master)
  678. {
  679. y = Q_SCAN_COUNT - cMirrorShift;
  680. }
  681. else
  682. {
  683. y = cMirrorShift;
  684. };
  685. x = (cBaseSegment * B_P_INTERLEAVE * KERNEL_COUNT) +
  686. cBaseSpinID * KERNEL_COUNT + // 7 -
  687. //( cBaseShift * B_P_INTERLEAVE ) / 450 +
  688. Kernel;
  689. }
  690. else
  691. {
  692. x = y = 0;
  693. };
  694. if (Range > 4000)
  695. {
  696. return false;
  697. }
  698. return true;
  699. }
  700. #endif
  701. #endif