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

Plane: add As5600 angle-of-attack sensor #16795

Closed
wants to merge 10 commits into from

Conversation

colejmero
Copy link

Branch would add library for AS5600 sensor to allow reading of angles.

Copy link
Contributor

@peterbarker peterbarker left a 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.

ArduPlane/ArduPlane.cpp Outdated Show resolved Hide resolved
ArduPlane/ArduPlane.cpp Outdated Show resolved Hide resolved
ArduPlane/Plane.h Outdated Show resolved Hide resolved
ArduPlane/wscript Outdated Show resolved Hide resolved
libraries/AP_AS5600_AOA/AS5600_AOA.cpp Outdated Show resolved Hide resolved
libraries/AP_AS5600_AOA/AS5600_AOA.cpp Outdated Show resolved Hide resolved
libraries/AP_AS5600_AOA/AS5600_AOA.cpp Outdated Show resolved Hide resolved
libraries/AP_AS5600_AOA/AS5600_AOA.cpp Outdated Show resolved Hide resolved
libraries/AP_AS5600_AOA/AS5600_AOA.cpp Outdated Show resolved Hide resolved
libraries/AP_AS5600_AOA/AS5600_AOA.h Outdated Show resolved Hide resolved
@rmackay9 rmackay9 changed the title PR for review. Plane: add As5600 angle-of-attack sensor Mar 3, 2021
@rmackay9
Copy link
Contributor

rmackay9 commented Mar 3, 2021

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"

@IamPete1
Copy link
Member

IamPete1 commented Mar 3, 2021

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.

@peterbarker
Copy link
Contributor

peterbarker commented Mar 3, 2021 via email

Copy link
Contributor

@peterbarker peterbarker left a 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.

Comment on lines +197 to +204
/*
* Read and log Angle of Attack
*/

//void Plane::read_aoa(void){
// aoa_sensor.getRawAngle();
//}

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'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 @@
/****************************************************
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not accurate.

Comment on lines 56 to 75
//
// 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;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code

Comment on lines 77 to 82
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;
}
Copy link
Contributor

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

Comment on lines +48 to +50



Copy link
Contributor

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);
Copy link
Contributor

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.

@peterbarker
Copy link
Contributor

Closing in favour of #16397

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants