Ben Katz / Hobbyking_Cheetah_Compact

Motor control for robots. More compact, less object-oriented revision.

Dependencies:   CANnucleo FastPWM3 mbed

Fork of Hobbyking_Cheetah_V1 by Ben Katz

Committer:
benkatz
Date:
Wed Apr 05 20:54:16 2017 +0000
Revision:
23:2adf23ee0305
Added bayley's flash writer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
benkatz20:bf9ea5125d52 1
benkatz20:bf9ea5125d52 2#include "math_ops.h"
benkatz20:bf9ea5125d52 3
benkatz20:bf9ea5125d52 4
benkatz20:bf9ea5125d52 5float fmaxf(float x, float y){
benkatz20:bf9ea5125d52 6 return (((x)>(y))?(x):(y));
benkatz20:bf9ea5125d52 7 }
benkatz20:bf9ea5125d52 8
benkatz20:bf9ea5125d52 9float fminf(float x, float y){
benkatz20:bf9ea5125d52 10 return (((x)<(y))?(x):(y));
benkatz20:bf9ea5125d52 11 }
benkatz20:bf9ea5125d52 12
benkatz20:bf9ea5125d52 13float fmaxf3(float x, float y, float z){
benkatz20:bf9ea5125d52 14 return (x > y ? (x > z ? x : z) : (y > z ? y : z));
benkatz20:bf9ea5125d52 15 }
benkatz20:bf9ea5125d52 16
benkatz20:bf9ea5125d52 17float fminf3(float x, float y, float z){
benkatz20:bf9ea5125d52 18 return (x < y ? (x < z ? x : z) : (y < z ? y : z));
benkatz20:bf9ea5125d52 19 }
benkatz20:bf9ea5125d52 20
benkatz20:bf9ea5125d52 21void limit_norm(float *x, float *y, float limit){
benkatz20:bf9ea5125d52 22 float norm = sqrt(*x * *x + *y * *y);
benkatz20:bf9ea5125d52 23 if(norm > limit){
benkatz20:bf9ea5125d52 24 *x = *x * limit/norm;
benkatz20:bf9ea5125d52 25 *y = *y * limit/norm;
benkatz20:bf9ea5125d52 26 }
benkatz20:bf9ea5125d52 27 }