Ironcup Mar 2020

Dependencies:   mbed mbed-rtos MotionSensor EthernetInterface

Committer:
starling
Date:
Mon Sep 21 21:45:08 2020 +0000
Revision:
22:b7cca3089dfe
Parent:
21:8a98c6450e00
01 mar 2020

Who changed what in which revision?

UserRevisionLine numberNew contents of line
drelliak 21:8a98c6450e00 1 /**
drelliak 21:8a98c6450e00 2 @file receiver.h
drelliak 21:8a98c6450e00 3 @brief Receiver side functions declarations.
drelliak 21:8a98c6450e00 4 */
drelliak 21:8a98c6450e00 5
drelliak 21:8a98c6450e00 6 /*
drelliak 21:8a98c6450e00 7 Copyright 2016 Erik Perillo <erik.perillo@gmail.com>
drelliak 21:8a98c6450e00 8
drelliak 21:8a98c6450e00 9 This file is part of piranha-ptc.
drelliak 21:8a98c6450e00 10
drelliak 21:8a98c6450e00 11 This is free software: you can redistribute it and/or modify
drelliak 21:8a98c6450e00 12 it under the terms of the GNU General Public License as published by
drelliak 21:8a98c6450e00 13 the Free Software Foundation, either version 3 of the License, or
drelliak 21:8a98c6450e00 14 (at your option) any later version.
drelliak 21:8a98c6450e00 15
drelliak 21:8a98c6450e00 16 This is distributed in the hope that it will be useful,
drelliak 21:8a98c6450e00 17 but WITHOUT ANY WARRANTY; without even the implied warranty of
drelliak 21:8a98c6450e00 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
drelliak 21:8a98c6450e00 19 See the GNU General Public License for more details.
drelliak 21:8a98c6450e00 20
drelliak 21:8a98c6450e00 21 You should have received a copy of the GNU General Public License
drelliak 21:8a98c6450e00 22 along with this. If not, see <http://www.gnu.org/licenses/>.
drelliak 21:8a98c6450e00 23 */
drelliak 21:8a98c6450e00 24
drelliak 21:8a98c6450e00 25
drelliak 21:8a98c6450e00 26 #ifndef __PIRANHA_RCV_PROTOCOL_H__
drelliak 21:8a98c6450e00 27 #define __PIRANHA_RCV_PROTOCOL_H__
drelliak 21:8a98c6450e00 28
drelliak 21:8a98c6450e00 29 #include "protocol.h"
drelliak 21:8a98c6450e00 30 #include "mbed.h"
drelliak 21:8a98c6450e00 31 #include "EthernetInterface.h"
drelliak 21:8a98c6450e00 32
drelliak 21:8a98c6450e00 33 #define TEST
drelliak 21:8a98c6450e00 34
drelliak 21:8a98c6450e00 35 class Receiver
drelliak 21:8a98c6450e00 36 {
drelliak 21:8a98c6450e00 37
drelliak 21:8a98c6450e00 38 #ifdef TEST
drelliak 21:8a98c6450e00 39 public:
drelliak 21:8a98c6450e00 40 #else
drelliak 21:8a98c6450e00 41 protected:
drelliak 21:8a98c6450e00 42 #endif
drelliak 21:8a98c6450e00 43 UDPSocket sock;
drelliak 21:8a98c6450e00 44 char message[MSG_BUF_LEN];
drelliak 21:8a98c6450e00 45 Endpoint sender_addr;
drelliak 21:8a98c6450e00 46
drelliak 21:8a98c6450e00 47 float un_scale(uint16_t value, float min, float max);
drelliak 21:8a98c6450e00 48 uint8_t get_header();
drelliak 21:8a98c6450e00 49 uint16_t get_raw_val(int pos=0);
drelliak 21:8a98c6450e00 50 float get_val(float min, float max, int pos=0);
drelliak 21:8a98c6450e00 51 void get_vals(float min, float max, float* vals, int size);
drelliak 21:8a98c6450e00 52
drelliak 21:8a98c6450e00 53 public:
drelliak 21:8a98c6450e00 54 Receiver();
drelliak 21:8a98c6450e00 55 Receiver(Endpoint sender_addr, const UDPSocket& sock);
drelliak 21:8a98c6450e00 56 Receiver(Endpoint sender_addr, int sock_port=RECEIVER_PORT, int timeout=1);
drelliak 21:8a98c6450e00 57
drelliak 21:8a98c6450e00 58 void set_sender_addr(const Endpoint& sender_addr);
drelliak 21:8a98c6450e00 59 void set_socket(const UDPSocket& sock);
drelliak 21:8a98c6450e00 60 void set_socket(int port=RECEIVER_PORT, int timeout=1);
drelliak 21:8a98c6450e00 61 Endpoint get_sender_addr();
drelliak 21:8a98c6450e00 62 UDPSocket get_socket();
drelliak 21:8a98c6450e00 63
drelliak 21:8a98c6450e00 64 bool receive();
drelliak 21:8a98c6450e00 65 uint8_t get_msg();
drelliak 21:8a98c6450e00 66 float get_abs_ang_ref();
drelliak 21:8a98c6450e00 67 float get_rel_ang_ref();
drelliak 21:8a98c6450e00 68 float get_mag_ang_ref();
drelliak 21:8a98c6450e00 69 float get_gnd_vel();
drelliak 21:8a98c6450e00 70 void get_brake(float* intensity, float* period);
drelliak 21:8a98c6450e00 71 void get_jog_vel(float* period, float* ratio);
drelliak 21:8a98c6450e00 72 void get_pid_params(float* params);
drelliak 21:8a98c6450e00 73 void get_mag_calib(float* params);
drelliak 21:8a98c6450e00 74 };
drelliak 21:8a98c6450e00 75
drelliak 21:8a98c6450e00 76 #endif
drelliak 21:8a98c6450e00 77