By popular demand a simple example of how to modify the stepper_mm sample configuration to output phase-A/phase-B quadrature signals (stepgen type=2).
In core_stepper.hal we specify step type 2, and re-name/wire the stepgen output:
loadrt stepgen step_type=2,2,2
net XA <= stepgen.0.phase-A
net XB <= stepgen.0.phase-B
net YA <= stepgen.1.phase-A
net YB <= stepgen.1.phase-B
net ZA <= stepgen.2.phase-A
net ZB <= stepgen.2.phase-B
Then in standard_pinout.hal we wire the phases to the parport:
net XA => parport.0.pin-03-out
net XB => parport.0.pin-02-out
net YA => parport.0.pin-05-out
net YB => parport.0.pin-04-out
net ZA => parport.0.pin-07-out
net ZB => parport.0.pin-06-out
Since I have neither a parport nor an oscilloscope at hand right now I'm using some pyvcp LEDs to look at the A/B signals. These are set up with two changes to the INI-file:
[DISPLAY]
PYVCP = phaseleds.xml
I thought I would build EMC2-simulator on 64-bit Ubuntu 11.10 following the instructions from the wiki. To get the source and dependencies:
$ git clone git://git.linuxcnc.org/git/emc2.git emc2-dev
$ cd emc2-dev
$ cd debian
$ ./configure sim
$ cd ..
$ dpkg-checkbuilddeps
Then install all the required packages with "sudo apt-get install". dpkg-checkbuilddeps suggests installing tk8.4 and tcl8.4 but I found that in ordet to get the configure-script to run without errors I needed tk8.5, tk8.5-dev, tcl8.5 and tcl8.5-dev, and I removed all the 8.4 packages of tk and tcl. That makes configure run without errors. Then try building:
$ cd src
$ ./autogen.sh
$ ./configure --enable-simulator
$ make
However that produces a number of linking errors. Don't ask me exactly why but this patch: 0001-changes-to-make-sim-build-on-ubuntu-11.10.patch.tar (updated corrected version!) seems to fix things, and I get emc2 sim built and running. Just in case anyone else wants to build on 64-bit Ubuntu 11.10.
I've made some more progress with my voronoi diagram code. I described the topology-oriented incremental algorithm earlier here (point sites) and here (line segments). When we want to add a new site (a point or a line-segment) to the diagram we should find a tree of to-be-deleted vertices/edges (red), create new (green) vertices on all in-out edges, and hook up the new vertices with new edges (green) to form the face for the new site. For point sites it looks like this(click thumbnail to see GIF animation!):
For line-segment sites we need to modify the in_circle() predicate to calculate the minimum distance from a point to a line-segment. Then we need a much more involved solver that figures out points that are equidistant from points/lines. There are four different cases: point/point/point, point/point/line, point/line/line, and line/line/line (or you could identify a fifth and sixth type of vertex if you treat the case where one vertex is a line-segment endpoint differently, see drawing here).
In addition to simple line-edges between two point-sites we now also get two new types of edges: between line/line sites we have line-edges (but parametrized a little differently), and between point/line sites we have parabolic edges. The basic algorithm however looks pretty similar: we again find the delete-tree (red), create new vertices (green), and hook them up with new edges (green) to form a new face. (again click thumbnail to see GIF animation!).
There are (at least!) two more complications arising with line-sites that don't show up with just point-sites. These are handled with additional APEX and SPLIT vertices, which don't really add new geometry or topology to the diagram, they just make the algorithm handle certain special cases correctly.
It turns out that with parabolic edges there can be cases where both endpoints of the edge are marked IN (red, or to-be-deleted), but some parts of the edge still needs to be preserved. To handle this case correctly we insert a new type of APEX vertex at the apex of each parabolic edge. These APEX vertices can be seen at the tip of each parabola in the GIF-animation above.
The second special case is more subtle. There can be situations where the algorithm finds a to-be-deleted set of vertices that contains a loop/cycle. This is obviously forbidden because that would delete a face from the graph - which isn't allowed. That's why we require the delete-set to be a tree. Here is an image:
We are inserting a new line-segment (yellow) starting at 48. The IN-vertices already found are colored red. Vertex 142 should be marked IN because it is closer to the new line-segment than to any other site. However that would create a loop of red vertices (134-135-143-148-142-138) and the face corresponding to the point-site 133 would be deleted. The problem is similar to that with APEX points: the end-points of edge 148-142 are both marked IN, but the edge should not be deleted completely. To handle this case we need to insert a SPLIT vertex at a position on the 148-142 edge which will be preserved(i.e. marked OUT). We do this by projecting the site 133 onto the edge 148-142 using the line-segment(yellow) as a mirror. This vertex will be marked OUT and ensures that the 148-142 edge is not completely removed. The same reasoning should work for circular arc-sites where we project radially through the center of the arc.
Here is a longer animation (best watched at 1080p/fullscreen!) which shows the insertion of 100 point-sites followed (after around 1:15) by insertion of (non-crossing!) line-segments:
The code now runs without errors until about 50 line-segments. There are problems with finding the proper end-points for separators in degenerate cases where the solver positions vertices on top of each other or very very close to each other.
Update: Some further bugfixes and filtering solution-points by both maximum and minimum t-value (clearance disk radius) has made the code run without assert()'s or problems up to N=100 line-segments:
Update2: now up to 200 line-sites:
Update3: Here is one case which I have identified as "hard" for the vd-vertex location solver code. We have as input to the solver a line-segment, one of its endpoints, and a third site (in this case also a line-segment). In some cases it happens that the offsets (dashed lines) of these three input sites are nearly parallel, which results in bad numerical precision, and the resulting solution can have an error which is as much as 1e9 times the normal errors I see.
My legs aren't exactly recovered from Saturday's marathon, but a slow 5k jog anyway today. Sports Tracker was released for the N9 last week (or was it earlier?), so I thought I'd do some GPS testing. Held Garmin Edge 800 in my right hand and the N9 in my left. The results aren't that great for the N9:
I should do a test on the bike later. Maybe include the Garmin 405cx and older C7 phone also?
The touch-screens on these devices are different: Edge 800 works fine with gloves, N9 doesn't work at all with gloves.
Rautaveden marathon, the last 'big' marathon in the Finnish running calendar, loops around lake rautavesi around 50km west of Tampere. Rogaining and biking earlier in the fall together with a week of flu meant that it was either this event, or possibly Åland a week earlier (but that would have been more of a hassle travel-wise).
The first 9k of the route is quite flat and takes us out of the city and onto the big Tampere road. Almost the whole 9-10 km interval is a big uphill which resulted in a slowish 5m:50s kilometer-time. After that it's a bit of downhill and varied terrain until around 19k (after ski-resort Ellivuori) where there is a big downhill. For me a fast kilometer-time of 5:02 - but as I haven't practiced running downhill much I think my legs got beat in that downhill pretty bad. After that it's more flat/varied until the turn at the top of the map around 26k. This is where my legs were about finished 🙂 I then walked most of the steeper uphills, and some flat-bits too during each kilometer between maybe 32k and 39k. At the end after the last drinking-station at 40k I ran again all the way to the finish for a time of 4h 12min 40s - a new personal best, but not the sub-4h I had maybe hoped for...
Splits for the first and second 20k:
1-20k: 1:49:51 (5:30/km)
21-40k: 2:06:50 (6:21/km)
Or broken down into 10ks: 59min, 2nd 62min, 3rd 67min, and 4th 76min.
1-10k: 54:59 (5:30/km) (HCM: 59m)
11-20k: 54:52 (5:29/km) (HCM: 62m)
21-30k: 1:00:06 (6:01/km) (HCM: 67m)
31-40k: 1:06:44 (6:40/km) (HCM: 76m)
Or broken down into 5ks, and compared to last year's Helsinki City Marathon:
1-5k: 27:13 (5:27/km) (HCM: 29m)
6-10k: 27:46 (5:33/km) (HCM: 30m)
11-15k: 27:29 (5:30/km) (HCM: 30m)
16-20k: 27:23 (5:29/km) (HCM: 31m)
21-25k: 28:57 (5:47/km) (HCM: 33m)
26-30k: 31:09 (6:14/km) (HCM: 34m)
31-35k: 31:27 (6:17/km) (HCM: 36m)
36-40k: 35:17 (7:03/km) (HCM: 40m)
Finally the all important medal:
A comparison of the elevation-graph from the organizers website with data from my garmin 405cx. The heart-rate graph clearly shows how hitting "the wall" at 32k results on walking-breaks and a lower heart rate.
I've made some progress with my voronoi diagram code:
Sites/generators in yellow. Line-edges in cyan, parabolic edges in red. Note that the parabolic edges are split at their apex, i.e. the closest point to the adjacent site.
Some problems with hooking up the half-edges of the two new faces that are associated with a new line-site remain. Hopefully soon to be fixed.
This code should in principle work for circular arc sites too. Adding arcs to the diagram results in elliptic and hyperbolic edges (in addition to line and parabola, which seem to work now).
I'm experimenting with compiling programs for the N9.
Go to http://harmattan-dev.nokia.com and get their python script harmattan-sdk-setup.py. Make it executable: chmod a+x harmattan-sdk-setup.py
Run the script as root: sudo ./harmattan-sdk-setup.py
Press "0" for admininstall. This will start a lengthy install. On my machine it started with installing python-qt4. Then scratchbox (89Mb download for X86 and another 89Mb download for ARM). Then comes the SDK itself, one 825 Mb download for the X86-SDK and another 806 Mb download for the ARMEL-SDK.
Now I get:
:~/Desktop$ scratchbox
bash: /usr/bin/scratchbox: Permission denied
That's because the scratchbox install creates a new user group sbox, and adds your username to this group. We now need to log out of the machine and log in again so that this group is created and your user is added to the group. Now we can run scratchbox. Now, from another terminal on the host-machine, start Xephyr with this:
Xephyr :2 -host-cursor -screen 854x480 -dpi 96 -ac +extension Composite &
From the scratchbox terminal we can now start meego:
meego-sb-session start
This gives a little bit of error-messages, but nothing major I guess. And we have a working "phone":
If we start Xephyr in portrait mode instead with 480x854x16 it looks a bit better: (should also work by passing '-landscape' flag to meego-sb-session)
The screen where all the open applications are shown looks a bit strange:
This environment should allow coding and compiling in the correct environment on X86, and then cross-compiling on the ARMEL-target and packaging into debs for sending to the device. But on IRC I am told there's an alternative QtSDK toolchain that does the same thing - maybe in a simpler way. To be continued...
25k in 2h 40min (avg pace 6:25/km) with avg HR 139. This is about the longest training run I will do in preparation for a marathon - I think. Some training programs advocate increasing the long-run distance up to 30k and above, but many others claim the risk of injury or overtraining increases dramatically when doing 3+ hour training runs and thus they are not worth the risk.