-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
gz simulation adding tiltrotor airframe #24028
base: main
Are you sure you want to change the base?
Conversation
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 8 byte (0 %)]
px4_fmu-v6x [Total VM Diff: 0 byte (0 %)]
Updated: 2024-12-16T13:06:17 |
8d2185c
to
827ed69
Compare
c8bd4a4
to
d223a8a
Compare
d223a8a
to
08494be
Compare
bf264cf
to
66ab707
Compare
827ed69
to
81fc89a
Compare
b561a74
to
4ec9990
Compare
81fc89a
to
f08beb8
Compare
4ec9990
to
d47d5f8
Compare
28a3c8b
to
1ab426e
Compare
d47d5f8
to
ab93cd7
Compare
@@ -64,8 +64,8 @@ bool GZMixingInterfaceServo::updateOutputs(bool stop_motors, uint16_t outputs[MA | |||
for (auto &servo_pub : _servos_pub) { | |||
if (_mixing_output.isFunctionSet(i)) { | |||
gz::msgs::Double servo_output; | |||
///TODO: Normalize output data | |||
double output = (outputs[i] - 500) / 500.0; | |||
double output = math::radians((double)outputs[i] / 10. - 180.);; |
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.
Are you assuming +1 is always 180 degrees? This is not true in general. We need a parameter defined which maps the normalized angles to servo angles. (part of the reason why the +1 radian was left like that)
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.
I assume that we only use angles within +-180 deg and the output default values has been changed.
So if we want a zero symmetrical range of +-45 deg, then output max is set to 2250, and min to 1350.
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.
@Perrrewi I am not talking about the limits, but rather that the angles need to be configurable. For example, tiltrotors normally operate the servo angles 0-90 deg, which you could do with +-45, but it would be great if we can actually do it properly and configure it.
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.
@Jaeyoung-Lim I made an update with angle min max as parameters.
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.
I tried adding the parameters on the control surface parameters CA_SV_CS in the control allocator, but then some targets got out of flash memory.
For now I cannot see a good solution before changing the types from uints to floats as proposed here: #22488
0c60b0b
to
642f09f
Compare
33d2023
to
94da813
Compare
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.
Looks good, I assume this is what jaey meant with the parameter based implementation,
left just a few minor improvements, to avoid issues with other airframe implementations if accessing out of range indices.
94da813
to
639b005
Compare
639b005
to
6b83045
Compare
disarmed: { min: 0, max: 3600, default: 1800 } | ||
min: { min: 0, max: 3600, default: 1350 } | ||
max: { min: 0, max: 3600, default: 2250 } | ||
failsafe: { min: 0, max: 3600 } |
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.
Where do these numbers come from? Can we normalize it for simulation?
@@ -33,6 +33,9 @@ | |||
|
|||
#include "GZMixingInterfaceServo.hpp" | |||
|
|||
#define SERVO_OUTPUT_SCALING (10.) |
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.
Why 10?
@@ -33,6 +33,9 @@ | |||
|
|||
#include "GZMixingInterfaceServo.hpp" | |||
|
|||
#define SERVO_OUTPUT_SCALING (10.) | |||
#define SERVO_OUTPUT_OFFSET (180.) |
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.
Why is it necessary to have this as an ifdef?
Solved Problem
Moving the tiltrotor from gazebo classic to gz sim as gazebo garden will be depreciated by the end of nov 24
Solution
Adding an airframe and fixed the bug in gz-bridge. PX4 sends an output value from 0 to 1000 of the servo and the GZbridge normalized it to be within +-1. The problem was that gazebo needs a servo input of angles in radian which meant the currently servos only works in the range +-1 rad.
Test coverage
Tested with QGC
Context
Test: Toggling the actuator testing slider with max output value 1000 while gazebo angle limitations were set to 90 deg
Before updating GZMixingInterfaceServo.cpp:
After updating GZMixingInterfaceServo.cpp: