Mobile Robot Control 2024 Optimus Prime: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
Tag: 2017 source edit
Tags: Manual revert 2017 source edit
Line 66: Line 66:
# '''Converting the body fixed frame into global coordinates''' To implement this the transformedOdometry() function was created which was used to convert the odometry data of the robot into the global coordinate system.
# '''Converting the body fixed frame into global coordinates''' To implement this the transformedOdometry() function was created which was used to convert the odometry data of the robot into the global coordinate system.
# '''Normalizing the angle''' The normalize_angle() function ensures that any given angle is mapped to an equivalent angle within the standard range of −π to π radians. This is useful because angles can be represented in multiple ways (e.g., 3π is the same as π), and having a consistent representation simplifies many calculations and comparisons.
# '''Normalizing the angle''' The normalize_angle() function ensures that any given angle is mapped to an equivalent angle within the standard range of −π to π radians. This is useful because angles can be represented in multiple ways (e.g., 3π is the same as π), and having a consistent representation simplifies many calculations and comparisons.
# '''Calculating attractive forces'''<nowiki> The attraction_force() function calculates a linear attractive force towards a target position. This force is proportional to the distance between the current position and the target position, scaled by an attraction coefficient.
# '''Calculating attractive forces''' The attraction_force() function calculates a linear attractive force towards a target position. This force is proportional to the distance between the current position and the target position, scaled by an attraction coefficient.
# '''Calculating repulsive forces''' The repulsion_force() function calculates a repulsive force that acts to push a point (or robot) away from an obstacle when it gets too close. The force is designed to be strong when the point is very close to the obstacle and diminishes as the point moves away, ensuring safe navigation around obstacles.
# '''Calculating repulsive forces''' The repulsion_force() function calculates a repulsive force that acts to push a point (or robot) away from an obstacle when it gets too close. The force is designed to be strong when the point is very close to the obstacle and diminishes as the point moves away, ensuring safe navigation around obstacles.



Revision as of 18:44, 6 June 2024

Introduction

We are Optimus Prime, a team of six members applying various control techniques and coding skills to optimize a robot for restaurant environments. Our goal is to enable the robot to efficiently deliver orders from the kitchen to the tables, even when faced with various obstacles. This project focuses on ensuring precise and reliable performance, ultimately improving service efficiency and the overall dining experience.

Group Members

Caption
Name student ID
Yuvan Dwaraga 1563793
Wiktor Bocian 1628798
Ramakrishnan Rajasekar 1979027
Ariyanayag Ramesh Skandan 2012618
Abhir Adiverekar 1984136
Suryakumar Hariharan 1974076

Exercise 1 - The art of not crashing

This exercise aims to enhance our understanding of control techniques and obstacle avoidance algorithms.

Simulation of the robot moving

Solution 1

The odometry and laser data were obtained based on the instructions from the manual, enabling the robot to be aware of its surroundings. Although this sensor data does not provide instructions for the robot to stop or go when an obstacle is on its way, a discussion was held to include a constant safe distance value, which ensures that the robot maintains a safe distance from obstacles and avoids collisions. Loops were also introduced as the robot operates to check whether the obstacles are close to the robot or not. Specifically, if an obstacle is detected within a certain range less than the predefined safe distance (0.5 meters) the robot will come to a halt. This algorithm ensures that the robot can navigate in its surroundings safely.

Solution 2

Advancements to the previous solution were made by introducing rotation values and forward motion values to enhance the robot's performance. These values were effective when the obstacle was too close to the robot. The stoppage of the robot comes into play and the rotation values allow it to rotate with movement restriction and later it allows the robot to move in the forward direction with constant units. This approach ensures that the robot not only stops to avoid immediate collisions but also actively seeks a safe route forward. Overall, the combination of a constant safe distance, rotation and forward actions allows the robot to perform more efficiently.

Simulation of the robot movement in x direction

Learnings from solution

The robot's performance in this case was evidenced in both simulation and practical sessions. Alterations in the code were made so that, in case of obstacle detection, the robot was made to move in the x direction in adherence to the safe distance.

Visual representation of sim

https://youtu.be/Q3MBRWl5mNM

Practical session

The live testing of the don't crash test can be evidenced by accessing the link https://youtu.be/QnT6EBChmf4




Exercise 2 - Local navigation

Artificial potential fields

Motivation

Choosing the artificial potential field (APF) method for the local navigation of a robot comes with several compelling motivations:

  1. Simplicity and intuitiveness: The APF approach is reasonably easy to grasp and apply. It mimics the environment using attractive and repulsive forces that naturally direct the robot to its destination while avoiding obstacles.
  2. Continuous and smooth path generation: This approach creates smooth and continuous tracks for the robot without any jerks. Because the forces are computed as gradients of potential fields, the resulting motion is smooth, avoiding the possibility of sudden changes in direction that would be difficult for the robot to perform.
  3. Scalability: APF is easily adaptable to many types and sizes of settings (environment). The approach may be adjusted to a variety of circumstances by modifying the potential field parameters, ranging from basic inside navigation to more difficult outdoor settings.
  4. Combination with Other Methods: APF may be utilized effectively with other navigation systems. For example, it may be used for local navigation inside a larger framework that handles global path planning, integrating the benefits of several frameworks.
  5. Computation time: This method is much less computationally intensive than other ones.

Solutions

  1. Converting the body fixed frame into global coordinates To implement this the transformedOdometry() function was created which was used to convert the odometry data of the robot into the global coordinate system.
  2. Normalizing the angle The normalize_angle() function ensures that any given angle is mapped to an equivalent angle within the standard range of −π to π radians. This is useful because angles can be represented in multiple ways (e.g., 3π is the same as π), and having a consistent representation simplifies many calculations and comparisons.
  3. Calculating attractive forces The attraction_force() function calculates a linear attractive force towards a target position. This force is proportional to the distance between the current position and the target position, scaled by an attraction coefficient.
  4. Calculating repulsive forces The repulsion_force() function calculates a repulsive force that acts to push a point (or robot) away from an obstacle when it gets too close. The force is designed to be strong when the point is very close to the obstacle and diminishes as the point moves away, ensuring safe navigation around obstacles.

Learnings from each solution

While the artificial potential field (APF) approach has significant benefits for robot navigation, it also has certain drawbacks, such as the possibility of being caught in local minima or oscillations. To address these concerns, many fixes and improvements to the APF approach have been proposed:


Gradient Descent with Escape Strategies: One typical problem with APF is getting stuck in local minima when the attractive and repulsive forces cancel out.

Solution: Random Walks or Perturbations - By introducing small random movements or perturbations, the robot can escape local minima. To come out of the local minima random perturbations were added in the APF algorithm and it was successful at the end.


Combination with Global Path Planning: Integrating APF with a global path planning algorithm can provide a more comprehensive navigation solution.

Solution: Hybrid Approaches - Finding a rough path with a global planner such as A* or Dijkstra's algorithm, and then using APF for local navigation to fine-tune the path and avoid obstacles.

Testing and tuning

Initially, the robot was not given a maximum velocity that it can achieve using artificial potential fields. This worked in simulation well with the robot getting to the end position with a smooth trajectory. However, when testing in practice this proved to be insufficient since the robot always just drove into obstacles. To avoid that and make sure the robot has enough time to react extra guard for the maximum linear velocity of the robot was added. This method led to less smooth trajectories however it ensured that both in simulation and in practice it did not hit the obstacle.

Furthermore, when testing different gains for the APF it was found that for some maps it was stuck in the local minima. This is typical for this method, however, to check if still the end could be achieved with it all of the map parameters were tuned (attractive gains and repulsive gains) for each map and after implementing this strategy the robot was able to function properly for each map efficiently.

Visual representation of sim

  1. Map 1 - https://www.youtube.com/watch?v=PWZg0-T9-U8
  2. Map 2 - https://www.youtube.com/watch?v=E6Xz24zsPdE
  3. Map 3 - https://www.youtube.com/watch?v=ZnRjnttkkrE
  4. Map 4 - https://www.youtube.com/watch?v=ERdRPLcliLk

For the first three simulations, the parameters were the same, but for the fourth simulation, the parameters were a bit different.

Practical video

  1. Map 1-https://youtube.com/shorts/2iPmLHOHZgY?feature=share
  2. Map 2-https://youtube.com/shorts/V9yEWU9jpt0?feature=share
  3. Map 3-https://youtube.com/shorts/jpvrOMJoCuI?feature=share
  4. Map 4-https://youtu.be/s8pXRdhEtTc
  5. Map 3 with a dynamic moving obstacle (most recent) -

Dynamic window approach

Motivation

Our motivation for choosing the Dynamic Window Approach (DWA) algorithm is that it is one of the most ideal algorithms for the local navigation of Mobile Robot Controllers (MRC). DWA strikes a balance between robust obstacle avoidance and efficient navigation. It generates control commands in real time, which is crucial for dynamic environments. Additionally, it considers the robot's kinematic and dynamic constraints, ensuring that the paths are feasible. The algorithm effectively navigates around obstacles while moving towards its goal, maintaining both precise and responsive movement.

Solutions

  1. To convert the robot odometry data from the body-fixed frame to the global coordinate system transformOdometry() function helps in maintaining the robot's current position and orientation in the global frame, which is essential for planning and executing paths.
  2. normalize_angle() Normalizes any given angle to the range of -pi to pi radians.

the distance between two points in the 2D space, length() function calculates Measures distances for obstacle avoidance and goal-reaching computations.

  1. generateAllPossibleVels() Generates a list of possible velocities within specified minimum and maximum bounds. Provides a range of velocity options to evaluate for the best possible path.
  2. SaveXYCoordinatesObstacle() Converts laser scan data to global coordinates of obstacles and helps in identifying the position of obstacles relative to the robot for collision avoidance.
  3. the robot's future position based on its current state and a given time step, we also use this function to predict future positions and evaluate possible trajectories and their feasibility using the NextPose() function.
  4. CalcClosestDistObstacle() Computes the distance to the closest obstacle for a given trajectory and the safety of each potential path by measuring how close the robot will come to obstacles.
  5. the angular error between the robot's future position (next iteration) and the target goal is done in calcAngleError().

How These Functions Help DWA Coding

  • Localization and Coordination: Functions like transformOdometry and normalize_angle ensure the robot accurately knows its position and orientation.
  • Path Planning: Functions such as NextPose and CalcClosestDistObstacle are crucial for evaluating possible trajectories and avoiding collisions.
  • Trajectory Evaluation: The generateAllPossibleVels and BestVels functions generate and select the best possible velocities, ensuring safe and efficient navigation.
  • Obstacle Avoidance: SaveXYCoordinatesObstacle and CalcClosestDistObstacle help in mapping obstacles and ensuring that the robot does not collide with them.
  • Goal Alignment: The calcAngleError function ensures that the robot's trajectory is aligned with its goal, improving navigation efficiency.


Learnings from each solution

  1. While the Dynamic Window Approach (DWA) is effective for robot navigation, it also faces certain challenges. Here are three common problems that were faced during Implementation:
  2. Local Minima: DWA can get stuck in local minima, particularly in complex environments where optimal paths are not available we introduced recovery behaviours such as random perturbations or backtracking. Combine DWA with global path planning algorithms to guide the robot out of local minima.
  3. Handling Dynamic Obstacles: DWA may struggle with many obstacles within a small space and recalculations that can be computationally demanding we tried implementing predictive modelling for dynamic obstacles, allowing the algorithm to anticipate and react to future positions of obstacles.
  4. Parameter Tuning: DWA performance heavily depends on parameter tuning, such as velocity bounds and acceleration limits we tried implementing adaptive tuning techniques that adjust parameters dynamically based on the robot's position.

Visual representation of sim

  1. Map 1-
  2. Map 2-https://youtu.be/pB4MbaJzdcg
  3. Map 3-
  4. Map 4-

Practical video

  1. Map 1-https://youtube.com/shorts/-xgMeAtbdBQ?feature=share
  2. Map 2-https://youtube.com/shorts/nsv2eGVvw7o?feature=share
  3. Map 3-https://youtube.com/shorts/1eL7xdEf0vs?feature=share
  4. Map 4-

Assignment questions - Rough draft

  1. What are the advantages and disadvantages of your solutions?
    1. Artificial Potential fields:
      • Advantages
        1. Simplicity: The APF approach is straightforward to implement and understand. It uses simple mathematical functions to represent attractive forces towards the goal and repulsive forces away from obstacles.
        2. Real-time Computation: APF algorithms are computationally efficient, making them suitable for real-time applications. The computations involved are minimal and can be handled by most modern processors with ease.
        3. Scalability: APF methods can be scaled to handle different sizes and types of robots without significant modifications to the algorithm.
      • Disadvantage
        1. Local Minima Problem: One of the significant drawbacks of APF methods is the local minima problem, where the robot can get stuck in a position that is not the goal due to equal attractive and repulsive forces cancelling each other out.
        2. Inability to Handle Complex Environments: APF methods may struggle with complex environments with narrow passages or multiple closely spaced obstacles, leading to suboptimal or infeasible paths.
        3. Parameter Tuning: The performance of APF methods heavily depends on the tuning of parameters such as the strength of attractive and repulsive forces. Improper tuning can lead to inefficient navigation or failure to reach the goal.
    2. Dynamic Window Approach:
      • Advantages
        1. Dynamic Feasibility: DWA accounts for the robot's dynamic constraints (like velocity and acceleration) ensuring that the generated paths are feasible and safe for the robot to follow.
        2. Collision Avoidance: The algorithm effectively avoids collisions by evaluating possible trajectories within a feasible velocity window.
        3. Real-time Feedback: DWA computes in real-time, making it suitable for applications where the robot needs to react quickly to changing environments.
        4. Smooth Path Generation: It generates smooth and continuous paths, which are essential for the stable and efficient movement of robots.
      • Disadvantages
        1. Computational Load: DWA evaluates numerous possible trajectories within each window, which can become computationally intensive, especially in environments with many obstacles.
        2. Local Minima Problem: Like APF, DWA can get stuck in local minima, particularly in complex environments where optimal paths are hard to find.
        3. Handling Dynamic Obstacles: DWA adapts to dynamic environments but may struggle with fast-moving obstacles, requiring frequent recalculations that can be computationally expensive
  2. What are possible scenarios which can result in failures (crashes, movements in the wrong direction, ...) for each implementation? For example, set the target position in an obstacle and let the robot try to get to the target; what happens? Try to think of more examples yourself!
    1. Artificial Potential Fields:
      • Crash
        1. If the target position is set inside an obstacle - The robot collides with the obstacle repeatedly as it tries to get as close as possible to the goal.
        2. Not initializing the maximum velocity - The robot follows the path and once it detects the obstacles, it droves into the obstacle and crashes.
        3. Less repulsive force - The robot is confused with the less repulsive force and safe distance ultimately crashing into obstacles
      • Movement in the wrong direction
        1. Poor tuning of the values - The robot makes an oscillatory behaviour by moving back and forth between obstacles and is unable to make a decision.
      • Repeated movement
        1. Local minima - The robot gets trapped in a local minimum where the attractive and repulsive forces balance out to zero. It makes a constant circular movement wasting energy.
    2. Dynamic Window Approach:
      • Crash
        1. If the target position is set inside an obstacle - The robot collides with the obstacle repeatedly as it tries to get as close as possible to the goal.
        2. Moving obstacles - The robot fails to avoid fast-moving dynamic obstacles effectively, especially if the other entities are moving unpredictably, leading to a crash.
      • No movement
        1. Dead end - The robot encounters a narrow passage that is difficult to navigate due to its velocity and acceleration constraints. The DWA may fail to find a feasible velocity that fits through the narrow opening, causing the robot to get stuck.
  3. How would you prevent these scenarios from happening?
    1. Artificial Potential Fields:
      • Crash
        1. Target position and obstacle - Use a map of the environment to ensure the target is in a free space and not inside an obstacle.
        2. Maximum velocity -Always initialize and cap the robot's maximum velocity based on the environment's characteristics and the robot's specifications. Implement obstacle detection and dynamic re-planning to slow down or stop when obstacles are detected.
        3. Repulsive force - Adjust the repulsive force parameters through careful calibration so that the robot maintains a safe distance from obstacles without causing instability.
      • Movement in the wrong direction
        1. Tuning the values - Use a systematic approach to tune the attractive and repulsive parameters. Implement adaptive parameter tuning algorithms that adjust parameters in real time based on the robot's performance and the environment.
      • Repeated movement
        1. Local minima - - By introducing small random movements or perturbations, the robot can escape local minima.
    2. Dynamic Window Approach:
      • Crash
        1. Target position and obstacle - Using an occupancy grid or another mapping technique to validate goal positions before the robot starts moving towards them.
        2. Moving obstacles - Incorporate algorithms that can model and anticipate the trajectories of moving obstacles. This might include machine learning models or probabilistic approaches to predict future positions of dynamic obstacles and adjust the robot's path accordingly.
      • No movement
        1. Dead end - Improve the DWA by incorporating global path planning algorithms that can recognize dead ends and provide alternative routes. Additionally, enhances the local planning aspect of DWA to better handle narrow passages by fine-tuning velocity and acceleration constraints and implementing more sophisticated search techniques within the dynamic window.
  4. For the final challenge, you will have to link local and global navigation. The global planner will provide a list of (x, y) (or (x, y, θ)) positions to visit. How could these two algorithms be combined? (Implementing this will be part of next week's assignment.)
    • Hybrid Approaches - Combine APF and DWA with other navigation strategies. Use a global path planner like A* or Dijkstra's algorithm for long-term planning and APF or DWA for local, real-time adjustments. This can help mitigate the weaknesses of each method.

Exercise 3 - Global Path Planning

A* algorithm

A* algorithm is used to determine the shortest path from the start node to the goal node through the known network of nodes and their connections. It initializes the _nodelist() which contains all the nodes and the connection data generated by the PRM algorithm. During each iteration, the next node in the connection of the current node is chosen based on the minimum cost (f) to reach the goal. (i.e.) the sum of cost-to-come and cost-to-go (heuristic cost). This cost represents the absolute distance between the node being evaluated and the goal node. The algorithm iterates until the goal node is reached and all open nodes have been evaluated.

  • Node with minimum f

The node with a minimum f value from the list of open nodes is selected. The variable 'nodeID minimum f' is initialized to signify that no node has been identified yet. The 'minimum_f' variable is initialized to infinity assuming that the actual 'f' value will be from the nodes will be finite and lower when iteration starts. Subsequently, a for-loop iterates over all node IDs in the 'open nodes' container. For each node, it retrieves the 'f' value from the '_nodelist' vector storing nodes. If the 'f' value of the current node is less than the recorded minimum, 'minimum f' is updated with the new lower value and 'nodeID minimum f' will be set to the current node's ID.

  • Exploring the node connections

Exploration of node connections is iterating over nodes connected to the current node, verifying if they have already been evaluated (in the 'closed nodes' list). For each unprocessed adjacent node, it computes a new cost-to-come ('g') as the sum of the current node's 'g'(value) and the distance between both nodes. If this new 'g' is lower than the adjacent node's existing 'g', the node's 'g', heuristic estimate ('h'), and total cost ('f') are updated, and its parent is set to the current node. If the adjacent node isn't in the 'open nodes' list, it is added for subsequent evaluation. After processing all connections, the current node is moved to the 'closed nodes' list, marking it as evaluated. This ensures that the search focuses on the path with the optimal cost, efficiently guiding the search towards the goal.

  • Trace back the optimal path

The final step involves tracing back the optimal path, As soon as the goal node is reached the algorithm starts tracing the optimal path. It begins at the goal node and works backwards using the 'parent node ID' of each node, which points to the preceding node on the optimal path. In the loop, the current node ID is appended at the beginning of the 'path node IDs' list within a loop, constructing the path from start to goal. This backtracking persists until it reaches the start node, which is then added to the list. Once the path is fully identified, the list of node IDs is stored and the algorithm marks the path as successfully found. This ensures that the shortest path is clearly outlined and can be utilized by the respective local planner to navigate towards the goal while avoiding obstacles.

Inflated walls with dilation size equal to 1

Probabilistic Road Map (PRM)

To implement the path planning algorithm, a preliminary step involves generating a set of potential paths on the map that will be used to find an optimal path. The Probabilistic Roadmap Method (PRM) serves this purpose by generating connections between randomly positioned points on the map.

  • Wall inflation

In the process of wall inflation, the walls on the map are expanded to mitigate the risk of collision for the robot, which occupies more space than a point. This inflation is achieved through dilation on the map image. To do that, the map colours are first inverted since dilation works on white parts of the binary image. It is done by specifying the type and size of the Kernel that is used to check if there is a white point inside it and if there is such a point it changes the other ones inside the kernel to this color. For the desired implementation the square kernel is being used since all of the maps mostly consist of straight lines and the size of this kernel can be adjusted by changing the dilation size variable.

Inflated walls with dilation size equal to 2

After the dilation the map is transformed back to its initial color scheme and examples with different kernel sizes of such operation can be seen to the right.

  • Distance from other points

To ensure that points are distributed more evenly around the map the distance between the new vertex and all the previously created ones is being checked. This is done by checking the difference between the x and y coordinates is no smaller than 0.3 m. This ensures that each vertex has a square 0.3x0.3 m area around it of 0.3x0.3 m where there are no other vertices.

  • Check for valid edge

To see if the vertex is valid two checks are being done. First to ensure that only the vertices that are relatively close to each other are connected the distance between them is being checked. This is done by computing the absolute value of a difference between the x and y variables of 2 vertices and then taking a square root of a sum of those values squared, which allows us to compute the distance between them in a straight line.

The other check that is being performed is seeing if there is a wall between the two nodes. To do that a line between two points is created using Bresenham's algorithm. It creates all the points along the straight line between two vertices and is used to check if there is a black point along the path. If the line encounters the black point it is marked as invalid and the edge between the two points is not created. This algorithm works by first computing the difference between the x and y position on the line and its final destination. The difference in y is subtracted from the difference in x and doubled to always work on integers, this gives information on how far the generated line is from the ideal straight line between two points. Knowing that if this error is higher than the difference in the y coordinate means that the lines should be less horizontal and the y value needs to be adjusted and the same is done for the x coordinate.

Example

Example of the map created using the probabilistic roadmap

To test the algorithm the example map was used with several vertices equal to 70, and a dilation size equal to 2 which means that (5,5) square kernel was used for dilation and a maximum distance between two edges of 1 m was created and can be seen on the Figure.

Assignment questions

  1. How could finding the shortest path through the maze using the A* algorithm be made more efficient by placing the nodes differently? Sketch the small maze with the proposed nodes and the connections between them. Why would this be more efficient?
    • The way A* star works is it searches for the nodes in the graphs and checks for the nodes that can give the shortest path from the start node to the end goal. Firstly, reducing the number of nodes will help in using less storage space in node_lists() and as well as reducing the required computational power as the algorithm will have fewer nodes to evaluate. This can be done by placing the nodes strategically at places where there are junctions, ends or where paths diverge in the maze. This will surely enhance the efficiency of the A* algorithm by focusing on the nodes on key points.
  2. Would implementing PRM in a map like the maze be efficient?
    • Yes, using PRM can be more effective in the case where the maze is complex and has many obstacles to tackle. PRM uses sampling nodes which are more useful to find possible paths around the obstacles. On the contrary, it can be a disadvantage since it uses more storage and computational power to compute and find the minimal cost when it is not necessary to have several nodes in straight paths/passages it is more effective and logical to have nodes at key points.
  3. What would change if the map suddenly changes (e.g. the map gets updated)?
    • In the case of a map suddenly changes,
  4. How did you connect the local and global planner?
    • When seen conceptually, the local planner uses the global planner as an input or guide to reach a given goal from its starting point. Global planner uses PRM or the grid map algorithm to explore and plot the feasible nodes with connections between them throughout the map forming networks and potential paths and stores it. These are used by the A* algorithm to find the most optimal path by evaluating each node connection and the result is stored in a structured path_node_ID() list. Whereas the local planner retrieves this list from "planner.h". Then planner algorithm sets the initial node in the list as the target node and continuously updates its target node coordinates (Target_x, Target_y) to the next node in the list. This is updated when the robot reaches within a predefined safe distance of the current target node, as soon as the robot reaches the goal node (last item in the list) the target node updating loop is terminated.
  5. Test the combination of your local and global planner for a longer period on the real robot. What do you see that happens in terms of the calculated position of the robot? What is a way to solve this?
    • It was observed that the actual position of the robot was not exactly equal to what the odometry data shown. This could be due to the slip of wheels while turning and was observed more when angular velocity was high. For now, this slip can be avoided by lowering the angular velocity and avoiding jerks. Also, Localization will help to solve this issue by identifying the exact location of the robot in the environment.
  6. Run the A* algorithm using the grid map (with the provided node list) and using the PRM. What do you observe? Comment on the advantage of using PRM in an open space.

Exercise 4 - Localization

Questions and Answers

Assignment 0.1

1. How is the code structured?

2. What is the difference between the ParticleFilter and ParticleFilterBase classes, and how are they related to each other?

Particle filter inherits from the ParticlefilterBase class which gives it access to the members of PatricleFilterBase. In the ParticleFilterBase, the particles are initialized, and then their average positions are computed. It also uses the computeLikelihood() function that provides a weight for each of the LIDAR data points which is used to compute the average pose of the robot. While in the particleFilter, multiple resampling methods can be defined and used.

3. How are the ParticleFilter and Particle class related to each other?

The Particle class stores the properties of each particle separately, while in the ParticleFilter class, all particles are updated together.

4. Both the ParticleFilterBase and Particle classes implement a propagation method. What is the difference between the methods?

The ParticleFilter implements noise for each particle uniquely, and the ParticleFilterBase propagates all particles.

Assignment 0.2

The figure to the right depicts that all test cases are passed with the initial Localization code.

Assignment 1.1

What are the advantages/disadvantages of using the first constructor, what are the advantages/disadvantages of the second one?

The first constructor uses a uniform distribution for the position of each particle. But, the second one uses Gaussian distributions to do the same. With a good initial estimate, the Gaussian distribution provides more particles around the real position of the robot since more particles are distributed around the mean. In the case that a good estimate of the initial position is not present, it is better to use a uniform distribution approach.

Assignment 1.2

Interpret the resulting filter average. What does it resemble? Is the estimated robot pose correct? Why?

This gives the value close to the mean guess input to the Gaussian distribution. It is not correct since the initial guess is shifted relative to the actual position of the robot.


Imagine a case in which the filter average is inadequate for determining the robot's position.

If there are similar environmental features in a map that are present at either end, then the particles will be distributed near both these positions. But, this will lead to the average being in between the two features which completely does not resemble the true robot position. In this case, the two guesses will not be differentiable, hence the filter average method will not be adequate.

Assignment 1.3

Why do we need to inject noise into the propagation when the received odometry information already has an unknown noise component?

the sensor measurement is not accurate so we add noises to get more data and we compare it with the Gaussian distribution to get more sample data which has similar properties.


What happens when we stop here and do not incorporate a correction step?

If the correction step is not done, then the initially created particles propagate continuously which leads to multiple particles indicating positions that have a low likelihood that do not help with localization. This is computationally demanding even though it does not give reasonable approximations.

Assignment 2.1

In the measurement model all the components of measurement model are guarded by the max range, in reality, in both simulation and practical test it became apparent that lidar can give the value as infinity for the range and because of that the likelihood of the particle would be zero since we multiply with the likelihood with another particle, if one particle is out of range it will get the likelihood to out of range or as infinity. because of this, an if statement was added which checks the range value of each laser data, if it were higher than the max range this value was overwritten to the max range.


What does each of the components of the measurement model represent, and why is each necessary.

measurement model consists of 4 different models, one is responsible for Gaussian distribution, uniform distribution for the max range and uniform distribution throughout the exponential component.

Gaussian Distribution - this is used to check the probabilities of each hit from the robot to the surroundings without this it would be very hard to guess a map.


Exponential component - it is used to check for unexpected obstacles that are not part of the map


Uniform Distribution - it is for any unexpected hit in the whole range


Uniform Distribution for max range - it is used for the maximum or highest range possible by the lidar