Skip to content
Snippets Groups Projects
Commit ec5a0d5e authored by Lorenz Meier's avatar Lorenz Meier
Browse files

segway: Fix code style

parent d18d43b0
No related branches found
No related tags found
No related merge requests found
#include "BlockSegwayController.hpp"
void BlockSegwayController::update() {
void BlockSegwayController::update()
{
// wait for a sensor update, check for exit condition every 100 ms
if (poll(&_attPoll, 1, 100) < 0) return; // poll error
if (poll(&_attPoll, 1, 100) < 0) { return; } // poll error
uint64_t newTimeStamp = hrt_absolute_time();
float dt = (newTimeStamp - _timeStamp) / 1.0e6f;
......@@ -10,20 +11,21 @@ void BlockSegwayController::update() {
// check for sane values of dt
// to prevent large control responses
if (dt > 1.0f || dt < 0) return;
if (dt > 1.0f || dt < 0) { return; }
// set dt for all child blocks
setDt(dt);
// check for new updates
if (_param_update.updated()) updateParams();
if (_param_update.updated()) { updateParams(); }
// get new information from subscriptions
updateSubscriptions();
// default all output to zero unless handled by mode
for (unsigned i = 2; i < NUM_ACTUATOR_CONTROLS; i++)
for (unsigned i = 2; i < NUM_ACTUATOR_CONTROLS; i++) {
_actuators.control[i] = 0.0f;
}
// only update guidance in auto mode
if (_status.main_state == MAIN_STATE_AUTO) {
......
......@@ -4,10 +4,11 @@
using namespace control;
class BlockSegwayController : public control::BlockUorbEnabledAutopilot {
class BlockSegwayController : public control::BlockUorbEnabledAutopilot
{
public:
BlockSegwayController() :
BlockUorbEnabledAutopilot(NULL,"SEG"),
BlockUorbEnabledAutopilot(NULL, "SEG"),
th2v(this, "TH2V"),
q2v(this, "Q2V"),
_attPoll(),
......
......@@ -74,8 +74,9 @@ static void usage(const char *reason);
static void
usage(const char *reason)
{
if (reason)
if (reason) {
fprintf(stderr, "%s\n", reason);
}
fprintf(stderr, "usage: segway {start|stop|status} [-p <additional params>]\n\n");
exit(1);
......@@ -107,11 +108,11 @@ int segway_main(int argc, char *argv[])
thread_should_exit = false;
deamon_task = px4_task_spawn_cmd("segway",
SCHED_DEFAULT,
SCHED_PRIORITY_MAX - 10,
5120,
segway_thread_main,
(argv) ? (char * const *)&argv[2] : (char * const *)NULL);
SCHED_DEFAULT,
SCHED_PRIORITY_MAX - 10,
5120,
segway_thread_main,
(argv) ? (char *const *)&argv[2] : (char *const *)NULL);
exit(0);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment