Skip to content
Snippets Groups Projects
Commit 9ed21afd authored by Beat Küng's avatar Beat Küng
Browse files

vmount: simplify initialization

parent 021b808f
No related branches found
No related tags found
No related merge requests found
......@@ -220,55 +220,27 @@ static int vmount_thread_main(int argc, char *argv[])
case 0:
// Automatic
if (!thread_data.input_objs[0]) {
thread_data.input_objs[0] = new InputMavlinkCmdMount();
if (!thread_data.input_objs[0]) { alloc_failed = true; }
}
if (!thread_data.input_objs[1]) {
thread_data.input_objs[1] = new InputMavlinkROI();
if (!thread_data.input_objs[1]) { alloc_failed = true; }
}
thread_data.input_objs[0] = new InputMavlinkCmdMount();
thread_data.input_objs[1] = new InputMavlinkROI();
// RC is on purpose last here so that if there are any mavlink
// messages, they will take precedence over RC.
// This logic is done further below while update() is called.
if (!thread_data.input_objs[2]) {
thread_data.input_objs[2] = new InputRC(params.mnt_man_roll, params.mnt_man_pitch, params.mnt_man_yaw);
if (!thread_data.input_objs[2]) { alloc_failed = true; }
}
thread_data.input_objs[2] = new InputRC(params.mnt_man_roll, params.mnt_man_pitch, params.mnt_man_yaw);
thread_data.input_objs_len = 3;
break;
case 1: //RC
if (!thread_data.input_objs[0]) {
thread_data.input_objs[0] = new InputRC(params.mnt_man_roll, params.mnt_man_pitch, params.mnt_man_yaw);
if (!thread_data.input_objs[0]) { alloc_failed = true; }
}
thread_data.input_objs[0] = new InputRC(params.mnt_man_roll, params.mnt_man_pitch, params.mnt_man_yaw);
break;
case 2: //MAVLINK_ROI
if (!thread_data.input_objs[0]) {
thread_data.input_objs[0] = new InputMavlinkROI();
if (!thread_data.input_objs[0]) { alloc_failed = true; }
}
thread_data.input_objs[0] = new InputMavlinkROI();
break;
case 3: //MAVLINK_DO_MOUNT
if (!thread_data.input_objs[0]) {
thread_data.input_objs[0] = new InputMavlinkCmdMount();
if (!thread_data.input_objs[0]) { alloc_failed = true; }
}
thread_data.input_objs[0] = new InputMavlinkCmdMount();
break;
default:
......@@ -277,6 +249,12 @@ static int vmount_thread_main(int argc, char *argv[])
}
}
for (int i = 0; i < thread_data.input_objs_len; ++i) {
if (!thread_data.input_objs[i]) {
alloc_failed = true;
}
}
switch (params.mnt_mode_out) {
case 0: //AUX
thread_data.output_obj = new OutputRC(output_config);
......
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