19#ifndef _USE_MATH_DEFINES
20#define _USE_MATH_DEFINES
25#define DEG2RAD M_PI/180.0
31using namespace rp::standalone::rplidar;
39 u_result result = m_drv->startMotor();
48 if (m_pwm_val > 0 && m_pwm_val < 1023)
50 result = m_drv->setMotorPWM(m_pwm_val);
61 yCError(
RP_LIDAR4) <<
"Invalid motor pwm request " << m_pwm_val <<
". It should be a value between 0 and 1023.";
68bool RpLidar4::startScan()
78 <<
", max distance:" <<
scanModes[
i].max_distance
79 <<
", us per sample:" <<
scanModes[
i].us_per_sample
80 <<
", samples/s:" << 1.0 /
scanModes[
i].us_per_sample * 1000000;
102 yCInfo(
RP_LIDAR4,
"\t%s: max_distance: %.1f m, Point number: %.1fK",
iter->scan_mode,
iter->max_distance, (1000 /
iter->us_per_sample));
136 bool br = config.
check(
"GENERAL");
144 if (
general_config.check(
"sample_buffer_life") ==
false) {
yCError(
RP_LIDAR4) <<
"Missing sample_buffer_life param in GENERAL group";
return false; }
183 m_drv = RPlidarDriver::CreateDriver(rp::standalone::rplidar::CHANNEL_TYPE_SERIALPORT);
193 RPlidarDriver::DisposeDriver(
m_drv);
197 if (!deviceinfo())
return false;
198 if (!startMotor())
return false;
199 if (!startScan())
return false;
217 RPlidarDriver::DisposeDriver(
m_drv);
249 return ReturnValue::return_code::return_value_error_not_implemented_by_device;
259#define _countof(_Array) (int)(sizeof(_Array) / sizeof (_Array[0]))
311 for (
size_t i = 0;
i < count; ++
i)
332 distance = std::numeric_limits<double>::infinity();
394bool RpLidar4::deviceinfo()
415 m_info = std::string(
"Firmware Version: ") + std::to_string(
info.firmware_version) +
416 "\nHardware Version: " + std::to_string(
info.hardware_version) +
417 "\nModel: " + std::to_string(
info.model) +
rpLidar4: The device driver for the RP lidar S2
yarp::dev::ReturnValue setScanLimits(double min, double max) override
set the scan angular range.
void threadRelease() override
Release method.
bool acquireDataFromHW() override final
This method should be implemented by the user, and contain the logic to grab data from the hardware.
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue setScanRate(double rate) override
set the scan rate (scans per seconds)
bool threadInit() override
Initialization method.
void run() override
Loop function.
rplidar_response_measurement_node_hq_t * m_nodes
yarp::dev::ReturnValue setHorizontalResolution(double step) override
get the angular step between two measurements (if available)
yarp::dev::ReturnValue setDistanceRange(double min, double max) override
set the device detection range.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
virtual bool updateLidarData()
This utility method calls in sequence: grabDataFromHW(), updateTimestamp and applyLimitsOnLaserData()...
yarp::dev::IRangefinder2D::Device_status m_device_status
bool parseConfiguration(yarp::os::Searchable &config)
yarp::sig::Vector m_laser_data
A mini-server for performing network communication in the background.
bool setPeriod(double period)
Set the (new) period of the thread.
bool start()
Call this to start the thread.
void step()
Call this to "step" the thread rather than starting it.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
const yarp::os::LogComponent & RP_LIDAR4()