JaciBrunning / Pathfinder

Cross-Platform, Multi-Use Motion Profiling and Trajectory Generation
MIT License
255 stars 78 forks source link

TankModifier causes massive acceleration, velocity and jerk #2

Closed lopsided98 closed 8 years ago

lopsided98 commented 8 years ago

When a valid trajectory is modified using a TankModifier, it creates invalid left and right trajectories. The velocity, acceleration and jerk are much higher than the limits specified in the config.

The velocity reaches a max value, and then never decreases. The max velocity in influenced by the period and the wheelbase width. A smaller period causes a larger max velocity. The max velocity is also proportional to the wheelbase width.

Looking more closely at the velocities, I noticed that they do increase and decrease. Once the velocity reaches its large value by the second point, it increases very slightly and then decreases by the end of the trajectory.

Here is an example of the velocities of the left side of a trajectory that drives straight forward, with period = 0.01 s and wheelbase width = 0.5 m.

0.002485673490909272
25.0
25.0
25.0
25.00000001829044
25.000012357142353
25.000017794283053
25.000024219993264
25.00003163427223
25.00004003711906
25.000049428532765
25.000059808512226
25.00007117705622
25.00008353416339
25.000096879832274
25.00011121406129
25.000126536848732
25.00014284819279
25.00016014809152
25.00017843654288
25.000197713544697
25.00021797909468
25.000239233190424
25.000261475829415
25.000284707009012
25.000308926726454
25.000334134978875
25.000360331763282
25.000387517076565
25.000415690915506
25.000444853276758
25.000475004156858
25.000506143552236
25.00053827145919
25.000571387873933
25.000605492792506
25.000640586210874
25.000676668124882
25.000713738530244
25.000751797422566
25.000790844797326
25.0008308806499
25.000871904975536
25.000913917769374
25.00095691902642
25.001000908741588
25.001045886909644
25.001091853525264
25.00113880858299
25.001186752077263
25.00123568400238
25.001285604352553
25.001336513121856
25.001388410304248
25.00144129589357
25.001495169883565
25.001550032267833
25.00160588303986
25.00166272219304
25.001720549720616
25.00177936561574
25.00183916987143
25.0018999624806
25.00196174343604
25.00202451273042
25.002088270356285
25.0021530163061
25.002218750572162
25.002285473146696
25.002353184021775
25.002421883189374
25.002491570641343
25.00256224636943
25.00263391036524
25.002706562620286
25.002780203125944
25.00285483187349
25.00293044885407
25.003007054058717
25.003084647478357
25.00316322910378
25.00324279892567
25.00332335693459
25.003404903120995
25.00348743747522
25.003570959987464
25.00365547064784
25.00374096944632
25.00382745637277
25.003914931416936
25.004003394568446
25.004092845816817
25.004183285151438
25.004274712561593
25.004367128036442
25.004460531565027
25.004554923136272
25.004650302739
25.004746670361893
25.00484402599353
25.004909731632452
25.004893832049202
25.004812466213494
25.00471542976706
25.004619381333075
25.004524320922933
25.004430248547887
25.00433716421909
25.004245067947593
25.0041539597443
25.004063839620017
25.003974707585424
25.00388656365109
25.003799407827465
25.00371324012488
25.00362806055355
25.003543869123583
25.003460665844944
25.00337845072752
25.00329722378104
25.003216985015136
25.003137734439335
25.003059472063015
25.002982197895474
25.002905911945867
25.00283061422323
25.002756304736504
25.002682983494502
25.002610650505908
25.0025393057793
25.00246894932315
25.002399581145788
25.002331201255444
25.002263809660228
25.002197406368133
25.002131991387028
25.002067564724673
25.00200412638871
25.00194167638666
25.001880214725936
25.001819741413822
25.001760256457484
25.00170175986398
25.001644251640254
25.001587731793112
25.001532200329272
25.001477657255315
25.00142410257771
25.001371536302806
25.00131995843684
25.001269368985927
25.001219767956073
25.001171155353152
25.001123531182934
25.001076895451067
25.00103124816309
25.000986589324402
25.000942918940314
25.000900237015998
25.000858543556518
25.000817838566824
25.000778122051734
25.00073939401597
25.00070165446412
25.000664903400654
25.00062914082995
25.00059436675623
25.000560581183635
25.000527784116155
25.000495975557694
25.000465155512025
25.000435323982796
25.000406480973545
25.000378626487706
25.00035176052857
25.00032588309934
25.000300994203066
25.00027709384271
25.000254182021102
25.000232258740972
25.000211324004905
25.0001913778154
25.00017242017481
25.000154451085393
25.000137470549273
25.00012147856847
25.00010647514488
25.000092460280275
25.000079433976328
25.000067396234588
25.000056347056464
25.00004628644329
25.00003721439624
25.0000291309164
25.000022036004726
25.000015929662066
25.000010811889133
25.000006682686543
25.00000354205478
25.000001389994225
25.000000283777617
25.00000001415657
25.0
lopsided98 commented 8 years ago

I copied the pathfinder_modify_tank() function into my Java code and made minimal modifications so that it was valid Java, and it is working correctly. I did not change any of the math. This seems to indicate that the bug is in the code that interfaces with the Java library.

lopsided98 commented 8 years ago

I forgot to mention, I am using v1.3, and it did not fix the problem.

androb4 commented 8 years ago

Did not work for me neither

JaciBrunning commented 8 years ago

@lopsided98 Can you send me your code as modified in Java?

JaciBrunning commented 8 years ago

Nevermind, found a fix.

JaciBrunning commented 8 years ago

Grab release v1.4