Skip to content

Commit ee34182

Browse files
update FlightController API
remove deleted methods, describe methods 'request' and 'respond' for sending and receiving messages
1 parent 3d28d4e commit ee34182

File tree

1 file changed

+15
-30
lines changed

1 file changed

+15
-30
lines changed

README.md

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,10 @@ Instantiate and setup the `FlightController` class:
136136
```
137137
#include <FlightController.hpp>
138138
139-
fcu::FlightController fcu("/dev/ttyUSB0");
139+
fcu::FlightController fcu("/dev/ttyUSB0", 115200);
140140
141-
// set conversion units for Imu measurements
142-
fcu.setAcc1G(512.0);
143-
fcu.setGyroUnit(1.0/4096);
144-
fcu.setMagnGain(1090.0/100.0);
145-
fcu.setStandardGravity(9.80665);
146-
147-
// create default messages
148-
fcu.populate_database();
149-
150-
// wait for connection
151-
fcu.waitForConnection();
141+
// wait for connection and setup
142+
fcu.initialise();
152143
```
153144

154145
### Periodic request for messages
@@ -167,31 +158,25 @@ public:
167158
}
168159
```
169160

170-
#### Register callbacks
171-
Instantiate class with callbacks and register them to the FCU:
161+
Instantiate class with callbacks and register them to the FCU with the desired update rate in seconds:
172162
```
173163
App app;
174164
175-
fcu.subscribe(&App::onStatus, &app);
176-
fcu.subscribe(&App::onImu, &app);
177-
```
178-
179-
Messages can now be requested and handled in a loop:
180-
```
181-
while(true) {
182-
fcu.sendRequests();
183-
fcu.handleRequests();
184-
}
165+
fcu.subscribe(&App::onStatus, &app, 0.1);
166+
fcu.subscribe(&App::onImu, &app, 0.01);
185167
```
186168

187169
Requests are sent to and processed by the flight controller as fast as possible. It is important to note that the MultiWii FCU only processed a single message per cycle. All subscribed messages therefore share the effective bandwidth of 1/(2800 us) = 357 messages per second.
188170

189-
#### Register callbacks with different priorities
190-
It is possible to provide a target update rate to the subscribe method that allows to use more frequent updates of important messages (such as Imu) and less frequent updates of less important messages (such as the battery voltage).
171+
### Request and Send Messages
172+
Additional messages that are not requested periodically can be requested by the method
173+
```
174+
bool request(msp::Request &request, const double timeout = 0)
175+
```
176+
You need to instantiate a message of type `msp::Request` and provide it to the method with an optional timeout.
191177

192-
If a target period (in seconds) is provided:
178+
Response messages are sent by
193179
```
194-
fcu.subscribe(&App::onStatus, &app, 1);
195-
fcu.subscribe(&App::onImu, &app, 0.01);
180+
bool respond(const msp::Response &response, const bool wait_ack=true)
196181
```
197-
the subscribed Request will periodically be sent by a background thread. In this case it is not required to call `sendRequests()` as this method will only send request of callbacks that have not been registered with a period time.
182+
where the method will block until an acknowledge is received if `wait_ack=true` (default).

0 commit comments

Comments
 (0)