Skip to content

Commit 8d2b43f

Browse files
committed
a test case is added
1 parent 5ab8a7b commit 8d2b43f

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

PathTracking/model_predictive_speed_and_steer_control/model_predictive_speed_and_steer_control.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,17 @@ def get_straight_course2(dl):
510510
return cx, cy, cyaw, ck
511511

512512

513+
def get_straight_course3(dl):
514+
ax = [0.0, -10.0, -20.0, -40.0, -50.0, -60.0, -70.0]
515+
ay = [0.0, -1.0, 1.0, 0.0, -1.0, 1.0, 0.0]
516+
cx, cy, cyaw, ck, s = cubic_spline_planner.calc_spline_course(
517+
ax, ay, ds=dl)
518+
519+
cyaw = [i - math.pi for i in cyaw]
520+
521+
return cx, cy, cyaw, ck
522+
523+
513524
def get_forward_course(dl):
514525
ax = [0.0, 60.0, 125.0, 50.0, 75.0, 30.0, -10.0]
515526
ay = [0.0, 0.0, 50.0, 65.0, 30.0, 50.0, -20.0]
@@ -543,8 +554,9 @@ def main():
543554
dl = 1.0 # course tick
544555
# cx, cy, cyaw, ck = get_straight_course(dl)
545556
# cx, cy, cyaw, ck = get_straight_course2(dl)
557+
cx, cy, cyaw, ck = get_straight_course3(dl)
546558
# cx, cy, cyaw, ck = get_forward_course(dl)
547-
cx, cy, cyaw, ck = get_switch_back_course(dl)
559+
# CX, cy, cyaw, ck = get_switch_back_course(dl)
548560

549561
sp = calc_speed_profile(cx, cy, cyaw, TARGET_SPEED)
550562

@@ -577,11 +589,11 @@ def main2():
577589
print(__file__ + " start!!")
578590

579591
dl = 1.0 # course tick
580-
cx, cy, cyaw, ck = get_straight_course2(dl)
592+
cx, cy, cyaw, ck = get_straight_course3(dl)
581593

582594
sp = calc_speed_profile(cx, cy, cyaw, TARGET_SPEED)
583595

584-
initial_state = State(x=cx[0], y=cy[0], yaw=math.pi, v=0.0)
596+
initial_state = State(x=cx[0], y=cy[0], yaw=0.0, v=0.0)
585597

586598
t, x, y, yaw, v, d, a = do_simulation(
587599
cx, cy, cyaw, ck, sp, dl, initial_state)
@@ -607,5 +619,5 @@ def main2():
607619

608620

609621
if __name__ == '__main__':
610-
main()
611-
# main2()
622+
# main()
623+
main2()

PathTracking/model_predictive_speed_and_steer_control/notebook.ipynb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,33 @@
3232
"$$ \\dot{v} = a$$\n",
3333
"$$ \\dot{\\phi} = \\frac{vtan(\\delta)}{L}$$\n",
3434
"\n",
35+
"\n",
36+
"\n"
37+
]
38+
},
39+
{
40+
"cell_type": "markdown",
41+
"metadata": {},
42+
"source": [
3543
"ODE is\n",
3644
"\n",
37-
"$$ \\dot{z} = Az+Bu$$\n",
45+
"$$ \\dot{z} = A'z+B'u$$\n",
3846
"\n",
39-
"and A, B are\n",
47+
"\\begin{equation*}\n",
48+
"A' = \n",
49+
"\\begin{bmatrix}\n",
50+
"0 & 0 & cos(\\bar{\\phi}) & -\\bar{v}sin(\\bar{\\phi})\\\\\n",
51+
"0 & 1 & sin(\\bar{\\phi}) & \\bar{v}cos(\\bar{\\phi}) \\\\\n",
52+
"0 & 0 & 0 & 0 \\\\\n",
53+
"0 & 0 &\\frac{tan(\\bar{\\delta})}{L} & 0 \\\\\n",
54+
"\\end{bmatrix}\n",
55+
"\\end{equation*}\n",
4056
"\n",
4157
"\n",
4258
"\n",
4359
"You can get a discrete-time mode with Forward Euler Discretization with sampling time dt.\n",
4460
"\n",
45-
"$$z_{k+1}=z_k+f(z_k,u_k)dt$$\n",
46-
"\n"
61+
"$$z_{k+1}=z_k+f(z_k,u_k)dt$$"
4762
]
4863
},
4964
{

0 commit comments

Comments
 (0)