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 protocol.h
drelliak 21:8a98c6450e00 3 @brief Protocol definitions.
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_PROTOCOL_H__
drelliak 21:8a98c6450e00 27 #define __PIRANHA_PROTOCOL_H__
drelliak 21:8a98c6450e00 28
drelliak 21:8a98c6450e00 29 //@{
drelliak 21:8a98c6450e00 30 ///PID parameters range.
drelliak 21:8a98c6450e00 31 #define PID_PARAMS_MIN 0.0
drelliak 21:8a98c6450e00 32 #define PID_PARAMS_MAX 100.0
drelliak 21:8a98c6450e00 33 //@}
drelliak 21:8a98c6450e00 34
drelliak 21:8a98c6450e00 35 //@{
drelliak 21:8a98c6450e00 36 ///Ground velocity range.
drelliak 21:8a98c6450e00 37 #define GND_VEL_MIN -100.0
drelliak 21:8a98c6450e00 38 #define GND_VEL_MAX 100.0
drelliak 21:8a98c6450e00 39 //@}
drelliak 21:8a98c6450e00 40
drelliak 21:8a98c6450e00 41 //@{
drelliak 21:8a98c6450e00 42 ///Angle reference range (in radians).
drelliak 21:8a98c6450e00 43 #define PI 3.141593
drelliak 21:8a98c6450e00 44 #define ABS_ANG_REF_MIN -PI
drelliak 21:8a98c6450e00 45 #define ABS_ANG_REF_MAX PI
drelliak 21:8a98c6450e00 46 //@}
drelliak 21:8a98c6450e00 47
drelliak 21:8a98c6450e00 48 //@{
drelliak 21:8a98c6450e00 49 ///Angle reference from robot range (in radians).
drelliak 21:8a98c6450e00 50 #define REL_ANG_REF_MIN -PI
drelliak 21:8a98c6450e00 51 #define REL_ANG_REF_MAX PI
drelliak 21:8a98c6450e00 52 //@}
drelliak 21:8a98c6450e00 53
drelliak 21:8a98c6450e00 54 //@{
drelliak 21:8a98c6450e00 55 ///Angle reference from magnetometer range (in radians).
drelliak 21:8a98c6450e00 56 #define MAG_ANG_REF_MIN -PI
drelliak 21:8a98c6450e00 57 #define MAG_ANG_REF_MAX PI
drelliak 21:8a98c6450e00 58 //@}
drelliak 21:8a98c6450e00 59
drelliak 21:8a98c6450e00 60 //@{
drelliak 21:8a98c6450e00 61 ///Break intensity
drelliak 21:8a98c6450e00 62 #define BRAKE_INTENSITY_MIN 0.0
drelliak 21:8a98c6450e00 63 #define BRAKE_INTENSITY_MAX 100.0
drelliak 21:8a98c6450e00 64 //@}
drelliak 21:8a98c6450e00 65
drelliak 21:8a98c6450e00 66 //@{
drelliak 21:8a98c6450e00 67 ///Jogging speed ratio.
drelliak 21:8a98c6450e00 68 #define BRAKE_PERIOD_MIN 0.0
drelliak 21:8a98c6450e00 69 #define BRAKE_PERIOD_MAX 100.0
drelliak 21:8a98c6450e00 70 //@}
drelliak 21:8a98c6450e00 71
drelliak 21:8a98c6450e00 72 //@{
drelliak 21:8a98c6450e00 73 ///Jogging speed period (in seconds).
drelliak 21:8a98c6450e00 74 #define JOG_VEL_PERIOD_MIN 0.0
drelliak 21:8a98c6450e00 75 #define JOG_VEL_PERIOD_MAX 300.0
drelliak 21:8a98c6450e00 76 //@}
drelliak 21:8a98c6450e00 77
drelliak 21:8a98c6450e00 78 //@{
drelliak 21:8a98c6450e00 79 ///Jogging speed ratio.
drelliak 21:8a98c6450e00 80 #define JOG_VEL_RATIO_MIN 0.0
drelliak 21:8a98c6450e00 81 #define JOG_VEL_RATIO_MAX 1.0
drelliak 21:8a98c6450e00 82 //@}
drelliak 21:8a98c6450e00 83
drelliak 21:8a98c6450e00 84 //@{
drelliak 21:8a98c6450e00 85 ///Magnetometer calibration values.
drelliak 21:8a98c6450e00 86 #define MAG_CALIB_MIN -750.0
drelliak 21:8a98c6450e00 87 #define MAG_CALIB_MAX 750.0
drelliak 21:8a98c6450e00 88 //@}
drelliak 21:8a98c6450e00 89
drelliak 21:8a98c6450e00 90 ///Messages to send via protocol.
drelliak 21:8a98c6450e00 91 enum
drelliak 21:8a98c6450e00 92 {
drelliak 21:8a98c6450e00 93 ///Do nothing.
drelliak 21:8a98c6450e00 94 NONE,
drelliak 21:8a98c6450e00 95
drelliak 21:8a98c6450e00 96 ///Brake the robot.
drelliak 21:8a98c6450e00 97 BRAKE,
drelliak 21:8a98c6450e00 98
drelliak 21:8a98c6450e00 99 ///Reset gyroscope.
drelliak 21:8a98c6450e00 100 GYRO_ZERO,
drelliak 21:8a98c6450e00 101
drelliak 21:8a98c6450e00 102 ///Set zero axis to current angle measure.
drelliak 21:8a98c6450e00 103 ANG_SET,
drelliak 21:8a98c6450e00 104
drelliak 21:8a98c6450e00 105 ///Reset angle zero axis.
drelliak 21:8a98c6450e00 106 ANG_RST,
drelliak 21:8a98c6450e00 107
drelliak 21:8a98c6450e00 108 ///Turn on leds
drelliak 21:8a98c6450e00 109 LED_ON,
drelliak 21:8a98c6450e00 110
drelliak 21:8a98c6450e00 111 ///Turn off leds
drelliak 21:8a98c6450e00 112 LED_OFF,
drelliak 21:8a98c6450e00 113
drelliak 21:8a98c6450e00 114 ///Set new angle reference relative to zero axis.
drelliak 21:8a98c6450e00 115 ABS_ANG_REF,
drelliak 21:8a98c6450e00 116
drelliak 21:8a98c6450e00 117 ///Set new angle reference relative to robot axis.
drelliak 21:8a98c6450e00 118 REL_ANG_REF,
drelliak 21:8a98c6450e00 119
drelliak 21:8a98c6450e00 120 ///Set new angle reference relative to north using magnetometer.
drelliak 21:8a98c6450e00 121 MAG_ANG_REF,
drelliak 21:8a98c6450e00 122
drelliak 21:8a98c6450e00 123 ///Set new ground velocity for robot.
drelliak 21:8a98c6450e00 124 GND_VEL,
drelliak 21:8a98c6450e00 125
drelliak 21:8a98c6450e00 126 ///Set new jogging speed for robot.
drelliak 21:8a98c6450e00 127 JOG_VEL,
drelliak 21:8a98c6450e00 128
drelliak 21:8a98c6450e00 129 ///Magnetometer calibration (min_x, max_x, min_y, max_y).
drelliak 21:8a98c6450e00 130 MAG_CALIB,
drelliak 21:8a98c6450e00 131
drelliak 21:8a98c6450e00 132 ///Send PID control parameters (P, I, D, N).
drelliak 21:8a98c6450e00 133 PID_PARAMS
drelliak 21:8a98c6450e00 134 };
drelliak 21:8a98c6450e00 135
drelliak 21:8a98c6450e00 136 #define MSG_HEADER_SIZE 1
drelliak 21:8a98c6450e00 137 #define MSG_VAL_SIZE 2
drelliak 21:8a98c6450e00 138 #define MSG_MAX_NUM_VALS 4
drelliak 21:8a98c6450e00 139 #define MSG_BUF_LEN (MSG_HEADER_SIZE + MSG_VAL_SIZE*MSG_MAX_NUM_VALS)
drelliak 21:8a98c6450e00 140 #define MSG_HEADER_IDX 0
drelliak 21:8a98c6450e00 141 #define MSG_VALS_START_IDX (MSG_HEADER_IDX + 1)
drelliak 21:8a98c6450e00 142
drelliak 21:8a98c6450e00 143 #define SENDER_PORT 7532
drelliak 21:8a98c6450e00 144 #define SENDER_IFACE_ADDR "192.168.7.2"
drelliak 21:8a98c6450e00 145 #define SENDER_NETMASK_ADDR "255.255.255.0"
drelliak 21:8a98c6450e00 146 #define SENDER_GATEWAY_ADDR "0.0.0.0"
drelliak 21:8a98c6450e00 147
drelliak 21:8a98c6450e00 148 #define RECEIVER_PORT 7533
drelliak 21:8a98c6450e00 149 #define RECEIVER_IFACE_ADDR "192.168.7.3"
drelliak 21:8a98c6450e00 150 #define RECEIVER_NETMASK_ADDR "255.255.255.0"
drelliak 21:8a98c6450e00 151 #define RECEIVER_GATEWAY_ADDR "0.0.0.0"
drelliak 21:8a98c6450e00 152
drelliak 21:8a98c6450e00 153 #endif
drelliak 21:8a98c6450e00 154