From ec5a0d5e80b3ed654bccfb22990fea68407cedc9 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 5 Sep 2015 22:17:58 +0200 Subject: [PATCH] segway: Fix code style --- src/modules/segway/BlockSegwayController.cpp | 12 +++++++----- src/modules/segway/BlockSegwayController.hpp | 5 +++-- src/modules/segway/segway_main.cpp | 13 +++++++------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/modules/segway/BlockSegwayController.cpp b/src/modules/segway/BlockSegwayController.cpp index 91230a37cb..ba7665201a 100644 --- a/src/modules/segway/BlockSegwayController.cpp +++ b/src/modules/segway/BlockSegwayController.cpp @@ -1,8 +1,9 @@ #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) { diff --git a/src/modules/segway/BlockSegwayController.hpp b/src/modules/segway/BlockSegwayController.hpp index 4a01f785c5..4413a3cff8 100644 --- a/src/modules/segway/BlockSegwayController.hpp +++ b/src/modules/segway/BlockSegwayController.hpp @@ -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(), diff --git a/src/modules/segway/segway_main.cpp b/src/modules/segway/segway_main.cpp index 67acd94bf7..667b2ad3fe 100644 --- a/src/modules/segway/segway_main.cpp +++ b/src/modules/segway/segway_main.cpp @@ -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 ]\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); }