Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlightTasks Refactor #12492

Closed
Stifael opened this issue Jul 16, 2019 · 7 comments
Closed

FlightTasks Refactor #12492

Stifael opened this issue Jul 16, 2019 · 7 comments

Comments

@Stifael
Copy link
Contributor

Stifael commented Jul 16, 2019

Given that FlightTasks library does not contain too many tasks yet, it makes sense to do a small refactor rather sooner than late based on the feedback that was received.

Originally the FlightTasks library was designed to simplify the process of adding a new flight maneuver without having to change the already existing tasks. Unfortunately, two implementation strategies evolved:

1.) functionality was shared via inheritance
Initially, it seemed to be a good idea to exploit inheritance for tasks which are similar in nature. However, often only one small part of an existing task needed to change for a "new" task that could not solely be resolved with inheritance but rather was resolved by duplicating the code or add another if-statement. In addition, inheritance made code readability much more difficult.

2.) sharing functionality via utility-classes/functions
This is the preferred way to share functionalities because it simplifies the process of creating new tasks by not having to mess around with existing tasks.

The current state of the FlightTasks library has the following issues:

  • too complicated to trigger a new task (Firmware issue) (overwrite existing task via parameter vs creating a new PX4-flight mode which requires non-simple changes)
  • individual tasks poorly tested
  • duplicated code (FlightTaskAuto + its children)
  • some parameters are consumed by different tasks but require different tuning
  • tasks for the same purposes have a different implementation in terms of behavior (FlightTaskAutoLine passes waypoints with full speed if they are located on a straight line vs FlightTaskAutoSmoothVel which stops at every waypoint)
  • failsafe is not working as expected
  • several methods that can be overwritten via inheritance makes readability difficult
  • tasks cannot stop itself (was requested during PX4-devsummit)

short-term suggestions

  • keep inheritance to a minimum by only allow the update-method to be overwritten
  • merge same functionalities of FlightTaskAutoLine / FlightTaskAutoSmoothVel
  • each task that belongs to a specific PX4 flight-mode should behave similarly
  • move common functionality into Utility-library
  • enable setpoint passing between tasks
@MaEtUgR
Copy link
Member

MaEtUgR commented Jul 16, 2019

Sounds good. Some smaller changes into that direction are already in #12072 and will hopefully not create too much conflicts with someone else starting to refactor. I'll try to really bring it into a mergable state now before it explodes.

@hamishwillee
Copy link
Contributor

hamishwillee commented Jul 17, 2019

@MaEtUgR I presume the new docs come after this?

Perhaps we should just create a placeholder doc and link your presentation from devday for now?

@Stifael
Copy link
Contributor Author

Stifael commented Jul 17, 2019

Perhaps we should just create a placeholder doc and link your presentation from devday for now?

yep. the refactor will also not happen within one day and will also not make the presentation obsolete. It is more about aligning on an overall structure such that new tasks follow the new idea instead of copying the existing framework.

@stale
Copy link

stale bot commented Oct 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Oct 15, 2019
@MaEtUgR
Copy link
Member

MaEtUgR commented Feb 19, 2020

  • merge same functionalities of FlightTaskAutoLine / FlightTaskAutoSmoothVel

is resolved in 7e78eed

The other points are definitely needed moving forward to scale the setup and make it more modular. Especially the library over inheritance strategy e.g. with FlightTaskManualAltitude getting more and more of a kitchen sink task accumulating logic to inherit.

@stale stale bot removed the stale label Feb 19, 2020
@stale
Copy link

stale bot commented May 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label May 19, 2020
@bresch
Copy link
Member

bresch commented Aug 15, 2022

We fixed quite a couple of issues in the last years, let's re-open an issue with up-to-date tasks

@bresch bresch closed this as completed Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants