-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
Plane: add As5600 angle-of-attack sensor #16795
Conversation
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.
mav_0_1.parm
has to be removed - and all the others you've added. Generally avoid using "git commit -a" if that's how they got in.
I've skipped the commented out blocks.
Bit of work to be done here, but little to make it safe for flight.
In keeping with our regular conventions it would be good to prefix the commits with the vehicle, library or directory being modified. For example the first commit should probably be renamed, "Plane: adds AS5600 library" |
I don't want to feature creep you to much, but it would be great to have a generic backed for this sensor. AP_Encoder or similar. The has been some interest in using them for sailboat windvanes, wheel encoders on rover also jump to mind. |
On Wed, 3 Mar 2021, Peter Hall wrote:
I don't want to feature creep you to much, but it would be great to have a generic backed for this sensor. AP_Encoder or similar. The has been some
interest in using them for sailboat windvanes, wheel encoders on rover also jump to mind.
This will probably end up in AP_AOA/AP_AOA_AS5600.h etc - is that near
enough to what you had in mind?
... and "AP_Encoder"?! Really? :-P
|
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.
Remove stray files.
Lots of unimplemented methods and unused state in the object not commented on as I believe you wanted to flesh this stuff out.
/* | ||
* Read and log Angle of Attack | ||
*/ | ||
|
||
//void Plane::read_aoa(void){ | ||
// aoa_sensor.getRawAngle(); | ||
//} | ||
|
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.
Remove
@@ -67,6 +67,9 @@ void Plane::init_ardupilot() | |||
|
|||
rpm_sensor.init(); | |||
|
|||
//initialise AS5600_AOA sensor |
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.
//initialise AS5600_AOA sensor | |
//initialise Angle Of Attack sensor |
@@ -29,6 +29,7 @@ def build(bld): | |||
'AP_Devo_Telem', | |||
'AP_OSD', | |||
'AC_AutoTune', | |||
'AP_AS5600_AOA', |
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.
'AP_AS5600_AOA', | |
'AP_AngleOfAttack', |
Before merge we'll need to rename this library so we can support more sensors into the future.
Related changes not mentioned in this review.
@@ -0,0 +1,177 @@ | |||
/**************************************************** |
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.
This file will become
libraries/AP_AngleOfAttack/AP_AngleOfAttack_AS5600.cpp
(it's possible people will actually prefer AP_AOA/AP_AOA_AS5600.cpp
- @WickedShell ? )
* access the AS5600 magnetic encoder sensor to | ||
* read the angle of attack and record it for experimental purposes | ||
* | ||
* It was adapted from the Arduino library available for the AS5600 sensor. |
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.
Nice to give a link to the original implementation here.
/******************************************************* | ||
* Method: getRawAngle | ||
* In: none | ||
* Out: value of raw angle register |
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.
Not accurate.
libraries/AP_AS5600_AOA/AS5600_AOA.h
Outdated
// | ||
// int _zmco; | ||
// int _zpos_hi; /*zpos[11:8] high nibble START POSITION */ | ||
// int _zpos_lo; /*zpos[7:0] */ | ||
// int _mpos_hi; /*mpos[11:8] high nibble STOP POSITION */ | ||
// int _mpos_lo; /*mpos[7:0] */ | ||
// int _mang_hi; /*mang[11:8] high nibble MAXIMUM ANGLE */ | ||
// int _mang_lo; /*mang[7:0] */ | ||
// int _conf_hi; | ||
// int _conf_lo; | ||
// int _raw_ang_hi; | ||
// int _raw_ang_lo; | ||
// int _ang_hi; | ||
// int _ang_lo; | ||
// int _stat; | ||
// int _agc; | ||
// int _mag_hi; | ||
// int _mag_lo; | ||
// int _burn; | ||
|
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.
Dead code
WITH_SEMAPHORE(dev->get_semaphore()); | ||
|
||
//uint16_t angleRaw = readTwoBytes(REG_RAW_ANG_HI, REG_RAW_ANG_LO); | ||
if (!dev->read_registers(REG_RAW_ANG_HI, &highByte, 1) || !dev->read_registers(REG_RAW_ANG_LO, &lowByte, 1)){ | ||
return; | ||
} |
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.
Can't do this in the main thread. If something goes wrong with the i2c bus then your Plane falls out of the sky (or worse).
You do need to take a semaphore here - but one to protect data shared between this and a thread which is doing this i2c bus operation.
I've put a patch here which shows that: https://github.com/peterbarker/ardupilot/commits/colejmero-corem
|
||
|
||
|
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.
Stray whitespace.
} | ||
|
||
WITH_SEMAPHORE(dev->get_semaphore()); | ||
dev->set_speed(AP_HAL::Device::SPEED_LOW); |
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 should be looking for a WHOAMI
register here to make sure we're talking to who we're supposed to be talking to.
Closing in favour of #16397 |
Branch would add library for AS5600 sensor to allow reading of angles.