YouTube2Text

Princeton Intro to Robotics (Fall 2026) | Lecture 6: Trajectory Optimization — Transcript

by Introduction to Robotics @ Princeton · 10,277 words · 1,792 segments · language en · Watch on YouTube

Full transcript

  1. 0:10All right, I think we'll go ahead and
  2. 0:11get started. So, we're going to continue
  3. 0:13our discussion of motion planning and
  4. 0:15control,
  5. 0:16which is still the the first kind of
  6. 0:18technical module that we're covering in
  7. 0:19this course.
  8. 0:21So, in the last lecture we started
  9. 0:22talking about how to do motion planning
  10. 0:25while taking into account some dynamics
  11. 0:27of the drone.
  12. 0:28The idea was that not all continuous
  13. 0:30paths in configuration space are
  14. 0:33physically executable by the robot.
  15. 0:35You need some way of handling the
  16. 0:38dynamics, taking into account the
  17. 0:40dynamics that your particular system
  18. 0:42has.
  19. 0:43So, two lectures ago we talked a bit
  20. 0:44about how we can describe dynamics using
  21. 0:47equations of motion. These are
  22. 0:49differential equations that come from
  23. 0:50Newton's laws that describe the dynamics
  24. 0:52of your system.
  25. 0:53And then in the last lecture we started
  26. 0:55thinking about a particular class of
  27. 0:57mechanical systems
  28. 0:59known as differentially flat systems.
  29. 1:01Where the main idea is that differential
  30. 1:04flatness gives you the ability to
  31. 1:06control
  32. 1:07flat outputs. So, flat outputs are some
  33. 1:09function of the state and potentially
  34. 1:11control inputs.
  35. 1:13And if I
  36. 1:15kind of
  37. 1:16specify some trajectory in flat output
  38. 1:18space for my system to follow,
  39. 1:20then I can find control inputs that are
  40. 1:23going to make the the system actually
  41. 1:25follow any arbitrary trajectory that I
  42. 1:28specify.
  43. 1:29And moreover, we can also recover the
  44. 1:31full state of the the system at every
  45. 1:34point in time. There were some caveats
  46. 1:36here, some assumptions on the smoothness
  47. 1:38of the trajectory.
  48. 1:39So, for the
  49. 1:41planar quadrotor, the flat outputs
  50. 1:43correspond to the center of mass
  51. 1:44location, so X and Y.
  52. 1:46And differential flatness for the planar
  53. 1:48quadrotor says that if I specify some
  54. 1:51smooth trajectory for the center of mass
  55. 1:53location of the drone, then I can
  56. 1:55compute control inputs Uh, will make the
  57. 1:59the center of mass follow the trajectory
  58. 2:01I specified, and I can recover
  59. 2:03everything else. So, the orientation,
  60. 2:06um, the velocities and the orientation
  61. 2:08rates as well.
  62. 2:09And then we looked at a couple of, uh,
  63. 2:11examples of of differential flatness.
  64. 2:13Uh, I mentioned that, uh, not every
  65. 2:15system is known to be differentially
  66. 2:17flat, but it's a pretty broad and kind
  67. 2:19of powerful, uh, set of, uh, systems uh,
  68. 2:22that we know, uh, we as in kind of the
  69. 2:24community as a whole, uh, knows is
  70. 2:26differentially flat. And I showed this
  71. 2:28one example in particular, which is a a
  72. 2:30fixed-wing airplane, uh, which can take
  73. 2:33off and land vertically and transition
  74. 2:35to forward flight.
  75. 2:36And this system is is known to be
  76. 2:38differentially flat. The 3D quadrotor is
  77. 2:40flat. There's a couple of examples that
  78. 2:42you'll see in the assignment uh, that
  79. 2:44goes out tomorrow as well.
  80. 2:46Uh, okay, but I guess there are a couple
  81. 2:48of, uh, issues here with with
  82. 2:49differential flatness.
  83. 2:51So, the first one is what if we want to
  84. 2:53control states that are not in my flat
  85. 2:56outputs? So, for the planar quadrotor,
  86. 2:59suppose I really want to control the
  87. 3:01orientation, like maybe my drone has to
  88. 3:03go through some small slit,
  89. 3:06uh, in which case the orientation as
  90. 3:08it's going through that slit, like
  91. 3:09through the those obstacles, has to be
  92. 3:11some kind of particular value or
  93. 3:13particular range of values, then
  94. 3:16differential flatness is not sufficient,
  95. 3:18uh, because flatness doesn't give me the
  96. 3:20authority to control the orientation of
  97. 3:23the planar quadrotor.
  98. 3:24So, that's that's one limitation with,
  99. 3:26uh, with flatness.
  100. 3:28Uh, the other limitation, uh, is we
  101. 3:30might just not know if our system is
  102. 3:33differentially flat.
  103. 3:34Uh, if you build a new robot,
  104. 3:37um, yeah, you might not know if it is
  105. 3:39flat and it might not be differentially
  106. 3:41flat. Like there are examples where,
  107. 3:43um,
  108. 3:44at least for kind of non-trivial
  109. 3:45definitions of flatness, uh, your
  110. 3:47robotic system is is not differentially
  111. 3:49flat. Question.
  112. 3:58Yes. So, for the planar quadrotor, the
  113. 4:00flat outputs are X and Y.
  114. 4:02So, the theta, like the orientation, is
  115. 4:05something that's that's not captured by
  116. 4:07by the flat outputs.
  117. 4:08So, flatness is just saying that you can
  118. 4:11arbitrarily control the flat outputs,
  119. 4:14right? So, if I want to control the the
  120. 4:17orientation of the drone,
  121. 4:19like if I want to specify some
  122. 4:20constraints on the orientation, then
  123. 4:23that's not something that differential
  124. 4:25flatness is giving me. For the 3D
  125. 4:27quadrotor, I had mentioned that the flat
  126. 4:29outputs are X, Y, Z, and yaw. So, if I
  127. 4:32want to control roll and pitch at some
  128. 4:34particular location, let's say in the
  129. 4:36environment, differential flatness does
  130. 4:38not give me that authority.
  131. 4:46Right, exactly. So, if you want to use
  132. 4:49differential flatness
  133. 4:50to do obstacle avoidance,
  134. 4:53because you can only control X, Y in the
  135. 4:55planar case or X, Y, Z and yaw in the
  136. 4:59in the 3D case, you basically have to
  137. 5:02approximate your system as a as a
  138. 5:04sphere, because the other angles, like
  139. 5:06the roll and pitch angles, could be just
  140. 5:08doing completely arbitrary things. You
  141. 5:09have no
  142. 5:10control over them, at least from
  143. 5:13differential flatness.
  144. 5:15Okay, yeah. Any other questions on the
  145. 5:17setup?
  146. 5:19Okay, so the the goal today is to
  147. 5:22think of a a more general set of
  148. 5:24techniques for handling dynamics
  149. 5:27when we're doing motion planning.
  150. 5:29So, one idea is is maybe we can somehow
  151. 5:32modify the RRT algorithm, which we
  152. 5:35discussed a couple of lectures ago, to
  153. 5:37take into account the dynamics of our
  154. 5:39robot.
  155. 5:40So, I'll I'll present a couple of ideas
  156. 5:42for doing this. So, starting with the
  157. 5:44RRT algorithm, which doesn't take into
  158. 5:46account dynamics, and then modifying it
  159. 5:48to account for for dynamics.
  160. 5:50So, here's one idea. So, let's say we've
  161. 5:53modeled our robotic system, and these
  162. 5:56are the the differential equations that
  163. 5:58describe the dynamics. So, X dot equals
  164. 6:00f of X, U.
  165. 6:02One idea is to construct the RRT in
  166. 6:05state space
  167. 6:07instead of configuration space.
  168. 6:09So maybe this is how how it could work.
  169. 6:11So we start by initializing the tree the
  170. 6:15RRT
  171. 6:16with just one vertex. Let's say this is
  172. 6:18the the starting state. So the state
  173. 6:21here is now the full state of the system
  174. 6:23not just the configurations.
  175. 6:26So we we start our our tree with this as
  176. 6:29the only vertex in the tree.
  177. 6:31And then we iterate. So in each
  178. 6:32iteration we sample some random state X
  179. 6:36rand
  180. 6:37from the existing tree. So this is
  181. 6:39slightly different from the RRT
  182. 6:41algorithm we originally described. In
  183. 6:43the original version we were
  184. 6:45randomly sampling some configuration
  185. 6:48not from the tree but just from the
  186. 6:49space of all configurations. Here I'm
  187. 6:51saying let's sample from the the
  188. 6:53existing tree. Is there a question?
  189. 6:56Okay.
  190. 6:57Okay. So in the next next step let's say
  191. 7:00we randomly sample some control input as
  192. 7:03well. Just some random control input for
  193. 7:05the let's say for the drone.
  194. 7:08And then you do this extension. So from
  195. 7:10the random state that you sample from
  196. 7:13your existing tree
  197. 7:15you apply this random control input for
  198. 7:18some short time duration. So zero to to
  199. 7:22delta T.
  200. 7:23And then you integrate your system. So
  201. 7:25you we're assuming that we know what the
  202. 7:27dynamics are. So you can predict the
  203. 7:29trajectory of the system if you start
  204. 7:32from state X rand. You apply control
  205. 7:35input U rand for some short duration of
  206. 7:37time.
  207. 7:38Given the equations of motion you can
  208. 7:39predict exactly where you're going to
  209. 7:42end up at the end of delta T.
  210. 7:45So yeah, I guess what's what's happening
  211. 7:46here is we're just integrating the the
  212. 7:48equations of motion.
  213. 7:50So X rand plus the integral of the
  214. 7:53dynamics DT.
  215. 7:56And then we can kind of proceed as usual
  216. 7:58with the RRT algorithm. So this is our
  217. 8:00extended state. We can check whether
  218. 8:03this state XS is in collision with any
  219. 8:06obstacles or not. Uh if it's not in
  220. 8:09collision with with any obstacles, we
  221. 8:11add it to the tree. If it is in
  222. 8:13collision, then we throw it away and we
  223. 8:15iterate.
  224. 8:16So, all right. So, I guess this is one
  225. 8:18kind of attempt at taking into account
  226. 8:20the the dynamics of your system uh when
  227. 8:23you're building the the RRT. Uh the
  228. 8:26high-level idea is instead of building
  229. 8:27the tree in configuration space,
  230. 8:29uh build it in state space and then kind
  231. 8:31of modify things accordingly.
  232. 8:34All right. I guess any intuitions on on
  233. 8:36um
  234. 8:37whether this is a good algorithm? Like,
  235. 8:40what do you think is going to happen
  236. 8:42if we try this out? Like, will it will
  237. 8:43it work well? Is this something that we
  238. 8:44might actually want to use in practice
  239. 8:47to do planning
  240. 8:48while taking into account dynamics?
  241. 8:52Yep.
  242. 8:53>> I guess it doesn't make sense to work
  243. 8:55out.
  244. 8:55>> Good. Yeah. So, that that's exactly
  245. 8:57right. I guess you have some intuition
  246. 8:58for for why?
  247. 9:00>> Uh random point
  248. 9:01in the existing tree.
  249. 9:03>> Yep.
  250. 9:04Perfect. Yeah. So, that that's exactly
  251. 9:06the right intuition.
  252. 9:07So, theoretically, you can actually show
  253. 9:09that this algorithm is probabilistically
  254. 9:11complete. So, if you allow the number of
  255. 9:15iterations to go to infinity, if there
  256. 9:17is some way to get from start to to goal
  257. 9:19or at least close to goal, uh then this
  258. 9:22algorithm will
  259. 9:23uh the probability that the algorithm
  260. 9:25finds the trajectory is going to
  261. 9:26approach one as the number of iterations
  262. 9:28goes to infinity.
  263. 9:30Uh unfortunately, in practice, this is a
  264. 9:31completely useless algorithm. You
  265. 9:33basically just end up with this kind of
  266. 9:35muddled uh mess. Like as you suggested,
  267. 9:37you you you don't get any exploration.
  268. 9:39You're always sampling points from the
  269. 9:41existing tree. Uh if I have this kind of
  270. 9:44jumble of points to begin with, uh if I
  271. 9:46sample within this jumble, I'm just
  272. 9:48going to get something in the jumble and
  273. 9:50then I'll extend and I'll just get more
  274. 9:51jumble. Like, there's no way to to
  275. 9:53really explore the the state space uh
  276. 9:56using the the algorithm uh that I
  277. 9:57described.
  278. 9:59Um so, here's another idea, slightly uh
  279. 10:03maybe so more sophisticated idea uh to
  280. 10:06to take into account dynamics as we're
  281. 10:07building the RRT.
  282. 10:09Again, we're going to keep the the
  283. 10:11general structure of the RRT algorithm
  284. 10:13the same as what we originally
  285. 10:15introduced.
  286. 10:16Um but just change the the way the
  287. 10:19extension of the tree is happening. So,
  288. 10:21in the original RRT algorithm, uh we
  289. 10:23have some existing tree.
  290. 10:25We sample some random configuration. We
  291. 10:28find the closest point in the existing
  292. 10:30tree to that newly sampled point. Uh and
  293. 10:32then we extend with just a line segment.
  294. 10:35Uh and the problem there was that we're
  295. 10:36not taking into account the dynamics in
  296. 10:39that extension operation. Like it's just
  297. 10:41a line segment. Uh there's no accounting
  298. 10:43for the specific motions that are
  299. 10:45actually physically feasible for your
  300. 10:47robot.
  301. 10:49Uh so, what we're going to do instead is
  302. 10:50solve what's known as a a boundary value
  303. 10:53problem
  304. 10:54uh for connecting the nearest point on
  305. 10:56the tree
  306. 10:57uh
  307. 10:59to extend it uh to this new point XS.
  308. 11:02Um so, yeah. I guess here's a a sketch
  309. 11:04of what uh what this looks like. So,
  310. 11:06let's say we built our tree up to some
  311. 11:09uh number of iterations.
  312. 11:10We randomly sample some state, which I'm
  313. 11:12calling X rand over here.
  314. 11:15We find the nearest
  315. 11:17uh state in the existing tree, which is
  316. 11:20X near.
  317. 11:21XS is the the extension going from X
  318. 11:24near to X rand.
  319. 11:25So, in the original RRT algorithm, we
  320. 11:27would just connect X near and X XS uh
  321. 11:30with a line segment. Uh but here we want
  322. 11:33to actually account for the the dynamics
  323. 11:35of the system. Like we want to find some
  324. 11:37control inputs that will make the the
  325. 11:39system go from X near uh to XS.
  326. 11:44Okay.
  327. 11:45So, all right. I guess maybe questions
  328. 11:48on on that general approach. So, the the
  329. 11:50basic structure of the RRT algorithm is
  330. 11:52identical to the original version that
  331. 11:54we introduced. Uh the only change is
  332. 11:57instead of of a line segment connecting
  333. 12:00XS to X near,
  334. 12:02uh we're going to to find control inputs
  335. 12:05that uh such that when your system
  336. 12:08executes control inputs, uh your robot
  337. 12:11actually goes from X near to X S. Yeah,
  338. 12:13I guess questions on on that
  339. 12:15modification uh, compared to the the
  340. 12:17original RT algorithm.
  341. 12:22Okay.
  342. 12:23So,
  343. 12:25I guess that the hard part here, uh, is
  344. 12:27the boundary value problem. So, I
  345. 12:28haven't told you actually how to do
  346. 12:30this. Like I've just said we want to
  347. 12:31find some way of of uh, computing
  348. 12:33control inputs that go from X near to to
  349. 12:35X S. Uh, the question now becomes how do
  350. 12:37we uh, how do we find these control
  351. 12:40inputs?
  352. 12:42This problem is also known as trajectory
  353. 12:44optimization uh, in in this literature
  354. 12:47on motion planning with with dynamics
  355. 12:48constraints.
  356. 12:50Uh, and you can tackle this problem,
  357. 12:52this boundary value problem or
  358. 12:53trajectory optimization problem uh,
  359. 12:55using techniques from non-linear uh,
  360. 12:57optimization.
  361. 12:59Uh, maybe just a quick show of hands.
  362. 13:01How many people have seen some
  363. 13:03optimization before? Like maybe if
  364. 13:05you've taken uh, off 363 or something
  365. 13:08like that. Okay, I guess a few people.
  366. 13:11Yeah.
  367. 13:11Uh, sounds good. So, I'll give you a uh,
  368. 13:14just a kind of quick uh, overview of a
  369. 13:17specific case in which this optimization
  370. 13:19problem is actually quite
  371. 13:21computationally straightforward uh, to
  372. 13:24tackle. Uh, and then I'll briefly
  373. 13:26describe the the general version.
  374. 13:29Um, so the special version the special
  375. 13:31case is going to be
  376. 13:33uh, trajectory optimization with linear
  377. 13:35dynamics uh, and I'll I'll switch to the
  378. 13:37the blackboard actually for for this
  379. 13:39part.
  380. 13:47So, again just for visualization I'm
  381. 13:49going to draw things in 2D.
  382. 13:54Uh, but really the the tree is being
  383. 13:56built in the state space. So, for the
  384. 13:58planar quadrotor the state space is
  385. 14:00six-dimensional. For the 3D quadrotor
  386. 14:03the state space is is 12-dimensional.
  387. 14:05Let's say we're starting off
  388. 14:08at some start state X A.
  389. 14:13We want to get to some some goal state,
  390. 14:15XB.
  391. 14:17The RT algorithm, you randomly sample
  392. 14:21some
  393. 14:22state, which I'm calling X rand.
  394. 14:26Um you find the nearest point in the
  395. 14:29tree. So, initially, your tree is just
  396. 14:31this, the starting state.
  397. 14:34You connect the
  398. 14:35uh
  399. 14:36the initial state or the closest state
  400. 14:38uh to to the randomly randomly sampled
  401. 14:41state with a line segment.
  402. 14:43Uh and then in the original RT
  403. 14:45algorithm, the one which is in
  404. 14:46configuration space, uh which ignores
  405. 14:48the dynamics of the robot, you just
  406. 14:50extend, right? This is just a line
  407. 14:51segment uh going from the the closest
  408. 14:54point to X rand.
  409. 14:57So, what we're doing instead is trying
  410. 14:59to find some control inputs uh that will
  411. 15:02make the the the system that you have go
  412. 15:05from here to to here.
  413. 15:08Uh and this is XS.
  414. 15:11So, that's the the only change. It might
  415. 15:13be that the line segment is actually
  416. 15:14physically
  417. 15:16feasible, like it's executable by a
  418. 15:17robot, in which case this kind of curve
  419. 15:19will just be the line segment. Uh but
  420. 15:22there might be cases, as we discussed
  421. 15:23previously, where the system cannot
  422. 15:26follow a line segment. So, for the
  423. 15:28drone, if you want to translate
  424. 15:29horizontally, uh there's no way to to do
  425. 15:32that.
  426. 15:33Uh the other example we had was of a
  427. 15:35car.
  428. 15:37So, this is a top view of a
  429. 15:40a car, let's say.
  430. 15:42Um this is forwards.
  431. 15:44This is the initial state, XA.
  432. 15:51And then this is the
  433. 15:53the state that we want to get to. Let's
  434. 15:55call this XS.
  435. 15:59There's no way to to just horizontally
  436. 16:00translate your vehicle, unless it's a
  437. 16:03omnidirectional vehicle.
  438. 16:04So, you need to do something, right? You
  439. 16:05need to maybe go
  440. 16:07forwards this way
  441. 16:10and then back up. That could be one
  442. 16:12option.
  443. 16:13Uh or maybe you you go this way and then
  444. 16:15go forwards. There might be many many
  445. 16:17ways uh of going from here to here, but
  446. 16:20just translating horizontally is not a a
  447. 16:23feasible trajectory given the dynamics
  448. 16:26of the the system.
  449. 16:28Uh so, this this problem is the is the
  450. 16:30one that we want to solve. So, let's say
  451. 16:31we want to go from some state XA
  452. 16:35to some other state.
  453. 16:37Can we find some sequence of control
  454. 16:39inputs that will make the system
  455. 16:41actually do that? All right, so I guess
  456. 16:42that that's the the setup. That's what I
  457. 16:44mean by the boundary value problem or
  458. 16:47trajectory optimization. I just want to
  459. 16:49make sure that idea is clear before
  460. 16:51actually telling you how to solve it.
  461. 16:52Questions on that?
  462. 16:56All right.
  463. 16:56So, I mentioned that there's a a special
  464. 16:58case in which this trajectory
  465. 17:00optimization problem is actually quite
  466. 17:02computationally straightforward
  467. 17:04uh to to try to tackle.
  468. 17:07Uh and that's the case where we have
  469. 17:10linear dynamics.
  470. 17:21So, I'll start off with a a concrete
  471. 17:23example, uh and then I'll I'll tell you
  472. 17:25about the the kind of general case.
  473. 17:28So, for the planar quadrotor,
  474. 17:34we had written down the dynamics, I
  475. 17:36guess a couple of lectures ago now.
  476. 17:38Uh I'll just write down the dynamics
  477. 17:40again. So, X is the state, X dot equals
  478. 17:43the time derivative
  479. 17:47of X, Y, theta.
  480. 17:51Um and then VX,
  481. 17:54VY,
  482. 17:56uh and then omega.
  483. 18:01And by definition, VX, VY, omega, VX is
  484. 18:04X dot.
  485. 18:05Uh VY is Y dot.
  486. 18:07Uh and omega is theta dot.
  487. 18:13Uh and this was equal to
  488. 18:16uh so, X dot, the time derivative of X
  489. 18:18is VX.
  490. 18:20The time derivative of Y is VY.
  491. 18:23The time derivative of theta is omega.
  492. 18:27Uh and then the time derivative of VX
  493. 18:30is the time derivative of X dot, so it's
  494. 18:32X double dot. Uh and that's the part
  495. 18:34that comes from Newton's second law.
  496. 18:36So, this was negative U1
  497. 18:41over M sin theta.
  498. 18:46And then we had U1
  499. 18:48over M cosine theta
  500. 18:52minus G.
  501. 18:55Uh and then the last one was U2 divided
  502. 18:57by I.
  503. 19:03And the control inputs, again just a
  504. 19:05reminder, U1 was defined as F1 plus F2.
  505. 19:11So, the summation of the two thrust
  506. 19:13forces.
  507. 19:19So, F1 is the left one, left thrust. F2
  508. 19:23is the the right one.
  509. 19:25Uh and then U2
  510. 19:28we defined as F2
  511. 19:30minus F1
  512. 19:33multiplied by L, where L is this arm
  513. 19:36length.
  514. 19:39Uh right, so this is just from uh from a
  515. 19:41previous lecture, uh writing down the
  516. 19:43dynamics of the the planar quadrotor.
  517. 19:45Uh again in this first-order form. Uh
  518. 19:47so, these equations have the form X dot
  519. 19:49equals
  520. 19:51F, which is some function of the state
  521. 19:54and our control inputs. So, the it's a
  522. 19:55six-dimensional state over here.
  523. 19:59Okay.
  524. 20:00So, if you look at these dynamics, these
  525. 20:02dynamics are non-linear. Uh there are
  526. 20:05some trigonometric terms.
  527. 20:08Uh actually, let me just write write
  528. 20:09down that general form again. So, X dot
  529. 20:11equals
  530. 20:12some function of X U.
  531. 20:16Uh let's say X is
  532. 20:21So, X is the state.
  533. 20:23uh in this case it's R
  534. 20:26I'll call it N. N is six for the planar
  535. 20:28quadrotor.
  536. 20:30Uh and then
  537. 20:32the control input
  538. 20:34is RM.
  539. 20:36So, M is uh two. So, two control inputs
  540. 20:39for the planar quadrotor. N is six uh
  541. 20:42six-dimensional state space.
  542. 20:45Uh and yeah, I guess when I say uh that
  543. 20:47the dynamics are are nonlinear, uh what
  544. 20:49I mean is that F is a nonlinear function
  545. 20:52of uh the state and or the the control
  546. 20:55input.
  547. 20:57So, what we want to do is is uh
  548. 20:59approximate the dynamics with something
  549. 21:01that's linear.
  550. 21:03Uh and that's going to make this
  551. 21:04trajectory optimization problem uh much
  552. 21:06much uh simpler.
  553. 21:08Uh yeah, I guess thoughts on
  554. 21:10on uh on how do we do this? Um yeah, I
  555. 21:13guess how do we take this
  556. 21:15nonlinear uh function, nonlinear
  557. 21:17dynamics and approximate it with
  558. 21:19something that's linear?
  559. 21:21Go ahead.
  560. 21:23Good. Yeah, so just a a first-order
  561. 21:25Taylor approximation.
  562. 21:27Uh so, we need to find some state and
  563. 21:29control input uh about which we we do
  564. 21:32the the expansion, the Taylor expansion.
  565. 21:34So, some kind of nominal or reference
  566. 21:36state and and control input.
  567. 21:38Um the specific reference state and
  568. 21:41control input you use to linearize, like
  569. 21:43to do the Taylor approximation, uh
  570. 21:45depends on the specific system and and
  571. 21:47and so on.
  572. 21:48Uh just to make things concrete for the
  573. 21:50planar quadrotor,
  574. 21:52I'll define a nominal
  575. 21:56state. By nominal, I mean like some like
  576. 21:58reference state
  577. 22:00um about which we're going to do the the
  578. 22:02Taylor approximation. So, nominal state,
  579. 22:03I'll call it X0.
  580. 22:07Um and yeah, I guess maybe what what
  581. 22:09would be a reasonable
  582. 22:11state to do the Taylor approximation
  583. 22:14about for the for the planar quad?
  584. 22:20Depends on on the specific application,
  585. 22:22but but yeah, maybe um
  586. 22:25if you were to to just kind of for this
  587. 22:28lecture the actual optimization problem,
  588. 22:29let's say
  589. 22:30uh yeah, what might be a reasonable
  590. 22:34state to to do the Taylor approximation
  591. 22:36about?
  592. 22:40That's
  593. 22:43Yep, at the back here.
  594. 22:45Uh yeah, all zeros works.
  595. 22:52So
  596. 22:53uh this is basically saying uh so the
  597. 22:56state again is is this vector XY theta
  598. 22:58VX VY omega.
  599. 23:00Uh
  600. 23:01so these three components being zero
  601. 23:03means we're Taylor approximating about X
  602. 23:05equals zero, Y equals zero, theta equals
  603. 23:06zero. That's the configuration where the
  604. 23:08drone is just at the origin uh and has a
  605. 23:11horizontal orientation.
  606. 23:13Uh and then these are the the time
  607. 23:14derivatives. Uh so basically this is
  608. 23:16saying like the drone is just steady uh
  609. 23:18at at the origin
  610. 23:20uh and and in a horizontal
  611. 23:22configuration.
  612. 23:24Um we can also define some reference
  613. 23:26control input.
  614. 23:34So I'll call this U0.
  615. 23:38And then again maybe we can think about
  616. 23:40this. What might be a reasonable given
  617. 23:42that we've committed to this
  618. 23:44reference state
  619. 23:46uh what might be a reasonable control
  620. 23:48input
  621. 23:49uh
  622. 23:50as um
  623. 23:51yeah, I guess a nominal control input or
  624. 23:53reference control input
  625. 23:54to do the Taylor approximation about?
  626. 23:58Good, yeah. So
  627. 24:00uh
  628. 24:01basically the the control input that
  629. 24:02will cancel gravity, right? Uh
  630. 24:04So if I want to stay at this state, like
  631. 24:07if I'm at the if my drone is at the
  632. 24:08origin, has no velocities, if I want to
  633. 24:11stay at that state, uh all I need to do
  634. 24:13is cancel gravity.
  635. 24:15Um so I can
  636. 24:17um
  637. 24:18just figure out what that control input
  638. 24:19is. So I define U1 and U2 as
  639. 24:22up there. So U1 is the total thrust F1
  640. 24:24plus F2. Uh Uh is the the total moment.
  641. 24:28Uh so U1 just needs to be mg.
  642. 24:33So this is going to to cancel out
  643. 24:35gravity.
  644. 24:36Uh and then U2 I can pick to just be
  645. 24:38zero.
  646. 24:40So no difference between F2 and and F1.
  647. 24:43So we're just applying enough thrust to
  648. 24:45cancel out gravity. There's no moment,
  649. 24:47so the drone is just going to stay
  650. 24:50at the origin uh if it starts off at the
  651. 24:53at the origin. Question?
  652. 24:58Um yes, so my definition for the control
  653. 25:01input vector
  654. 25:03is like up here. So U is really
  655. 25:07uh U1 U2.
  656. 25:12Right. Um
  657. 25:13I guess if the the U vector was F1 F2,
  658. 25:17uh then what you're saying would be
  659. 25:18correct. Uh but just the way I've
  660. 25:20defined it, uh U is U1 U2. U1 is the
  661. 25:23total thrust. Uh U2 is the total moment.
  662. 25:25Yeah.
  663. 25:27Uh there's no fundamental reason to to
  664. 25:29do it uh this way. It just makes the
  665. 25:30equations slightly more compact. Like
  666. 25:33here I would have had to write F2 minus
  667. 25:34F1 times L. Uh so it's just slightly
  668. 25:36slightly more compact notation.
  669. 25:39Uh but yeah, that that's the only only
  670. 25:40reason. So total thrust cancels gravity,
  671. 25:43uh no net torque.
  672. 25:46Okay.
  673. 25:47So one thing to to note, I kind of
  674. 25:49mentioned this intuitively, like this is
  675. 25:51canceling out gravity. So if my drone
  676. 25:54starts off at this state, then it's
  677. 25:56going to remain there.
  678. 25:58Uh and we can we can see that. So
  679. 26:01uh if I calculate
  680. 26:05f of x0 u0,
  681. 26:15um so I just plug in x equals x0 u
  682. 26:18equals the u0 up there.
  683. 26:20Uh we can see so the first three
  684. 26:23components of the state are just going
  685. 26:24to be zero.
  686. 26:27Uh because vx vy omega, uh these are
  687. 26:30zero over here.
  688. 26:33Uh and then if I take theta equal zero
  689. 26:36then sine of theta is zero. So this
  690. 26:38component is going to be zero.
  691. 26:41Uh
  692. 26:42and then cosine of zero is one.
  693. 26:46So I have U1 divided by M minus G. U1
  694. 26:49we're taking to be mg.
  695. 26:51So it's mg
  696. 26:53over M minus G
  697. 26:56uh which is equal to zero.
  698. 26:58Uh and then U2 is equal to to zero.
  699. 27:04Right, so at the nominal
  700. 27:07state, if I apply the nominal control
  701. 27:10input, uh then I'm just going to stay
  702. 27:11there. Uh and this Yeah, hopefully this
  703. 27:13makes sense intuitively. All it's saying
  704. 27:15is if your drone is hovering perfectly,
  705. 27:17uh it has no velocities, it's kind of
  706. 27:19exactly at the origin, and you're
  707. 27:21canceling out gravity exactly, then
  708. 27:23nothing is going to happen. So X dot is
  709. 27:24just going to be equal to zero.
  710. 27:26Uh and that's what we have uh over here.
  711. 27:29All right, questions on this?
  712. 27:33Okay.
  713. 27:38All right, so how do we do the the
  714. 27:40Taylor approximation?
  715. 27:42Uh so our function is a function of two
  716. 27:44variables. So F is a function of X and a
  717. 27:46function of U.
  718. 27:48Uh let me just write it again. So X dot
  719. 27:51is a function F of the state and the
  720. 27:54control input.
  721. 27:57Uh and by Taylor's theorem, Taylor
  722. 27:59approximation uh theorem, we can
  723. 28:01approximate this to first order
  724. 28:04as F
  725. 28:06of X0 U0.
  726. 28:09So the function evaluated at the nominal
  727. 28:11state and the control input
  728. 28:14plus
  729. 28:16um
  730. 28:17Let me stick to the notation here. So
  731. 28:19partial derivatives
  732. 28:23with respect to X
  733. 28:26uh evaluated at X equals
  734. 28:30X0 U equals U0
  735. 28:35times the the state minus the reference
  736. 28:38state.
  737. 28:41And then plus
  738. 28:46the partials with respect to the control
  739. 28:48input
  740. 28:49again evaluated at the nominal state and
  741. 28:52control input.
  742. 28:57Uh and then u minus u 0.
  743. 29:02Right, so this is just uh
  744. 29:03the Taylor series approximation to the
  745. 29:05first order.
  746. 29:07Um yeah, any questions on this?
  747. 29:10Hopefully everyone has seen this.
  748. 29:13Okay, I don't see anyone nodding.
  749. 29:16Uh maybe a quick show of hands if you
  750. 29:18have seen it.
  751. 29:19Okay, most of you, good. All right.
  752. 29:22Uh okay, so yeah, I guess this is uh the
  753. 29:24the sort of general um
  754. 29:27expression uh Taylor approximation to to
  755. 29:29first order.
  756. 29:30Um we have to compute these matrices. So
  757. 29:33this this matrix over here, this is a
  758. 29:35matrix, this is a a matrix.
  759. 29:37Uh so yeah, let's let me just go ahead
  760. 29:39and and do that.
  761. 29:52All right, so let's Oh, and actually I
  762. 29:53should have mentioned this term over
  763. 29:55here, we computed up there.
  764. 29:57Uh this is just zero. So we need to
  765. 29:59calculate
  766. 30:00this matrix times x minus x 0 uh plus
  767. 30:04this matrix u minus u 0.
  768. 30:07Uh and I'm just going to give these
  769. 30:08names, so I'll call this A
  770. 30:11and I'll call this B.
  771. 30:14So A is going to be
  772. 30:17uh n by n matrix.
  773. 30:22Uh and then B is going to be
  774. 30:28uh n by m
  775. 30:30matrix to make the dimensions work out.
  776. 30:34So let's start by calculating A
  777. 30:39for the planar quadrotor.
  778. 30:44Um
  779. 30:45So, let me Maybe let me just write down
  780. 30:47the general expression and then we'll
  781. 30:49plug in some values.
  782. 30:51So, the the first row is going to be DF.
  783. 30:55Uh So, the partial of F with respect to
  784. 31:00uh X and actually the the first
  785. 31:01component of of F.
  786. 31:05So, the first component of F is is up
  787. 31:07there, so VX.
  788. 31:13And then partial of VX
  789. 31:17partial Y
  790. 31:19uh partial VX
  791. 31:22partial theta. Maybe I'll write down the
  792. 31:25the full first row just to be concrete.
  793. 31:28So, partial VX partial X
  794. 31:32dot, which is VX
  795. 31:34partial V
  796. 31:36um X
  797. 31:40partial VY
  798. 31:42and the last one partial VX partial
  799. 31:46uh omega.
  800. 31:49So, that's the the full first row.
  801. 31:52Uh and then the the second row is going
  802. 31:54to be the partial of the second
  803. 31:56component of F, which is VY up there.
  804. 32:02And then partial X and then same same
  805. 32:04thing over here, partial VY
  806. 32:07um
  807. 32:09partial Y
  808. 32:12I won't write the full thing, but just
  809. 32:13just enough terms to make sure it's
  810. 32:15clear.
  811. 32:18theta and so on.
  812. 32:23Right. So, basically each row over here,
  813. 32:25we're fixing uh the thing that we're
  814. 32:27taking the partial with respect to.
  815. 32:29Um so, in the first row, it's going to
  816. 32:31be the first component of F,
  817. 32:33which is the the first row up there,
  818. 32:35which is VX. In the second row, it's
  819. 32:37going to be all VY's. and the third row
  820. 32:39it's going to be all uh omegas uh and
  821. 32:42and so on.
  822. 32:43Right, that's the the full expression.
  823. 32:47So, if we think about this matrix, let's
  824. 32:49just look at the the first row.
  825. 32:51I guess what is that first row going to
  826. 32:53to be?
  827. 32:55Uh is it going to be all zeros? Is it
  828. 32:57going to be some
  829. 32:59non-zero things uh in each element?
  830. 33:04Can people see it?
  831. 33:11Yep, go ahead.
  832. 33:16Yep.
  833. 33:19Perfect, yeah. So, we're taking
  834. 33:20partials. So, the partial of V X with
  835. 33:22respect to X is zero. V X Yeah, there's
  836. 33:25no explicit dependence on on X.
  837. 33:27Uh same thing with Y, same thing with
  838. 33:29theta. The only
  839. 33:32non-trivial like non-zero
  840. 33:35element is this one. So, the partial of
  841. 33:36V X with respect to itself is going to
  842. 33:39be
  843. 33:40one.
  844. 33:41And then everything else is is zero.
  845. 33:44Uh and then you can see it's kind of a
  846. 33:45similar pattern for the next two rows.
  847. 33:48So, for the second row,
  848. 33:50everything is going to be zero uh except
  849. 33:52there's going to be a partial V Y uh
  850. 33:55and partial
  851. 33:57Yeah, this one over here, partial V Y V
  852. 34:00Y.
  853. 34:03That's going to be one.
  854. 34:05Uh and then in the third row, you're
  855. 34:07going to have a
  856. 34:08partial omega partial omega.
  857. 34:12And that's going to be one.
  858. 34:14So, the first three rows are actually
  859. 34:16pretty straightforward.
  860. 34:25Let me write it down. So, A, the first
  861. 34:27three rows
  862. 34:28So, 0 0 0
  863. 34:311 0 0
  864. 34:34and then 0 0 0 0 1 0
  865. 34:39and then all zeros except for the last
  866. 34:41one.
  867. 34:45All right. Questions on on that?
  868. 34:50Okay.
  869. 34:51Um yeah, I guess it turns out that
  870. 34:52basically all the the other elements are
  871. 34:55also equal to to zero except for
  872. 34:58for one. So,
  873. 35:00uh
  874. 35:01yeah, let me put all the zeros. This
  875. 35:02element over here is going to be
  876. 35:04non-zero.
  877. 35:06Uh but everything else
  878. 35:08yeah, if you go through
  879. 35:10the partials are zero.
  880. 35:18And yeah, maybe we can just calculate
  881. 35:20this one. So, this is the fourth row.
  882. 35:22So, we're going to take the partial
  883. 35:25with respect to the fourth
  884. 35:27element of F.
  885. 35:38So, partial of
  886. 35:40uh with respect to
  887. 35:42uh the fourth element of F, so that's
  888. 35:43negative U1
  889. 35:49over M sin theta.
  890. 35:52Uh
  891. 35:53and then it's the third column. So, it's
  892. 35:56the partial with respect to the third
  893. 35:57element in the state, which is theta.
  894. 36:02Okay, so this partial
  895. 36:06is negative
  896. 36:08uh U1
  897. 36:10over M
  898. 36:12cosine theta.
  899. 36:16And then we're evaluating it
  900. 36:18at the nominal state and the nominal
  901. 36:21control input.
  902. 36:26Uh so, the nominal state has theta
  903. 36:28equals zero.
  904. 36:30So, cosine of zero is one.
  905. 36:35And then
  906. 36:36U1
  907. 36:38uh this I I think I just erased it, but
  908. 36:41U1 was just canceling out gravity. Uh
  909. 36:43so, it was just mg.
  910. 36:44Uh so, this is mg over here.
  911. 36:48Uh so, this is just negative g.
  912. 36:54Uh so, that's that turns out to be the
  913. 36:56only non-zero element here. So, this is
  914. 36:58negative g.
  915. 37:02Okay. Yeah, I guess questions on on
  916. 37:04this.
  917. 37:07All right.
  918. 37:09Yeah, question.
  919. 37:11Yeah.
  920. 37:15Yeah, so I haven't uh
  921. 37:18uh sort of said it kind of
  922. 37:20what what I said was like we're doing
  923. 37:21the Taylor approximation just to get a
  924. 37:23first-order approximation of the
  925. 37:24dynamics, which is then going to help us
  926. 37:26solve the trajectory optimization. Uh
  927. 37:27but I haven't actually told you like why
  928. 37:29it's easy. Like I'm just that's just a
  929. 37:31claim. Once we Taylor approximate to
  930. 37:33first order, uh then I'll talk about how
  931. 37:35to actually solve the trajectory
  932. 37:36optimization problem.
  933. 37:38Yeah, other questions?
  934. 37:42Okay.
  935. 37:43All right, people are like super quiet,
  936. 37:44which makes me nervous usually. Uh
  937. 37:46>> [laughter]
  938. 37:48>> Uh yeah, I guess is it clear or or not?
  939. 37:51Yeah,
  940. 37:51I guess I see some some thumbs up. Okay.
  941. 37:54Uh yeah, do ask questions. I guess the
  942. 37:55whole point of this is to to answer
  943. 37:57questions if you have them.
  944. 37:59Okay. So, this was the A matrix. Um so,
  945. 38:02let me just quickly go through the B
  946. 38:04matrix as well.
  947. 38:06So, the B matrix is this one, the
  948. 38:07partial
  949. 38:09of f with respect to the control inputs.
  950. 38:25So, again, I won't go through all the
  951. 38:27the elements. Um
  952. 38:30but let me just write down. So, partial
  953. 38:32of f with respect to u1.
  954. 38:36And sorry, f here is the the first
  955. 38:38element,
  956. 38:40uh which is vx.
  957. 38:43And then partial vx with respect to U 2
  958. 38:49partial V
  959. 38:51Y with respect to U 1
  960. 38:57V Y
  961. 38:59U 2
  962. 39:00Uh and so on.
  963. 39:06Uh yeah, so it's going to be a a 6 by 2.
  964. 39:09So, N by
  965. 39:10M
  966. 39:13N is the number of states and M is the
  967. 39:14number of control inputs. So, 6 by 2 for
  968. 39:16the planar quadrotor.
  969. 39:20Uh and again, most of the the elements
  970. 39:22turn out to be
  971. 39:24zero.
  972. 39:25Like if you look at this one for
  973. 39:27instance,
  974. 39:29uh there's no explicit dependence of
  975. 39:32U 1 uh or of V X on on U 1. This is
  976. 39:36going to be zero. This is going to be
  977. 39:37zero. So, yeah, all basically turns out
  978. 39:39to be zero
  979. 39:40except for two elements.
  980. 39:43Zero, zero. I think the first four rows
  981. 39:46are all zero.
  982. 39:52Uh
  983. 39:53and then one of the the elements is this
  984. 39:56one that's not zero. And then this is
  985. 39:57zero.
  986. 39:59This is zero. And then this one is not
  987. 40:01zero.
  988. 40:06Okay.
  989. 40:10All right. So, let's calculate one of
  990. 40:12them.
  991. 40:25Uh and yeah, maybe let's do let's do
  992. 40:27this one over here.
  993. 40:31Uh this element right here. So, it's the
  994. 40:33fifth row and then the first column.
  995. 40:37Um and yeah, maybe let's do this as an
  996. 40:40exercise. Uh
  997. 40:41yeah, maybe let's come back and and
  998. 40:43discuss. Uh yeah, I guess anyone want to
  999. 40:45just volunteer to to to
  1000. 40:47your work.
  1001. 40:50Go ahead. Yeah.
  1002. 40:58Yeah.
  1003. 41:04Okay, maybe just let's write down what
  1004. 41:06the partials are. So, it's the partial
  1005. 41:08of something with respect to something.
  1006. 41:13Uh V Y
  1007. 41:15Uh
  1008. 41:16is that right? So,
  1009. 41:18let's see.
  1010. 41:19Uh
  1011. 41:20It's not quite V Y.
  1012. 41:22Uh so, V Y is the fifth component of the
  1013. 41:24state, right? Uh
  1014. 41:26So, it's like the derivative of V Y.
  1015. 41:30Yeah, which is this this thing over
  1016. 41:31here.
  1017. 41:32Um
  1018. 41:34So, yeah, the derivative of V Y
  1019. 41:39to U 1. Yeah, okay, good. So, the
  1020. 41:40derivative of V Y, which is just the
  1021. 41:42fifth component of this right-hand side,
  1022. 41:45is U 1.
  1023. 41:52Good. Yeah.
  1024. 41:56Yep.
  1025. 41:57Yeah.
  1026. 42:00Yeah.
  1027. 42:07Yeah, good. So, cosine theta
  1028. 42:11divided by M.
  1029. 42:21Yep.
  1030. 42:23Good. Yeah.
  1031. 42:25Yeah, perfect. Okay.
  1032. 42:27Good. Yeah, so this was this was one of
  1033. 42:28the non-zero ones. It's 1 over M.
  1034. 42:33Over here. Uh and then yeah, I don't
  1035. 42:35know if someone worked out the other one
  1036. 42:36as well.
  1037. 42:38Uh does someone else want to give a
  1038. 42:40shot?
  1039. 42:41Yeah, go ahead at the front.
  1040. 42:46Yeah, so partial So, it's the sixth
  1041. 42:49Yeah, U 2 over I.
  1042. 42:53with respect to U2.
  1043. 42:59Yep, good. So, just one over I.
  1044. 43:03All right, perfect. So, yeah, this is
  1045. 43:04the the other
  1046. 43:07non-zero term. Everything else you can
  1047. 43:09check is is just equal to to zero.
  1048. 43:11Uh all right. So, we've done what we set
  1049. 43:14out to to do.
  1050. 43:15Uh so, we wanted to approximate our
  1051. 43:17dynamics uh using
  1052. 43:20a linear approximation. So, just a
  1053. 43:22first-order Taylor approximation.
  1054. 43:36Uh so, our linearized dynamics
  1055. 43:42This is not going to be a perfect
  1056. 43:44approximation, but kind of good enough
  1057. 43:45if you're close to the the nominal
  1058. 43:47state, close to the nominal control
  1059. 43:48input.
  1060. 43:50The linear linearized dynamics
  1061. 43:55are X dot
  1062. 43:58equals this A matrix that we calculated
  1063. 44:02X minus X0
  1064. 44:05uh plus B
  1065. 44:07U minus U0.
  1066. 44:17Okay. So, I guess as we saw, uh it's a
  1067. 44:20little bit tedious to do this by hand.
  1068. 44:21Like, it's good to understand the
  1069. 44:22process. Like, it's good to know that
  1070. 44:24it's just a Taylor approximation. It's
  1071. 44:26good to you kind of go through it once
  1072. 44:27or twice by hand and just see exactly
  1073. 44:29how it works. Uh in the next assignment
  1074. 44:31that goes out tomorrow, uh you'll see
  1075. 44:33how we can do this in Python. So, it's
  1076. 44:35uh yeah, just a few lines of Python code
  1077. 44:37uh that that does the first-order Taylor
  1078. 44:39approximation.
  1079. 44:40Um and especially for more complicated
  1080. 44:43systems, like for the full 3D quadrotor,
  1081. 44:46uh we don't want to compute partial
  1082. 44:47derivatives by hand, like plug in values
  1083. 44:49and so on. Uh it's We can do it, but
  1084. 44:51it's just super tedious.
  1085. 44:52Uh so, you'll see some Python code that
  1086. 44:54uh that does that for you and that's
  1087. 44:56quite convenient.
  1088. 44:57But okay, I guess going back to to the
  1089. 45:00question that someone asked, like what
  1090. 45:01is the point of this? Why are we
  1091. 45:03approximating our nice dynamics for the
  1092. 45:06planar quadrotor with these like linear
  1093. 45:10dynamics approximations?
  1094. 45:12So, I promised that the trajectory
  1095. 45:13optimization problem
  1096. 45:15for
  1097. 45:17a system that has linear dynamics is
  1098. 45:18computationally efficient.
  1099. 45:21So, I want to just go through that.
  1100. 45:24So, I want to write down some
  1101. 45:27So, the trajectory optimization problem
  1102. 45:34assuming linear dynamics.
  1103. 45:41So, again the problem set up for
  1104. 45:43trajectory optimization is we're given
  1105. 45:44some starting state.
  1106. 45:47We're given some end state.
  1107. 45:50I'll call it X, let's say XA, XB.
  1108. 45:56And we want to find some control inputs
  1109. 45:58that will take the the drone or whatever
  1110. 46:00system you have from the starting state
  1111. 46:03to this goal state XB. So, that's the
  1112. 46:05the problem.
  1113. 46:07So, the way we're going to formulate
  1114. 46:09this trajectory optimization problem is
  1115. 46:11as a
  1116. 46:14as a search problem or an optimization
  1117. 46:16problem. So, we want to find
  1118. 46:18um
  1119. 46:21Yeah, let's let's say
  1120. 46:23Actually, I guess sorry, just one more
  1121. 46:25thing before that.
  1122. 46:26So, it's going to be helpful to
  1123. 46:29just do one more approximation here,
  1124. 46:30which is this is a continuous time
  1125. 46:33differential equation. We're going to to
  1126. 46:35discretize time
  1127. 46:37and that's going to make the the problem
  1128. 46:39a bit easier to to solve.
  1129. 46:41So, X
  1130. 46:44Let's say T plus delta T.
  1131. 46:49So, the state at some time T
  1132. 46:52plus some small
  1133. 46:54delta T, some small time delta T
  1134. 46:56is approximately going to be equal to
  1135. 46:59from this equation
  1136. 47:00the the A matrix
  1137. 47:04X at time T minus X zero
  1138. 47:09uh plus B
  1139. 47:14uh
  1140. 47:15at time T
  1141. 47:18minus U zero
  1142. 47:20uh and then this thing
  1143. 47:22multiplied by delta T.
  1144. 47:28Plus the state
  1145. 47:33at time T. So, this is our Euler
  1146. 47:34discretization.
  1147. 47:45We're taking this continuous time
  1148. 47:46differential equation and turning it
  1149. 47:48into a difference equation
  1150. 47:50uh just by Euler integrating. So, the
  1151. 47:53state at some T plus delta T
  1152. 47:55uh is the state at T
  1153. 47:57plus the time derivative X dot, which is
  1154. 48:00this thing, uh multiplied by by delta T.
  1155. 48:03Right? So, just Euler integration.
  1156. 48:05Um so, yeah, I guess with this
  1157. 48:07discretized version of the problem
  1158. 48:09we can state our trajectory optimization
  1159. 48:11problem
  1160. 48:13uh as trying to find
  1161. 48:16states
  1162. 48:18and control inputs at different times
  1163. 48:22where T goes from let's say zero
  1164. 48:27delta T
  1165. 48:29two delta T
  1166. 48:31uh up to some capital T, which is our
  1167. 48:34time horizon. So, let's say I I specify
  1168. 48:375 seconds or 10 seconds, like the amount
  1169. 48:39of time
  1170. 48:40uh the maximum amount of time I'm
  1171. 48:42willing to wait
  1172. 48:43uh for my system to go from
  1173. 48:45XA to XB. Uh that's what this capital T
  1174. 48:48is.
  1175. 48:50So, we want to find these variables,
  1176. 48:52states and control inputs.
  1177. 48:54Um
  1178. 48:55we want to also have some
  1179. 48:59objective, like something we were we're
  1180. 49:00trying to to optimize.
  1181. 49:02So, let's say we want to minimize
  1182. 49:11uh
  1183. 49:11the control effort.
  1184. 49:14So, the total amount of
  1185. 49:17control inputs that I need to apply. So,
  1186. 49:18going from T zero to capital T.
  1187. 49:24The control input at time T
  1188. 49:27uh the magnitude squared.
  1189. 49:30Like this is saying like be as lazy as
  1190. 49:31possible. Uh like apply as little
  1191. 49:33control input uh as possible.
  1192. 49:36Uh and then we need we have some
  1193. 49:37constraints.
  1194. 49:44Uh things that XT and UT need to
  1195. 49:47satisfy.
  1196. 49:49So, because this is a a boundary value
  1197. 49:50problem,
  1198. 49:52uh the state
  1199. 49:56at time zero should be XA.
  1200. 50:01Uh the state at let's say capital T
  1201. 50:05should be XB.
  1202. 50:09This is saying the Yeah, the state
  1203. 50:11starts off where you want it to start
  1204. 50:12off. The state ends up where you want it
  1205. 50:14to to end up.
  1206. 50:16And we also have
  1207. 50:19uh the dynamics. So, your states and
  1208. 50:21control inputs need to satisfy
  1209. 50:24these like linear approximated dynamics
  1210. 50:26that we have. So, X
  1211. 50:29uh
  1212. 50:31T plus delta T
  1213. 50:35is equal to
  1214. 50:37X
  1215. 50:38at time T
  1216. 50:40plus A
  1217. 50:45XT minus X0
  1218. 50:47plus B
  1219. 50:50uh
  1220. 50:53UT minus U0.
  1221. 50:58See
  1222. 50:59the parentheses right here.
  1223. 51:01Uh delta T
  1224. 51:04Uh and this is for T going from
  1225. 51:07zero to capital T for all time.
  1226. 51:12Uh and then we might have some obstacle
  1227. 51:14constraints. So, I'll just write this as
  1228. 51:16some matrix C
  1229. 51:19times X
  1230. 51:22T is less than or equal to
  1231. 51:26D.
  1232. 51:27Uh I guess this should be explicit here.
  1233. 51:28So, C is some
  1234. 51:31matrix. Maybe I'll write it over here.
  1235. 51:38Uh so, C let's say is
  1236. 51:43Um yeah, I guess what should it be? So,
  1237. 51:45it's
  1238. 51:46K by N, let's say. So,
  1239. 51:50and then D is
  1240. 51:54K by 1.
  1241. 51:59Okay, let me just pause for a for a
  1242. 52:01minute and just explain what what's
  1243. 52:02going on over here.
  1244. 52:04Uh so, we're we're kind of formulating
  1245. 52:06this optimization problem. So, we're
  1246. 52:07trying to find states and control
  1247. 52:09inputs.
  1248. 52:11Um the objective, the thing we're trying
  1249. 52:13to minimize, is just control effort.
  1250. 52:15Like just be as lazy as possible, apply
  1251. 52:17as few as little control input as
  1252. 52:19possible.
  1253. 52:21Uh and then these are the the
  1254. 52:22constraints. So, the first two
  1255. 52:23constraints are just saying start off at
  1256. 52:25the start state that we want, XA.
  1257. 52:28End up at the end state that we want,
  1258. 52:29which is XB.
  1259. 52:31Uh along the way, satisfy the dynamics
  1260. 52:35um of your system, these linear
  1261. 52:38approximated dynamics.
  1262. 52:41Uh and this last constraint is saying uh
  1263. 52:43is just a a kind of boundedness
  1264. 52:45constraint on the state. So, it's saying
  1265. 52:47like keep the state uh within some
  1266. 52:49region that's specified by these this
  1267. 52:51linear inequality.
  1268. 52:54Um
  1269. 52:55Okay, so I guess why is this Maybe
  1270. 52:57before describing why this is special, I
  1271. 53:00just want to make sure that this
  1272. 53:01formulation is clear. Like what are we
  1273. 53:02trying to find?
  1274. 53:03Uh what does this mean? Like what are
  1275. 53:05the constraints? What what are the uh
  1276. 53:07the objective? Yeah, questions on the
  1277. 53:09formulation itself?
  1278. 53:13Yeah, question.
  1279. 53:16Yeah, so the last constraint is
  1280. 53:20saying that the state needs to be in
  1281. 53:23some region
  1282. 53:25for all time.
  1283. 53:29Uh so this these this is like a set of
  1284. 53:31linear constraints.
  1285. 53:32>> constraints
  1286. 53:33>> Uh so each row over here is going to
  1287. 53:37basically say like
  1288. 53:39your state needs to be
  1289. 53:41on this side of some hyperplane.
  1290. 53:45Uh and then
  1291. 53:46yeah, another
  1292. 53:48constraint says your state needs to be
  1293. 53:50over here. Maybe you have another
  1294. 53:52constraint over here
  1295. 53:53that says the state needs to be uh on
  1296. 53:56this side. Uh this is just like bounding
  1297. 53:58the the state.
  1298. 54:00Uh
  1299. 54:00and yeah, one way to think about it is
  1300. 54:02like imagine that you had an obstacle
  1301. 54:03here.
  1302. 54:05You had some obstacle over here. You had
  1303. 54:06some obstacle over here.
  1304. 54:08Uh you're just approximating the region
  1305. 54:11that's collision-free uh with a
  1306. 54:12polytope, so a sequence of um linear
  1307. 54:15constraints.
  1308. 54:16Uh and just saying that the the state
  1309. 54:18needs to be in this free space defined
  1310. 54:20by a polytope for for all time.
  1311. 54:24So this is not a kind of fully general
  1312. 54:26formulation. Uh like if I had some
  1313. 54:29obstacles
  1314. 54:31like maybe over here and and over here
  1315. 54:34uh and my state needed to do something
  1316. 54:36like this. I'll I'll show a a video in
  1317. 54:37just a minute.
  1318. 54:39Um then maybe there's no kind of clean
  1319. 54:41way of of capturing the free space
  1320. 54:44uh with a a set of inequalities, um but
  1321. 54:48this is just a set of constraints that
  1322. 54:50we can add. Like if you can approximate
  1323. 54:52the free space
  1324. 54:53uh the collision-free space uh with with
  1325. 54:55these kind of inequalities
  1326. 54:57uh then we can just throw that into the
  1327. 54:59the problem. Yeah, I guess does that
  1328. 55:00make sense? Okay.
  1329. 55:01Yeah, other questions on the
  1330. 55:02formulation?
  1331. 55:06Okay. So the the key kind of uh
  1332. 55:08observation over here for for this
  1333. 55:10optimization problem
  1334. 55:12uh is one that the objective, the thing
  1335. 55:16we're trying to minimize,
  1336. 55:18is convex and quadratic. So, it's a
  1337. 55:20quadratic function of the control input
  1338. 55:22and the state.
  1339. 55:24Um so, convex means it sort of looks
  1340. 55:26like a a bowl.
  1341. 55:27Uh and then the constraints are all
  1342. 55:29linear in the state and the control
  1343. 55:32input. So, there are linear constraints.
  1344. 55:34Like each each constraint over here
  1345. 55:36uh just has the state and control input
  1346. 55:39appearing linearly. Like there are no
  1347. 55:41nonlinearities. If you maybe if you just
  1348. 55:43started it and then kind of convince
  1349. 55:44yourself.
  1350. 55:45Um and yeah, this kind of optimization
  1351. 55:48problem, so it's called a convex
  1352. 55:52QP, quadratic program.
  1353. 56:01Uh is something that there are extremely
  1354. 56:03extremely efficient uh computational
  1355. 56:05methods for solving.
  1356. 56:07Uh you can solve uh
  1357. 56:08these kinds of problems with like
  1358. 56:10thousands of of variables like very very
  1359. 56:12easily, like milliseconds uh
  1360. 56:14computational times. I won't go into the
  1361. 56:15the methods
  1362. 56:16for how to solve this. Uh again, if
  1363. 56:17you're interested in this kind of thing,
  1364. 56:19uh we have entire courses like our 363
  1365. 56:22uh devoted to this.
  1366. 56:23Uh but the main point I want to make is
  1367. 56:24just this observation that one, this
  1368. 56:27captures the trajectory optimization
  1369. 56:29problem for the linear systems.
  1370. 56:31Uh
  1371. 56:32two, just the meaning of all this stuff.
  1372. 56:35Right? Like what what is it What are we
  1373. 56:37What is it that we're trying to find?
  1374. 56:38What are we trying to minimize? What are
  1375. 56:40the constraints that these variables
  1376. 56:41need to to satisfy?
  1377. 56:43Uh and then yeah, I guess the last thing
  1378. 56:44is just the claim that you can solve
  1379. 56:45these extremely efficiently. Like for
  1380. 56:47the planar quadrotor, it might even be
  1381. 56:49microseconds uh if you're um have a fast
  1382. 56:52implementation. Question?
  1383. 56:54>> I still don't understand
  1384. 56:56the expression
  1385. 56:57>> Say that again. Still don't understand
  1386. 56:58what?
  1387. 56:59>> I still don't understand the expression
  1388. 57:00that
  1389. 57:03>> Oh yeah. So, this expression over here,
  1390. 57:07uh Uh, this is the summation over time
  1391. 57:11uh, of the control inputs that your
  1392. 57:13system is applying squared.
  1393. 57:15Um, so if we try to minimize this, like
  1394. 57:17basically it's saying
  1395. 57:19uh, for the planar quadrotor
  1396. 57:22at each time compute the total thrust
  1397. 57:25and the total torque.
  1398. 57:27Uh, just uh, uh, square them and and sum
  1399. 57:30them up uh, and then add over time and
  1400. 57:32just minimize that. So just basically
  1401. 57:33minimize the total thrust and torque
  1402. 57:36that the drone is applying.
  1403. 57:38Uh, so yeah, it's just like as kind of
  1404. 57:40efficient or lazy as possible.
  1405. 57:46Subject to to these constraints. Yeah,
  1406. 57:48does that make sense? Okay, good.
  1407. 57:50All right, so I guess first just a a
  1408. 57:51couple of uh, visualizations uh, just to
  1409. 57:55um, just to connect back to uh, to what
  1410. 57:57I uh, claimed on the on the on the
  1411. 57:59board.
  1412. 58:00Uh, so I mentioned this is a a quadratic
  1413. 58:02program and you can um, visualize what
  1414. 58:04what these things look like. For
  1415. 58:06visualization purposes, I'm going to
  1416. 58:07draw pictures in 2D, but you can imagine
  1417. 58:09that uh, this is really in a
  1418. 58:10high-dimensional space uh, that these
  1419. 58:12functions and constraints are are
  1420. 58:13living.
  1421. 58:15So without any constraints, if I'm just
  1422. 58:17trying to minimize some quadratic
  1423. 58:19function of some decision variables like
  1424. 58:21X1 and X2, like let's say I have some
  1425. 58:23quadratic function of of X1 X2
  1426. 58:25uh, I can visualize this using level
  1427. 58:28sets. So each uh, kind of oval here,
  1428. 58:30ellipsoid or ellipse
  1429. 58:32uh, is one of the the level sets of the
  1430. 58:34uh, the function.
  1431. 58:36Uh, and if I'm trying to minimize this
  1432. 58:37function
  1433. 58:38without any constraints, then for the
  1434. 58:40specific function that I've drawn, uh,
  1435. 58:42it's kind of at that point uh, 4,3,
  1436. 58:44let's say.
  1437. 58:46Uh,
  1438. 58:47so this kind of problem is like almost
  1439. 58:48trivial to solve. Like you can just do
  1440. 58:50gradient descent, like just uh, randomly
  1441. 58:52initialize X1 X2 uh, compute the
  1442. 58:55gradient, the negative of the gradient,
  1443. 58:56take a little step uh, and keep going
  1444. 58:58until convergence.
  1445. 59:00Uh, it gets much more interesting uh,
  1446. 59:02when you start adding constraints.
  1447. 59:04So now suppose I say that
  1448. 59:07I have two constraints. So X1 and X2
  1449. 59:10must satisfy this linear constraint,
  1450. 59:13which is written up there. So, 2 x 2 - x
  1451. 59:151 is less than or equal to 4.
  1452. 59:18Uh that's saying that your x 1 x 2 needs
  1453. 59:20to be on this side of this line over
  1454. 59:22here.
  1455. 59:24Uh and then I have another constraint, x
  1456. 59:251 + x 2 is less than or equal to 4. So,
  1457. 59:28I have this line over here. Uh and this
  1458. 59:30constraint is saying that x 1 and x 2
  1459. 59:32must satisfy
  1460. 59:34the constraint and that you're on on
  1461. 59:35this side.
  1462. 59:37Uh and both of these must be satisfied.
  1463. 59:39Uh which means that your x 1 and x 2
  1464. 59:41must lie in this green region, shaded
  1465. 59:44region over here.
  1466. 59:46Um so, yeah, I guess this is sort of a
  1467. 59:48visualization of what a convex quadratic
  1468. 59:50program looks like. We're trying to
  1469. 59:52minimize some quadratic function
  1470. 59:55uh
  1471. 59:55of some decision variables, like things
  1472. 59:57that we're trying to find.
  1473. 59:59Uh and we have these constraints
  1474. 1:00:01uh which are linear. Uh and subject to
  1475. 1:00:04these constraints, like in this kind of
  1476. 1:00:06shaded region, I will minimize my
  1477. 1:00:08function.
  1478. 1:00:09Um and yeah, I guess my my claim, uh if
  1479. 1:00:12you haven't seen some convex
  1480. 1:00:13optimization before, is that these kinds
  1481. 1:00:15of problems are are extremely extremely
  1482. 1:00:16efficient to solve. Uh in the notes, I I
  1483. 1:00:19pointed to a a couple of software
  1484. 1:00:20packages, uh things like Mosek, Gurobi,
  1485. 1:00:23CPLEX. There's a whole bunch of them.
  1486. 1:00:25You can just kind of write simple uh
  1487. 1:00:27Python code uh to to solve these
  1488. 1:00:29optimization problems.
  1489. 1:00:31Um
  1490. 1:00:32So, I guess that's the the story for
  1491. 1:00:34linear systems. If you have a linear
  1492. 1:00:36system,
  1493. 1:00:37uh if the thing that you're trying to
  1494. 1:00:39minimize, the control effort, is
  1495. 1:00:41quadratic, uh and if your constraints
  1496. 1:00:43are all linear, then it's super super
  1497. 1:00:45efficient.
  1498. 1:00:47Uh
  1499. 1:00:47but of course, our systems are never
  1500. 1:00:50kind of exactly linear. Our constraints
  1501. 1:00:52are never quite linear, either. Um
  1502. 1:00:55So, we need some way of of handling the
  1503. 1:00:56the general uh problem as well. So, how
  1504. 1:00:58do we solve these trajectory
  1505. 1:01:00optimization problems uh when your
  1506. 1:01:01system is is non-linear?
  1507. 1:01:03Uh I won't go into the the details of
  1508. 1:01:05this. I just want to kind of sketch out
  1509. 1:01:07uh what the the approach uh looks like.
  1510. 1:01:10Uh and have a a visualization uh over
  1511. 1:01:12here. So, this is white coded with with
  1512. 1:01:14Claude. Uh but hopefully gives you a
  1513. 1:01:16clear picture of uh of the way the the
  1514. 1:01:18algorithm works.
  1515. 1:01:20Uh it's the same setup as before, so we
  1516. 1:01:22have some start state XA. Uh we have
  1517. 1:01:25some goal state XB.
  1518. 1:01:28Uh and we want to avoid these obstacles.
  1519. 1:01:30So, we want to find some control inputs
  1520. 1:01:32that that avoid the obstacles.
  1521. 1:01:34Uh basically, the way
  1522. 1:01:36these kinds of problems are solved is
  1523. 1:01:39like iterative approximation with
  1524. 1:01:41quadratic programs.
  1525. 1:01:43Uh initially, in the the very first
  1526. 1:01:44iteration,
  1527. 1:01:46you just guess some solution.
  1528. 1:01:48So, we'll go back to the the start. So,
  1529. 1:01:49you just guess like a line. Like this
  1530. 1:01:51violates the constraints. Like it goes
  1531. 1:01:53through the obstacles.
  1532. 1:01:54Uh but you can come up with some linear
  1533. 1:01:56approximation of the dynamics along that
  1534. 1:01:58line.
  1535. 1:01:59Uh
  1536. 1:02:00so, now you have
  1537. 1:02:01at least the dynamics part is is linear.
  1538. 1:02:04Uh you can approximate the
  1539. 1:02:06obstacle constraints as being linear as
  1540. 1:02:09well.
  1541. 1:02:10Uh or you can just relax them. Like
  1542. 1:02:12initially, like kind of just don't
  1543. 1:02:13bother too much about imposing the the
  1544. 1:02:15obstacle constraints.
  1545. 1:02:16Uh you find some trajectory,
  1546. 1:02:18uh and then you crank up the penalty for
  1547. 1:02:21violating the constraints from the
  1548. 1:02:23obstacles. Uh and then you
  1549. 1:02:25re-approximate the dynamics about the
  1550. 1:02:28the latest trajectory that you found.
  1551. 1:02:30Uh solve the problem as a quadratic
  1552. 1:02:32program, kind of keep going, uh and uh
  1553. 1:02:35and hopefully, you'll converge to to
  1554. 1:02:36something that's feasible, like
  1555. 1:02:38something that doesn't collide.
  1556. 1:02:39Question?
  1557. 1:02:40>> Is there a heuristic in there
  1558. 1:02:41where you know how to do the
  1559. 1:02:42down the short path or something like
  1560. 1:02:44that, or is it really just based on the
  1561. 1:02:45control
  1562. 1:02:46like minimizing the control
  1563. 1:02:47>> Yeah, so this particular one is is just
  1564. 1:02:49control input, uh but you can throw in
  1565. 1:02:52other objectives as well. Like minimum
  1566. 1:02:53path length is a reasonable one. Uh
  1567. 1:02:55minimum time is a is another reasonable
  1568. 1:02:57one.
  1569. 1:02:58Uh yeah, it kind of depends on on
  1570. 1:03:00exactly what you care about.
  1571. 1:03:02If you do minimum time, uh what you end
  1572. 1:03:04up with is what's known as bang-bang
  1573. 1:03:06control. Like this is the the technical
  1574. 1:03:07term for it. Like where you just like
  1575. 1:03:10max out the control input, stay there,
  1576. 1:03:12uh and then kind of go to the other
  1577. 1:03:14extreme. Uh Uh, and usually, this is not
  1578. 1:03:17uh, extremely friendly when you're
  1579. 1:03:19implementing stuff on a physical system
  1580. 1:03:21like just maxing the the kind of control
  1581. 1:03:23inputs back and forth.
  1582. 1:03:25Um, so in practice you might have some
  1583. 1:03:27minimal time penalty, maybe some control
  1584. 1:03:31effort penalty, maybe some path length
  1585. 1:03:32penalty, and you throw all of those
  1586. 1:03:34together.
  1587. 1:03:35Uh, that's your objective, and then you
  1588. 1:03:36have constraints in the form of
  1589. 1:03:37obstacles. Yeah.
  1590. 1:03:40Cool. All right. So again, just, uh, to
  1591. 1:03:42iterate, the part that I went through
  1592. 1:03:44carefully is the linear part. If your
  1593. 1:03:46dynamics are linear, if your constraints
  1594. 1:03:48are linear,
  1595. 1:03:49uh, then you can solve these problems
  1596. 1:03:51extremely efficiently,
  1597. 1:03:53um, and pretty much exactly
  1598. 1:03:55up to like very small numerical errors.
  1599. 1:03:58Uh, but if your obstacle constraints are
  1600. 1:04:00not linear, if your dynamics are not
  1601. 1:04:01linear, then you iteratively
  1602. 1:04:03approximate, uh, using quadratic
  1603. 1:04:05programs.
  1604. 1:04:06Uh, this is called sequential quadratic
  1605. 1:04:08programming.
  1606. 1:04:09Uh, there's no guarantee that you're
  1607. 1:04:10going to find some collision-free path.
  1608. 1:04:13Uh, and especially as the number of
  1609. 1:04:15obstacles gets larger,
  1610. 1:04:17uh, as the geometry of the environment
  1611. 1:04:19gets more complicated, um, the
  1612. 1:04:21likelihood that you're going to find
  1613. 1:04:23some solution with sequential quadratic
  1614. 1:04:25programming becomes,
  1615. 1:04:27uh, lower.
  1616. 1:04:28Uh, but yeah, I guess this is why we
  1617. 1:04:30combine it with the RRT algorithm.
  1618. 1:04:32Um, so if you do this trajectory
  1619. 1:04:34optimization just for the extension
  1620. 1:04:37operation in the RRT,
  1621. 1:04:39uh, usually that extension is over a a
  1622. 1:04:40short time duration,
  1623. 1:04:42uh, for which we can solve these
  1624. 1:04:44trajectory optimization problems pretty
  1625. 1:04:45efficiently.
  1626. 1:04:47Um, and yeah, I guess that that's the
  1627. 1:04:49the kind of fully general approach. Like
  1628. 1:04:51build your RRT, every time you extend
  1629. 1:04:53the tree, solve one of these little
  1630. 1:04:55optimization problems, uh, and then at
  1631. 1:04:56the end, uh, hopefully you get some, uh,
  1632. 1:04:59path that's dynamically feasible for
  1633. 1:05:01your system, uh, that goes from, uh, A
  1634. 1:05:03to B.
  1635. 1:05:05Okay.
  1636. 1:05:06I'll show some examples, but yeah, I
  1637. 1:05:08guess any questions on the,
  1638. 1:05:10the math or formulation.
  1639. 1:05:15Okay.
  1640. 1:05:16All right. So this is going to be a
  1641. 1:05:17super biased, uh,
  1642. 1:05:19set of examples. These are all from my
  1643. 1:05:20own work.
  1644. 1:05:23Uh but yeah, hopefully it gives you a
  1645. 1:05:24clear picture.
  1646. 1:05:27Let me
  1647. 1:05:32Let me just describe the the system over
  1648. 1:05:34here. Uh this is what's known as a
  1649. 1:05:36acrobot. Uh this is a a system that I
  1650. 1:05:39worked quite a lot with during my my
  1651. 1:05:40PhD.
  1652. 1:05:41Uh it's a double pendulum, so a classic
  1653. 1:05:43kind of example of a chaotic system. So,
  1654. 1:05:45two degrees of freedom, one at the
  1655. 1:05:47shoulder, one at the elbow.
  1656. 1:05:49Uh but the important thing here is that
  1657. 1:05:51it's under actuated. So, there's only
  1658. 1:05:53one motor uh that's controlling the
  1659. 1:05:56elbow joint. So, there's no motor at the
  1660. 1:05:58the shoulder joint, just a motor at the
  1661. 1:06:00the elbow joint.
  1662. 1:06:01Uh it's sort of meant to
  1663. 1:06:03model an acrobat, so a human acrobat
  1664. 1:06:06like hanging from a bar. Uh you don't
  1665. 1:06:08have much torque at the wrist, uh but
  1666. 1:06:11you have a lot of torque at the hip. Uh
  1667. 1:06:12so, that that's kind of what what this
  1668. 1:06:13system is.
  1669. 1:06:14Uh it's also a very simple model for a
  1670. 1:06:17walking robot. Uh so, if you imagine
  1671. 1:06:19it's also Yeah, called the compass gait
  1672. 1:06:21walker. So, like a drawing compass, uh
  1673. 1:06:23one end is like fixed to the ground, uh
  1674. 1:06:25the other end is the the swing leg.
  1675. 1:06:28Um so, you don't have any torque at the
  1676. 1:06:30ground. You have a little bit of torque
  1677. 1:06:32from your ankle, but not that much. But,
  1678. 1:06:33you have a lot of torque at the hip. So,
  1679. 1:06:35that's what uh this system is supposed
  1680. 1:06:36to model.
  1681. 1:06:38Uh and the goal here is to start from
  1682. 1:06:40the bottom state, so the pendulum kind
  1683. 1:06:43of hanging downwards, and you want to
  1684. 1:06:44find some control inputs that'll make it
  1685. 1:06:46go all the way to the top and then
  1686. 1:06:48balance at the at the top. Uh so, this
  1687. 1:06:50was This trajectory was found using
  1688. 1:06:52sequential quadratic programming,
  1689. 1:06:55uh and this is what it looks like.
  1690. 1:07:07Yeah, you can see it doesn't quite
  1691. 1:07:09stabilize itself at the top. Like,
  1692. 1:07:11there's a bunch of friction, so it it
  1693. 1:07:12keeps going back and forth, back and
  1694. 1:07:14forth. Uh I'll say more about uh that
  1695. 1:07:16those errors uh a a bit later, but here
  1696. 1:07:19I I want to just focus on the planning
  1697. 1:07:20part. So, the planning problem, there's
  1698. 1:07:22no obstacles, like just go from uh
  1699. 1:07:24initial state, which is downright, to
  1700. 1:07:27the final state, which is upright, while
  1701. 1:07:29obeying the dynamics of the system.
  1702. 1:07:32Uh here's another, maybe more exciting,
  1703. 1:07:34example.
  1704. 1:07:36Uh this is for a airplane, a fixed-wing
  1705. 1:07:38airplane.
  1706. 1:07:40It gets shot off a launcher.
  1707. 1:07:42Uh and then it needs to avoid these
  1708. 1:07:44obstacles, which are less than a
  1709. 1:07:46wingspan away from each other. So, it
  1710. 1:07:48needs to do this like knife edge
  1711. 1:07:50maneuver uh goes through the obstacles.
  1712. 1:07:53Uh and then the room was very small, so
  1713. 1:07:55it just crashes into a net
  1714. 1:07:57at the end.
  1715. 1:08:03Uh so, here the the problem is more
  1716. 1:08:05interesting. Uh obviously, there's
  1717. 1:08:06non-trivial dynamics. So, the first step
  1718. 1:08:08here was just to model the dynamics of
  1719. 1:08:10the system, like the aerodynamics,
  1720. 1:08:12and so on.
  1721. 1:08:13Uh and then there's obstacles as well.
  1722. 1:08:15So, you need to find some trajectory
  1723. 1:08:17that obeys the dynamics of the system
  1724. 1:08:19and avoids the the
  1725. 1:08:21uh PVC pipes.
  1726. 1:08:24Uh and again, we're using the the same
  1727. 1:08:26methods that I talked about today. So,
  1728. 1:08:28sequential quadratic programming uh to
  1729. 1:08:30to solve for that trajectory.
  1730. 1:08:34Um and then yeah, maybe final uh video
  1731. 1:08:36over here. Uh
  1732. 1:08:41Let me Yeah, let me just play it uh play
  1733. 1:08:43it back. So, I guess what video is going
  1734. 1:08:45to What this video is going to show is
  1735. 1:08:46like real-time planning.
  1736. 1:08:48Um so, if you don't have the ability to
  1737. 1:08:50solve trajectory optimization problems
  1738. 1:08:53uh at run time. So, if your robot sees
  1739. 1:08:56some obstacles, ideally, you'd want it
  1740. 1:08:57to just plan some trajectory.
  1741. 1:08:59Uh but if it's going really fast, you
  1742. 1:09:00might just not have enough time to to
  1743. 1:09:02plan in real time. Uh so, how do you
  1744. 1:09:04solve that problem?
  1745. 1:09:06Uh let me just play the clip, and then
  1746. 1:09:07I'll I'll explain it.
  1747. 1:09:11Yeah, I guess that was me in my PhD
  1748. 1:09:13days.
  1749. 1:09:37>> So yeah, we compute these funnels that
  1750. 1:09:39the plane is is uh
  1751. 1:09:42guaranteed to stay within.
  1752. 1:09:57Yeah, and the basic idea is like you
  1753. 1:09:58have a a whole family of these funnels
  1754. 1:10:01like corresponding to different
  1755. 1:10:02trajectories and control inputs
  1756. 1:10:04precomputed offline. So before the the
  1757. 1:10:06drone starts flying, uh you just compute
  1758. 1:10:08all of these trajectories, these funnels
  1759. 1:10:10that are associated with them.
  1760. 1:10:12Uh and then at runtime, all you need to
  1761. 1:10:13do is collision checking. Like you just
  1762. 1:10:15search through this kind of library of
  1763. 1:10:17funnels uh and then find something that
  1764. 1:10:19doesn't collide with the obstacles.
  1765. 1:10:41Yeah, I guess last one I was bored one
  1766. 1:10:42day, so I put uh MIT with PVC pipes.
  1767. 1:10:54All right. So yeah, I guess all the all
  1768. 1:10:56the videos I I showed uh the
  1769. 1:10:58trajectories are computed using
  1770. 1:11:00sequential quadratic programming, these
  1771. 1:11:01like trajectory optimization techniques.
  1772. 1:11:03Um what I didn't talk about is the
  1773. 1:11:06control part. So when you actually try
  1774. 1:11:08to execute one of these trajectories on
  1775. 1:11:10your real system, you're not going to
  1776. 1:11:12follow it exactly, right? Your dynamics
  1777. 1:11:14are not going to be perfect. Uh maybe
  1778. 1:11:16there's unmodeled aerodynamics, maybe
  1779. 1:11:18there's a wind gust or something that
  1780. 1:11:20blows you off the trajectory that you
  1781. 1:11:21planned. Uh so the thing that we're
  1782. 1:11:23going to start talking about from the
  1783. 1:11:24next lecture is how do we make those
  1784. 1:11:27corrections? If you're following some
  1785. 1:11:29trajectory uh but there's a disturbance
  1786. 1:11:31or there's some imperfection, how do you
  1787. 1:11:33apply some control inputs that kind of
  1788. 1:11:35take you back? So, that's going to be
  1789. 1:11:36the the next topic. All right, I guess
  1790. 1:11:38any final questions?
  1791. 1:11:41All right, I'll see you next time.
  1792. 1:11:47>> [music]

About this transcript

This page contains the full transcript of Princeton Intro to Robotics (Fall 2026) | Lecture 6: Trajectory Optimization by Introduction to Robotics @ Princeton, generated from the public captions YouTube serves with the video. The transcript has 10,277 words across 1,792 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.