Nicely format doxygen documentation
parent
d955897829
commit
051bce9098
|
|
@ -18,47 +18,51 @@ using config::Speed;
|
||||||
using pulse_gen::pos_t;
|
using pulse_gen::pos_t;
|
||||||
using pulse_gen::steps_t;
|
using pulse_gen::steps_t;
|
||||||
|
|
||||||
/// Specialized axis unit type for compile-time conformability testing. Like config::Unit
|
/// Specialized axis unit type for compile-time conformability testing. Like for
|
||||||
/// this is done ensure unit quantities are not mixed between types, while also providing
|
/// unit::Unit this is done ensure quantities are not mixed between types, while also
|
||||||
/// convenience methods to convert from physical units to AxisUnits directly at compile
|
/// providing convenience methods to convert from physical units to AxisUnits directly at
|
||||||
/// time. AxisUnits are just as efficient as non-checked pos_t and steps_t.
|
/// compile time. AxisUnits are just as efficient as the non-checked pulse_gen::pos_t and
|
||||||
|
/// pulse_gen::steps_t.
|
||||||
///
|
///
|
||||||
/// Each axis unit type is separate for each axis, since the low-level count is not
|
/// Each axis provides separate types for each quantity, since the low-level count is also
|
||||||
/// directly comparable across axes. Quantities are normally defined through the
|
/// not directly comparable across each (depending on the configuration settings).
|
||||||
/// literal operators. Types and base axes are prefixed with a single letter identifier
|
/// Quantities are normally defined through the literal operators. Types and base axes are
|
||||||
/// for the axis: P=pulley, S=selector, I=idler.
|
/// prefixed with a single letter identifier for the axis: P=pulley, S=selector, I=idler.
|
||||||
///
|
///
|
||||||
/// P_pos_t pulley_position = 10.0_P_mm;
|
/// P_pos_t pulley_position = 10.0_P_mm;
|
||||||
/// auto pulley_zero = 0.0_P_mm; // implicit type
|
/// auto pulley_zero = 0.0_P_mm; // implicit type
|
||||||
/// P_speed_ pulley_feedrate = 30.0_P_mm_s;
|
/// P_speed_ pulley_feedrate = 30.0_P_mm_s;
|
||||||
/// I_pos_t idler_position = 15.0_I_deg;
|
/// I_pos_t idler_position = 15.0_I_deg;
|
||||||
/// pulley_position + idler_position; // compile time error
|
/// pulley_position + idler_position; // compile time error
|
||||||
///
|
///
|
||||||
/// modules::motion::Motion.PlanMove (and related functions) support both physical and
|
/// motion::Motion.PlanMove (and related functions) support both physical and AxisUnit
|
||||||
/// AxisUnit natively. This is done by specifying the axis through the first template
|
/// natively. This is done by specifying the axis through the first template parameter,
|
||||||
/// parameter, which ensures related units are also conforming:
|
/// which ensures related units are also conforming:
|
||||||
///
|
///
|
||||||
/// motion.PlanMoveTo<Pulley>(10.0_mm, 100._mm_s); // using physical units
|
/// motion.PlanMoveTo<Pulley>(10.0_mm, 100._mm_s); // using physical units
|
||||||
/// motion.PlanMoveTo<Pulley>(10.0_P_mm, 100._P_mm_s); // using AxisUnit
|
/// motion.PlanMoveTo<Pulley>(10.0_P_mm, 100._P_mm_s); // using AxisUnit
|
||||||
///
|
///
|
||||||
/// Physical units are always represented with the largest floating point type, so they
|
/// Physical units are always represented with the largest floating point type, so they
|
||||||
/// should only be used at compile-time (constants, fixed-lenght moves).
|
/// should only preferably be used at compile-time only.
|
||||||
///
|
///
|
||||||
/// If runtime manipulation is necessary, use AxisUnit should always be used instead.
|
/// If runtime manipulation is necessary, AxisUnit should be used instead. Conversion from
|
||||||
/// Conversion from physical to AxisUnit can be done through unitToAxisUnit:
|
/// physical to AxisUnit can be done through motion::unitToAxisUnit:
|
||||||
///
|
///
|
||||||
/// unitToAxisUnit<final_type>(physical_type)
|
/// unitToAxisUnit<final_type>(physical_type)
|
||||||
///
|
///
|
||||||
/// Examples:
|
/// Examples:
|
||||||
///
|
///
|
||||||
/// P_pos_t pulley_pos = unitToAxisUnit<P_pos_t>(10.0_mm);
|
/// P_pos_t pulley_pos = unitToAxisUnit<P_pos_t>(10.0_mm);
|
||||||
/// P_speed_t pulley_speed = unitToAxisUnit<P_speed_t>(100.0_mm_s);
|
/// P_speed_t pulley_speed = unitToAxisUnit<P_speed_t>(100.0_mm_s);
|
||||||
///
|
///
|
||||||
/// Conversion to pos_t or steps_t works the same using unitToSteps instead.
|
/// Conversion to pos_t or steps_t works the same using motion::unitToSteps instead.
|
||||||
///
|
///
|
||||||
/// The low-level step count can be accessed when necessary through AxisUnit::v, which
|
/// The low-level step count can be accessed when necessary through AxisUnit::v, which
|
||||||
/// should be avoided as it bypasses type checks. AxisUnit can also be constructed by
|
/// should be avoided as it bypasses all type checks. AxisUnit can also be constructed
|
||||||
/// providing a counter as the first initializer.
|
/// without checks by providing a counter as the first initializer.
|
||||||
|
///
|
||||||
|
/// The scaling factor is stored with the pair config::AxisConfig::uSteps and
|
||||||
|
/// config::AxisConfig::stepsPerUnit.
|
||||||
template <typename T, Axis A, config::UnitType U>
|
template <typename T, Axis A, config::UnitType U>
|
||||||
struct AxisUnit {
|
struct AxisUnit {
|
||||||
T v;
|
T v;
|
||||||
|
|
@ -88,7 +92,9 @@ static constexpr AxisScale axisScale[config::NUM_AXIS] = {
|
||||||
{ config::idlerLimits.base, config::idler.stepsPerUnit },
|
{ config::idlerLimits.base, config::idler.stepsPerUnit },
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Convert a Unit to AxisUnit
|
/// Convert a unit::Unit to AxisUnit.
|
||||||
|
/// The scaling factor is stored with the pair config::AxisConfig::uSteps and
|
||||||
|
/// config::AxisConfig::stepsPerUnit (one per-axis).
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
static constexpr T unitToAxisUnit(U v) {
|
static constexpr T unitToAxisUnit(U v) {
|
||||||
static_assert(T::unit == U::unit, "incorrect unit type conversion");
|
static_assert(T::unit == U::unit, "incorrect unit type conversion");
|
||||||
|
|
@ -96,7 +102,8 @@ static constexpr T unitToAxisUnit(U v) {
|
||||||
return { (typename T::type_t)(v.v * axisScale[T::axis].stepsPerUnit) };
|
return { (typename T::type_t)(v.v * axisScale[T::axis].stepsPerUnit) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert an Unit to a steps type (pos_t or steps_t)
|
/// Convert an unit::Unit to a steps type (pos_t or steps_t).
|
||||||
|
/// Extract the raw step count from an AxisUnit with type checking.
|
||||||
template <typename AU, typename U>
|
template <typename AU, typename U>
|
||||||
static constexpr typename AU::type_t unitToSteps(U v) {
|
static constexpr typename AU::type_t unitToSteps(U v) {
|
||||||
return unitToAxisUnit<AU>(v).v;
|
return unitToAxisUnit<AU>(v).v;
|
||||||
|
|
|
||||||
18
src/unit.h
18
src/unit.h
|
|
@ -7,20 +7,20 @@
|
||||||
/// daunting, usage is quite straightforward once the appropriate aliases and inline
|
/// daunting, usage is quite straightforward once the appropriate aliases and inline
|
||||||
/// operators are defined:
|
/// operators are defined:
|
||||||
///
|
///
|
||||||
/// U_mm distance = 10.0_mm;
|
/// U_mm distance = 10.0_mm;
|
||||||
/// auto another = 20.5_mm;
|
/// auto another = 20.5_mm;
|
||||||
/// auto sum = distance + another;
|
/// auto sum = distance + another;
|
||||||
///
|
///
|
||||||
/// auto angle = 15.0_deg;
|
/// auto angle = 15.0_deg;
|
||||||
/// auto test = distance + angle; // compile time error
|
/// auto test = distance + angle; // compile time error
|
||||||
///
|
///
|
||||||
/// Template parameters are only used for type checking. The Unit contains a single value
|
/// Template parameters are only used for type checking. Unit contains a single value
|
||||||
/// Unit<T>::v and is thus well suited for parameter passing and inline initialization.
|
/// Unit<T>::v and is thus well suited for parameter passing and inline initialization.
|
||||||
///
|
///
|
||||||
/// Conversion to physical steps is done in modules::motion through the sister class
|
/// Conversion to physical steps is done in modules::motion through the sister class
|
||||||
/// AxisUnit, which also ensures quantities from different axes are not mixed together.
|
/// modules::motion::AxisUnit, modules::motion::unitToAxisUnit and
|
||||||
/// AxisUnit are the normal units that should be used at runtime, which is why physical
|
/// modules::motion::unitToSteps, which also ensures quantities from different axes are
|
||||||
/// units and operators are not exported into the global namespace by default.
|
/// not mixed together. AxisUnit are the normal type that *should* be used at runtime.
|
||||||
namespace unit {
|
namespace unit {
|
||||||
|
|
||||||
/// Base units for conformability testing
|
/// Base units for conformability testing
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue