mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-24 15:40:31 +08:00
code style, warnings
This commit is contained in:
@@ -113,8 +113,7 @@ void UavcanEscController::update_outputs(float *outputs, unsigned num_outputs)
|
||||
msg.cmd.push_back(static_cast<int>(scaled));
|
||||
|
||||
_esc_status.esc[i].esc_setpoint_raw = abs(static_cast<int>(scaled));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg.cmd.push_back(static_cast<unsigned>(0));
|
||||
}
|
||||
}
|
||||
@@ -128,18 +127,20 @@ void UavcanEscController::update_outputs(float *outputs, unsigned num_outputs)
|
||||
|
||||
void UavcanEscController::arm_all_escs(bool arm)
|
||||
{
|
||||
if (arm)
|
||||
if (arm) {
|
||||
_armed_mask = -1;
|
||||
else
|
||||
} else {
|
||||
_armed_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void UavcanEscController::arm_single_esc(int num, bool arm)
|
||||
{
|
||||
if (arm)
|
||||
if (arm) {
|
||||
_armed_mask = MOTOR_BIT(num);
|
||||
else
|
||||
} else {
|
||||
_armed_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void UavcanEscController::esc_status_sub_cb(const uavcan::ReceivedDataStructure<uavcan::equipment::esc::Status> &msg)
|
||||
|
||||
@@ -346,13 +346,12 @@ int UavcanNode::run()
|
||||
|
||||
// can we mix?
|
||||
if (_test_in_progress) {
|
||||
float outputs[NUM_ACTUATOR_OUTPUTS] = {};
|
||||
outputs[_test_motor.motor_number] = _test_motor.value*2.0f-1.0f;
|
||||
float test_outputs[NUM_ACTUATOR_OUTPUTS] = {};
|
||||
test_outputs[_test_motor.motor_number] = _test_motor.value*2.0f-1.0f;
|
||||
|
||||
// Output to the bus
|
||||
_esc_controller.update_outputs(outputs, NUM_ACTUATOR_OUTPUTS);
|
||||
}
|
||||
else if (controls_updated && (_mixers != nullptr)) {
|
||||
_esc_controller.update_outputs(test_outputs, NUM_ACTUATOR_OUTPUTS);
|
||||
} else if (controls_updated && (_mixers != nullptr)) {
|
||||
|
||||
// XXX one output group has 8 outputs max,
|
||||
// but this driver could well serve multiple groups.
|
||||
|
||||
@@ -67,19 +67,15 @@ void motor_test(unsigned channel, float value)
|
||||
_test_motor.timestamp = hrt_absolute_time();
|
||||
_test_motor.value = value;
|
||||
|
||||
if (_test_motor_pub > 0) {
|
||||
/* publish armed state */
|
||||
orb_publish(ORB_ID(test_motor), _test_motor_pub, &_test_motor);
|
||||
} else {
|
||||
/* advertise and publish */
|
||||
_test_motor_pub = orb_advertise(ORB_ID(test_motor), &_test_motor);
|
||||
}
|
||||
_test_motor_pub = orb_advertise(ORB_ID(test_motor), &_test_motor);
|
||||
orb_publish(ORB_ID(test_motor), _test_motor_pub, &_test_motor);
|
||||
}
|
||||
|
||||
static void usage(const char *reason)
|
||||
{
|
||||
if (reason != NULL)
|
||||
if (reason != NULL) {
|
||||
warnx("%s", reason);
|
||||
}
|
||||
|
||||
errx(1,
|
||||
"usage:\n"
|
||||
@@ -90,8 +86,9 @@ static void usage(const char *reason)
|
||||
|
||||
int motor_test_main(int argc, char *argv[])
|
||||
{
|
||||
unsigned long channel, lval;
|
||||
float value;
|
||||
unsigned long channel = 0;
|
||||
unsigned long lval;
|
||||
float value = 0.0f;
|
||||
int ch;
|
||||
|
||||
if (argc != 5) {
|
||||
@@ -122,7 +119,7 @@ int motor_test_main(int argc, char *argv[])
|
||||
|
||||
motor_test(channel, value);
|
||||
|
||||
printf("motor %d set to %.2f\n", channel, value);
|
||||
printf("motor %d set to %.2f\n", channel, (double)value);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user