TrekkingPhoenix / Mbed 2 deprecated Trekking_Controller_refac

Dependencies:   mbed mbed-rtos MotionSensor EthernetInterface

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers protocol.h Source File

protocol.h

Go to the documentation of this file.
00001 /**
00002 @file protocol.h
00003 @brief Protocol definitions.
00004 */
00005 
00006 /*
00007 Copyright 2016 Erik Perillo <erik.perillo@gmail.com>
00008 
00009 This file is part of piranha-ptc.
00010 
00011 This is free software: you can redistribute it and/or modify
00012 it under the terms of the GNU General Public License as published by
00013 the Free Software Foundation, either version 3 of the License, or
00014 (at your option) any later version.
00015 
00016 This is distributed in the hope that it will be useful,
00017 but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00019 See the GNU General Public License for more details.
00020 
00021 You should have received a copy of the GNU General Public License
00022 along with this. If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00025 
00026 #ifndef __PIRANHA_PROTOCOL_H__
00027 #define __PIRANHA_PROTOCOL_H__
00028 
00029 //@{
00030 ///PID parameters range.
00031 #define PID_PARAMS_MIN 0.0
00032 #define PID_PARAMS_MAX 100.0
00033 //@}
00034 
00035 //@{
00036 ///Ground velocity range.
00037 #define GND_VEL_MIN -100.0
00038 #define GND_VEL_MAX 100.0
00039 //@}
00040 
00041 //@{
00042 ///Angle reference range (in radians).
00043 #define PI 3.141593
00044 #define ABS_ANG_REF_MIN -PI
00045 #define ABS_ANG_REF_MAX PI
00046 //@}
00047 
00048 //@{
00049 ///Angle reference from robot range (in radians).
00050 #define REL_ANG_REF_MIN -PI
00051 #define REL_ANG_REF_MAX PI
00052 //@}
00053 
00054 //@{
00055 ///Angle reference from magnetometer range (in radians).
00056 #define MAG_ANG_REF_MIN -PI
00057 #define MAG_ANG_REF_MAX PI
00058 //@}
00059 
00060 //@{
00061 ///Break intensity
00062 #define BRAKE_INTENSITY_MIN 0.0
00063 #define BRAKE_INTENSITY_MAX 100.0
00064 //@}
00065 
00066 //@{
00067 ///Jogging speed ratio.
00068 #define BRAKE_PERIOD_MIN 0.0
00069 #define BRAKE_PERIOD_MAX 100.0
00070 //@}
00071 
00072 //@{
00073 ///Jogging speed period (in seconds).
00074 #define JOG_VEL_PERIOD_MIN 0.0
00075 #define JOG_VEL_PERIOD_MAX 300.0
00076 //@}
00077 
00078 //@{
00079 ///Jogging speed ratio.
00080 #define JOG_VEL_RATIO_MIN 0.0
00081 #define JOG_VEL_RATIO_MAX 1.0
00082 //@}
00083 
00084 //@{
00085 ///Magnetometer calibration values.
00086 #define MAG_CALIB_MIN -750.0
00087 #define MAG_CALIB_MAX 750.0
00088 //@}
00089 
00090 ///Messages to send via protocol.
00091 enum
00092 {
00093     ///Do nothing.
00094     NONE,
00095 
00096     ///Brake the robot.
00097     BRAKE,
00098 
00099     ///Reset gyroscope.
00100     GYRO_ZERO,
00101 
00102     ///Set zero axis to current angle measure.
00103     ANG_SET,
00104 
00105     ///Reset angle zero axis.
00106     ANG_RST,
00107 
00108     ///Turn on leds
00109     LED_ON,
00110 
00111     ///Turn off leds
00112     LED_OFF,
00113 
00114     ///Set new angle reference relative to zero axis.
00115     ABS_ANG_REF,
00116 
00117     ///Set new angle reference relative to robot axis.
00118     REL_ANG_REF,
00119 
00120     ///Set new angle reference relative to north using magnetometer.
00121     MAG_ANG_REF,
00122 
00123     ///Set new ground velocity for robot.
00124     GND_VEL,
00125 
00126     ///Set new jogging speed for robot.
00127     JOG_VEL,
00128 
00129     ///Magnetometer calibration (min_x, max_x, min_y, max_y).
00130     MAG_CALIB,
00131 
00132     ///Send PID control parameters (P, I, D, N).
00133     PID_PARAMS
00134 };
00135 
00136 #define MSG_HEADER_SIZE 1
00137 #define MSG_VAL_SIZE 2
00138 #define MSG_MAX_NUM_VALS 4
00139 #define MSG_BUF_LEN (MSG_HEADER_SIZE + MSG_VAL_SIZE*MSG_MAX_NUM_VALS)
00140 #define MSG_HEADER_IDX 0
00141 #define MSG_VALS_START_IDX (MSG_HEADER_IDX + 1)
00142 
00143 #define SENDER_PORT 7532
00144 #define SENDER_IFACE_ADDR "192.168.7.2"
00145 #define SENDER_NETMASK_ADDR "255.255.255.0"
00146 #define SENDER_GATEWAY_ADDR "0.0.0.0"
00147 
00148 #define RECEIVER_PORT 7533
00149 #define RECEIVER_IFACE_ADDR "192.168.7.3"
00150 #define RECEIVER_NETMASK_ADDR "255.255.255.0"
00151 #define RECEIVER_GATEWAY_ADDR "0.0.0.0"
00152 
00153 #endif
00154