-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Bidirectional Control For Motors #10778
Draft
henrykotze
wants to merge
13
commits into
mavlink:master
Choose a base branch
from
henrykotze:wip-bidirectional-control-motors
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+132
−16
Draft
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8026b26
wip-Bidirectional control for motors
c91e0b1
Making changes in Mixer file
92d0c1e
adapt min and default value in Actuators
39f8c95
Remove debugging code
abafb53
Merge branch 'mavlink:master' into wip-bidirectional-control-motors
1d98545
wip still using parameter to define reversibility
098afb6
determine bidirectional from metadata scheme
b2c0451
snap in slider for bidi motors working
920ace8
wip: snap slider for bidirectional motors working
63dcbc9
Merge branch 'wip-use-metadata-schme' into wip-bidirectional-control-…
d63d4a2
fix missed merge changes
f5be7f9
fix merge changes
f7c0936
Remove hardcoded default value
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,6 +200,7 @@ void Actuators::parametersChanged() | |
QList<ActuatorTesting::Actuator*> actuators; | ||
QSet<int> uniqueConfiguredFunctions; | ||
const Mixer::ActuatorTypes &actuatorTypes = _mixer.actuatorTypes(); | ||
int num_motor = 0; | ||
for (int function : allFunctions) { | ||
if (uniqueConfiguredFunctions.find(function) != uniqueConfiguredFunctions.end()) { // only add once | ||
continue; | ||
|
@@ -221,9 +222,30 @@ void Actuators::parametersChanged() | |
const Mixer::ActuatorType& actuatorType = actuatorTypes[actuatorTypeName]; | ||
if (function >= actuatorType.functionMin && function <= actuatorType.functionMax) { | ||
bool isMotor = ActuatorGeometry::typeFromStr(actuatorTypeName) == ActuatorGeometry::Type::Motor; | ||
bool isBidirectional = false; | ||
float min_value = actuatorType.values.min; | ||
float default_value = actuatorType.values.defaultVal; | ||
|
||
if(isMotor){ | ||
QString bidirectional_param("CA_R_REV"); | ||
quint8 bitset_bidirectional = getFact(bidirectional_param)->rawValue().toInt(); | ||
quint8 is_bidi = (bitset_bidirectional >> num_motor) & 0b1; | ||
|
||
if(is_bidi == 1){ | ||
|
||
min_value = -1.0f; | ||
default_value = 0.0f; | ||
isBidirectional = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea is that if |
||
|
||
} | ||
num_motor++; | ||
|
||
} | ||
|
||
// qDebug() << "testinng: " << actuatorType.values.min << actuatorType.values.max << actuatorType.values.defaultVal; | ||
actuators.append( | ||
new ActuatorTesting::Actuator(&_actuatorTest, label, actuatorType.values.min, actuatorType.values.max, | ||
actuatorType.values.defaultVal, function, isMotor)); | ||
new ActuatorTesting::Actuator(&_actuatorTest, label, min_value, actuatorType.values.max, | ||
default_value, function, isMotor, isBidirectional)); | ||
found = true; | ||
break; | ||
} | ||
|
@@ -232,7 +254,7 @@ void Actuators::parametersChanged() | |
const Mixer::ActuatorType& actuatorType = actuatorTypes["DEFAULT"]; | ||
actuators.append( | ||
new ActuatorTesting::Actuator(&_actuatorTest, label, actuatorType.values.min, actuatorType.values.max, | ||
actuatorType.values.defaultVal, function, false)); | ||
actuatorType.values.defaultVal, function, false, false)); | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot use hardcoded parameter values here, as it makes it PX4-specific, and it will break easily.
Rather we need to set the
reversible
function on the PX4 side for the parameter, and then make use of it here. -> https://github.com/mavlink/mavlink/blob/master/component_metadata/actuators.schema.json#L63