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

The bug when aero_startup/Stroke2Angle.hh generated #385

Open
hi-kondo opened this issue Nov 7, 2018 · 0 comments
Open

The bug when aero_startup/Stroke2Angle.hh generated #385

hi-kondo opened this issue Nov 7, 2018 · 0 comments
Labels

Comments

@hi-kondo
Copy link
Contributor

hi-kondo commented Nov 7, 2018

If the value of csv being referenced is an integer value, the array of the generated file(Stroke2Angle.hh) is incorrect.
For example, this is aero_startup/Stroke2Angle.cc

static const std::vector<std::pair<std::vector<S2AData>, std::vector<S2AData>>> LegInvTableCandidates = {{{{0,0,0},{1,.655,0.655},{3,2,0.678}},{}}, {{{0,0.0f,0.0f}}, {}}, {{{4,2.688,0.688}},{{5,3.386,0.698}}}, {{{5,3.386,0.698}},{{6,4.092,0.706},{7,4.807,0.715}}}, {{{6,4.092,0.706},{7,4.807,0.715}},{{8,5.529,0.722}}}, {{{8,5.529,0.722}},{{9,6.258,0.729},{10,6.994,0.736}}}, {{{9,6.258,0.729},{10,6.994,0.736}},{{11,7.737,0.743}}}, {{{11,7.737,0.743}},{{12,8.484,0.747}}}, {{{12,8.484,0.747}},{{13,9.237,0.753},{14,9.995,0.758}}}, {{{13,9.237,0.753},{14,9.995,0.758}},{{15,10.756,0.761}}}, {{{15,10.756,0.761}},{{16,11.522,0.766}}}, {{{16,11.522,0.766}},{{17,12.291,0.769}}}, {{{17,12.291,0.769}},{{18,13.063,0.772},{19,13.838,0.775}}}, {{{18,13.063,0.772},{19,13.838,0.775}},{{20,14.615,0.777}}}, {{{20,14.615,0.777}},{{21,15.394,0.779}}}, {{{21,15.394,0.779}},{{22,16.175,0.781},{23,16.958,0.783}}}, {{{22,16.175,0.781},{23,16.958,0.783}},{{24,17.741,0.783}}}, {{{24,17.741,0.783}},{{25,18.526,0.785}}}, {{{25,18.526,0.785}},{{26,19.311,0.785}}}, {{{26,19.311,0.785}},{{27,20.096,0.785},{28,20.881,0.785}}}, {{{27,20.096,0.785},{28,20.881,0.785}},{{29,21.667,0.786}}}, {{{29,21.667,0.786}},{{30,22.451,0.784}}}, {{{30,22.451,0.784}},{{31,23.236,0.785}}}, {{{31,23.236,0.785}},{{32,24.019,0.783},{33,24.801,0.782}}}, {{{32,24.019,0.783},{33,24.801,0.782}},{{34,25.583,0.782}}}, {{{34,25.583,0.782}},{{35,26.362,0.779}}}, {{{35,26.362,0.779}},{{36,27.141,0.779},{37,27.917,0.776}}}, {{{36,27.141,0.779},{37,27.917,0.776}},{{38,28.691,0.774}}}, {{{38,28.691,0.774}},{{39,29.464,0.773}}}, {{{39,29.464,0.773}},{{40,30.234,0.77}}}, {{{40,30.234,0.77}},{{41,31.001,0.767},{42,31.767,0.766}}}, {{{41,31.001,0.767},{42,31.767,0.766}},{{43,32.529,0.762}}}, {{{43,32.529,0.762}},{{44,33.288,0.759}}}, {{{44,33.288,0.759}},{{45,34.045,0.757},{46,34.798,0.753}}}, {{{45,34.045,0.757},{46,34.798,0.753}},{{47,35.548,0.75}}}, {{{47,35.548,0.75}},{{48,36.294,0.746}}}, {{{48,36.294,0.746}},{{49,37.037,0.743},{50,37.776,0.739}}}, {{{49,37.037,0.743},{50,37.776,0.739}},{{51,38.512,0.736}}}, {{{51,38.512,0.736}},{{52,39.243,0.731},{53,39.97,0.727}}}, {{{52,39.243,0.731},{53,39.97,0.727}},{{54,40.694,0.724}}}, {{{54,40.694,0.724}},{{55,41.413,0.719}}}, {{{55,41.413,0.719}},{{56,42.127,0.714},{57,42.838,0.711}}}, {{{56,42.127,0.714},{57,42.838,0.711}},{{58,43.543,0.705}}}, {{{58,43.543,0.705}},{{59,44.244,0.701},{60,44.94,0.696}}}, {{{59,44.244,0.701},{60,44.94,0.696}},{{61,45.632,0.692}}}, {{{61,45.632,0.692}},{{62,46.318,0.686},{63,46.999,0.681}}}, {{{62,46.318,0.686},{63,46.999,0.681}},{{64,47.676,0.677}}}, {{{64,47.676,0.677}},{{65,48.347,0.671}}}, {{{65,48.347,0.671}},{{66,49.012,0.665},{67,49.672,0.66}}}, {{{66,49.012,0.665},{67,49.672,0.66}},{{68,50.327,0.655},{69,50.976,0.649}}}, {{{68,50.327,0.655},{69,50.976,0.649}},{{70,51.62,0.644}}}, {{{70,51.62,0.644}},{{71,52.258,0.638},{72,52.89,0.632}}}, {{{71,52.258,0.638},{72,52.89,0.632}},{{73,53.516,0.626}}}, {{{73,53.516,0.626}},{{74,54.136,0.62},{75,54.75,0.614}}}, {{{74,54.136,0.62},{75,54.75,0.614}},{{76,55.358,0.608},{77,55.96,0.602}}}, {{{76,55.358,0.608},{77,55.96,0.602}},{{78,56.556,0.596}}}, {{{78,56.556,0.596}},{{79,57.145,0.589},{80,57.729,0.584}}}, {{{79,57.145,0.589},{80,57.729,0.584}},{{81,58.305,0.576},{82,58.875,0.57}}}, {{{81,58.305,0.576},{82,58.875,0.57}},{{83,59.439,0.564},{84,59.996,0.557}}}, {{{83,59.439,0.564},{84,59.996,0.557}},{{85,60.546,0.55}}}, {{{85,60.546,0.55}},{{86,61.09,0.544},{87,61.626,0.536}}}, {{{86,61.09,0.544},{87,61.626,0.536}},{{88,62.156,0.53},{89,62.679,0.523}}}, {{{88,62.156,0.53},{89,62.679,0.523}},{{90,63.195,0.516}}}, {{{90,63.195,0.516}},{}}};

Value is incorrect like as " {{{0,0.0f,0.0f}},"

In this time, it refers below csv file.

角度 | ストローク[mm] | 偏差[mm] | 積算偏差[mm] | 偏差[pulse] | 積算偏差[pulse]
-- | -- | -- | -- | -- | --
0 | 6.0780 | 0 | 0 | 0 | 0
1 | 6.7610 | 0.683 | 0.683 | 1092.8 | 1092.8
2 | 7.4550 | 0.694 | 1.377 | 1110.4 | 2203.2
3 | 8.1570 | 0.702 | 2.079 | 1123.2 | 3326.4
4 | 8.8680 | 0.711 | 2.79 | 1137.6 | 4464
5 | 9.5880 | 0.72 | 3.51 | 1152 | 5616
6 | 10.3140 | 0.726 | 4.236 | 1161.6 | 6777.6
7 | 11.0470 | 0.733 | 4.969 | 1172.8 | 7950.4
8 | 11.7870 | 0.74 | 5.709 | 1184 | 9134.4
9 | 12.5330 | 0.746 | 6.455 | 1193.6 | 10328
10 | 13.2840 | 0.751 | 7.206 | 1201.6 | 11529.6
11 | 14.0390 | 0.755 | 7.961 | 1208 | 12737.6
12 | 14.7990 | 0.76 | 8.721 | 1216 | 13953.6
13 | 15.5640 | 0.765 | 9.486 | 1224 | 15177.6
14 | 16.3310 | 0.767 | 10.253 | 1227.2 | 16404.8
15 | 17.1020 | 0.771 | 11.024 | 1233.6 | 17638.4
16 | 17.8760 | 0.774 | 11.798 | 1238.4 | 18876.8
17 | 18.6530 | 0.777 | 12.575 | 1243.2 | 20120
18 | 19.4310 | 0.778 | 13.353 | 1244.8 | 21364.8
19 | 20.2110 | 0.78 | 14.133 | 1248 | 22612.8
20 | 20.9930 | 0.782 | 14.915 | 1251.2 | 23864
21 | 21.7760 | 0.783 | 15.698 | 1252.8 | 25116.8
22 | 22.5600 | 0.784 | 16.482 | 1254.4 | 26371.2
23 | 23.3450 | 0.785 | 17.267 | 1256 | 27627.2
24 | 24.1300 | 0.785 | 18.052 | 1256 | 28883.2
25 | 24.9160 | 0.786 | 18.838 | 1257.6 | 30140.8
26 | 25.7010 | 0.785 | 19.623 | 1256 | 31396.8
27 | 26.4860 | 0.785 | 20.408 | 1256 | 32652.8
28 | 27.2710 | 0.785 | 21.193 | 1256 | 33908.8
29 | 28.0540 | 0.783 | 21.976 | 1252.8 | 35161.6
30 | 28.8370 | 0.783 | 22.759 | 1252.8 | 36414.4
31 | 29.6190 | 0.782 | 23.541 | 1251.2 | 37665.6
32 | 30.3990 | 0.78 | 24.321 | 1248 | 38913.6
33 | 31.1780 | 0.779 | 25.1 | 1246.4 | 40160
34 | 31.9550 | 0.777 | 25.877 | 1243.2 | 41403.2
35 | 32.7300 | 0.775 | 26.652 | 1240 | 42643.2
36 | 33.5040 | 0.774 | 27.426 | 1238.4 | 43881.6
37 | 34.2740 | 0.77 | 28.196 | 1232 | 45113.6
38 | 35.0430 | 0.769 | 28.965 | 1230.4 | 46344
39 | 35.8090 | 0.766 | 29.731 | 1225.6 | 47569.6
40 | 36.5720 | 0.763 | 30.494 | 1220.8 | 48790.4
41 | 37.3330 | 0.761 | 31.255 | 1217.6 | 50008
42 | 38.0900 | 0.757 | 32.012 | 1211.2 | 51219.2
43 | 38.8450 | 0.755 | 32.767 | 1208 | 52427.2
44 | 39.5960 | 0.751 | 33.518 | 1201.6 | 53628.8
45 | 40.3440 | 0.748 | 34.266 | 1196.8 | 54825.6
46 | 41.0880 | 0.744 | 35.01 | 1190.4 | 56016
47 | 41.8290 | 0.741 | 35.751 | 1185.6 | 57201.6
48 | 42.5660 | 0.737 | 36.488 | 1179.2 | 58380.8
49 | 43.2990 | 0.733 | 37.221 | 1172.8 | 59553.6
50 | 44.0280 | 0.729 | 37.95 | 1166.4 | 60720
51 | 44.7530 | 0.725 | 38.675 | 1160 | 61880
52 | 45.4740 | 0.721 | 39.396 | 1153.6 | 63033.6
53 | 46.1910 | 0.717 | 40.113 | 1147.2 | 64180.8
54 | 46.9030 | 0.712 | 40.825 | 1139.2 | 65320
55 | 47.6110 | 0.708 | 41.533 | 1132.8 | 66452.8
56 | 48.3140 | 0.703 | 42.236 | 1124.8 | 67577.6
57 | 49.0120 | 0.698 | 42.934 | 1116.8 | 68694.4
58 | 49.7050 | 0.693 | 43.627 | 1108.8 | 69803.2
59 | 50.3940 | 0.689 | 44.316 | 1102.4 | 70905.6
60 | 51.0780 | 0.684 | 45 | 1094.4 | 72000
61 | 51.7560 | 0.678 | 45.678 | 1084.8 | 73084.8
62 | 52.4300 | 0.674 | 46.352 | 1078.4 | 74163.2
63 | 53.0980 | 0.668 | 47.02 | 1068.8 | 75232
64 | 53.7600 | 0.662 | 47.682 | 1059.2 | 76291.2
65 | 54.4180 | 0.658 | 48.34 | 1052.8 | 77344
66 | 55.0700 | 0.652 | 48.992 | 1043.2 | 78387.2
67 | 55.7160 | 0.646 | 49.638 | 1033.6 | 79420.8
68 | 56.3570 | 0.641 | 50.279 | 1025.6 | 80446.4
69 | 56.9910 | 0.634 | 50.913 | 1014.4 | 81460.8
70 | 57.6210 | 0.63 | 51.543 | 1008 | 82468.8
71 | 58.2440 | 0.623 | 52.166 | 996.8 | 83465.6
72 | 58.8610 | 0.617 | 52.783 | 987.2 | 84452.8
73 | 59.4720 | 0.611 | 53.394 | 977.6 | 85430.4
74 | 60.0770 | 0.605 | 53.999 | 968 | 86398.4
75 | 60.6760 | 0.599 | 54.598 | 958.4 | 87356.8
76 | 61.2690 | 0.593 | 55.191 | 948.8 | 88305.6
77 | 61.8550 | 0.586 | 55.777 | 937.6 | 89243.2
78 | 62.4350 | 0.58 | 56.357 | 928 | 90171.2
79 | 63.0090 | 0.574 | 56.931 | 918.4 | 91089.6
80 | 63.5760 | 0.567 | 57.498 | 907.2 | 91996.8
81 | 64.1370 | 0.561 | 58.059 | 897.6 | 92894.4
82 | 64.6900 | 0.553 | 58.612 | 884.8 | 93779.2
83 | 65.2380 | 0.548 | 59.16 | 876.8 | 94656
84 | 65.7780 | 0.54 | 59.7 | 864 | 95520
85 | 66.3120 | 0.534 | 60.234 | 854.4 | 96374.4
86 | 66.8390 | 0.527 | 60.761 | 843.2 | 97217.6
87 | 67.3590 | 0.52 | 61.281 | 832 | 98049.6
88 | 67.8720 | 0.513 | 61.794 | 820.8 | 98870.4
89 | 68.3780 | 0.506 | 62.3 | 809.6 | 99680
90 | 68.8770 | 0.499 | 62.799 | 798.4 | 100478.4

To fix this problem, we should modify aero\description/scripts/make_stroke_to_angle_header.sh.

    # negative stroke value case
    if [[ ${#ntable[@]} -gt 0 ]]
    then
        idx=$((${#ntable[@]} - 1))
        e=${ntable[$idx]}
        if [[ $e != "" ]]
        then
            code="${code}{{${e::-1}},{}}, "
            array_offset="-$idx"
        elif [[ ${#ntable[@]} -gt 1 ]]
        then
            idx=$(($idx - 1))
            array_offset="-$idx"
        fi
    fi
    for (( idx=${#ntable[@]}-2 ; idx>=0 ; idx-- ))
    do
        e=${ntable[$idx]}
	if [[ $e != "" ]]
	then
            code="${code}{{${e::-1}},"
	    j=1
	    if [[ ${ntable[$(($idx + $j))]} == "" ]]
	    then
		j=2
	    fi
	    appendix=$(echo -e "${ntable[$(($idx + $j))]}")
            if [[ "$appendix" = "" ]]
            then
                code="${code}{}}, "
            else
		code="${code}{${appendix::-1}}}, "
            fi
        elif [[ $idx != 0 ]]
        then
            echo "   detected empty table in -${idx} of ${function_name}"
            code="${code}{{{0,0.0f,0.0f}}, {}}, "
	fi
done
@hi-kondo hi-kondo added the bug label Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant