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