mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 22:13:34 +08:00
segway: Fix code style
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
#include "BlockSegwayController.hpp"
|
#include "BlockSegwayController.hpp"
|
||||||
|
|
||||||
void BlockSegwayController::update() {
|
void BlockSegwayController::update()
|
||||||
|
{
|
||||||
// wait for a sensor update, check for exit condition every 100 ms
|
// 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();
|
uint64_t newTimeStamp = hrt_absolute_time();
|
||||||
float dt = (newTimeStamp - _timeStamp) / 1.0e6f;
|
float dt = (newTimeStamp - _timeStamp) / 1.0e6f;
|
||||||
@@ -10,20 +11,21 @@ void BlockSegwayController::update() {
|
|||||||
|
|
||||||
// check for sane values of dt
|
// check for sane values of dt
|
||||||
// to prevent large control responses
|
// 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
|
// set dt for all child blocks
|
||||||
setDt(dt);
|
setDt(dt);
|
||||||
|
|
||||||
// check for new updates
|
// check for new updates
|
||||||
if (_param_update.updated()) updateParams();
|
if (_param_update.updated()) { updateParams(); }
|
||||||
|
|
||||||
// get new information from subscriptions
|
// get new information from subscriptions
|
||||||
updateSubscriptions();
|
updateSubscriptions();
|
||||||
|
|
||||||
// default all output to zero unless handled by mode
|
// 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;
|
_actuators.control[i] = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// only update guidance in auto mode
|
// only update guidance in auto mode
|
||||||
if (_status.main_state == MAIN_STATE_AUTO) {
|
if (_status.main_state == MAIN_STATE_AUTO) {
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
using namespace control;
|
using namespace control;
|
||||||
|
|
||||||
class BlockSegwayController : public control::BlockUorbEnabledAutopilot {
|
class BlockSegwayController : public control::BlockUorbEnabledAutopilot
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
BlockSegwayController() :
|
BlockSegwayController() :
|
||||||
BlockUorbEnabledAutopilot(NULL,"SEG"),
|
BlockUorbEnabledAutopilot(NULL, "SEG"),
|
||||||
th2v(this, "TH2V"),
|
th2v(this, "TH2V"),
|
||||||
q2v(this, "Q2V"),
|
q2v(this, "Q2V"),
|
||||||
_attPoll(),
|
_attPoll(),
|
||||||
|
|||||||
@@ -74,8 +74,9 @@ static void usage(const char *reason);
|
|||||||
static void
|
static void
|
||||||
usage(const char *reason)
|
usage(const char *reason)
|
||||||
{
|
{
|
||||||
if (reason)
|
if (reason) {
|
||||||
fprintf(stderr, "%s\n", reason);
|
fprintf(stderr, "%s\n", reason);
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "usage: segway {start|stop|status} [-p <additional params>]\n\n");
|
fprintf(stderr, "usage: segway {start|stop|status} [-p <additional params>]\n\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -107,11 +108,11 @@ int segway_main(int argc, char *argv[])
|
|||||||
thread_should_exit = false;
|
thread_should_exit = false;
|
||||||
|
|
||||||
deamon_task = px4_task_spawn_cmd("segway",
|
deamon_task = px4_task_spawn_cmd("segway",
|
||||||
SCHED_DEFAULT,
|
SCHED_DEFAULT,
|
||||||
SCHED_PRIORITY_MAX - 10,
|
SCHED_PRIORITY_MAX - 10,
|
||||||
5120,
|
5120,
|
||||||
segway_thread_main,
|
segway_thread_main,
|
||||||
(argv) ? (char * const *)&argv[2] : (char * const *)NULL);
|
(argv) ? (char *const *)&argv[2] : (char *const *)NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user