Author: Mohamed Elgouhary
Project: TSPC Controller for F1TENTH-style Autonomous Driving
This repository contains a ROS2 Python implementation of a trajectory-sampling / predictive-control style controller for F1TENTH-style autonomous driving.
The main controller combines:
- Raceline tracking
- Fan-of-trajectories candidate rollout
- LiDAR-reactive obstacle avoidance
- Gap-following-style steering and speed adjustment
- Ackermann drive command publishing
- RViz visualization markers for waypoints, reference trajectory, and candidate paths
tspc_controller/
├── tspc_controller/
│ ├── tspc_controller/
│ │ ├── __init__.py
│ │ ├── tspc_node.py
│ │ └── utils.py
│ ├── package.xml
│ ├── setup.py
│ └── resource/
│ └── tspc_controller
├── launch/
│ └── tspc.launch.py
├── config/
│ └── tspc_params.yaml
├── csv_data/
│ └── README.md
├── requirements.txt
├── .gitignore
└── README.md
-
tspc_controller/tspc_controller/tspc_node.pyMain ROS2 node for fan-of-trajectories predictive control with LiDAR-reactive gap analysis. -
tspc_controller/tspc_controller/utils.pyUtility functions for trajectory processing, including nearest-point search.
The node uses the following topics by default:
| Type | Topic |
|---|---|
| Odometry / Pose input | /ego_racecar/odom in simulation, /pf/viz/inferred_pose on real car |
| LiDAR input | /scan |
| Ackermann command output | /drive |
| Reference trajectory marker | /ref_traj_marker |
| Waypoints marker | /waypoints_marker |
| Candidate path markers | /pred_path_marker |
This project expects ROS2 with the following message packages:
rclpynav_msgssensor_msgsgeometry_msgsackermann_msgsvisualization_msgs
Python dependencies are listed in requirements.txt.
Clone the repository into the src folder of your ROS2 workspace:
cd ~/your_ros2_ws/src
git clone https://github.com/ICPS-LAB-WVU/Trajectory-Sampling-Predictive-Controller.git
cd ..
rosdep install --from-paths src --ignore-src -r -y
colcon build
source install/setup.bashReplace YOUR_USERNAME with your GitHub username.
Run the controller using the launch file:
ros2 launch tspc_controller tspc.launch.pyOr run the node directly:
ros2 run tspc_controller tspc_nodeThe controller expects raceline CSV files inside the csv_data/ folder.
The default map name in the code is:
Catalunya_fast
So the expected file is:
csv_data/Catalunya_fast.csv
Large raceline files, datasets, ROS bag files, and generated logs are not included by default.
The TSPC controller follows a raceline while also reacting to obstacles detected by LiDAR. Instead of solving a full optimization problem at every step, the controller generates a fan of candidate trajectories, evaluates them using tracking and safety costs, and selects the best candidate command.
The general pipeline is:
- Read the current vehicle pose and speed.
- Load the local reference trajectory from the raceline.
- Process LiDAR scans to detect free space and forward clearance.
- Generate candidate steering trajectories.
- Evaluate candidate trajectories for tracking quality and collision risk.
- Select the best trajectory.
- Publish an Ackermann drive command.
- Visualize waypoints, reference trajectory, and predicted candidate paths in RViz.
ros2
f1tenth
autonomous-driving
trajectory-sampling
predictive-control
mpc
gap-follow
lidar
ackermann
robotics
This repository is developed and maintained by:
Mohamed Elgouhary
PhD Student and Graduate Research Assistant
Lane Department of Computer Science and Electrical Engineering
West Virginia University
The main TSPC controller implementation in this repository was developed by Mohamed Elgouhary.
The utils.py file includes an MIT License header and credits the original authors listed in that file. Please keep that header if you modify or redistribute the file.
Add your preferred license for the full repository after confirming how you want to release your own controller code.
This repository is intended for research and development in F1TENTH-style autonomous racing and ROS2-based autonomous vehicle control. Before using the controller on a physical vehicle, carefully test it in simulation and verify all topic names, vehicle parameters, speed limits, steering limits, and safety behavior.