PhillyOpen / Cycle-Philly-iOS

CyclePhilly for iPhone
www.cyclephilly.org
GNU General Public License v3.0
2 stars 8 forks source link

Calorie counting #2

Closed AcriCAA closed 10 years ago

AcriCAA commented 11 years ago

When a user completes a trip, the app creates a summary of the data collected for that trip which the user can access under "my trips." One of the items is a "kCal" estimate of calories burned.

Based on other apps I have used, the numbers the app estimates are much higher than what they should be.

I can't tell what part of the app is calculating calories but it is probably doing it based on some formula. I have done some research and all of the formulas for calculating calories require a person's weight for the calculation. If someone can point me to the code in the app that is calculating the calories, I may be able to figure out how to modify it for a more accurate calorie count.

flibbertigibbet commented 10 years ago

Line 641 of SavedTripsViewController.m:

double calory = 49 * [trip.distance doubleValue] / 1609.344 - 1.69;
flibbertigibbet commented 10 years ago

Based on the bike power formula on Wikipedia, I've changed the kCal formula to the following:

P = g m V_g (K_1+s) + K_2 V_g^3

Constants:
gravity = 9.81 m/s^2 average weight in US = 74.7 kg average bike weight = 13.6 kg So, using weight constant 88.3 kg for bike+rider assume flat grade (s = 0) K_1 is frictional loss = 0.0053 K_2 is aerodynamic drag constant = 0.185 kg/m assume no wind

P = ( 9.81 * 88.3 * speed * (0.0053 + 0) ) + ( 0.185 * speed^3 ) P is in watts (Joules/sec). 1 cal ~= 1 watt on bike

simplifying to: kCal = ((4.5909819 * speed + 0.185 * speed^3) / 1000) * [trip time, in seconds]

It's probably not very accurate, considering the assumptions it's making about rider+bike weight, wind, incline, and constant speed.

AcriCAA commented 10 years ago

For the trip I recorded this morning the app calculated 47.8 kCals burned. I simultaneously ran Runkeeper for the same ride which calculated 135 calories, which is consistent with what other apps would calculate for a route of the same duration based on my weight. This is a pretty accurate calculator. I was also able to access the javascript formula they are using on this page which I put here, this is another js that seems to output the same numbers. Their calculations come close to what RunKeeper calculates but I am trying to figure out what formula they are using.

AcriCAA commented 10 years ago

This is using the following formula, which I believe is the most straightforward to implement.

kg = 1lbs * .45359237

Pace = 6 for Biking 10-12 mph 8 for Biking 12-14 mph 10 for Biking 14-16 mph 12 for Biking 16-20 mph 16 for Biking > 20 mph

hr = Minutes/60

Calories Burned = (kg * Pace) * hr

So I weigh 145 pounds, converted to kgs that's 65.8 kg If I biked 19 minutes at a pace of 10-12 mph (pace value 6) the formula would look like this:

(65.8 * 6) * (19/60) = 125.02 calories, which is approximately correct compared to other formulas

flibbertigibbet commented 10 years ago

I don't think we collect rider weight currently. I'm not sure what would be the best way to put that prompt in the interface, while making clear we won't upload it with the other personal info. On Jan 21, 2014 9:03 PM, "Corey Acri" notifications@github.com wrote:

This http://jsbin.com/AxECOva/1/ is using the following formula, which I believe is the most straightforward to implement.

kg = 1lbs * .45359237

Pace = 6 for Biking 10-12 mph 8 for Biking 12-14 mph 10 for Biking 14-16 mph 12 for Biking 16-20 mph 16 for Biking > 20 mph

hr = Minutes/60

Calories Burned = (kg * Pace) * hr

So I weigh 145 pounds, converted to kgs that's 65.8 kg If I biked 19 minutes at a pace of 10-12 mph (pace value 6) the formula would look like this:

(65.8 * 6) * (19/60) = 125.02 calories, which is approximately correct compared to other formulas

— Reply to this email directly or view it on GitHubhttps://github.com/PhillyOpen/Cycle-Philly-iOS/issues/2#issuecomment-32986970 .

AcriCAA commented 10 years ago

I think we should just use the average weight you found.

On Tuesday, January 21, 2014, Kathryn Killebrew notifications@github.com wrote:

I don't think we collect rider weight currently. I'm not sure what would be the best way to put that prompt in the interface, while making clear we won't upload it with the other personal info. On Jan 21, 2014 9:03 PM, "Corey Acri" <notifications@github.com<javascript:_e({}, 'cvml', 'notifications@github.com');>> wrote:

This http://jsbin.com/AxECOva/1/ is using the following formula, which I believe is the most straightforward to implement.

kg = 1lbs * .45359237

Pace = 6 for Biking 10-12 mph 8 for Biking 12-14 mph 10 for Biking 14-16 mph 12 for Biking 16-20 mph 16 for Biking > 20 mph

hr = Minutes/60

Calories Burned = (kg * Pace) * hr

So I weigh 145 pounds, converted to kgs that's 65.8 kg If I biked 19 minutes at a pace of 10-12 mph (pace value 6) the formula would look like this:

(65.8 * 6) * (19/60) = 125.02 calories, which is approximately correct compared to other formulas

— Reply to this email directly or view it on GitHub< https://github.com/PhillyOpen/Cycle-Philly-iOS/issues/2#issuecomment-32986970>

.

— Reply to this email directly or view it on GitHubhttps://github.com/PhillyOpen/Cycle-Philly-iOS/issues/2#issuecomment-32987173 .

emelleme commented 10 years ago

chiming in: Weight is a bit more dynamic than, say, your age. For example. I am currently down 5 pounds from my weight last week. That makes a big difference in the calculation.

If we have that, it should be a field on end of trip (optional) that give them the option to calculate calories for them.

themightychris commented 10 years ago

The calorie calculation isn't an exact science anyway, and I think most people are just curious to see it.

What I would personally prefer would be if it showed the calorie estimate after the trip, with a note if there's room that it's based on the age/weight in the settings screen. Then put age and weight on the settings screen but default them to the average age/weight.

That way everyone wins -- the casual user doesn't have to do anything and gets a rough estimate that will at least give them relative values between trips, and the serious users like Lloyd can update their weight every time they get off the scale to make all their future trips more accurate.

On Wed, Jan 22, 2014 at 5:41 PM, emelleme notifications@github.com wrote:

chiming in: Weight is a bit more dynamic than, say, your age. For example. I am currently down 5 pounds from my weight last week. That makes a big difference in the calculation.

If we have that, it should be a field on end of trip (optional) that give them the option to calculate calories for them.

— Reply to this email directly or view it on GitHubhttps://github.com/PhillyOpen/Cycle-Philly-iOS/issues/2#issuecomment-33077285 .

Chris Alfano

emelleme commented 10 years ago

haha! Good point Chris. Seems logical to add it in the settings, and offer the field for update at each trip, pre-populated with settings weight. Corey, Kat, what do you guys think?

AcriCAA commented 10 years ago

Instead of having a prompt after every trip, how about we add an optional weight field to the demographic screen/settings screen, as Chris said. If it is blank we go with the average weight as Chris described. If it is entered we use that weight to calculate.

Don't prompt on a trip by trip basis. That disturbs the workflow of getting the data uploaded to our servers, which is our goal - to make it as quick and easy as possible to get accurate route data. If we start adding in more steps at the end of the trip, the user will get frustrated with the app. 

If the user wants accurate calorie data they could enter the weight in the settings screen. Otherwise they get it based on the average weight. 

Let's chat tomorrow.  — Sent from Mailbox for iPhone

On Wed, Jan 22, 2014 at 7:38 PM, emelleme notifications@github.com wrote:

haha! Good point Chris. Seems logical to add it in the settings, and offer the field for update at each trip, pre-populated with settings weight.

Corey, Kat, what do you guys think?

Reply to this email directly or view it on GitHub: https://github.com/PhillyOpen/Cycle-Philly-iOS/issues/2#issuecomment-33086142

AcriCAA commented 10 years ago

Can we just gut this?

flibbertigibbet commented 10 years ago

Removed calorie counter in bfe625c90589d74ea6ebeae309916bf9588712f4. Closing this one.