Valor 6800 1.0
Loading...
Searching...
No Matches
valor::LidarSensor Class Reference

Specific implementation of the Lidar Sensor for Grapple Robotics LidarCAN device. More...

#include <LidarSensor.h>

Inheritance diagram for valor::LidarSensor:
valor::BaseSensor< units::millimeter_t > valor::Loggable valor::LaserProximitySensor valor::CANrangeSensor valor::GrappleSensor

Classes

struct  SimState
 

Public Member Functions

 LidarSensor (frc::TimedRobot &robot)
 Construct a new LidarSensor object.
 
units::millimeter_t getMaxDistance ()
 Get the maximum distance threshold for the Lidar sensor.
 
void setMaxDistance (units::millimeter_t maxDistance)
 Set the maximum distance threshold for the Lidar sensor.
 
void setupSim (std::function< frc::Pose2d()> robotPoseGetter, frc::Transform2d sensorPosition, std::vector< sim::FieldFeature > features)
 
void setGetter (std::function< units::millimeter_t()> getter)
 
- Public Member Functions inherited from valor::BaseSensor< units::millimeter_t >
virtual void reset ()
 Reset the sensor state.
 
void setGetter (std::function< units::millimeter_t()> _lambda)
 Set the lambda function to fetch sensor data.
 
void applyPostProcessing (std::function< units::millimeter_t(units::millimeter_t)> func)
 Set a post-processing function for sensor data.
 
units::millimeter_t get ()
 Get the current sensor state.
 
- Public Member Functions inherited from valor::Loggable
void LogChild (std::string_view name, Loggable *child)
 Register a child Loggable under a named subtree.
 
void LogChild (std::string_view name, wpi::Sendable *child)
 Register a child Sendable under a named subtree.
 
void setLoggingPeriod (units::millisecond_t period)
 Set the minimum period between LoggablePeriodic() invocations.
 
template<>
decltype(Loggable::subscribers) ::iterator addSubscriber (std::string_view field, const std::vector< bool > &defaultValue)
 
template<>
void WriteLogImpl (nt::Publisher *pub, const std::vector< bool > &data)
 
template<>
std::vector< boolReadLogImpl (nt::Subscriber *sub)
 

Protected Member Functions

void calculate () override
 Perform Lidar-specific calculations.
 
- Protected Member Functions inherited from valor::BaseSensor< units::millimeter_t >
 BaseSensor (frc::TimedRobot &robot)
 Construct a new BaseSensor object.
 
virtual void refresh ()
 Refresh the sensor state.
 
- Protected Member Functions inherited from valor::Loggable
 Loggable (std::string_view name)
 Construct a Loggable that registers a top-level table name.
 
 Loggable ()
 Default construct an uninitialized Loggable.
 
virtual ~Loggable ()=default
 Virtual destructor.
 
virtual void OnLoggingStart ()
 Hook invoked when logging is started for this object.
 
virtual void LoggablePeriodic ()
 Periodic callback for logging updates.
 
template<typename T >
T WriteLog (std::string_view field, const T &data)
 Publish a value to NetworkTables under the given field.
 
template<typename T >
ReadLog (std::string_view field, const T &defaultValue={})
 Read a value from NetworkTables for the given field.
 

Protected Attributes

std::unique_ptr< SimStatesimState
 
- Protected Attributes inherited from valor::BaseSensor< units::millimeter_t >
std::function< units::millimeter_t()> sensorLambda
 Lambda function to fetch sensor data.
 
std::function< units::millimeter_t(units::millimeter_t)> postProcessor
 Lambda function to post-process sensor data.
 
units::millimeter_t prevState
 Previous and current sensor states.
 
units::millimeter_t currState
 
frc::Timer profiler
 

Additional Inherited Members

- Static Public Member Functions inherited from valor::Loggable
static units::millisecond_t GetLoggingTime ()
 

Detailed Description

Specific implementation of the Lidar Sensor for Grapple Robotics LidarCAN device.

This class extends the BaseSensor class and provides functionality specific to the Lidar sensor. It allows for fetching distance measurements and setting a maximum distance threshold.

Constructor & Destructor Documentation

◆ LidarSensor()

valor::LidarSensor::LidarSensor ( frc::TimedRobot & robot)
explicit

Construct a new LidarSensor object.

Parameters
robotReference to the robot, used to schedule the calculate method.

Member Function Documentation

◆ calculate()

void valor::LidarSensor::calculate ( )
overrideprotectedvirtual

Perform Lidar-specific calculations.

This method is called every 10ms and processes the sensor data fetched by the lambda function.

Implements valor::BaseSensor< units::millimeter_t >.

◆ getMaxDistance()

units::millimeter_t valor::LidarSensor::getMaxDistance ( )

Get the maximum distance threshold for the Lidar sensor.

Returns
units::millimeter_t Maximum distance threshold.

◆ setMaxDistance()

void valor::LidarSensor::setMaxDistance ( units::millimeter_t maxDistance)

Set the maximum distance threshold for the Lidar sensor.

Parameters
maxDistanceMaximum distance threshold in millimeters.

The documentation for this class was generated from the following file: