TrekkingPhoenix / Mbed 2 deprecated TrekkingControllerV1-4_WinterChallenge20

Dependencies:   mbed mbed-rtos MotionSensor EthernetInterface

Committer:
drelliak
Date:
Mon Apr 11 05:20:40 2016 +0000
Revision:
0:88faaa1afb83
Child:
8:a1067fcde341
Trekking Controller

Who changed what in which revision?

UserRevisionLine numberNew contents of line
drelliak 0:88faaa1afb83 1 /*
drelliak 0:88faaa1afb83 2 Copyright 2016 Erik Perillo <erik.perillo@gmail.com>
drelliak 0:88faaa1afb83 3
drelliak 0:88faaa1afb83 4 This file is part of piranha-ptc.
drelliak 0:88faaa1afb83 5
drelliak 0:88faaa1afb83 6 This is free software: you can redistribute it and/or modify
drelliak 0:88faaa1afb83 7 it under the terms of the GNU General Public License as published by
drelliak 0:88faaa1afb83 8 the Free Software Foundation, either version 3 of the License, or
drelliak 0:88faaa1afb83 9 (at your option) any later version.
drelliak 0:88faaa1afb83 10
drelliak 0:88faaa1afb83 11 This is distributed in the hope that it will be useful,
drelliak 0:88faaa1afb83 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
drelliak 0:88faaa1afb83 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
drelliak 0:88faaa1afb83 14 See the GNU General Public License for more details.
drelliak 0:88faaa1afb83 15
drelliak 0:88faaa1afb83 16 You should have received a copy of the GNU General Public License
drelliak 0:88faaa1afb83 17 along with this. If not, see <http://www.gnu.org/licenses/>.
drelliak 0:88faaa1afb83 18 */
drelliak 0:88faaa1afb83 19
drelliak 0:88faaa1afb83 20
drelliak 0:88faaa1afb83 21 #ifndef __PIRANHA_RCV_PROTOCOL_H__
drelliak 0:88faaa1afb83 22 #define __PIRANHA_RCV_PROTOCOL_H__
drelliak 0:88faaa1afb83 23
drelliak 0:88faaa1afb83 24 #include "protocol.h"
drelliak 0:88faaa1afb83 25 #include "mbed.h"
drelliak 0:88faaa1afb83 26
drelliak 0:88faaa1afb83 27
drelliak 0:88faaa1afb83 28 /**
drelliak 0:88faaa1afb83 29 Reads serial and converts a string of (one or two) bytes into an unsigned int.
drelliak 0:88faaa1afb83 30 Least-significant bytes must come first.
drelliak 0:88faaa1afb83 31 Assumes big-endian representation of numbers on architecture.
drelliak 0:88faaa1afb83 32 */
drelliak 0:88faaa1afb83 33 uint16_t read(Serial& serial);
drelliak 0:88faaa1afb83 34
drelliak 0:88faaa1afb83 35 /**
drelliak 0:88faaa1afb83 36 Converts unsigned int into float following unit-normalization rules.
drelliak 0:88faaa1afb83 37 */
drelliak 0:88faaa1afb83 38 float un_scale(uint16_t value, float min, float max);
drelliak 0:88faaa1afb83 39
drelliak 0:88faaa1afb83 40 /**
drelliak 0:88faaa1afb83 41 Applies un_scale to value read on serial.
drelliak 0:88faaa1afb83 42 */
drelliak 0:88faaa1afb83 43 float get_param(Serial& serial, float min, float max);
drelliak 0:88faaa1afb83 44
drelliak 0:88faaa1afb83 45 /**
drelliak 0:88faaa1afb83 46 Gets all 4 pid parameters from serial stream.
drelliak 0:88faaa1afb83 47 */
drelliak 0:88faaa1afb83 48 void get_pid_params(Serial& serial, float* kp, float* ki, float* kd, float* n);
drelliak 0:88faaa1afb83 49
drelliak 0:88faaa1afb83 50 //macros just to make life easier
drelliak 0:88faaa1afb83 51 #define get_pid_param(serial) get_param(serial, PID_PARAMS_MIN, PID_PARAMS_MAX)
drelliak 0:88faaa1afb83 52 #define get_gnd_speed(serial) get_param(serial, GND_SPEED_MIN, GND_SPEED_MAX)
drelliak 0:88faaa1afb83 53 #define get_ang_ref(serial) get_param(serial, ANG_REF_MIN, ANG_REF_MAX)
drelliak 0:88faaa1afb83 54
drelliak 0:88faaa1afb83 55 #endif
drelliak 0:88faaa1afb83 56