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

AAVAA board addition #668

Merged
merged 12 commits into from
Sep 13, 2023
Merged

Conversation

aavaa-farnood
Copy link
Contributor

I added the AAVAA V3 board.
Along with the new addition, I had to add more methods for new channel types as well.

@Andrey1994
Copy link
Member

Andrey1994 commented Aug 18, 2023

Could you explain what rotation_calib_channel is and how its different from rotation_channels?

You can setup this https://brainflow.readthedocs.io/en/stable/BrainFlowDev.html#code-style to fix clang-format CI job

Copy link
Member

@Andrey1994 Andrey1994 left a comment

Choose a reason for hiding this comment

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

looks really good!

I am not confident that rotation_calib_channel is really needed, looks too specific as for me, maybe it makes sense to move it to other_channels instead.

Also, I dont fully understand what do you mean by rotation_channels but as for me it looks like data from IMU/gyroscrope sensor, and there is a convention to use get_gyro_channels for it, this way it will be convenient with all other devices

src/board_controller/aavaa/aavaa_v3.cpp Show resolved Hide resolved
@aavaa-farnood
Copy link
Contributor Author

Could you explain what rotation_calib_channel is and how its different from rotation_channels?

You can setup this https://brainflow.readthedocs.io/en/stable/BrainFlowDev.html#code-style to fix clang-format CI job

rotation_calib_channel can definitely be removed. It is a byte giving info about the calibration of the IMU.

@aavaa-farnood
Copy link
Contributor Author

looks really good!

I am not confident that rotation_calib_channel is really needed, looks too specific as for me, maybe it makes sense to move it to other_channels instead.

Also, I dont fully understand what do you mean by rotation_channels but as for me it looks like data from IMU/gyroscrope sensor, and there is a convention to use get_gyro_channels for it, this way it will be convenient with all other devices

In the AAVAA board, we have a pitch/roll/yaw info that is different from gyro info and it is processed on the board itself. I realized it's better to create a new set of commands for those channels as it might get confusing.

@Andrey1994
Copy link
Member

Could you explain what rotation_calib_channel is and how its different from rotation_channels?
You can setup this https://brainflow.readthedocs.io/en/stable/BrainFlowDev.html#code-style to fix clang-format CI job

rotation_calib_channel can definitely be removed. It is a byte giving info about the calibration of the IMU.

lets remove it or move this data to other_channels if needed, I am trying to dont create too many methods like this. This way, it is more uniform and also less methods to add when adding support for new programming languages

@Andrey1994
Copy link
Member

looks really good!
I am not confident that rotation_calib_channel is really needed, looks too specific as for me, maybe it makes sense to move it to other_channels instead.
Also, I dont fully understand what do you mean by rotation_channels but as for me it looks like data from IMU/gyroscrope sensor, and there is a convention to use get_gyro_channels for it, this way it will be convenient with all other devices

In the AAVAA board, we have a pitch/roll/yaw info that is different from gyro info and it is processed on the board itself. I realized it's better to create a new set of commands for those channels as it might get confusing.

ok

@Andrey1994
Copy link
Member

ok, we can merge it when all ci checks are passed, if you want it before fixing #667 its ok and up to you, or we can fix #667 first

@Andrey1994
Copy link
Member

Andrey1994 commented Sep 7, 2023

Hi!

I still have no mac to take a look at the issue with ble on macos, in the meantime do you have any updates on this? Can merge as soon as all checks are passed and rotation_callib channel is removed

@aavaa-farnood
Copy link
Contributor Author

Hi!

I still have no mac to take a look at the issue with ble on macos, in the meantime do you have any updates on this? Can merge as soon as all checks are passed and rotation_callib channel is removed

@Andrey1994, I almost gave up after playing around with it for a while.

I added some NSLogs in centralManagerDidUpdateState to see the state and I found that it ends up in CBManagerStatePoweredOn! five times, and gets stuck there. I added a condition to refuse extra calls after the first one, but did not solve the issue.
I also added the new WAIT_UNTIL_FALSE_WITH_TIMEOUT you added but it just makes it not get stuck in that loop.

I don't know what else I can do to solve the issue.

@Andrey1994
Copy link
Member

if you try to call connect 3 times like in other BLE boards with the latest changes in macos backend to avoid deadlock do all 3 attemps fail?

@aavaa-farnood
Copy link
Contributor Author

if you try to call connect 3 times like in other BLE boards with the latest changes in macos backend to avoid deadlock do all 3 attemps fail?

@Andrey1994, Good news! After doing your suggestion, I can connect and it takes roughly 7 seconds, but I find the behaviour somewhat weird, because it connects to peripheral twice. Here is the NSlog output:

2023-09-12 15:07:31.503 Python[61967:1042304] CBManagerStatePoweredOn!
2023-09-12 15:07:31.572 Python[61967:1042304] CBManagerStatePoweredOn!
2023-09-12 15:07:32.667 Python[61967:1042304] CBManagerStatePoweredOn!
2023-09-12 15:07:32.755 Python[61967:1042304] CBManagerStatePoweredOn!
2023-09-12 15:07:32.886 Python[61967:1042326] CBManagerStatePoweredOn!
2023-09-12 15:07:32.903 Python[61967:1040538] Connecting to peripheral...
2023-09-12 15:07:32.903 Python[61967:1040538] Waiting...
2023-09-12 15:07:37.910 Python[61967:1040538] Done waiting.
2023-09-12 15:07:37.910 Python[61967:1040538] Peripheral Connection failed
2023-09-12 15:07:37.911 Python[61967:1040978] Connected to peripheral: <CBPeripheral: 0x12e51a5d0, identifier = 82823F62-BA42-1F50-5027-96A513454000, name = AAVAAB12, mtu = 247, state = connected>
2023-09-12 15:07:38.916 Python[61967:1040538] Connecting to peripheral...
2023-09-12 15:07:38.916 Python[61967:1040538] Waiting...
2023-09-12 15:07:38.917 Python[61967:1042304] Connected to peripheral: <CBPeripheral: 0x12e51a5d0, identifier = 82823F62-BA42-1F50-5027-96A513454000, name = AAVAAB12, mtu = 247, state = connected>
2023-09-12 15:07:38.927 Python[61967:1040538] Done waiting.
2023-09-12 15:07:38.927 Python[61967:1040538] Discovering serives...

@Andrey1994
Copy link
Member

Good, could you do the final cleanup in this PR? Revert changes in simpleble, drop rotation callib channel method, fix clang format job, and check that it builds with --warnings-as-errors like in CI

@aavaa-farnood
Copy link
Contributor Author

Sure will do that.
I managed to solve the 7 sec issue, I just needed to add a sleep(1) before the first try to connect and it connects in 2 secs.

@Andrey1994
Copy link
Member

if you try to call connect 3 times like in other BLE boards with the latest changes in macos backend to avoid deadlock do all 3 attemps fail?

@Andrey1994, Good news! After doing your suggestion, I can connect and it takes roughly 7 seconds, but I find the behaviour somewhat weird, because it connects to peripheral twice. Here is the NSlog output:

2023-09-12 15:07:31.503 Python[61967:1042304] CBManagerStatePoweredOn!
2023-09-12 15:07:31.572 Python[61967:1042304] CBManagerStatePoweredOn!
2023-09-12 15:07:32.667 Python[61967:1042304] CBManagerStatePoweredOn!
2023-09-12 15:07:32.755 Python[61967:1042304] CBManagerStatePoweredOn!
2023-09-12 15:07:32.886 Python[61967:1042326] CBManagerStatePoweredOn!
2023-09-12 15:07:32.903 Python[61967:1040538] Connecting to peripheral...
2023-09-12 15:07:32.903 Python[61967:1040538] Waiting...
2023-09-12 15:07:37.910 Python[61967:1040538] Done waiting.
2023-09-12 15:07:37.910 Python[61967:1040538] Peripheral Connection failed
2023-09-12 15:07:37.911 Python[61967:1040978] Connected to peripheral: <CBPeripheral: 0x12e51a5d0, identifier = 82823F62-BA42-1F50-5027-96A513454000, name = AAVAAB12, mtu = 247, state = connected>
2023-09-12 15:07:38.916 Python[61967:1040538] Connecting to peripheral...
2023-09-12 15:07:38.916 Python[61967:1040538] Waiting...
2023-09-12 15:07:38.917 Python[61967:1042304] Connected to peripheral: <CBPeripheral: 0x12e51a5d0, identifier = 82823F62-BA42-1F50-5027-96A513454000, name = AAVAAB12, mtu = 247, state = connected>
2023-09-12 15:07:38.927 Python[61967:1040538] Done waiting.
2023-09-12 15:07:38.927 Python[61967:1040538] Discovering serives...

I think its the same for other devices and maybe its the reason why I call it several times, idk much about macos backend in simpleble. Maybe @kdewald can suggest smth.

As long as it works we are good to go, if it calls smth a couple of times but does not hang/crash/etc, its ok for me

@aavaa-farnood
Copy link
Contributor Author

Good, could you do the final cleanup in this PR? Revert changes in simpleble, drop rotation callib channel method, fix clang format job, and check that it builds with --warnings-as-errors like in CI

I did all of those, except for when I run build.py with --warnings-as-errors it has a lot of deprecation warnings related to sprintf and they result in errors. Was not part of my code so didn't touch that.

@Andrey1994
Copy link
Member

I did all of those, except for when I run build.py with --warnings-as-errors it has a lot of deprecation warnings related to sprintf and they result in errors. Was not part of my code so didn't touch that.

Thanks, its fine, I worry about CI job and seems like there its not a warning, maybe you have a newer version of compiler locally.

I see there is a still failing clang-format job, I will fix it by myself, for the future you need to configure this - https://brainflow.readthedocs.io/en/stable/BrainFlowDev.html#code-style with the same clang-format version as in CI job.

I will create a new release tomorrow, so your new board will be available using brainflow installed from package managers.

@Andrey1994
Copy link
Member

Couple of final questions:

  1. Do you want your board to be visible here - https://brainflow.readthedocs.io/en/stable/SupportedBoards.html and do you want me to write a blog post or smth at brainflow.org? In that case I will need some images and links, you can also send a PR to update docs.
  2. I expect there will be changes in simpleble in the future and some validation will be needed, I have no this device, so can I ask you to run some tests? BrainFlow slack is a better place for such stuff, so will be good if you ping me there
  3. If you are working on it on behalf of a company I will be grateful if your company helps to promote brainflow a little bit)

@Andrey1994 Andrey1994 merged commit b7e6753 into brainflow-dev:master Sep 13, 2023
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants