RowMetrics - communicating with the PM using Python on Linux

Post questions and issues with Concept2 PM3 SDK
vishalpatel
Paddler
Posts: 4
Joined: April 15th, 2009, 11:44 pm

RowMetrics - communicating with the PM using Python on Linux

Post by vishalpatel » April 16th, 2009, 6:17 am

Hi all,

I've seen a few posts here regarding development on Linux and with python. Just wanted to mention a little application I wrote using these very tools. I made a post announcing it in the SDK/General forum (which, by the way, doesn't show up in the list of forums unless I'm logged in :?: ); just check the thread at http://www.c2forum.com/viewtopic.php?t=9039

The application itself is available here: http://www.vishalpatel.net/projects/rowmetrics . Hopefully a look through the source will be more illuminating than confusing for anyone hoping to communicate with the PM using Linux and/or python. Hope this helps someone! :)
[url=http://www.vishalpatel.net/projects/rowmetrics/]RowMetrics[/url] - a workout performance logger/plotter for Linux

User avatar
Citroen
SpamTeam
Posts: 8062
Joined: March 16th, 2006, 3:28 pm
Location: A small cave in deepest darkest Basingstoke, UK

Post by Citroen » April 16th, 2009, 9:07 am

I had a quick look at http://www.vishalpatel.net/projects/row ... 34358Z.csv

How are you getting the "corrected" numbers? What's the correction.

Where's the elapsed time? I can see you've rowed 2K, but I can't see how long it took.

I've got a PM4A, but I don't have a rower near my Linux machine (it's 5Km to my gym). And I don't have a portable Linux machine.

Would it work on Windows running under CYGWIN?
Dougie Lawson
61yrs, 172cm, Almost LWt (in my dreams).
Twitter: @DougieLawson

vishalpatel
Paddler
Posts: 4
Joined: April 15th, 2009, 11:44 pm

Post by vishalpatel » April 16th, 2009, 11:44 am

The weight adjustment is calculated using the formula given here: http://www.concept2.com/us/interactive/ ... stment.asp It's supposed to give you a rough idea of how fast an eight would go if you cloned yourself 7 times and filled a boat.

Time in seconds is actually in the first column of the CSV (check the very first line in the file for column headings). It's not just an index column; I'm just sampling once per second. So the elapsed time is 531 seconds. I can see how you might have gotten confused as that's an embarrassingly long time. ;)

I don't have a Windows machine near my rower ;) so I can't really say if it would work on Cygwin. The script asks libusb to detach the kernel driver, which I think is only a valid operation on Linux. If you've got a few minutes before you start your workout, maybe take a Linux LiveCD with you one day, and pop it in your laptop's drive and try it that way.
[url=http://www.vishalpatel.net/projects/rowmetrics/]RowMetrics[/url] - a workout performance logger/plotter for Linux

chris350
Paddler
Posts: 1
Joined: June 6th, 2009, 8:23 am

Post by chris350 » June 6th, 2009, 8:53 am

Hi,

i downloaded RowMetrics and got it running without any problem.
I have a PM4 and the Vendor- Product ID ist 17a4:0002.

The only Problem i ran into is logging of Interval Training, because the Time is set back to 0 if you stop rowing. Since the Logging class detects the end by the time, the log ends with the first interval.
Since i have no Python experience it is a little bit tricky for me to change that, but i will try :)

Beside of that, it is a really nice Tool, i have been missing so long as non windooze user.

Thanks for that,
Chris

vishalpatel
Paddler
Posts: 4
Joined: April 15th, 2009, 11:44 pm

Post by vishalpatel » June 11th, 2009, 12:45 am

Hi chris,

Thanks for trying it out! Glad it (mostly) worked. I'll admit to never even considering the interval workouts when I was writing it (I tend to stick to fixed time or distance), so I'm glad someone thought to check!

I remember I originally was detecting the end of the workout the "right" way, but the last time point would (non-reproducibly) have the distance/time reset to 0/0 which was messing up the graphs, so I switched to the time-based method. You'll want to start playing with the line in the LogProcessor class that looks like this:

Code: Select all

if not results is None and results[0] >= self.__data[-1][0]:
That last check makes sure the time is always increasing, which for interval workouts, isn't true. You'll need to remove that part, add some logic to detect if the time has decreased and if so, add back in the amount of time that elapsed in all previous intervals (unless you want your interval plots to overlap, which might be interesting).

I actually might try to fix this . . . one day when I have time. But you might be able to learn enough Python to get it worked out before then. ;) Especially if you have experience in another language.
[url=http://www.vishalpatel.net/projects/rowmetrics/]RowMetrics[/url] - a workout performance logger/plotter for Linux

T_B
Paddler
Posts: 27
Joined: June 21st, 2009, 5:56 pm

Post by T_B » June 21st, 2009, 6:14 pm

This just motivates me even more to buy a concept 2. Great job, and a very nice gesture to share it.
Whenever I receive mine, I will certainly try this.

T_B
Paddler
Posts: 27
Joined: June 21st, 2009, 5:56 pm

Post by T_B » June 28th, 2009, 3:14 pm

Hi vishalpatel,

I've tried rowmetrics and it works fine on Ubuntu 8.10.

I would love to see some visuals during the workouts, like competing against a Pace Boat or even better previous work outs.
Wouldn't have to be fancy, just a couple of ascii keys representing a boat would be okay.
Something like this:

-----------------------
P
------------------------
M
------------------------
Q
-----------------------
D
-----------------------

Tried to understand the code but it is way too advanced for my coding skills (just starting to learn Python).

yoogie
Paddler
Posts: 2
Joined: October 16th, 2010, 3:36 pm

Re: RowMetrics - communicating with the PM using Python on L

Post by yoogie » October 25th, 2010, 5:47 am

Hi T_B. I took the great python script from vishalptel (great thanks for sharing) and modified it a bit to put everything out immediately to standard out. The python script is started by my perl-script which talks to a VDR plugin.

I am not sure if you know VDR. It is a video disk recorder for linux. Great system for watching TV or recordings while rowing (even in HD). There is a great distribution for it you just need to install : http://www.yavdr.org

My rowing system waits until the rower is connected and it can talk to the VDR. Then it will present you a menu (controllable via infrared remote ) with the choice to select a user and a saved workout with the date/time and length of the workout. The data from that workout is then taken as reference and you can race against that paceboat while watching your favourite show.

The stats like Watt, heart rate, distance and stuff is shown in the top left border with a semi-transparent background. Values will go green, red or white based on their average being better, equal or worse than the one from the paceboat.
Additionally in the top there goes a bar over the whole screen which represents the total distance from the pace track and two elipses which represent both boats.

So it seems like exactly what you wanted to have + the television option :)

mindex
Paddler
Posts: 1
Joined: October 28th, 2011, 8:02 am
Contact:

Re: RowMetrics - communicating with the PM using Python on L

Post by mindex » October 28th, 2011, 8:12 am

actually might try to fix this . . . one day when I have time. But you might be able to learn enough Python to get it worked out before then. Especially if you have experience in another language.

zaf
Paddler
Posts: 12
Joined: January 10th, 2012, 5:57 am

Re: RowMetrics - communicating with the PM using Python on L

Post by zaf » January 10th, 2012, 6:05 am

I've gome as far as installing the required software but running the python script on an ubuntu linux machine I get the following error:


Code: Select all

python row_metrics.py -i 17a4:0001 -p 3 -w 165 -f 0.2
Found device 17a4:0001.
Traceback (most recent call last):
  File "row_metrics.py", line 576, in <module>
    pm = Concept2PM(options.id.split(':')[0], options.id.split(':')[1])
  File "row_metrics.py", line 54, in __init__
    product = self.__handle.getString(dev.iProduct, 256)
  File "/usr/local/lib/python2.7/dist-packages/usb/legacy.py", line 267, in getString
    raise NotImplemented('This function has not been implemented yet')
TypeError: 'NotImplementedType' object is not callable
Anyone have ideas on how to proceed?

User avatar
Citroen
SpamTeam
Posts: 8062
Joined: March 16th, 2006, 3:28 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: RowMetrics - communicating with the PM using Python on L

Post by Citroen » January 10th, 2012, 1:02 pm

On my Oneiric system apt wouldn't let me install python-pyusb (don't know why it disliked that), installing python-usb gets a different package and pyrow.py fails with

Code: Select all

dougie@The-Doctor:/tmp/pyrow$ python pyrow.py
Traceback (most recent call last):
  File "pyrow.py", line 8, in <module>
    import usb.core
ImportError: No module named core
So you'll need to talk to the guy who wrote the thread: http://www.c2forum.com/viewtopic.php?f=15&t=12009 to see if he'll work with you to get it working with python-usb rather than python-pyusb.

gambrell
Paddler
Posts: 5
Joined: December 6th, 2011, 6:06 pm
Location: Shelton, CT
Contact:

Re: RowMetrics - communicating with the PM using Python on L

Post by gambrell » January 10th, 2012, 5:36 pm

Citroen,

The error you are getting (not finding the usb.core module) is due to pyusb not being installed on your system. On most systems (there is always the exception) installing python modules directly (without a port or package) is fairly fool proof. If you want to give it a try you can ...
1) Download pyusb from gethub (https://github.com/walac/pyusb) by choosing the downloads tab from the top then choosing the file type you prefer (zip or tar.gz)
2) Extracting it to a local directory
3) Then running 'python setup.py install' from the command prompt in the directory you just extracted the files to

You will also need libusb 0.1, libusb 1.0 or openusb installed on your system for pyusb to work, from what I can tell Ubuntu has all these options as packages for Ubuntu Oneiric. The pyusb website goes into greater detail than I may ever fully understand (http://sourceforge.net/apps/trac/pyusb/).

Hope this helps.

User avatar
Citroen
SpamTeam
Posts: 8062
Joined: March 16th, 2006, 3:28 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: RowMetrics - communicating with the PM using Python on L

Post by Citroen » January 10th, 2012, 9:07 pm

Remember there are lots of Ubuntu folks who won't want to do that (because their Linux system is becoming a black box that almost looks like Windows). Using the other Python USB stuff may be a better/more sane option for the less technical user.

zaf
Paddler
Posts: 12
Joined: January 10th, 2012, 5:57 am

Re: RowMetrics - communicating with the PM using Python on L

Post by zaf » January 11th, 2012, 5:45 am

In the current state of play even the programmers can't get the stuff to work ;)

gambrell
Paddler
Posts: 5
Joined: December 6th, 2011, 6:06 pm
Location: Shelton, CT
Contact:

Re: RowMetrics - communicating with the PM using Python on L

Post by gambrell » January 17th, 2012, 10:12 pm

Citroen,

Looking through Ubuntu's website and some of their forums it appears that their 'python-pyusb' was renamed to 'python-usb' and the package they currently have is the older version of PyUSB (0.4 vs 1.0, which are not compatible with each other <http://sourceforge.net/apps/trac/pyusb/>). I cannot speak for PyUSB or Ubuntu as to when versions will be finalized and packages will be updated but hopefully this issue of incompatibility between pyrow and Ubuntu will take care of itself.

I know it doesn't really address the issue at hand but unfortunately as of now I am neither skilled enough as a programmer or have enough free time to try to create and manage a more robust and legacy friendly project.

Post Reply