You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -269,7 +269,7 @@ So how do you use ROS? Learning ROS (and robotics programming in general) takes
269
269
### ROS System Diagram
270
270
Here's a simple diagram of three ROSnodes talking to each other. This is the generic way most robotics developers look at robotics systems.
271
271
272
-
![]()
272
+

273
273
274
274
### ROS Node
275
275
A process that is running instances of ROS objects is called a ROSnode. What this means is, as long as your code has ROS objects that listen/publish data to the network, then it is considered a ROSnode. You can think of ROSnodes as the building blocks of a robotics system.
@@ -297,7 +297,7 @@ In the warmup, we made you write a simple publisher. Please use the warmup code
297
297
### The Sky's the Limit
298
298
A robotics system can be composed of a bunch of different ROSnodes communcating in a bunch of different ways. In fact, a ROSnode can consist of multiple publishers and subscribers. You just need to be careful of the concurrency between them.
299
299
300
-
![]()
300
+

301
301
302
302
Unfortunately, the only way to truly understand ROS is to read their docs and use it. If you have any questions when programming ROS, please ask them in our Discord.
303
303
@@ -374,7 +374,7 @@ From before, you know that this robot will need the following high-level modules
374
374
### A Simple Navigation Architecture
375
375
Below is a diagram of a simple navigation architecture that can be used to help the robot navigate from point A to point B.
376
376
377
-
![]()
377
+

378
378
379
379
Here is a description of each node:
380
380
-**Costmap:** A ROSnode that takes in LaserScans from the `/lidar` topic, and converts them into a costmap. This is a discretized grid of squares that represent the chances as object exists in that grid with an arbitrary score.
@@ -859,6 +859,7 @@ private:
859
859
> - 1 Subscriber that subscribes to the '/path' topic for [nav_msgs::msg::Path](https://docs.ros.org/en/lunar/api/nav_msgs/html/msg/Path.html) messages
860
860
> - 1 Subscriber that subscribes to the '/odom/filtered' topic for [nav_msgs::msg::Odometry](https://docs.ros.org/en/noetic/api/nav_msgs/html/msg/Odometry.html) messages
861
861
> - 1 Publisher that publishes [geometry_msgs::msg::Twist](https://docs.ros.org/en/lunar/api/geometry_msgs/html/msg/Twist.html) messages to a '/costmap' topic
862
+
> - 1 Timer to follow a stored path
862
863
863
864
![]()
864
865
@@ -880,130 +881,152 @@ The lookahead distance controls how far ahead the target point is chosen. A larg
880
881
881
882
You can read more about Pure Pursuit [here](https://www.mathworks.com/help/nav/ug/pure-pursuit-controller.html).
882
883
883
-
---
884
-
885
-
#### **Node Behavior**
886
-
887
-
The control node continuously tracks the robot's position relative to the path and calculates how the robot should move to reach the next "lookahead point." The Pure Pursuit algorithm determines the steering curvature needed to bring the robot closer to this point, ensuring smooth and dynamic path tracking.
888
-
889
-
#### **Core Functionalities**
884
+
#### **Node Behavior and Design**
890
885
891
-
1. **Path Tracking**:
892
-
- Subscribes to `/path` (`nav_msgs::msg::Path`) for the global path generated by the planner.
893
-
- Selects a "lookahead point" on the path that lies a fixed distance ahead of the robot.
886
+
The Pure Pursuit Controller node is responsible for taking a path and odometry data as inputs and generating velocity commands to guide the robot along the path. The node operates in a closed-loop fashion: it continuously checks the robot's current position, calculates the desired heading based on the "lookahead point," and generates appropriate linear and angular velocity commands.
894
887
895
-
2. **Robot Pose Tracking**:
896
-
- Subscribes to `/odom/filtered` (`nav_msgs::msg::Odometry`) to get the robot's current position and orientation.
888
+
The node subscribes to:
889
+
- **`/path`**: Receives the global path as a series of waypoints.
890
+
- **`/odom/filtered`**: Tracks the robot's current position and orientation.
897
891
898
-
3. **Twist Calculation**:
899
-
- Computes linear and angular velocities:
900
-
- Linear velocity is proportional to the distance to the lookahead point.
901
-
- Angular velocity is determined based on the curvature required to reach the lookahead point.
902
-
- Publishes the velocity commands as a `geometry_msgs::msg::Twist` message to the `/cmd_vel` topic.
892
+
The node publishes:
893
+
- **`/cmd_vel`**: Outputs velocity commands in the form of linear and angular velocities.
903
894
904
-
4. **Dynamic Behavior**:
905
-
- Continuously updates the lookahead point and recalculates velocities as the robot moves.
895
+
Additionally, the node employs a timer to ensure regular updates of the velocity commands.
906
896
907
897
---
908
898
909
-
#### **Key Pure Pursuit Components**
899
+
#### **Key Functionalities**
900
+
901
+
1. **Path Tracking**:
902
+
- Extract the current lookahead point from the path based on the robot’s position and a fixed lookahead distance.
903
+
- Compute the steering angle required to reach the lookahead point.
910
904
911
-
- **Lookahead Point**: A target point chosen on the path at a fixed distance ahead of the robot.
912
-
- **Steering Angle**: Computed based on the curvature of the circular arc connecting the robot to the lookahead point.
913
-
- **Curvature**: Determines the angular velocity needed to follow the circular arc.
905
+
2. **Velocity Commands**:
906
+
- Calculate linear and angular velocities using the steering angle and the robot’s dynamics.
914
907
915
-
The steering curvature is calculated as:
916
-
```math
917
-
\kappa = \frac{2 \cdot y}{L_d^2}
918
-
```
919
-
- y: Lateral error (perpendicular distance to the lookahead point).
920
-
- L_d: Lookahead distance.
908
+
3. **Error Handling**:
909
+
- Handle edge cases like when the path is empty or the robot is close to the final goal.
921
910
922
-
The angular velocity is then:
923
-
```math
924
-
\omega = v \cdot \kappa
925
-
```
926
-
- v: Linear velocity (proportional to L_d).
911
+
4. **Timer for Updates**:
912
+
- The node updates the velocity commands at a fixed rate (e.g., 10 Hz) for smooth and consistent control.
927
913
928
914
---
929
915
930
-
#### **Pseudo-ROS Node Implementation**
916
+
#### **PseudoROS Code Example**
931
917
932
918
```cpp
933
-
classControlNode : publicrclcpp::Node {
919
+
#include <rclcpp/rclcpp.hpp>
920
+
#include <nav_msgs/msg/path.hpp>
921
+
#include <nav_msgs/msg/odometry.hpp>
922
+
#include <geometry_msgs/msg/twist.hpp>
923
+
#include <cmath>
924
+
#include <optional>
925
+
926
+
class PurePursuitController : public rclcpp::Node {
auto node = std::make_shared<PurePursuitController>();
1011
+
rclcpp::spin(node);
1012
+
rclcpp::shutdown();
1013
+
return 0;
1014
+
}
998
1015
```
999
1016
1000
1017
---
1001
1018
1002
1019
#### **Key Details**
1003
-
1. **Dynamic Path Tracking**: Continuously adjusts to changes in the path and robot's position.
1004
-
2. **Smooth Control**: The Pure Pursuit algorithm ensures smooth motion by steering toward the lookahead point.
1005
-
3. **Lookahead Distance**: A tunable parameter that balances tracking accuracy and smoothness.
1006
-
4. **Twist Output**: Publishes both linear and angular velocities, which can be consumed by the robot's hardware abstraction layer (in our case, our simulation).
1020
+
1021
+
-**Lookahead Distance**: The controller selects a point on the path at a fixed distance ahead of the robot. This distance must be tuned for the robot's dynamics and desired path-following performance.
1022
+
1023
+
-**Linear Speed**: The robot’s speed is typically kept constant, while the angular velocity adjusts based on the curvature.
1024
+
1025
+
-**Edge Cases**: Ensure the node handles scenarios like an empty path or reaching the final goal. You can stop the robot when the goal is within the `goal_tolerance`.
1026
+
1027
+
-**Yaw Calculation**: Converting the robot’s quaternion orientation to yaw is essential for computing the steering angle.
1028
+
1029
+
This implementation provides a simple yet effective way to integrate Pure Pursuit Control in ROS for smooth path following.
1007
1030
1008
1031
## Helpful Tips
1009
1032
- You never need to run `colcon build` because our monorepo infrastructure runs it automatically whenever you run `./watod build`. A good amount of ROS packaging and Launchfiles has also been abstracted away from you. This was deliberate in order to make your experience with the assignment as "code-heavy" as possible.
0 commit comments