Skip to content

Commit

Permalink
Fixed crash
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiaai committed Jan 26, 2024
1 parent c5a3357 commit efa5662
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
5 changes: 2 additions & 3 deletions src/LDS_LDS02RR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ LDS_LDS02RR::LDS_LDS02RR() : LDS() {
clearVars();

pwm_val = 0.5;

scan_rpm = 0;
scan_rpm_setpoint = DEFAULT_SCAN_RPM; // desired RPM 1.8KHz/5FPS/360 = 1 deg resolution

scanFreqPID.init(&scan_rpm, &pwm_val, &scan_rpm_setpoint, 3.0e-3, 1.0e-3, 0.0, PID_v1::DIRECT);
scanFreqPID.SetOutputLimits(0, 1.0);
scanFreqPID.SetSampleTime(20);
scanFreqPID.SetMode(PID_v1::AUTOMATIC);

scan_rpm = 0;
}

uint32_t LDS_LDS02RR::getSerialBaudRate() {
Expand Down
22 changes: 11 additions & 11 deletions src/LDS_LDS02RR.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ class LDS_LDS02RR : public LDS {
public:
LDS_LDS02RR();

result_t start();
void stop();
void loop(); // Call loop() frequently from Arduino loop()
result_t start() override;
void stop() override;
void loop() override; // Call loop() frequently from Arduino loop()

uint32_t getSerialBaudRate();
float getCurrentScanFreqHz();
float getTargetScanFreqHz();
int getSamplingRateHz();
bool isActive();
uint32_t getSerialBaudRate() override;
float getCurrentScanFreqHz() override;
float getTargetScanFreqHz() override;
int getSamplingRateHz() override;
bool isActive() override;

result_t setScanTargetFreqHz(float freq);
result_t setScanPIDCoeffs(float Kp, float Ki, float Kd);
result_t setScanPIDSamplePeriodMs(uint32_t sample_period_ms);
result_t setScanTargetFreqHz(float freq) override;
result_t setScanPIDCoeffs(float Kp, float Ki, float Kd) override;
result_t setScanPIDSamplePeriodMs(uint32_t sample_period_ms) override;

protected:
static constexpr float DEFAULT_SCAN_RPM = 300.0f;
Expand Down
22 changes: 11 additions & 11 deletions src/LDS_YDLIDAR_X4.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ class LDS_YDLIDAR_X4 : public LDS {
public:
LDS_YDLIDAR_X4();

result_t start();
void stop();
void loop(); // Call loop() frequently from Arduino loop()
result_t start() override;
void stop() override;
void loop() override; // Call loop() frequently from Arduino loop()

uint32_t getSerialBaudRate();
float getCurrentScanFreqHz();
float getTargetScanFreqHz();
int getSamplingRateHz();
bool isActive();
uint32_t getSerialBaudRate() override;
float getCurrentScanFreqHz() override;
float getTargetScanFreqHz() override;
int getSamplingRateHz() override;
bool isActive() override;

result_t setScanTargetFreqHz(float freq);
result_t setScanPIDCoeffs(float Kp, float Ki, float Kd);
result_t setScanPIDSamplePeriodMs(uint32_t sample_period_ms);
result_t setScanTargetFreqHz(float freq) override;
result_t setScanPIDCoeffs(float Kp, float Ki, float Kd) override;
result_t setScanPIDSamplePeriodMs(uint32_t sample_period_ms) override;

protected:
bool motor_enabled;
Expand Down

0 comments on commit efa5662

Please sign in to comment.