aboutsummaryrefslogtreecommitdiff
path: root/src/modules/uORB/topics/esc_status.h
blob: 628824efa89154b1fc8894237324feb2b08e8a8a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/****************************************************************************
 *
 *   Copyright (C) 2013 PX4 Development Team. All rights reserved.
 *   Author: @author Marco Bauer <marco@wtns.de>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name PX4 nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************/

/**
 * @file esc_status.h
 * Definition of the esc_status uORB topic.
 *
 * Published the state machine and the system status bitfields
 * (see SYS_STATUS mavlink message), published only by commander app.
 *
 * All apps should write to subsystem_info:
 *
 *  (any app) --> subsystem_info (published) --> (commander app state machine)  --> esc_status --> (mavlink app)
 */

#ifndef ESC_STATUS_H_
#define ESC_STATUS_H_

#include <stdint.h>
#include <stdbool.h>
#include "../uORB.h"

/**
 * The number of ESCs supported.
 * Current (Q2/2013) we support 8 ESCs,
 */
#define CONNECTED_ESC_MAX   8

enum ESC_VENDOR {
	ESC_VENDOR_GENERIC = 0,					/**< generic ESC */
	ESC_VENDOR_MIKROKOPTER,					/**< Mikrokopter */
	ESC_VENDOR_GRAUPNER_HOTT				/**< Graupner HoTT ESC */
};

enum ESC_CONNECTION_TYPE {
	ESC_CONNECTION_TYPE_PPM = 0,			/**< Traditional PPM ESC */
	ESC_CONNECTION_TYPE_SERIAL,			/**< Serial Bus connected ESC */
	ESC_CONNECTION_TYPE_ONESHOOT,			/**< One Shoot PPM */
	ESC_CONNECTION_TYPE_I2C,				/**< I2C */
	ESC_CONNECTION_TYPE_CAN					/**< CAN-Bus */
};

/**
 * @addtogroup topics
 * @{
 */

/**
 * Electronic speed controller status.
 */
struct esc_status_s {
	/* use of a counter and timestamp recommended (but not necessary) */

	uint16_t counter;   		/**< incremented by the writing thread everytime new data is stored */
	uint64_t timestamp; 		/**< in microseconds since system start, is set whenever the writing thread stores new data */

	uint8_t esc_count;			/**< number of connected ESCs */
	enum ESC_CONNECTION_TYPE esc_connectiontype;	/**< how ESCs connected to the system */

	struct {
		uint16_t esc_address;			/**< Address of current ESC (in most cases 1-8 / must be set by driver) */
		enum ESC_VENDOR esc_vendor;		/**< Vendor of current ESC */
		uint16_t esc_version;			/**< Version of current ESC - if supported */
		uint16_t esc_voltage;			/**< Voltage measured from current ESC - if supported */
		uint16_t esc_current;			/**< Current measured from current ESC (100mA steps) - if supported */
		uint16_t esc_rpm;				/**< RPM measured from current ESC - if supported */
		uint16_t esc_temperature;		/**< Temperature measured from current ESC - if supported */
		float    esc_setpoint;			/**< setpoint of current ESC */
		uint16_t esc_setpoint_raw;		/**< setpoint of current ESC (Value sent to ESC) */
		uint16_t esc_state;				/**< State of ESC - depend on Vendor */
		uint16_t esc_errorcount;		/**< Number of reported errors by ESC - if supported */
	} esc[CONNECTED_ESC_MAX];

};

/**
 * @}
 */

/* register this as object request broker structure */
//ORB_DECLARE(esc_status);
ORB_DECLARE_OPTIONAL(esc_status);

#endif