understanding slam using pose graph optimization | autonomous navigation, part 3 -凯发k8网页登录
from the series: 自主导航
this video provides some intuition around pose graph optimization - a popular framework for solving the simultaneous localization and mapping (slam) problem in autonomous navigation.
we’ll cover why uncertainty in a vehicle’s sensors and state estimation makes building a map of the environment difficult and how pose graph optimization can deal with it. we’ll also briefly cover occupancy grid maps as one way to represent the environment model.
in the last video, we talked about how we could estimate an autonomous vehicle’s pose, that’s its location and orientation, if we already had a model or a map of the environment. in this video, we’re not going to have a map ahead of time. we’re going to have to build one while simultaneously figuring out where the vehicle is within in that map using a process called slam; simultaneous localization and mapping.
there are many different slam algorithms, but they can mostly be classified into two groups; filtering and smoothing. filtering, like the extended kalman filter or the particle filter, models the problem as an on-line state estimation where the robot state (and maybe part of the environment) is updated on-the-go as new measurements become available.
on the other hand, smoothing techniques estimate the full robot trajectories from the complete set of measurements, not just the new measurements. understanding these methods can be more intuitive if we address them under a graph-based formulation. in fact, in recent years, one particular framework, pose graph optimization (or more generically, factor graph optimization) has become the de facto standard for most modern slam software solutions (like g2o or gtsam). so, in this video, we are going to focus on understanding what pose graph optimization is and why it works. so, i hope you stick around for it. i’m brian, and welcome to matlab tech talk.
let’s set up the problem. we have an autonomous vehicle, a robot, that has the ability to move through an environment. we’ve given it lidar to sense the distances and angles to nearby obstacles and we’ve given it a way to dead reckon its relative position over time using odometry. in this case, it uses wheel encoders to count the number of rotations each wheel makes as it drives and from that it estimates how far it has gone and how it has turned since its last known position.
so, the question is, how can we use these sensors to understand what the environment map looks like and figure out the robot’s pose over time? well, let’s start with a simple mapping problem.
here, i’ve placed the robot in a rectangular room with a circular obstacle in the corner. we can see this map and see where the robot it, but it has no idea of either. to it, it’s just in an unknown void. let’s start with a very ideal situation, one in which there is no uncertainty or errors in the lidar or odometry measurements, they’re just perfect. in this situation, developing a map of the environment is relatively trivial. the robot could take a lidar measurement and we’d have confidence that what it measured is the real obstacle location. it could save that off in a global map and continue on. after driving some distance, which again we know precisely because of the perfect odometry, it takes another measurement. the two measurements will align nicely in the global map since there are no errors in our system and in this way we can drive all around the environment and create a perfect map, all while knowing exactly where we are at all times.
of course, this scenario isn’t realistic. there is error in both the lidar measurement and the odometry and so there is some uncertainty in the estimated robot pose and in the distances to the measured obstacles. so, let’s try mapping this room one more time, but this time we’ll say the lidar is still pretty accurate, but there is a large uncertainty in the odometry measurements. maybe one of the wheels keeps slipping so the robot thinks it’s moving in a different direction than it actually is.
so, let’s see how this works out for our robot. we get an initial lidar measurement, and we assume that there is an obstacle there, just like before, and then we drive a bit. except, this time, the estimated pose is different than the real pose. so, the lidar returns some relative distances to the wall that the real robot sees, but we can only assume it is relative to the estimated robot pose since that is all we know.
this places the two measured obstacles in different frames and not a global environment frame and so they don’t line up. if we continue this process as we drive the robot around the room, the error in odometry causes our estimated pose to deviate more from the real pose and what we’re left with in the end, is this map of obstacles that don’t resemble the real environment. so, this is one of the reasons why we can’t just take measurements of the environment and stick the results into a map. uncertainty in our system is going to mess it up. but this is where slam algorithms can help us.
now, there are several different ways to approach solving the slam problem. as i said at the beginning, in this video we’re going to focus on pose graph optimization. i want to provide a little intuition behind the algorithm and give you a feeling for how it works without a bunch of math, but if you want to learn more about the mathematics, i’ve left some great resources in the description that go through it in detail.
just like before, we have our real and estimated robot poses, which at the beginning lie right on top of each other in the real environment map. but now, on the right, there is also this blank area. and this is where we are going to build up the pose graph.
the first thing our robot does is take a measurement of the environment. this measurement is associated with the current estimated robot pose and we can add both to the pose graph. so, essentially what we’re doing is saying that this pose is defined as an x and y location and a rotation angle and along with it we save off the the distances and angles to the sensed obstacles. now, there is is also uncertainties associated with this pose entry, but i'll get to that in a second.
alright, we have our first entry in the post graph, let’s get the second. again, the robot drives for a little bit and our estimated pose starts to deviate from the real pose. another measurement of the environment, which gets associated with the new estimated pose and this combination is now saved in the pose graph.
so, we have two poses, each with their own local estimate of where the obstacles are. and even though we don’t know where these two poses are in the environment, we do have an idea of about how far apart they are from each other. in our case, this came from counting the wheel rotations, but the idea behind this slam algorithm isn’t tied to a specific set of sensors. the relative pose distances could have come from another internal measurement source like an imu, or we could have figured out how far the robot moved from other external sources like gps or visible odometry. the point is that we have some best guess as to how far these two poses are from each other, as well as a measure of how confident we are in that guess.
in this way, there is a constraint that we can place on the relative distance between these two poses. ideally, they would stay exactly this far apart, since that’s our best estimate, but due to our uncertainty in the odometry process, maybe we’d be better off if we moved these two poses around relative to each other. for example, it would be nice if there was a mechanism that would be able move the two poses around to align the currently misaligned obstacles. well, there is! and the constraints are the key to doing so.
now, to visualize a constraint, i think it’s helpful to imagine a rubber bar connecting the two poses. the nominal length of the bar is how far apart we estimate them to be. with no external forces on these poses, the bar will just keep them at this fixed distance. however, if i hold one pose fixed and move the other pose closer to or further from it, it will compress or stretch the rubber bar and there will be a force that wants to restore the poses back to their nominal distance. the strength of the rubber bar depends on how confident we are in the distance estimate. if we have more confidence, or we have a really good odometry process, then this is a really strong bar that makes it difficult to change this nominal distance. if we have almost no confidence, then this rubber bar is very weak and provides almost no restoring force.
so, in pose graph nomenclature, we’d say the poses are the nodes of the graph and the constraint, or the rubber bar, is an edge. of course, this constraint acts in all three pose dimensions, both x and y, and in rotation, always trying to bring it back to its estimated distance. alright, there’s not much we can do with two nodes and one edge, so let’s keep going.
just like before, the robot keeps driving along and measuring the environment. and after a measurement we can take the estimated pose, along with its measurement of the local obstacles, and place it in our pose graph and add a constraint. so now we have three nodes and two edges. and we can continue this, filling out our pose graph one pose at a time until we have something that looks like the incorrect map that we built earlier, with the exception that there are constraints connecting all of the poses.
now, we still can’t do much with this information, because you can imagine that all of the bars are at their nominal length and everything wants to stay right where it is. however, we’re at a point where something interesting can happen. our first pose and the current pose are both observing the same feature in the environment. this means that we can build a new edge, a new constraint between these two nodes. we just need to understand how these two features align to figure out where the two poses have to be relative to each other. and, in this example, they would have to be in the exact same location.
so, now we can add a new constraint that connects the first and last poses and closes the loop. this bar has a nominal length of 0, since these two poses want to be right on top of each other. and the strength of this rubber bar depends on how confident you are in your external measurements and your ability to associate the two sets of data as the same feature. if you’re really confident, like we are in this example, this bar is extremely strong, it really wants to pull these two poses together.
so, hopefully you can start to see that a loop closure is the thing that makes all of this work. without a closure, all of the constraints were just happily being met. but with a loop closure, we have a way to inject tension into this graph. the blue bar wants to pull these two nodes together and the purple bars all want to keep the relative distances the way they are. allowing this graph to settle to equilibrium, or to balance all of the forces that each of the constraints are imposing is the optimization part of pose graph optimization.
and what’s really cool about this is that by optimizing the pose graph, not only do we have a better estimate of the current pose and a better model of the environment, but we also have a better estimate of where the robot was in the past, since all of the past poses were updated as well. so, we got a lot of value from this one loop closure. of course, we don’t have a perfect model of the environment, or the robots poses, but that’s ok because we can continue to improve our estimate by making more loop closures.
the robot can continue to drive, adding new poses from odometry, and new loop closures whenever it’s able to determine a relationship using external data. for this example, let’s assume we were able to relate these three poses together even though this area of the room is relatively featureless.
at this point, all of the previous constraints are the same as they were before, and until we added these loop closures the graph was in equilibrium. but now that we’ve added new loop closures, this has created more tension, which wants tugs and pushes on all of the poses a little bit more, and so we need to rerun the optimization again and allow the graph to re-settle.
in this way, you can see how after each loop closure the graph will continue to improve its global model of the environment and the past robots poses.
that is, as long as the two poses that you connect are truly looking at the same environment feature. if you make an incorrect association, and you build an edge with a constraint that is not real, you can imagine how that would persists in your graph and continue to skew your optimization process every time you run it. it would always be pulling those nodes in a direction away from truth. so, it is incredibly important that you are confident in any loop closures that you make. in fact, it is better to miss a real loop closure than it is to add a false one. you can always drive around some more and make another closure in the future, it’s harder to remove the bad ones once they’re in.
now, it’s important to note that a loop closure requires an absolute measurement of the environment, like we got with lidar, or you could get with a visible camera, or some other environment sensor. you can’t close the loop using a relative sensor like an imu or the wheel encoders because there is no way to relate that information back to an older pose. you may think you’re near a past node, but without checking the environment you can’t know for sure.
ok, so we have our pose graph and we’ve optimized it, now how do we build a map of the environment from all of these data points? well, there’s several different ways to represent an environment model but i’m going to quickly introduce the binary occupancy grid. the idea behind it is that the environment is broken up into a grid of cells. if you believe the cell it occupied, you set the value to a 1, and not occupied you set it to a 0. here’s i’m assuming the entire environment is empty, and filling in the cells where i believe there is an obstacle. you could also assume the opposite, where the cells are all occupied and you set them to a zero when your sensor indicates that there’s nothing there. you can see that with just 1’s and 0’s i we’ve generated a pretty accurate model of the rectangular room and part of the circular obstacle. there are some holes and we can fill them in by driving around more, but overall it looks ok.
now, there are also probabilistic occupancy grids where the cell doesn’t have to be fully occupied or not and instead there is a probability that it’s occupied between 0 and 1. with this model, you have full confidence in black and white cells and everywhere else is some shade of gray depending on your uncertainty.
and there we have it, slam using pose graph optimization. hopefully now you can see how a map of the environment and the pose of the robot can be determined simultaneously with this method. and now that we have an occupancy grid map, we can start the process of planning a future trajectory through this environment. the robot no longer has to wander around aimlessly, but can use this map to plan where it wants to go. and we’re going to cover some ways to approach planning in the next video.
but, before i end this one, i want to remind you that a great way to learn this stuff is to just practice it and try it out on your own. there is a matlab example that uses the navigation toolbox called implement slam with lidar scans that builds up an occupancy grid map of an environment using just lidar, no relative odometry process required. essentially, the environment has enough unique features in it that the lidar measurement of every pose can be related back to other past poses just through data association - or feature matching. it’s worth checking out and playing around with. i’ve linked to another video below that walks through this exact example if you want more information on it.
ok, that’s where i’ll end this video. if you don’t want to miss any other future tech talk videos don’t forget to subscribe to this channel. and you want to check out my channel, control system lectures, i cover more control theory topics there as well. thanks watching, and i’ll see you next time.
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 mathworks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- (español)
- (english)
- (english)
欧洲
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
亚太
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)