Skip to content

JMarple/BNSLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BNSLib V0.15.0

This library is designed to be an advanced library for Highschool and University Vex Robotics Teams. It can be compiled on RobotC 4.27 (older versions may not compile correctly). The library features several concepts: - Dynamic Memory Allocation - Complex Matrix Operations (+ - * /, deterimant, trace, and others) - Gaussian Distribution Functions - Kalman Filter and Median Filter (more to come) - PID Controllers

This library was designed by Justin Marple on Team BNS
Contact: jmarple@umass.edu

Cheat Sheet

Matrix Basics:

  • CreateMatrix (Matrix *dst, char *input)
  • CreateZerosMatrix (Matrix *dst, int height, int width)
  • CreateIdentityMatrix (Matrix *dst, int height)
  • SetMatrixAt (Matrix *dst, int height, int width, float value)
  • GetMatrixAt (Matrix *dst, int height, int width)
  • DeleteMatrix (Matrix *dst)
  • CopyMatrix (Matrix *dst, Matrix src)
  • CopyMatrixByValue (Matrix *dst, Matrix src)

Matrix Arithmetic:

  • MatrixAdd (Matrix *dst, Matrix A, Matrix B)
  • MatrixSub (Matrix *dst, Matrix A, Matrix B)
  • MatrixMult (Matrix *dst, Matrix A, Matrix B)
  • MatrixInv (Matirx *dst, Matrix A)

Matrix Operations:

  • MatrixTranspose (Matrix *dst, Matrix A)
  • MatrixDeterminant (Matrix *src)
  • MatrixTrace (Matrix *src)

Dynamic Array Basics:

  • DynamicArrayAdd (DynamicArray *array, float value)
  • DynamicArrayGet (DynamicArray *array)
  • DynamicArraySize (DynamicArray *array)
  • DynamicArrayRemoveAt (DynamicArray *array, float index)
  • DynamicArrayClear (DynamicArray *array)
  • DynamicArrayDelete (DynamicArray *array)

Stack Basics:

  • StackPush (Stack *object, float value)
  • StackPop (Stack *object)
  • StackPeek (Stack *object)
  • StackIsEmpty (Stack *object)

Circular Buffer Basics:

  • CircularBufferInit (CircularBuffer *object, int size)
  • CircularBufferIsEmpty (CircularBuffer *object)
  • CircularBufferIsFull (CircularBuffer *object)
  • CircularBufferSize (CircularBuffer *object)
  • CircularBufferAdd (CircularBuffer *object, float value)
  • CircularBufferGet (CircularBuffer *object)

Motion Profile Basics:

  • MotionProfileInit (MotionProfile *profile)
  • MotionProfileSetAccel (MotionProfile *profile, float accel, float decel)
  • MotionProfileSetVelocity(MotionProfile *profile, float enterVel, float maxVel, float endVel)
  • MotionProfileSetDistance(MotionProfile *profile, float distance)
  • MotionProfileIsComplete(MotionProfile *profile, float time)
  • MotionProfileCompute (MotionProfile *profile, float time)
  • MotionProfileEasyParams(MotionProfile *profile, float accel, float speed, float distance)

PID Basics:

  • PIDInit (PID *controller, float kP, float kI, float kD)
  • PIDCompute (PID *controller, float error)

Gaussian Distribution Basics:

  • GaussianInit (Gaussian *gau, Matrix mean, Matrix covariance)
  • GaussianPDF (Gaussian *gau, Matrix data)

Kalman Filter Basics:

  • KalmanInit (KalmanFilter *kal, int variables, int measurements, [...])
  • KalmanPredict (KalmanFilter *kal)
  • KalmanUpdate (KalmanFilter *kal, Matrix measurement)

Simple Kalman Filter Basics:

  • SimpleKalmanInit (KalmanFilter *kal, double dt)
  • SimpleKalmanUpdate (KalmanFilter *kal, float data)

Median Filter Basics:

  • MedianInit (MedianFilter *filter, float size)
  • MedianAddData (MedianFilter *filter, float data)
  • MedianCompute (MedianFilter *filter)


Update Log

  • V0.10.0: First release, basic matrix operation and filters implemented
  • V0.11.0: Updated for portability with most C compilers (note: still some issues with portability though)
  • V0.12.0: PID controller added. Changed MultiplyScalarToMatrix to MatrixMultiplyScalar
  • V0.13.0: DynamicArray & Stack Data Structures Added. Added PID Integral functions.
  • V0.13.3: BNSMatrix changed to use DynamicArray. Significant bug found where uninitialized structs could seen as initialized.
  • V0.14.0: SimpleKalmanFilter created. CircularBuffer added as a data structure.
  • V0.15.0: Added MotionProfile Controller.