ReduxLib C++ 2025.0.0-beta2
Loading...
Searching...
No Matches
redux::sensors::canandgyro::CanandgyroSettings Class Reference

#include <CanandgyroSettings.h>

Inheritance diagram for redux::sensors::canandgyro::CanandgyroSettings:
redux::canand::CanandSettings

Public Member Functions

const std::vector< uint8_t > & SettingAddresses () const override
 
void SetYawFramePeriod (units::second_t period)
 
void SetAngularPositionFramePeriod (units::second_t period)
 
void SetAngularVelocityFramePeriod (units::second_t period)
 
void SetAccelerationFramePeriod (units::second_t period)
 
void SetStatusFramePeriod (units::second_t period)
 
std::optional< units::second_t > GetYawFramePeriod ()
 
std::optional< units::second_t > GetAngularPositionFramePeriod ()
 
std::optional< units::second_t > GetAngularVelocityFramePeriod ()
 
std::optional< units::second_t > GetAccelerationFramePeriod ()
 
std::optional< units::second_t > GetStatusFramePeriod ()
 
- Public Member Functions inherited from redux::canand::CanandSettings
 CanandSettings ()=default
 
 CanandSettings (CanandSettings &stg)
 
 ~CanandSettings ()=default
 
std::unordered_map< uint8_t, uint64_t > FilteredMap ()
 
bool AllSettingsReceived () const
 
virtual const std::vector< uint8_t > & SettingAddresses () const
 
std::unordered_map< uint8_t, uint64_t > & GetMap ()
 
bool IsEmpty () const
 
bool IsEphemeral () const
 
void SetEphemeral (bool value)
 
std::string ToString ()
 

Additional Inherited Members

- Protected Attributes inherited from redux::canand::CanandSettings
std::unordered_map< uint8_t, uint64_t > values
 
bool ephemeral = false
 

Detailed Description

The settings class for the Canandgyro.

This class holds settings values that can be used to reconfigure Canandgyro via Canandgyro::SetSettings Additionally, objects of this class can be filled using Canandgyro.GetSettings which can be used to read the encoder's settings.

// Only settings that are explicitly set here will be edited, so other settings
// such as the status frame period will remain untouched.
stg.SetAngularVelocityFramePeriod(0_ms); // disables angular velocity readings
stg.SetYawFramePeriod(5_ms); // sets the rate of yaw measurements to every 5 ms
enc.SetSettings(stg);
Definition: CanandgyroSettings.h:54
void SetYawFramePeriod(units::second_t period)
void SetAngularVelocityFramePeriod(units::second_t period)
Definition: Canandgyro.h:110

Objects returned by the blocking Canandgyro::GetSettings() method will generally have all setting values populated and the getters will not return std::nullopt assuming no timeout occured.

However, they may return std::nullopt if the object is either manually constructed and the corresponding getter hasn't been called yet (e.g. calling GetStatusFramePeriod before SetStatusFramePeriod on an object you made) or if the object comes from Canandgyro::GetSettingsAsync() and not all settings have been received (use AllSettingsReceived() to check if all are present)

cppreference on std::optional may be helpful here.

Example blocking fetch:

Canandgyro canandgyro{0};
CanandgyroSettings stg = canandgyro.GetSettings();
if (stg.AllSettingsReceived()) { // check for timeout
fmt::print("status frame period: {}\n", *stg.GetStatusFramePeriod()); // print the status frame period (usually 1000 ms)
}
bool AllSettingsReceived() const
Definition: CanandSettings.h:55
std::optional< units::second_t > GetStatusFramePeriod()

Member Function Documentation

◆ GetAccelerationFramePeriod()

std::optional< units::second_t > redux::sensors::canandgyro::CanandgyroSettings::GetAccelerationFramePeriod ( )

Gets the acceleration frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

A value of 0 means acceleration frames are disabled.

Returns
the frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

◆ GetAngularPositionFramePeriod()

std::optional< units::second_t > redux::sensors::canandgyro::CanandgyroSettings::GetAngularPositionFramePeriod ( )

Gets the angular position frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

A value of 0 means angular position frames are disabled.

Returns
the frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

◆ GetAngularVelocityFramePeriod()

std::optional< units::second_t > redux::sensors::canandgyro::CanandgyroSettings::GetAngularVelocityFramePeriod ( )

Gets the angular velocity frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

A value of 0 means angular velocity frames are disabled.

Returns
the frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

◆ GetStatusFramePeriod()

std::optional< units::second_t > redux::sensors::canandgyro::CanandgyroSettings::GetStatusFramePeriod ( )

Gets the status frame period in seconds [0.001..16.383], or std::nullopt if the value has not beeno set on this object.

Returns
the status frame period in seconds [0.001..16.383], or std::nullopt if the value has not been set on this object.

◆ GetYawFramePeriod()

std::optional< units::second_t > redux::sensors::canandgyro::CanandgyroSettings::GetYawFramePeriod ( )

Gets the dedicated yaw frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

A value of 0 means yaw frames are disabled.

Returns
the frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

◆ SetAccelerationFramePeriod()

void redux::sensors::canandgyro::CanandgyroSettings::SetAccelerationFramePeriod ( units::second_t  period)

Sets the angular velocity frame period in seconds.

By factory default, acceleration frames are sent every 100 milliseconds (period = 0.100_s). If 0 is passed in, acceleration frames will be disabled and methods returning acceleration data will not return new values.

Parameters
periodthe new frame period in seconds [0_s, 65.535_s] inclusive

◆ SetAngularPositionFramePeriod()

void redux::sensors::canandgyro::CanandgyroSettings::SetAngularPositionFramePeriod ( units::second_t  period)

Sets the angular position frame period in seconds.

By factory default, angular position frames are sent every 20 milliseconds (period = 0.020_s). If 0 is passed in, angular position frames will be disabled and methods returning angular position data will not return new values.

The one exception is Canandgyro.GetYaw which by default uses the yaw frame instead.

Parameters
periodthe new frame period in seconds [0_s, 65.535_s] inclusive

◆ SetAngularVelocityFramePeriod()

void redux::sensors::canandgyro::CanandgyroSettings::SetAngularVelocityFramePeriod ( units::second_t  period)

Sets the angular velocity frame period in seconds.

By factory default, angular velocity frames are sent every 100 milliseconds (period = 0.100_s). If 0 is passed in, angular velocity frames will be disabled and methods returning angular velocity data will not return new values.

Parameters
periodthe new frame period in seconds [0_s, 65.535_s] inclusive

◆ SetStatusFramePeriod()

void redux::sensors::canandgyro::CanandgyroSettings::SetStatusFramePeriod ( units::second_t  period)

Sets the status frame period in seconds.

By factory default, the device will broadcast 10 status messages every second (period=0.1_s).

Parameters
periodthe new period for status frames in seconds in range [0.001_s, 16.383_s].

◆ SettingAddresses()

const std::vector< uint8_t > & redux::sensors::canandgyro::CanandgyroSettings::SettingAddresses ( ) const
overridevirtual

Gets the array of settings addresses this settings class records.

Returns
DetailsKey array

Reimplemented from redux::canand::CanandSettings.

◆ SetYawFramePeriod()

void redux::sensors::canandgyro::CanandgyroSettings::SetYawFramePeriod ( units::second_t  period)

Sets the dedicated yaw frame period in seconds.

By factory default, yaw frames are sent every 10 milliseconds (period = 0.010_s). If 0 is passed in, yaw frames will be disabled and Canandgyro::getYaw} will not return new values (unless configured to derive yaw from the angular position frame)

Parameters
periodthe new frame period in seconds [0_s, 65.535_s] inclusive

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