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

Experimental: ANT+ / BLE support for speed #89

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

chriselsen
Copy link
Contributor

@chriselsen chriselsen commented Oct 17, 2021

Tries to address #75 by:

Changes:

  • Adds wheel simulation to generate speed data
    • Assumes tire with 2.096 meter circumference (Garmin default), which corresponds to 700x23C
  • Adds speed support to bot bike for testing
  • Bikes that already support speed (Flywheel, IC4) pass through speed
  • Added speed calculation for Peleton based on https://ihaque.org/posts/2020/12/25/pelomon-part-ib-computing-speed/
  • Updated existing BLE GATT CSC + BLE GATT CPS server for speed (via wheel rotation + timestamp)
  • Created ANT+ SPD server for speed (via wheel rotation + timestamp)

Conscious decisions:

  • ANT+ support a SPD+CAD profile, which is very similar to the SPD profile. But as the PWR profile already provides cadence, the SPD profile seemed sufficient.

Issues:

  • Unable to get ANT+ PWR and SPD working at the same time
    • It appears that the required different broadcast intervals for PWR and SPD lead to a collision of messages at some point
  • Unable to test speed on BLE GATT CSC due to lack of supported devices
  • Unable to test the Peleton and Flywheel bikes

To try this out:

  • Start with current Gymnasticon Pi image
  • Place the device into R/W mode:

overctl -rw

  • Setup build environmant:
sudo apt-get update --allow-releaseinfo-change
sudo apt-get install git
cd
git clone https://github.com/ptx2/gymnasticon.git
cd gymnasticon
sudo service gymnasticon stop
sudo setcap cap_net_raw+eip $(eval readlink -f $(which node))

  • Checkout experimental branch and build it
git fetch origin pull/89/head:antble-speed
git checkout antble-speed
npm install
npm run build
npm link
gymnasticon

Provide output if things are not working

@ptx2 Would be great if you could have a look at the BLE GATT CSC part.

@chriselsen
Copy link
Contributor Author

I managed to get PWR and SPD working at the same time over ANT+:

  • Merged the two profiles into a common interval
  • Broadcasting out the SPD data twice for stability
    Looks a bit like a bad hack, but at least with the bot bike and a Garmin watch it seems to work so far.

@nealjane
Copy link

nealjane commented Oct 18, 2021

@chriselsen - Hi Chris, I have the upgraded Keiser computer which shows speed - if it’s any use I’m happy to test speed at various watts this evening to compare with peloton graph referenced - I’m assuming it likely works similar to the peloton calcs as the bike has no idea of users weight etc??…

@chriselsen
Copy link
Contributor Author

@nealjane The speed formula for Peleton is based on this article. If you can come up with a similar formula for the Keiser bike, I can definitely implement that.

You probably want to get started by graphing displayed speed at various power levels to see if you spot a pattern/formula.

@nealjane
Copy link

nealjane commented Oct 18, 2021

@nealjane The speed formula for Peleton is based on this article. If you can come up with a similar formula for the Keiser bike, I can definitely implement that.

You probably want to get started by graphing displayed speed at various power levels to see if you spot a pattern/formula.

Hi @chriselsen, Yes - Id seen that article before when I saw your referenced to it in the peloton file - Ive just taken down the speeds and power from my Keiser and its pretty much the same as the Peloton! see attached pdf doc.
Keiser is clearly working out the speed from a table as the speed only increases when the power increases to the next threshold.
keiser speed.pdf

@chriselsen
Copy link
Contributor Author

@nealjane Just pushed an update to the Keiser bike driver that calculates speed the same way as the Peleton. Give it a try.

@nealjane
Copy link

That’s fantastic Chris!! Will def give it a go tomorrow 🙏 👏👏👏

@nealjane
Copy link

nealjane commented Oct 18, 2021

“But as the PWR profile already provides cadence, the SPD profile seemed sufficient.”

Just thinking - users with lower spec Garmin watches that don’t have ‘Power profile’ and so won’t see the cadence within the power profile on Ant+ - and so will only get ‘speed’ in that case?? - is this correct?

Improved readability for ANT+ SaC implementation
Improve readability of Peloton + Keiser Power to Speed conversion
Improve ANT+ stability
@chriselsen
Copy link
Contributor Author

@nealjane Change the ANT+ SPD profile to SaC (speed and cadence). You can now get Speed also without using the power profile.

@nealjane
Copy link

nealjane commented Oct 19, 2021

That’s great Chris - wasn’t really for my benefit - there’s been a few wanting it on here who have lower spec garmins - so means it’ll work for all Garmin users hopefully👍🏻

Did try and install your update today (spent far too long trying to solve the issue)

@nealjane
Copy link

@chriselsen , ok, got it working with fresh eyes this morning.!

the new Keiser computer (with Bluetooth converter now built in) clearly has more power and I thinks it’s interfering with Gymnasticon (had to move Gymnasticon closer to bike since I fitted it and still get intermittent drops in power over ant), so I may just replace it with my older computer this am - just for avoidance of doubt.

CaS appears under ant sensors on watch, adding shows all power, speed and cadence in indoor bike on my fenix. It tends to loose connection (but I’m putting this down to the new Keiser computer and will see what happens when I swap computers this am)

connecting to the Bluetooth on Gymnasticon - zwift/RGT- power drops to zero intermittently on my iphone (both apps have power buffer set to zero).

these issues could be connected to the new Bluetooth Keiser computer (although I’ve never had the Bluetooth power dropping to zero previously.

@chriselsen
Copy link
Contributor Author

I found Fulgaz, which shows speed via BLE. But for whatever reason it shows speed of 0 km/h via BLE CPS, even if it is not present (CPS feature set to 0x08). With wheel rotation data present and the CPS feature set to 0x12, it still shows a speed of 0 km/h.

I wonder if other software is having similar issues: Seeing the correct speed via BLE CSC and additional non-existent speed of 0 km/h. I pushed one more change, which completely disables speed via CPS. Receivers should therefore only see it via CSC.
If that doesn't work, the only way to get speed reliably via BLE would be via FTMS.

What's also odd is that my Garmin watch recognizes the BLE CSC service, but then ends up only displaying cadence and no speed.

@nealjane
Copy link

nealjane commented Oct 25, 2021

Only had time for a quick test of the update this am (kids half term here this week- so won’t be able to do anything until Thursday eve after today - sorry)- think you’ll have some other testers this week as I messaged a few others who were interested in Speed for Gymnasticon. 🤞

good news is - current update has cadence working correctly back in Peloton and RGT.
Speed (and cad and power) all still showing on my fenix 6. Sufferfest on w10 still finds power cadence and speed over Bluetooth. 👍🏻

27/10 - still working perfectly, done a couple of rides and no issues at all with ant connection to my Fenix 6.

I’ve tweaked the peloton equation a little for the keiser and it’s now pretty much spot on ..will test for longer when I’ve got over my cold.. - did find this as an alternative speed/distance on github (attached)

53A0C275-4F7E-41E8-A31B-3C1399EC46EE

A6D4A316-1758-4217-937C-9735E6BE1534

@djfjeff
Copy link

djfjeff commented Oct 27, 2021

Just to let you know everything seems to works perfect with my IC4 bike and Fenix 6 over ANT (so, power, speed and cadence).

I only need to do a last test with my wife Vivoactive 4s as it does not support the power profile, so she need speed and cadence over ANT. I will let you know but if this works, this PR solved everything for me!

@chriselsen
Copy link
Contributor Author

Just to let you know everything seems to works perfect with my IC4 bike and Fenix 6 over ANT (so, power, speed and cadence).

Excellent news! I also did a few hundred km with an IC4 bike and ANT+ to a Garmin watch. Works great.
The total distance shown on the IC4 display diverges by 2-3 % from what Garmin records. But that's to be expected.

@gurase
Copy link

gurase commented Dec 29, 2021

What's also odd is that my Garmin watch recognizes the BLE CSC service, but then ends up only displaying cadence and no speed.

This is what I'm seeing too. I can see speed fine when paired over BLE with the Kinetic Fit app, just not on my watch (FR745). I don't have an ANT stick so was hoping to get BLE to work.

@screetch82
Copy link

Works perfectly fine with Garmin. I can now see the IC4/IC7 bike speed, power, cadence and record it to Garmin without needed additional sensors.

Thanks so much.

image

@crissag
Copy link

crissag commented Feb 18, 2022

I just found this update a few days ago and implemented everything. I have a Keiser M3i with the older computer that required the M Series Connector and a new Garmin Fenix 6 Pro. When I first set this up, I still had my Connector on for my first few rides. I saw the same dropouts that @nealjane was reporting with the new Keiser computer. I disconnected the M Series Connector and then everything has been running fine for me with very few dropouts during my rides. I'm very new to Garmin (long time Polar user) and don't know too much about ANT+. Is there anything that can be done to have it play nicely with Bluetooth? I tried two different lower cost ANT+ USB Sticks (CHILEAF and LIVLOV) because I wasn't willing to spend $50 on the Garmin version. Is it just the ANT+ signal that is a problem in a Bluetooth environment?

@nealjane
Copy link

nealjane commented Feb 18, 2022

Hi Cris, chileaf and livlov are basically the same ant+ dongle , it’s the brand I’ve mentioned to a couple of people on here /M3i fb group(basically they look different to the poor performance anself and clones which people have had issues with over last few years.)
. Performance wise I’ve had no issues with those vs Garmin one. Ant+ is low power so ideally you need it with line of sight and within a couple of metres of bike or more importantly your watch.

the new M connect computer drops in power signal over ant+ is a different matter - so just don’t upgrade if you need ant+!

@crissag
Copy link

crissag commented Feb 18, 2022

Hi Neal, thanks for the clarification. I'm glad to hear the chileaf/livlov are good to use; I really didn't want to spend more on the Garmin one. I have the Bluetooth converter; I have since pulled it out of usage (I wasn't getting the Gymnasticon cadence on the Peloton app, so was still using it; realized I had mistakenly used Gymnasticon as a sensor on my Garmin watch, which I fixed and now can see cadence on the Peloton app from Gymnasticon). I am still getting some interference when my wife is in the gym at the same time, which I attribute to other Bluetooth signals present at the same time. I'll try getting the ANT+ stick closer to my watch and see if that helps. I had it tucked away in our workout area. Thanks for the suggestions!

@crissag
Copy link

crissag commented Feb 26, 2022

I've had a lot of success with the Ant+ stick closer to my watch. I do still have occasional disconnects, where the Garmin watch loses the sensor and then reconnects, so only missing a very small amount of data. Not a huge deal to me.

If I wanted to put gymnasticon in debug mode where it creates a log file, how would I do that? I've tried reading everywhere here but can't find it.

@nealjane
Copy link

nealjane commented Feb 26, 2022

Stop Gymnasticon first -

sudo service gymnasticon stop

then restart with following (not log file- but closest thing to it) -

NODE_DEBUG=gymnasticon:bike* gymnasticon --bike keiser

@nealjane
Copy link

nealjane commented Mar 2, 2022

I've had a lot of success with the Ant+ stick closer to my watch. I do still have occasional disconnects, where the Garmin watch loses the sensor and then reconnects, so only missing a very small amount of data. Not a huge deal to me.

If I wanted to put gymnasticon in debug mode where it creates a log file, how would I do that? I've tried reading everywhere here but can't find it.

@crissag -Change this in keiser.js file which will reduce the drops to 0 over ant+ (try 2 seconds instead) - const KEISER_STATS_TIMEOUT_NEW = 1.0; // New Bike: If no stats received within 1 sec, reset power and cadence to 0

@crissag
Copy link

crissag commented Mar 2, 2022

@nealjane My kesier.js file had this set to 2; It must have been updated in this branch.

I also remembered how much I hated the vi editor.

@toma
Copy link

toma commented Mar 12, 2022

Hello, long suffering metric-less Garmin and Peloton user here who just wanted to thank you for all the work and report that this branch is working great for me. I'm using a FR745 and am using this ANT+ adapter on a Raspberry Pi 4.

Here's a nice example of the metrics reported to the watch aligning with what the bike recorded itself:
image

image

I'm using all the cabling as described in #12 but do not have the Bike TX connected to the tablet -- when I did that the metrics were correct on my watch but continually dropped out / maxed out on the bike like this:
image

@adanemayer
Copy link

@nealjane Thanks for the pointer to this branch. @chriselsen I followed the instructions and got my Pi pushing cadence stats to my Garmin Edge 25 from my IC4 bike. I didn't check which profile gymnasticon selected but for some reason speed was not published (heart rate came from a separate sensor paired directly to the Edge). I'll re-run with debug mode on and see if speed shows up, but otherwise this worked great. Thank you!
Screenshot from 2022-03-19 07-32-05

@nealjane
Copy link

I’m not sure that it works over Bluetooth - ant+ speed should be working though. 👍🏻

@crissag
Copy link

crissag commented Mar 21, 2022

I've had a lot of success with the Ant+ stick closer to my watch. I do still have occasional disconnects, where the Garmin watch loses the sensor and then reconnects, so only missing a very small amount of data. Not a huge deal to me.
If I wanted to put gymnasticon in debug mode where it creates a log file, how would I do that? I've tried reading everywhere here but can't find it.

@crissag -Change this in keiser.js file which will reduce the drops to 0 over ant+ (try 2 seconds instead) - const KEISER_STATS_TIMEOUT_NEW = 1.0; // New Bike: If no stats received within 1 sec, reset power and cadence to 0

@nealjane Did setting this to 3s solve your issues with the new Keiser computer as well? I had thought about setting this higher, but the dropouts were less of an issue for me when I moved the pi closer to my watch.

@nealjane
Copy link

@crissag - try 3s and see if it sorts out the dropouts if you’ve already got ant+ as close as you can to the bike.

@adanemayer
Copy link

@nealjane Thanks for the pointer to this branch. @chriselsen I followed the instructions and got my Pi pushing cadence stats to my Garmin Edge 25 from my IC4 bike. I didn't check which profile gymnasticon selected but for some reason speed was not published (heart rate came from a separate sensor paired directly to the Edge). I'll re-run with debug mode on and see if speed shows up, but otherwise this worked great. Thank you! Screenshot from 2022-03-19 07-32-05

Turns out I forgot to select "Indoor Mode" on the Edge once the sensors were connected. Speed shows up now along with the other stats. Thanks all!

@romansemko
Copy link

With most recent RPi image I am getting command not found for overctl. Any idea why?

I skipped that part and tested the rest with Garmin + IC4. Works like charm! GJ

@romansemko
Copy link

Answering my own question with another question. Is it possible that the changes from #58 are not present in the latest img as linked from the README.md ? At least that's where I got my image and it does not have overctl.

@nealjane
Copy link

With most recent RPi image I am getting command not found for overctl. Any idea why?

I skipped that part and tested the rest with Garmin + IC4. Works like charm! GJ

That command didn’t work for me either, but current version is write protected etc - I just use raspiconfig to write/lock the image when needed/which works.

ptx2 hasn’t been around in almost a year now - so don’t think there will be any furthet updates to the current Gymnasticon without him - Chris Elsens speed additions for ant+ are here though.

@romansemko
Copy link

I just use raspiconfig to write/lock the image when needed/which works.

Okay, thanks for clarifying! So, in order to do changes you disable the overlay FS with raspiconfig and when you are done you enable it again, right? It seems disabled in my case by default right now... Not sure if I restart the RPi now if all my changes will be gone! XD

@rmaster78
Copy link

Just wanted to say THANK YOU and also want to update @chriselsen and all others contributers that I've tried this on Flywheel bike and it is reporting speed to my Garmin 520 over ANT+ (can't check BLE as I don't have a head unit that can read BLE signal) so you can cross one of the issues in your list.

Not sure how accurate the speed value is, but seems high for the power I am generating. Below are some data points.
60 watts = 21.2 km/h
69 watts = 22.7 km/h
73 watts = 23.3 km/h
91 watts = 25 km/h
119 watts = 29.7 km/h
129 watts = 30.9 km/h

I am using "power-scale":0.9 parameter in the config file to reduce the power reported to my head unit as I found out my spin bike seems to report about 10% more watts than my friend's high end TACX smart trainer when I did a quick test ride side by side. Even if I don't use the "power-scale" parameter the speed seems high. I know this isn't your doing as you are just reporting whatever the bike is spitting out, but one suggestion would be to add "speed-scale" and "speed-offset" parameter for us to play with to fine tune the values to fi these type of issues.

Thank you once again!

@chriselsen
Copy link
Contributor Author

The Flywheel bike should be providing the speed via Bluetooth to Gymnasticon. Therefore Gymnasticon only passes through to ANT+ whatever it receives.
At least from experience with the IC4 bike, the speed shown by these bikes doesn't factor in resistance. It's purely some formula based on generated power. Therefore the speed displayed is what you would be riding on a flat surface - where resistance is close to 0.
The speed that you see within e.g. Zwift factors in the slope of the hill that you are climbing or going down. Therefore that speed will not match what your trainer shows you, unless you rid on a long flat stretch in Zwift.

@rmaster78
Copy link

Thanks for the response. I noticed gymnasticon sends the data as Spd/Cad sensor rather than just Speed sensor. If I search under Speed Sensor for Garmin 520, it can't find it, but it will find it under Spd/Cad sensor. Not sure if this has any overlap with Power sensor as this also provides Cadence.

Also I did notice few power drops to zero and speed going to ~4 mph intermittently, but I am not sure what is causing this. I don't recall having this issue before installing this branch (at least for power as I didn't have speed data before). The ANT+ is right below the Garmin head unit so I don't think it is a distance issue from the ANT+ dongle. I'll keep monitoring as I ride and report back any issues with Flywheel bike. Any idea what maybe causing this would be appreciate it and if you need anything from me let me know.

Below graph shows overlay of speed vs. power (speed is the area graph and power is the dark line graph). As you can see, power drops to zero 3x times, but speed drops to ~4 mph at many instances.

Screen Shot 2022-05-14 at 5 32 16 PM

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.

None yet

10 participants