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.
801 lines
21 KiB
801 lines
21 KiB
#ifndef __3D_LRF_GENERAL_SETTINGS_HEADER__
|
|
#define __3D_LRF_GENERAL_SETTINGS_HEADER__
|
|
|
|
typedef enum E_LRF_WORK_MODE{
|
|
WM_NONE = 0x00,
|
|
WM_INIT = 0x01,
|
|
WM_STUDY = 0x02,
|
|
WM_DETECTOR = 0x03,
|
|
WM_RESET = 0x04,
|
|
WM_BORDER = 0x05,
|
|
WM_FILE = 0x06,
|
|
WM_ERROR = 0xFF
|
|
}LRF_WORK_MODE;
|
|
|
|
#ifdef __linux__
|
|
#ifndef __GUI__
|
|
extern SOFTWARE_INFO gsSOFT_INFO;
|
|
#endif
|
|
#endif
|
|
|
|
#define SKIP_TARGET_LOG
|
|
//#define HIBERNATE_ENABLE
|
|
#define THREADED_FLIP
|
|
#define TH_JUST_UPDATE_WORKING
|
|
#define TH_FORCED_BOOM_CLEAN
|
|
//#define TH_PER_MIRROR
|
|
#define TH_FULL_PER_LRF
|
|
#define TH_NEW_FLIP_FUNC
|
|
#define STRONG_STAT
|
|
#define TRACKER_INSTANT_TARGET
|
|
//#define TRACKER_FULL_COMPARE
|
|
//#define SIMULATE_TARGETS
|
|
//#define SIMULATE_FLIPS
|
|
|
|
#define CHECK_SUN_BIT
|
|
#define THREADED_MOTORS_START
|
|
#define NO_BLACK_TARGETS
|
|
//#define SHIFT_50 683
|
|
#define TGD
|
|
|
|
|
|
#ifdef TGD
|
|
#define ENCODER_8192
|
|
#define TGD_VERSION_2
|
|
#define CHID_TAG_USED
|
|
#define PULSE_ALWAYS
|
|
// #define ADC_SYMUL_MODE
|
|
#endif
|
|
|
|
#ifdef PULSE_ALWAYS
|
|
#define PULSE_PREPULSES 40
|
|
#endif
|
|
|
|
#ifdef SIMULATE_TARGETS
|
|
#define SIMULATE_DOS_TARGETS
|
|
#endif
|
|
|
|
#define MINIMAL_DISTANCE_ADC 400 //~30 meters
|
|
//#define NO_MOTORS
|
|
|
|
#define PRU_SLAVE
|
|
|
|
#ifndef ENCODER_8192
|
|
#define ENCODER_7200
|
|
#endif
|
|
|
|
//#define PRF_KHZ 50000
|
|
//#define PRF_KHZ 18000
|
|
#define PRF_KHZ 14400
|
|
//#define PRF_KHZ 12000
|
|
|
|
#define B_MINIMAL_PF 2300
|
|
#define Q_MINIMAL_PF 32000
|
|
|
|
//#define Q_WORK_FREQ 48000
|
|
#define Q_WORK_FREQ 57600
|
|
//#define B_WORK_FREQ 6000
|
|
#define B_WORK_FREQ 4000
|
|
#define Q_SHIFT_DOWN_FOV 12.5f
|
|
#define Q_RADIAN_SHIFT_DOWN_FOV 0.21816615649929119711546134606108f
|
|
|
|
#define KERNEL_COUNT 8
|
|
|
|
#ifdef ENCODER_8192_OLD
|
|
|
|
#define Q_PULSE_START 448
|
|
|
|
#define Q_PULSE_STOP 1600
|
|
|
|
#define Q_PULSE_COUNT 1152 // 1152 or 576 or 288 depends on mode
|
|
|
|
#define Q_MIRROR_COUNT 4
|
|
|
|
#define Q_SCAN_COUNT 288
|
|
|
|
#define Q_P_INTERLEAVE 4
|
|
|
|
#define Q_Q_INTERLEAVE 2048
|
|
|
|
#define Q_DEGREE_FOV 100.1953125f
|
|
#define Q_RADIAN_FOV 1.7487380981896310018786198520208f
|
|
|
|
#define Q_BLOCK_COUNT 8192
|
|
|
|
#define M_BLOCK_COUNT 8192
|
|
|
|
#define B_DEGREE_FOV 360.f
|
|
#define B_RADIAN_FOV 6.283185307179586476925286766559f
|
|
|
|
#define B_TIC_PER_V_SCAN 60
|
|
|
|
#define B_BLOCK_COUNT 8192// 94208
|
|
|
|
#define B_P_INTERLEAVE 1
|
|
|
|
#define BASE_COUNT 8192// 94208
|
|
|
|
#define BASE_SCAN_COUNT 288 // 128 or 64 depends on Mode
|
|
|
|
#define M_SCAN_POINTS ( BASE_SCAN_COUNT * KERNEL_COUNT )
|
|
|
|
#define B_SCAN_COUNT (( BASE_SCAN_COUNT / Q_MIRROR_COUNT ) / B_P_INTERLEAVE ) // 128 or 64 depends on Mode
|
|
|
|
#endif
|
|
|
|
#ifdef ENCODER_8192
|
|
|
|
#define Q_PULSE_START 453
|
|
|
|
#define Q_PULSE_STOP 1605
|
|
|
|
#define Q_PULSE_COUNT 1152 // 1152 or 576 or 288 depends on mode
|
|
|
|
#define Q_MIRROR_COUNT 4
|
|
|
|
#define Q_SCAN_COUNT 288
|
|
|
|
#define Q_P_INTERLEAVE 4
|
|
|
|
#define Q_Q_INTERLEAVE 2048
|
|
|
|
#define Q_DEGREE_FOV 100.1953125f
|
|
#define Q_RADIAN_FOV 1.7487380981896310018786198520208f
|
|
|
|
#define Q_BLOCK_COUNT 8192
|
|
|
|
#define M_BLOCK_COUNT 8192
|
|
|
|
#define B_DEGREE_FOV 360.f
|
|
#define B_RADIAN_FOV 6.283185307179586476925286766559f
|
|
|
|
#define B_TIC_PER_V_SCAN 60
|
|
|
|
#define B_BLOCK_COUNT 8192// 94208
|
|
|
|
#define B_P_INTERLEAVE 1
|
|
|
|
#define BASE_COUNT 8192// 94208
|
|
|
|
#define BASE_SCAN_COUNT 288 // 128 or 64 depends on Mode
|
|
|
|
#define M_SCAN_POINTS ( BASE_SCAN_COUNT * KERNEL_COUNT )
|
|
|
|
#define B_SCAN_COUNT (( BASE_SCAN_COUNT / Q_MIRROR_COUNT ) / B_P_INTERLEAVE ) // 128 or 64 depends on Mode
|
|
|
|
#endif
|
|
|
|
|
|
#ifdef ENCODER_7200
|
|
|
|
#define Q_PULSE_START 324
|
|
|
|
#define Q_PULSE_STOP 1476
|
|
|
|
#define Q_PULSE_COUNT 1152 // 1000 or 500 or 250 depends on mode
|
|
|
|
#define Q_MIRROR_COUNT 4
|
|
|
|
#define Q_SCAN_COUNT 288
|
|
|
|
#define Q_P_INTERLEAVE 4
|
|
|
|
#define Q_Q_INTERLEAVE 1800
|
|
|
|
#define Q_DEGREE_FOV 115.2f
|
|
#define Q_RADIAN_FOV 2.0106192982974676726160917652989f
|
|
|
|
#define Q_BLOCK_COUNT 7200
|
|
|
|
#define B_P_INTERLEAVE 5
|
|
|
|
#define B_DEGREE_FOV 360.f
|
|
#define B_RADIAN_FOV 6.283185307179586476925286766559f
|
|
|
|
#define B_BLOCK_COUNT 7200
|
|
|
|
#define BASE_SCAN_COUNT 288
|
|
|
|
#define M_SCAN_POINTS ( BASE_SCAN_COUNT * KERNEL_COUNT )
|
|
|
|
#define B_SCAN_COUNT (( BASE_SCAN_COUNT / Q_MIRROR_COUNT ) / B_P_INTERLEAVE ) // 128 or 64 depends on Mode
|
|
|
|
#define B_TIC_PER_V_SCAN 100
|
|
|
|
inline uint32_t checkInterleavePosibility( uint8_t Inter ){
|
|
// Check Mirror Block Freq
|
|
if( PRF_KHZ * Q_P_INTERLEAVE < Q_MINIMAL_PF ) return 0;
|
|
// Check Base Block Freq
|
|
if( ( B_TIC_PER_V_SCAN * Inter * (( PRF_KHZ * Q_P_INTERLEAVE ) / Q_BLOCK_COUNT ) /* Scans Per Second */ ) < B_MINIMAL_PF ) return 0;
|
|
return 1;
|
|
};
|
|
|
|
inline uint32_t findInterleave( void ){
|
|
uint32_t index;
|
|
for( index = 1; index < 10; index++ ) if( checkInterleavePosibility(index)) break;
|
|
return index;
|
|
};
|
|
|
|
|
|
#endif
|
|
|
|
|
|
#define MAX_Q_PRF ( PRF_KHZ * Q_P_INTERLEAVE )
|
|
#define MAX_BASE_PRF ( B_TIC_PER_V_SCAN * B_P_INTERLEAVE * (( PRF_KHZ * Q_P_INTERLEAVE ) / Q_BLOCK_COUNT ))
|
|
#define P2P_PROPORTION ( Q_BLOCK_COUNT /( B_TIC_PER_V_SCAN * B_P_INTERLEAVE ) ) //( MAX_Q_PRF / MAX_BASE_PRF )
|
|
|
|
|
|
#define LGS_MAX_DETECTOR_ANGLES (BASE_SCAN_COUNT*KERNEL_COUNT*Q_SCAN_COUNT*Q_MIRROR_COUNT)
|
|
|
|
#define LGS_REAL_DETECTOR_ANGLES LGS_MAX_DETECTOR_ANGLES
|
|
|
|
#define LGS_MAX_BORDER_ANGLES LGS_REAL_DETECTOR_ANGLES
|
|
|
|
#define LGS_MAX_DETECTOR_RANGE_INFINITE 4000
|
|
#define LGS_MAX_DETECTOR_RANGE_OUTPUT 3999
|
|
|
|
#define CLK_HZ(X) ( 200000000u / X )
|
|
#define HZ_CLK(X) ( 200000000u / X )
|
|
|
|
#define PWM_POLARITY_INVERSE 1
|
|
|
|
/* V Motor Default setting */
|
|
#define VM_WORK_PERIOD 100000 // 1 = 10 nSec
|
|
|
|
#ifdef PWM_POLARITY_INVERSE
|
|
//#define VM_WORK_DUTY_CYCLE 7100 // 7.1%
|
|
#define VM_WORK_DUTY_CYCLE 8400 // 8.4%
|
|
#else
|
|
#define VM_WORK_DUTY_CYCLE 95000 // 95%
|
|
#endif
|
|
|
|
/* V Motor Speeed control settings */
|
|
#define VM_FREQ_PER_TICK_M 12 // Motor Pulses
|
|
#define VM_FREQ_PER_TICK_C 21 // PRU Clock Ticks
|
|
|
|
/* H Motor Default setting */
|
|
#define HM_WORK_PERIOD 100000 // 1 = 10 nSec
|
|
|
|
#ifdef PWM_POLARITY_INVERSE
|
|
//#define HM_WORK_DUTY_CYCLE 8888 // 8.888%
|
|
#define HM_WORK_DUTY_CYCLE 5932 // 5.932%
|
|
#else
|
|
#define HM_WORK_DUTY_CYCLE 95000 // 95%
|
|
#endif
|
|
|
|
/* H Motor Speeed control settings */
|
|
#define HM_FREQ_PER_TICK_M 12 // Motor Pulses
|
|
#define HM_FREQ_PER_TICK_C 21 // PRU Clock Ticks
|
|
|
|
typedef struct S_thresholdHeader{
|
|
uint16_t countNodes;
|
|
uint16_t countFlips;
|
|
uint32_t sizeBytes;
|
|
} thresholdHeader;
|
|
|
|
typedef union U_thresholdNode{
|
|
uint32_t data;
|
|
struct S_values{
|
|
uint32_t min: 12; // 11:0
|
|
uint32_t max: 12; // 23:12
|
|
#ifdef CHECK_SUN_BIT
|
|
uint32_t sbit: 1; // 24:24
|
|
uint32_t cnt: 7; // 32:25
|
|
#else
|
|
uint32_t cnt: 8; // 32:24
|
|
#endif
|
|
} values;
|
|
} thresholdNode;
|
|
|
|
typedef volatile thresholdNode vThresholdNode;
|
|
|
|
typedef struct S_targetRecord{
|
|
uint32_t width;
|
|
uint32_t begin_id;
|
|
uint32_t end_id;
|
|
union{
|
|
uint32_t status;
|
|
struct {
|
|
uint32_t active: 8;
|
|
uint32_t lrf: 8;
|
|
uint32_t type: 7;
|
|
uint32_t w_cnt: 9; // Values 1 - Q_SCAN_COUNT (288)
|
|
} flags;
|
|
};
|
|
} targetRecord;
|
|
|
|
typedef volatile targetRecord vTargetRecord;
|
|
|
|
typedef struct S_MO_STATUS{
|
|
uint32_t online: 1;
|
|
uint32_t lrf_en: 1;
|
|
uint32_t h_motor_ok: 1;
|
|
uint32_t v_motor_ok: 1;
|
|
uint32_t h_motor_en: 1;
|
|
uint32_t v_motor_en: 1;
|
|
uint32_t inter_mode: 3;
|
|
uint32_t simulate: 1;
|
|
uint32_t param_err: 1;
|
|
uint32_t sunbit_ena: 1;
|
|
uint32_t rsrvd: 20;
|
|
} MO_STATUS;
|
|
|
|
typedef volatile MO_STATUS V_MO_STATUS;
|
|
|
|
typedef struct{
|
|
union{
|
|
volatile uint32_t status;
|
|
V_MO_STATUS flags;
|
|
};
|
|
volatile uint32_t v_target;
|
|
volatile uint32_t h_target;
|
|
volatile uint32_t cmd;
|
|
} PRSS0_PRU0_IO;
|
|
|
|
|
|
typedef struct{
|
|
union{
|
|
volatile uint32_t status;
|
|
volatile struct{
|
|
uint32_t online: 1;
|
|
uint32_t work_en: 1;
|
|
uint32_t h_motor_ok: 1;
|
|
uint32_t v_motor_ok: 1;
|
|
uint32_t h_motor_en: 1;
|
|
uint32_t v_motor_en: 1;
|
|
uint32_t rsrvd: 26;
|
|
} flags;
|
|
};
|
|
volatile uint32_t cmd;
|
|
} PRSS0_PRU1_IO;
|
|
|
|
typedef struct{
|
|
union{
|
|
volatile uint32_t status;
|
|
volatile struct{
|
|
uint32_t online: 1;
|
|
uint32_t work_en: 1;
|
|
uint32_t mode: 2;
|
|
uint32_t q_shift: 9; // 0 - 287
|
|
uint32_t b_shift: 12; // 0 - 2303
|
|
uint32_t rsrvd: 7;
|
|
} flags;
|
|
};
|
|
volatile uint32_t cmd;
|
|
} PRSS1_PRU0_IO;
|
|
|
|
// Fields to Expose Detector statuses
|
|
typedef struct{
|
|
uint32_t online: 1;
|
|
uint32_t work_en: 1;
|
|
uint32_t mode: 2;
|
|
uint32_t req: 1;
|
|
uint32_t param_err: 1;
|
|
uint32_t v_dencity: 4;
|
|
uint32_t h_dencity: 4;
|
|
uint32_t spike_th: 2;
|
|
uint32_t rsrvd: 16;
|
|
} DT_STATUS;
|
|
typedef volatile DT_STATUS V_DT_STATUS;
|
|
|
|
// Fields To Provide Detector Core with settings
|
|
typedef struct{
|
|
uint32_t order: 3;// 1 - 7
|
|
uint32_t offset: 8;// 1 - 255
|
|
uint32_t self_build_ena: 1;// 0 - 1
|
|
uint32_t flip_size: 8;// 1 - 255
|
|
uint32_t good_points: 4;// 1 - 15
|
|
uint32_t delta: 7;// 1 - 127
|
|
uint32_t master: 1;
|
|
} TH_PARAMS;
|
|
|
|
typedef volatile TH_PARAMS V_TH_PARAMS;
|
|
typedef struct{
|
|
union{
|
|
volatile uint32_t status;
|
|
V_DT_STATUS flags;
|
|
};
|
|
union{
|
|
volatile uint32_t params;
|
|
V_TH_PARAMS fields;
|
|
};
|
|
volatile uint32_t cmd;
|
|
volatile uint32_t req;
|
|
} PRSS1_PRU1_IO;
|
|
|
|
typedef struct S_HW_PARAMS{
|
|
uint32_t Q_shift: 9;
|
|
uint32_t B_shift: 12;
|
|
uint32_t AutostartMotors: 1;
|
|
uint32_t SignalSimulator: 1;
|
|
uint32_t BBinterlace: 3;
|
|
uint32_t Spike_TH: 2;
|
|
uint32_t Sunbit_filter: 1;
|
|
uint32_t popo: 3;
|
|
//---------------------------------
|
|
uint16_t HorizontalFreq;
|
|
uint16_t VerticalFreq;
|
|
//---------------------------------
|
|
uint16_t MirrorScanCount; // Encoder Counts ?
|
|
uint16_t BaseScanCount;
|
|
//---------------------------------
|
|
uint8_t MirrorsCount;
|
|
uint8_t DetectorsCount;
|
|
//---------------------------------
|
|
uint16_t isMaster: 1;
|
|
uint16_t LaserPulsesOn: 1;
|
|
uint16_t VerticalMotorOn: 1;
|
|
uint16_t HorizontalMotorOn: 1;
|
|
uint16_t BuildThByCore: 1;
|
|
uint16_t DryContactMode1: 1;
|
|
uint16_t DryContactStatus1: 1;
|
|
uint16_t DryContactMode2: 1;
|
|
uint16_t DryContactStatus2: 1;
|
|
uint16_t QQinterlace: 3;
|
|
uint16_t TGZ_canENA: 1;
|
|
uint16_t TGZ_canBus: 1;
|
|
uint16_t TGZ_divider: 2;
|
|
//----------------------------------
|
|
uint16_t TGZ_ParamQ;
|
|
//----------------------------------
|
|
uint16_t TGZ_ParamB;
|
|
//----------------------------------
|
|
uint16_t TGZ_canSRC;
|
|
uint16_t TGZ_canDST;
|
|
} HW_PARAMS, *PHW_PARAMS;
|
|
|
|
typedef struct S_LGS_PARAMETERS{
|
|
uint8_t nOrder;
|
|
uint8_t nOffset;
|
|
uint8_t nDelta;
|
|
uint8_t nSun;
|
|
uint8_t bSST;
|
|
uint16_t nFlip; // For Quick models (pls30) must be up to 1024
|
|
uint32_t nWidth; // With future devices may gain big numbers
|
|
/* 3D LRF Specific */
|
|
uint8_t nGPointSamples;
|
|
|
|
union{
|
|
uint8_t flags_binary[sizeof(HW_PARAMS)];
|
|
HW_PARAMS flags;
|
|
};
|
|
} LGS_PARAMETERS, *PLGS_PARAMETERS;
|
|
|
|
|
|
enum {
|
|
COREX_CLEAR_CMD = 0x0000,
|
|
COREX_HALT = 0x0FFF,
|
|
|
|
CORE0_LRF_ENABLE = 0x00A1,
|
|
CORE0_LRF_DISABLE = 0x00A2,
|
|
CORE0_V_CTRL_ENABLE = 0x00A3,
|
|
CORE0_V_CTRL_DISABLE= 0x00A4,
|
|
CORE0_H_CTRL_ENABLE = 0x00A5,
|
|
CORE0_H_CTRL_DISABLE= 0x00A6,
|
|
CORE0_START_MOTORS = 0x00A7,
|
|
CORE0_STOP_MOTORS = 0x00A8,
|
|
CORE0_SET_PARAMS = 0x00A9,
|
|
CORE0_SET_ILV_MODE = 0x00AA,
|
|
CORE0_SYM_ENABLE = 0x00AB,
|
|
CORE0_SYM_DISABLE = 0x00AC,
|
|
CORE0_RESET = 0x00FF,
|
|
|
|
CORE1_WORK_ENABLE = 0x01A1,
|
|
CORE1_V_CTRL_ENABLE = 0x01A3,
|
|
CORE1_H_CTRL_ENABLE = 0x01A4,
|
|
CORE1_RESET = 0x01FF,
|
|
|
|
CORE2_WORK_ENABLE = 0x02A1,
|
|
CORE2_RESET = 0x02FF,
|
|
|
|
CORE3_WORK_DISABLE = 0x03A0,
|
|
CORE3_WORK_ENABLE = 0x03A1,
|
|
CORE3_SET_PARAMS = 0x03A2,
|
|
CORE3_SRESET = 0x03AA,
|
|
CORE3_RESET = 0x03FF,
|
|
CORE3_REQ_FLIP_TH = 0xA3A1,
|
|
CORE3_REQ_CLEAR_TH = 0xA3A2,
|
|
CORE3_REQ_UNLOCK = 0xA3A3
|
|
};
|
|
|
|
#define TH_BASE 0x98000000
|
|
#define TH_SIZE_MAX_BYTES 0x8000000
|
|
#define TH_SIZE_MAX_U32B 0x2000000
|
|
#define TH_NODE_SIZE 0x04
|
|
|
|
/*
|
|
#define TH_SIZE_NODES 0x288000
|
|
#define TH_SIZE_BYTES 0xA20000
|
|
#define TH_2ZONES_SIZE_BYTES 0x1440000
|
|
*/
|
|
|
|
#ifndef TH_FULL_PER_LRF
|
|
#define TH_PER_LRF
|
|
#endif
|
|
#ifdef TH_PER_MIRROR
|
|
#ifdef ENCODER_7200
|
|
#define TH_SIZE_NODES 0x288000
|
|
#define TH_LINE_NODES 0x900
|
|
#define TH_SIZE_BYTES 0xA20000
|
|
#define TH_LINE_BYTES 0x2400
|
|
#define TH_2ZONES_SIZE_BYTES 0x510000
|
|
#define TH_16ZONES_SIZE_BYTES 0x2881000
|
|
//#ifdef ROLLING_THRESHOLD
|
|
// #define TH_24ZONES_SIZE_BYTES 0x3CC0000
|
|
//#endif
|
|
#else
|
|
#define TH_SIZE_NODES ( M_SCAN_POINTS * Q_SCAN_COUNT ) //0xA2000
|
|
#define TH_LINE_NODES M_SCAN_POINTS //0x900
|
|
#define TH_SIZE_BYTES ( TH_SIZE_NODES << 2 ) //0x288000
|
|
#define TH_LINE_BYTES ( TH_LINE_NODES << 2 ) //0x2400
|
|
#define TH_2ZONES_SIZE_BYTES ( TH_SIZE_BYTES << 1 ) //0x510000
|
|
#define TH_16ZONES_SIZE_BYTES ( TH_SIZE_BYTES << 4 ) //0x2881000
|
|
//#ifdef ROLLING_THRESHOLD
|
|
// #define TH_24ZONES_SIZE_BYTES ( TH_SIZE_BYTES << 4 + TH_SIZE_BYTES << 3 )
|
|
//#endif
|
|
#endif
|
|
|
|
#ifdef TH_PER_LRF
|
|
#define TH_KERNEL_SIZE_NODES 0x14400
|
|
#define TH_KERNEL_LINE_NODES 0x120
|
|
#endif
|
|
|
|
#define TARGET_BASE 0x9A880000 // TH_BASE + 0x2880000
|
|
#define MAX_TARGETS_COUNT 32
|
|
#define TARGET_ZONE_SIZE 0x4000 //( sizeof(targetRecord) * MAX_TARGETS_COUNT )
|
|
#else // !TH_PER_MIRROR
|
|
#ifdef ENCODER_7200
|
|
#define TH_SIZE_NODES 0xA2000
|
|
#define TH_LINE_NODES 0x900
|
|
#define TH_SIZE_BYTES 0x288000
|
|
#define TH_LINE_BYTES 0x2400
|
|
#define TH_2ZONES_SIZE_BYTES 0x510000
|
|
#define TH_16ZONES_SIZE_BYTES 0x2881000
|
|
//#ifdef ROLLING_THRESHOLD
|
|
// #define TH_24ZONES_SIZE_BYTES 0x3CC0000
|
|
//#endif
|
|
#else
|
|
#define TH_SIZE_NODES ( M_SCAN_POINTS * Q_SCAN_COUNT ) //0xA2000
|
|
#define TH_LINE_NODES M_SCAN_POINTS //0x900
|
|
#define TH_SIZE_BYTES ( TH_SIZE_NODES << 2 ) //0x288000
|
|
#define TH_LINE_BYTES ( TH_LINE_NODES << 2 ) //0x2400
|
|
#define TH_2ZONES_SIZE_BYTES ( TH_SIZE_BYTES << 1 ) //0x510000
|
|
#define TH_16ZONES_SIZE_BYTES ( TH_SIZE_BYTES << 4 ) //0x2881000
|
|
//#ifdef ROLLING_THRESHOLD
|
|
// #define TH_24ZONES_SIZE_BYTES ( TH_SIZE_BYTES << 4 + TH_SIZE_BYTES << 3 )
|
|
//#endif
|
|
#endif
|
|
|
|
#ifdef TH_PER_LRF
|
|
#define TH_KERNEL_SIZE_NODES 0x14400
|
|
#define TH_KERNEL_LINE_NODES 0x120
|
|
#endif
|
|
|
|
#define TARGET_BASE 0x9A880000 // TH_BASE + 0x2880000
|
|
#define MAX_TARGETS_COUNT 32
|
|
#define TARGET_ZONE_SIZE 0x4000 //( sizeof(targetRecord) * MAX_TARGETS_COUNT )
|
|
#endif //! TH_PER_MIRROR
|
|
#define SCANS_TO_FLIP 16
|
|
#define SIGNAL_OFFSET 32
|
|
#define SIGNAL_ORDER 3
|
|
#define SIGNAL_DELTA 64
|
|
#define TH_POINT_GOOD 8
|
|
|
|
#define TARGET_WHITE 1
|
|
#define TARGET_BLACK 2
|
|
#define FLIP_COMPLETE 3
|
|
#define SCAN_COMPLETE 4
|
|
#define SCAN_FROZEN 5
|
|
#define MIRROR_FINISHED 6
|
|
#define ERROR_ANGLE 7
|
|
|
|
#define ADC0_EVENT 53
|
|
#define ADC1_EVENT 34
|
|
|
|
#ifndef am4378
|
|
inline void make3Drad(uint32_t sid, float &az, float &el, bool master = true ){
|
|
if( master ){
|
|
el = (float)(sid / TH_LINE_NODES) * (Q_RADIAN_FOV / Q_SCAN_COUNT) - Q_RADIAN_SHIFT_DOWN_FOV;
|
|
} else {
|
|
el = (Q_SCAN_COUNT - (float)(sid / TH_LINE_NODES)) * (Q_RADIAN_FOV / Q_BLOCK_COUNT) - Q_RADIAN_SHIFT_DOWN_FOV;
|
|
};
|
|
az = ((float)(TH_LINE_NODES - (sid % TH_LINE_NODES))) * (B_RADIAN_FOV / (float)M_SCAN_POINTS);
|
|
};
|
|
|
|
inline void make3Ddeg(uint32_t sid, float &az, float &el, bool master = true ){
|
|
az = ((float)(TH_LINE_NODES - (sid % TH_LINE_NODES))) * (B_DEGREE_FOV / (float)M_SCAN_POINTS);
|
|
if ( master ){
|
|
el = 90.0 - (float)(sid / TH_LINE_NODES) * (Q_DEGREE_FOV / Q_SCAN_COUNT) - Q_SHIFT_DOWN_FOV;
|
|
} else {
|
|
el = 90.0 - (Q_SCAN_COUNT - (float)(sid / TH_LINE_NODES)) * (Q_DEGREE_FOV / Q_BLOCK_COUNT) - Q_SHIFT_DOWN_FOV;
|
|
};
|
|
if( el < 0 ) {
|
|
el *= -1.0;
|
|
az = az + 180.0;
|
|
if( az > 360.0 ) az = az - 360.0;
|
|
};
|
|
};
|
|
|
|
inline void make3Dmildeg(uint32_t sid, float &az, float &el, bool master = true ){
|
|
if( master ){
|
|
el = 1000.f * ( ((float)Q_DEGREE_FOV) - (float)(sid / TH_LINE_NODES) * (Q_DEGREE_FOV / Q_SCAN_COUNT) - Q_SHIFT_DOWN_FOV );
|
|
} else {
|
|
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 );
|
|
};
|
|
az = 360000.f - 1000.f * ((float)(TH_LINE_NODES - (sid % TH_LINE_NODES))) * (B_DEGREE_FOV / (float)M_SCAN_POINTS);
|
|
if( el < 0 ) {
|
|
el = -1.f * el;
|
|
az = (float)(((int)az+180000 ) % 360000);
|
|
};
|
|
};
|
|
|
|
inline void makeXY(uint32_t sid, uint16_t &x, uint16_t &y, bool Master = true ){
|
|
if ( Master ){
|
|
y = sid / TH_LINE_NODES;
|
|
} else {
|
|
y = Q_SCAN_COUNT - (sid / TH_LINE_NODES);
|
|
};
|
|
x = sid % TH_LINE_NODES;
|
|
};
|
|
// inline void makeCds( uint32_t sid, int &x, int &y, bool Master = true ){
|
|
// if( Master ){
|
|
// y = Q_SCAN_COUNT - ( sid / TH_LINE_NODES );
|
|
// } else {
|
|
// y = ( sid / TH_LINE_NODES );
|
|
// };
|
|
// x = sid % TH_LINE_NODES;
|
|
// };
|
|
inline int32_t makeIds( int x, int y, bool Master = true ){
|
|
return (Master)?(288-y)*TH_LINE_NODES+x:y*TH_LINE_NODES+x;
|
|
};
|
|
inline int interpolate(int color1, int color2, float progress) {
|
|
int a1 = (color1 & 0xff000000) >> 24;
|
|
int r1 = (color1 & 0x00ff0000) >> 16;
|
|
int g1 = (color1 & 0x0000ff00) >> 8;
|
|
int b1 = color1 & 0x000000ff;
|
|
|
|
int a2 = (color2 & 0xff000000) >> 24;
|
|
int r2 = (color2 & 0x00ff0000) >> 16;
|
|
int g2 = (color2 & 0x0000ff00) >> 8;
|
|
int b2 = color2 & 0x000000ff;
|
|
|
|
float progress2 = (1 - progress);
|
|
int newA = (int)(a1 * progress2 + a2 * progress);
|
|
int newR = (int)(r1 * progress2 + r2 * progress);
|
|
int newG = (int)(g1 * progress2 + g2 * progress);
|
|
int newB = (int)(b1 * progress2 + b2 * progress);
|
|
|
|
return (newA << 24) + (newR << 16) + (newG << 8) + newB;
|
|
};
|
|
|
|
inline int makeSID(int kID, int qID, int bID){
|
|
int cid;
|
|
int cqid;
|
|
int mid;
|
|
int ccp;
|
|
int opp;
|
|
cqid = qID % Q_Q_INTERLEAVE;
|
|
if (cqid < Q_PULSE_START) cqid = Q_PULSE_START;
|
|
if (cqid > Q_PULSE_STOP) cqid = Q_PULSE_STOP;
|
|
bID += (kID * 7) >> 1; // X * 3.5
|
|
ccp = bID / (B_BLOCK_COUNT / BASE_SCAN_COUNT);
|
|
opp = ccp % B_P_INTERLEAVE;
|
|
cid = ccp + 72 * opp + cqid / 4;
|
|
//qDebug() << "K_ID:" << kID << " Q_ID:" << qID << " B_ID:" << bID << "\tSpin:" << opp << "Mirror:" << (ccp % 4) << "M-spin:" << ((ccp + 72 * opp) >> 4) << "\tID:" << cid;
|
|
return cid;
|
|
};
|
|
|
|
inline bool makeCoords(uint16_t Range, uint32_t sid, int &x, int &y, int &mid, int &seg, bool Master = true){
|
|
mid = 0;
|
|
seg = 0;
|
|
if (Master){
|
|
y = Q_SCAN_COUNT - (sid / TH_LINE_NODES) - 1;
|
|
}
|
|
else {
|
|
y = (sid / TH_LINE_NODES) - 1;
|
|
};
|
|
x = sid % TH_LINE_NODES;
|
|
if (Range > 4000) return false;
|
|
return true;
|
|
};
|
|
|
|
inline int makeIdx(int x, int y, bool Master = true){
|
|
return (Master) ? (288 - y)*TH_LINE_NODES + x : y*TH_LINE_NODES + x;
|
|
};
|
|
|
|
inline bool makeCoords_121(uint16_t Range, uint32_t sid, int &x, int &y, int &mid, int &seg, bool Master = true){
|
|
int Kernel;
|
|
int cMirror;
|
|
int cSpinID;
|
|
int cBaseSpinID;
|
|
int cScanID;
|
|
int cBaseSegment;
|
|
int cBaseShift;
|
|
int cMirrorShift;
|
|
int cPulseID;
|
|
|
|
float fPix = 0;
|
|
float fPixStp = (2304.f * 5.f) / 129600.f; // 0.013888888888888888888888888888889f;//0.64222f; //0.64f; //0.16f;
|
|
|
|
mid = 0;
|
|
seg = 0;
|
|
Kernel = sid % KERNEL_COUNT; //ok
|
|
cPulseID = (int)(sid / KERNEL_COUNT); //ok
|
|
cScanID = (int)(cPulseID / Q_SCAN_COUNT); //ok
|
|
cMirror = cScanID % 4; //ok
|
|
cMirrorShift = cPulseID % Q_SCAN_COUNT; //ok
|
|
cSpinID = (int)(cPulseID / (Q_MIRROR_COUNT * Q_SCAN_COUNT)); //ok
|
|
|
|
cBaseSpinID = (int)(cScanID / (BASE_SCAN_COUNT / (B_P_INTERLEAVE * Q_MIRROR_COUNT)));
|
|
cBaseSegment = cScanID % (BASE_SCAN_COUNT / (B_P_INTERLEAVE * Q_MIRROR_COUNT));
|
|
cBaseShift = (81 + cMirrorShift) % 450;
|
|
mid = cMirror;
|
|
seg = cBaseSegment;
|
|
if (Master){
|
|
y = Q_SCAN_COUNT - cMirrorShift - 2;
|
|
}
|
|
else {
|
|
y = cMirrorShift;
|
|
};
|
|
//qDebug() << "Pid:" << cPulseID << " ScanID:" << cScanID;
|
|
fPix = fPixStp * (float)(81 + cPulseID + cScanID * 162) + 7.0f - (float)Kernel;
|
|
|
|
x = ((int)fPix) % 2304;
|
|
//if( x != (int)fPix ) qDebug() << "Pix:" << fPix << " x:" << x;
|
|
if (Range > 4000) return false;
|
|
return true;
|
|
};
|
|
|
|
inline bool makePixel(uint16_t Range, uint32_t sid, int &x, int &y, int &mid, int &seg, bool Master = true){
|
|
int Kernel;
|
|
mid = 0;
|
|
seg = 0;
|
|
Kernel = sid % KERNEL_COUNT;
|
|
if (B_P_INTERLEAVE > 1){
|
|
int cMirror;
|
|
int cSpinID;
|
|
int cBaseSpinID;
|
|
int cScanID;
|
|
int cBaseSegment;
|
|
int cBaseShift;
|
|
int cMirrorShift;
|
|
int cPulseID;
|
|
|
|
//https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects
|
|
|
|
cPulseID = (int)(sid / KERNEL_COUNT);
|
|
cScanID = (int)(cPulseID / Q_SCAN_COUNT);
|
|
cMirror = cScanID % 4;
|
|
cMirrorShift = cPulseID % Q_SCAN_COUNT;
|
|
cSpinID = (int)(cPulseID / (Q_MIRROR_COUNT * Q_SCAN_COUNT));
|
|
cBaseSpinID = (int)(cScanID / 96);
|
|
//cBaseSegment = (int)(cScanID / 96) + cScanID % 96;//((BASE_SCAN_COUNT / Q_MIRROR_COUNT )/ B_P_INTERLEAVE );
|
|
cBaseSegment = cScanID % 96;
|
|
cBaseShift = (81 + cMirrorShift) % 450; //((BASE_SCAN_COUNT / Q_MIRROR_COUNT )/ B_P_INTERLEAVE ); //(cPulseID / (Q_MIRROR_COUNT * Q_SCAN_COUNT)) % B_SCAN_COUNT;
|
|
|
|
mid = cMirror;
|
|
seg = cBaseSegment;
|
|
|
|
if (Master){
|
|
y = Q_SCAN_COUNT - cMirrorShift;
|
|
}
|
|
else {
|
|
y = cMirrorShift;
|
|
};
|
|
|
|
x = (cBaseSegment * B_P_INTERLEAVE * KERNEL_COUNT) +
|
|
cBaseSpinID * KERNEL_COUNT + //7 -
|
|
//( cBaseShift * B_P_INTERLEAVE ) / 450 +
|
|
Kernel;
|
|
}
|
|
else {
|
|
x = y = 0;
|
|
};
|
|
if (Range > 4000) return false;
|
|
return true;
|
|
};
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|