Skip to content

Commit

Permalink
YDLIDAR SCL stub
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia O. authored and Ilia O. committed Aug 17, 2024
1 parent 6bbe362 commit 4b5899f
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
63 changes: 63 additions & 0 deletions src/LDS_YDLIDAR_SCL.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2023-2024 REMAKE.AI, KAIA.AI, MAKERSPET.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Based on https://github.com/YDLIDAR/lidarCar/

#include "LDS_YDLIDAR_SCL.h"

const char* LDS_YDLIDAR_SCL::getModelName() { return "YDLIDAR SCL"; }

LDS::result_t LDS_YDLIDAR_SCL::start() {
enableMotor(true);
postInfo(INFO_MODEL, getModelName());
return LDS::RESULT_OK;
}

uint32_t LDS_YDLIDAR_SCL::getSerialBaudRate() {
return 115200;
}

float LDS_YDLIDAR_SCL::getTargetScanFreqHz() {
return DEFAULT_VALUE;
}

int LDS_YDLIDAR_SCL::getSamplingRateHz() {
return 3000;
}

float LDS_YDLIDAR_SCL::getCurrentScanFreqHz() {
return LDS_YDLIDAR_X4::getCurrentScanFreqHz();
}

LDS::result_t LDS_YDLIDAR_SCL::stop() {
enableMotor(false);
return RESULT_OK;
}

void LDS_YDLIDAR_SCL::enableMotor(bool enable) {
motor_enabled = enable;

if (enable) {
// Drive PWM
//setMotorPin(DIR_INPUT, LDS_MOTOR_PWM_PIN);
setMotorPin(DIR_OUTPUT_CONST, LDS_MOTOR_PWM_PIN);
setMotorPin(VALUE_HIGH, LDS_MOTOR_PWM_PIN);
} else {
setMotorPin(DIR_OUTPUT_CONST, LDS_MOTOR_PWM_PIN);
setMotorPin(VALUE_LOW, LDS_MOTOR_PWM_PIN);
}

// Entire LDS on/off
//setMotorPin(enable ? VALUE_HIGH : VALUE_LOW, LDS_MOTOR_PWM_PIN);
}
32 changes: 32 additions & 0 deletions src/LDS_YDLIDAR_SCL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2023-2024 REMAKE.AI, KAIA.AI, MAKERSPET.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Based on https://github.com/YDLIDAR/lidarCar/

#pragma once
#include "LDS_YDLIDAR_X4.h"

class LDS_YDLIDAR_SCL : public LDS_YDLIDAR_X4 {
public:
virtual result_t start() override;
virtual result_t stop() override;
virtual const char* getModelName() override;

virtual float getCurrentScanFreqHz() override;
virtual uint32_t getSerialBaudRate() override;
virtual float getTargetScanFreqHz() override;
virtual int getSamplingRateHz() override;
protected:
virtual void enableMotor(bool enable) override;
};
1 change: 1 addition & 0 deletions src/lds_all_models.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "LDS_YDLIDAR_X3_PRO.h"
#include "LDS_YDLIDAR_X3.h"
#include "LDS_YDLIDAR_X2_X2L.h"
#include "LDS_YDLIDAR_SCL.h"
#include "LDS_NEATO_XV11.h"
#include "LDS_LDS02RR.h"
#include "LDS_RPLIDAR_A1.h"
Expand Down

0 comments on commit 4b5899f

Please sign in to comment.