LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
mathUtil.hpp File Reference
#include "okapi/api/device/motor/abstractMotor.hpp"
#include <algorithm>
#include <cstdint>
#include <math.h>
#include <type_traits>

Go to the source code of this file.

Namespaces

namespace  okapi
 

Functions

constexpr double okapi::ipow (const double base, const int expo)
 Integer power function.
 
constexpr double okapi::cutRange (const double value, const double min, const double max)
 Cuts out a range from the number.
 
constexpr double okapi::deadband (const double value, const double min, const double max)
 Deadbands a range of the number.
 
constexpr double okapi::remapRange (const double value, const double oldMin, const double oldMax, const double newMin, const double newMax)
 Remap a value in the range [oldMin, oldMax] to the range [newMin, newMax].
 
template<typename E >
constexpr auto okapi::toUnderlyingType (const E e) noexcept
 Converts an enum to its value type.
 
constexpr auto okapi::boolToSign (const bool b) noexcept
 Converts a bool to a sign.
 
constexpr long okapi::modulus (const long lhs, const long rhs) noexcept
 Computes lhs mod rhs using Euclidean division.
 
constexpr std::int32_t okapi::gearsetToTPR (const AbstractMotor::gearset igearset) noexcept
 Converts a gearset to its TPR.
 
constexpr std::int8_t okapi::transformADIPort (const std::int8_t port)
 Maps ADI port numbers/chars to numbers:
 

Variables

static constexpr double okapi::inchToMM = 25.4
 Converts inches to millimeters.
 
static constexpr double okapi::mmToInch = 0.0393700787
 Converts millimeters to inches.
 
static constexpr double okapi::degreeToRadian = 0.01745329252
 Converts degrees to radians.
 
static constexpr double okapi::radianToDegree = 57.2957795
 Converts radians to degrees.
 
static constexpr double okapi::imeTorqueTPR = 627.2
 The ticks per rotation of the 393 IME with torque gearing.
 
static constexpr std::int32_t okapi::imeSpeedTPR = 392
 The ticks per rotation of the 393 IME with speed gearing.
 
static constexpr double okapi::imeTurboTPR = 261.333
 The ticks per rotation of the 393 IME with turbo gearing.
 
static constexpr double okapi::ime269TPR = 240.448
 The ticks per rotation of the 269 IME.
 
static constexpr std::int32_t okapi::imev5RedTPR = 1800
 The ticks per rotation of the V5 motor with a red gearset.
 
static constexpr std::int32_t okapi::imev5GreenTPR = 900
 The ticks per rotation of the V5 motor with a green gearset.
 
static constexpr std::int32_t okapi::imev5BlueTPR = 300
 The ticks per rotation of the V5 motor with a blue gearset.
 
static constexpr std::int32_t okapi::quadEncoderTPR = 360
 The ticks per rotation of the red quadrature encoders.
 
static constexpr double okapi::pi = 3.1415926535897932
 The value of pi.
 
static constexpr double okapi::pi2 = 1.5707963267948966
 The value of pi divided by 2.
 
static constexpr double okapi::gravity = 9.80665
 The conventional value of gravity of Earth.
 
static constexpr auto okapi::OKAPI_PROS_ERR = INT32_MAX
 Same as PROS_ERR.
 
static constexpr auto okapi::OKAPI_PROS_ERR_F = INFINITY
 Same as PROS_ERR_F.
 
static constexpr double okapi::v5MotorMaxVoltage = 12000
 The maximum voltage that can be sent to V5 motors.
 
static constexpr std::int8_t okapi::motorUpdateRate = 10
 The polling frequency of V5 motors in milliseconds.
 
static constexpr std::int8_t okapi::adiUpdateRate = 10
 The polling frequency of the ADI ports in milliseconds.