CTRE Phoenix C++ 5.33.1
Utilities.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
4namespace ctre {
5namespace phoenix {
6
7/**
8 * Class with basic utility methods
9 */
10class Utilities {
11public:
12 /**
13 * Calculates absolute value of f
14 * @param f value to calculate absolute value of
15 * @return absolute value of f
16 */
17 static float abs(float f);
18 /**
19 * Caps the value
20 * @param value Value to cap
21 * @param capValue Maximum/-Minimum value can be
22 * @return Capped value
23 */
24 static float bound(float value, float capValue = 1);
25 /**
26 * Caps the value
27 * @param value Value to cap
28 * @param peak Maximum/-Minimum value can be
29 * @return Capped value
30 */
31 static float cap(float value, float peak);
32 /**
33 * Deadbands the value
34 * @param value reference of value to deadband
35 * @param deadband If abs of value is under this, it will be brought to 0
36 */
37 static void Deadband(float &value, float deadband = -.10f);
38 /**
39 * Calculates if value is within a delta
40 * @param value initial value to compare
41 * @param compareTo value to compare against first value
42 * @param allowDelta the range value can be away from compareTo
43 * @return true if value is within allowDelta range of compareTo
44 */
45 static bool IsWithin(float value, float compareTo, float allowDelta);
46 /**
47 * Gets the minimum of the two values
48 * @param value_1 first value
49 * @param value_2 second value
50 * @return minimum value
51 */
52 static int SmallerOf(int value_1, int value_2);
53 /**
54 * Converts forward and turn to left and right speeds
55 * @param forward forward value of robot
56 * @param turn turn value of robot
57 * @param left Pointer to the left speed of robot, this will be filled
58 * @param right Pointer to the right speed of robot, this will be filled
59 */
60 static void Split_1(float forward, float turn, float *left, float *right);
61 /**
62 * Converts left and right to forward and turn speeds
63 * @param left left speed of robot
64 * @param right right speed of robot
65 * @param forward Pointer to the forward speed of the robot, this will be filled
66 * @param turn Pointer to the turn speed of the robot, this will be filled
67 */
68 static void Split_2(float left, float right, float *forward, float *turn);
69private:
70 static bool Contains(char array[], char item);
71};
72
73}}
Class with basic utility methods.
Definition: Utilities.h:10
static int SmallerOf(int value_1, int value_2)
Gets the minimum of the two values.
static void Split_2(float left, float right, float *forward, float *turn)
Converts left and right to forward and turn speeds.
static void Deadband(float &value, float deadband=-.10f)
Deadbands the value.
static float cap(float value, float peak)
Caps the value.
static void Split_1(float forward, float turn, float *left, float *right)
Converts forward and turn to left and right speeds.
static bool IsWithin(float value, float compareTo, float allowDelta)
Calculates if value is within a delta.
static float bound(float value, float capValue=1)
Caps the value.
static float abs(float f)
Calculates absolute value of f.
namespace ctre
Definition: paramEnum.h:5