{{ message }}

# Handle variable turn according to SD2 #23

Merged
merged 1 commit into from Dec 2, 2016
Merged

# Handle variable turn according to SD2#23

merged 1 commit into from Dec 2, 2016

## Conversation

### m3d commented Nov 27, 2016 • edited

 Note, that in Speed Dreams 2 is variable turn in reality just composite of several turns with fixed radius. The length step is used from the parameter "profil steps length". This solution is simple "brute force" where original segment is split into several "ordinary" with fixed radius. Fixes #21.
added this to the Release demo.py milestone Nov 27, 2016
assigned zwn Nov 27, 2016

### zwn commented Nov 28, 2016

 Does this create closed loop circuits from all SD2 tracks?

### m3d commented Nov 28, 2016

 I manually tested A to K circuits - this would be nice to do it "automatically". I will check the rest, moment.

### m3d commented Nov 28, 2016

 Karwada: pit end 0.245409567132 0.0928922257346 2.07332408298e-13 Migrants: S50 0.00309183313288 0.00064039451858 -360.0 Ruudskogen: pit start 0.0457934923833 -0.0689310176035 -360.0 done. (i.e. error up to 25cm and angle 0 or +/-360deg)
requested changes
track.py Outdated
 segments.append(s) else: length = abs((s.radius + s.end_radius)/2.0 * s.arc) num_steps = int(length/4.0) + 1

#### zwn Nov 29, 2016 Member

I don't understand this line. Shouldn't `num_steps` be `length/profil_steps_length`? The variable `profil_steps_length` is set but never used.

track.py Outdated
 if num_steps == 1: segments.append(s) else: dlen = length/float(num_steps - 1)

#### zwn Nov 29, 2016 Member

Let's say I end up with `num_steps == 2`. Probably the step length is set to 10, length is 15, so I need to split the segment into two pieces. I want `dlen == length/2 == 7.5` , right? Why would I want to divide by `num_steps-1`?

track.py Outdated
 tmp_angle = 0.0 for i in xrange(num_steps): tmp_angle += dlen/(s.radius + i*dradius) dlen *= s.arc / tmp_angle

#### zwn Nov 29, 2016 Member

Sorry, I am lost here. What are we trying to achieve?

#### m3d Nov 29, 2016 Author Member

This is "imitation" (~ copy & paste) of original Speed Dreams code track4.cpp#L1445-L1454

track.py Outdated

#### zwn Nov 29, 2016 Member

`end_radius` is not used for anything.

### m3d commented Nov 30, 2016

 There is extra test now for all tracks in subdirectory. The result is: ``````d:\md\git\pyroborace>track.py "c:\Program Files (x86)\speed-dreams-2.2.1\data\tracks\circuit" aalborg.xml (0.0013696381565466709, -0.0005095824219278705, -6.283185307179587) brondehach.xml (0.0004889460990682437, -0.004291454008970227, -6.28318530717959) chemisay.xml (-0.0026334008695698685, -0.05039380851064525, 6.283185307179586) corkscrew.xml (1.8678876735108725, 2.375623972246894, 6.2831887978380925) espie.xml (-0.00013923340574706344, 0.00020790789545971805, -6.283185307179586) forza.xml (0.14858760180141362, -0.032226282759862626, -6.282906054499265) goldstone-sand.xml (-0.008332124542306474, 0.0010251185699555036, -6.283185307179583) karwada.xml (0.2454095671319152, 0.09289222573461238, 3.6186331708876196e-15) migrants.xml (0.003091833132884858, 0.0006403945185801958, -6.283185307179581) ruudskogen.xml (0.04579349238325392, -0.06893101760347149, -6.283185307179588) `````` There now also extra assert which will fail on corkscrew.xml (1.8678876735108725, 2.375623972246894, 6.2831887978380925)
reviewed
track.py Outdated
 if num_steps == 1: segments.append(s) else: dlen = length/float(num_steps - 1)

#### zwn Nov 30, 2016 Member

I still don't know why we have the -1 here (see my comments to the previous version).

#### zwn Nov 30, 2016 Member

Oh, well, see track4.cpp#L1442 and track4.cpp#L1446. That is why I didn't want to reimplement it ☹️ .

### zwn commented Nov 30, 2016

 When I have some spare time, I will check if corkscrew closes the loop in SD, so that we are not chasing some ghosts here.

### zwn commented Nov 30, 2016

 So for Espie circuit I get: ``````Last segment TR_EL (-0.003510, 13.005758) Last segment TR_ER (-0.003418, 0.005759) First segment TR_SL (0.000000, 13.000000) First segment TR_SR (0.000000, 0.000000) `````` and for Corkscrew ``````Last segment TR_EL (-0.011874, 11.995796) Last segment TR_ER (-0.011813, -0.004192) First segment TR_SL (0.000000, 12.000000) First segment TR_SR (0.000000, 0.000000) `````` So, it is down to 1cm accuracy. Do you want to merge anyway or do you want to try to get better? May I suggest another way? It is also (5) for #3 if anyone is keeping count 😉. I can patch my local SD tree to export the parsed track in a format you could parse in python, which would involve no calculations. This way we can still use the SD code to do the interpretation of its own file format. Doing this ourselves brings only work and no value (well unless it is your idea of fun 😆).

### m3d commented Dec 1, 2016 • edited

 I would merge it (I will rebase it now). As my colleague says "Perfect is the enemy of good" - there are many other issues (two more branches to merge now) and final Roborace will use different simulator and also probably different track description. Note, that at the moment is the worst circuilt is Forza: ``````forza.xml (0.14858760180141362, -0.032226282759862626, -6.282906054499265) `````` but it is still only 14cm, so I would ignore it for now. Corkscrew was fixed with variable `profil steps length` (the previous error was several meters). Edit: ``````karwada.xml (0.2454095671319152, 0.09289222573461238, 3.6186331708876196e-15) `````` is currently the worst, but still I would move forward.

### m3d commented Dec 1, 2016

 I added extra commit with the arc formula - it is actually simple geometric average and multiplication with dlen was useless (I was wandering why +/- 1 did not matter ... it canceled each other out). So still the same behavior but cleaner, I hope ;). Please confirm the rebase operation and let's move on ...
approved these changes

### zwn left a comment

 Looks good. Only in test_segment.py there is one tab instead of all spaces.

### m3d commented Dec 1, 2016 • edited

 I am not aware of that - do you mean XML which is not properly formatted? Edit - ignore (I did not search in HEX code)

### zwn commented Dec 1, 2016

 There! You've found it 😄. Are you going to rebase? Or shall I just do the "squash and merge" in the github ui? Or will you do it yourself? Or...?
``` Handle variable turn according to SD2 ```
``` d31354e ```
```Note, that in Speed Dreams 2 is variable turn in reality just composite
of several turns with fixed radius. The length step is used from the
parameter "profil steps length".

There is now test for all tracks defined by subdir containing XML files.
Variable profil_steps_length per segment is also supported.```
force-pushed the fix/step-change-radius branch to `d31354e` Dec 1, 2016

### m3d commented Dec 1, 2016

 Squash completed..
merged commit `78dfb66` into master Dec 2, 2016
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deleted the fix/step-change-radius branch Dec 2, 2016
mentioned this pull request Dec 2, 2016