Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-rtos MotionSensor EthernetInterface
Diff: Protocol/protocol.h
- Revision:
- 19:c709c5a9fb08
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Protocol/protocol.h Sun May 15 19:14:06 2016 +0000
@@ -0,0 +1,121 @@
+/**
+@file protocol.h
+@brief Protocol definitions.
+*/
+
+/*
+Copyright 2016 Erik Perillo <erik.perillo@gmail.com>
+
+This file is part of piranha-ptc.
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef __PIRANHA_PROTOCOL_H__
+#define __PIRANHA_PROTOCOL_H__
+
+//@{
+///PID parameters range.
+#define PID_PARAMS_MIN -100.0
+#define PID_PARAMS_MAX 100.0
+//@}
+
+//@{
+///Ground velocity range.
+#define GND_VEL_MIN -100.0
+#define GND_VEL_MAX 100.0
+//@}
+
+//@{
+///Angle reference range (in radians).
+#define PI 3.141593
+#define ANG_REF_MIN -PI
+#define ANG_REF_MAX PI
+//@}
+
+//@{
+///Angle reference from camera range (in radians).
+#define CAM_ANG_REF_MIN -PI
+#define CAM_ANG_REF_MAX PI
+//@}
+
+//@{
+///Jogging speed period (in seconds).
+#define JOG_VEL_PERIOD_MIN 0.0
+#define JOG_VEL_PERIOD_MAX 300.0
+//@}
+
+//@{
+///Jogging speed ratio.
+#define JOG_VEL_RATIO_MIN 0.0
+#define JOG_VEL_RATIO_MAX 1.0
+//@}
+
+//@{
+///Jogging speed period (in seconds).
+#define MAG_CALIB_MIN -1000.0
+#define MAG_CALIB_MAX 1000.0
+//@}
+
+///Messages to send via protocol.
+enum
+{
+ ///Do nothing.
+ NONE,
+
+ ///Brake the robot.
+ BRAKE,
+
+ ///Reset angle measurement.
+ ANG_RST,
+
+ ///Set new angle reference.
+ ANG_REF,
+
+ ///Set new angle reference from camera.
+ CAM_ANG_REF,
+
+ ///Set new ground velocity for robot.
+ GND_VEL,
+
+ ///Set new jogging speed for robot.
+ JOG_VEL,
+
+ ///Magnetometer calibration (min_x, max_x, min_y, max_y).
+ MAG_CALIB,
+
+ ///Send PID control parameters (P, I, D, N).
+ PID_PARAMS
+};
+
+#define MSG_HEADER_SIZE 1
+#define MSG_VAL_SIZE 2
+#define MSG_MAX_NUM_VALS 4
+#define MSG_BUF_LEN (MSG_HEADER_SIZE + MSG_VAL_SIZE*MSG_MAX_NUM_VALS)
+#define MSG_HEADER_IDX 0
+#define MSG_VALS_START_IDX (MSG_HEADER_IDX + 1)
+
+#define SENDER_PORT 7532
+#define SENDER_IFACE_ADDR "192.168.7.2"
+#define SENDER_NETMASK_ADDR "255.255.255.0"
+#define SENDER_GATEWAY_ADDR "0.0.0.0"
+
+#define RECEIVER_PORT 7533
+#define RECEIVER_IFACE_ADDR "192.168.7.3"
+#define RECEIVER_NETMASK_ADDR "255.255.255.0"
+#define RECEIVER_GATEWAY_ADDR "0.0.0.0"
+
+#endif
+