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

Parametrize Hackflight #37

Merged
merged 15 commits into from
Dec 13, 2018
Merged

Parametrize Hackflight #37

merged 15 commits into from
Dec 13, 2018

Conversation

juangallostra
Copy link
Member

Description of the issue/feature this PR addresses

Parametrize Hackflight.

Current behavior before PR

An Arduino sketch has to be created where all the parameters (type of board, PID constants, type of receiver, mixer...) are defined when running Hackflight on a BonaDrone board.

As an example see SBUSAltHold.ino

Desired behavior after PR is merged

Instead of having to create an Arduino sketch for each configuration, a generic routine that loads parameters from the EEPROM will handle the instantiation of Hackflight with the specified parameters.

The Arduino sketch gets reduced to: Parametrized.ino

And all the initialization is delegated to HackflightWrapper

Setting parameters

Parameters are specified via MSP messages. There are currently 3 MSP messages used to set parameters:

  1. SET_POSITIONING_BOARD: message ID is 225 with a payload of 1byte. 0/1 flag indicating whether the positioning board is present or not.
  2. SET_MOSQUITO_VERSION: message ID is 223 with a payload of 1byte. 0/1 flag indicating the Mosquito version (0 is Mosquito 150 and 1 is Mosquito 90).
  3. SET_PID_CONSTANTS: message ID is 224 with a payload of 64 bytes (16 floats x 4 bytes each). 16 floats that specify the parameters of the PID controllers.

When one of this messages is received its contents are stored in the appropriate EEPROM addresses. See BonaDrone's documentation (EEPROM usage chapter) for more details.

Loading parameters

A new class that acts as a wrapper for Hackflight has been implemented (see HackflightWrapper in main.hpp). This class reads and decodes EEPROM stored parameters and instantiates the required classes accordingly. After that Hackflight is initialized and ran as before.

--
I confirm I have tested this PR thoroughly

@juangallostra juangallostra added the enhancement New feature or request label Dec 13, 2018
@juangallostra juangallostra self-assigned this Dec 13, 2018
@juangallostra juangallostra merged commit 83467a2 into integration Dec 13, 2018
@juangallostra juangallostra deleted the parametrization branch January 24, 2019 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant