This repository implements a learning-based mixed-strategy pursuit-evasion trajectory generation and demonstrates its feasibility using a physical micro-drone testbed, specifically the Crazyflie 2.1, utilizing the CrazySwarm 2 ROS package.
Aerial pursuit-evasion games pose significant challenges with applications ranging from anti-drone military operations to civilian missions like search and rescue. In these scenarios, agents must consider their adversary's potential strategies when determining their actions.
Traditionally, obtaining the optimal trajectories in real-time has not been feasible due to the mathematical complexity, even if highly approximated. However, the recent development in deep declarative networks provides a potential way to compute high-quality pursuit-evasion trajectories in real-time.
- Python 3.x
- PyTorch
- NumPy
- CvXpy
- ROS2
- Crazyflie 2.1 drones (or compatible models)
- Crazyradio PA dongles (or compatible communication interface)
- Vicon motion capture system (or compatible system)
- Clone this repository:
https://github.com/Avvienash/Mixed-Learning-Trajectory-Generation/upload/main
- Install dependencies:
pip install -r requirements.txt
-
Set up hardware: Ensure your Crazyflie drones and Vicon motion capture system are configured correctly. Refer to their respective documentation for specific instructions.
-
Make sure ROS2 is installed and running.
-
Install the Crazyflie 2 ROS2 package if not already present: CrazySwarm 2 Installation
-
Build ROS2 nodes: Navigate to your ROS2 workspace and build the nodes:
cd <your_ros2_workspace>
colcon build --symlink-install
- Run the physical test: In separate terminals:
- Launch Crazyflies
ros2 launch crazyflie launch.py
- Run Trajectory generator
ros2 run my_crazyflie_controller traj_gen
- Run Plotter
ros2 run my_crazyflie_controller plotter
- Run Agents (Pursuer and Evader)
ros2 run my_crazyflie_controller pursuer ros2 run my_crazyflie_controller evader
Note: Control drones manually or run recorded trajectories by using other ROS2 nodes from my_crazyflie_controller.
traj_gen
: Generates real-time trajectories for agents and publishes them.plotter
: Plots the position and trajectories of the agents in real-time.pursuer
: Sends commands to the pursuer Crazyflie based on the generated trajectory.evader
: Sends commands to the evader Crazyflie based on the generated trajectory.pursuer_sim
: Runs the pursuer in simulation and publishes the states.evader_sim
: Runs the evader in simulation and publishes the states.pursuer_marker
: Represents the pursuer as a MOCAP marker (User may move marker during the run).evader_marker
: Represents the evader as a MOCAP marker (User may move marker during the run).circler
: Flies the agent in a prerecorded circular path around the origin.figure8
: Flies the agent in a prerecorded figure 8 path around the origin (base test from Crazyswarm).land
: Returns agents to their starting position.
- Consider ethical and safety guidelines when operating drones in real-world environments. Refer to the risk assessment guidelines in media/documents/risk_assesnt.pdf.
- Adjust configuration files in config/ as needed for your specific environment.
- For simulation testing, refer to alternative instructions.
- Clone this repository:
git clone https://github.com/avvienash/pursuit-evasion-trajectory-gen.git
- Install dependencies:
pip install -r requirements.txt
- Run the test script:
python test_single_run.py
main.py
: This script defines the model and handles the training process.test_single_run.py
: It runs scenarios of pursuer vs. evader with either specified initial conditions or random ones.test_random_states.py
: This script runs multiple tests with random initial states and plots the results.test_grid.py
: It runs tests for each possible initial condition in the xy grid.
The implementation of the trajectory generation is shown in the figure above and explained in the steps below.
The trajectory generator starts by using the states of the pursuer and evader as input for a neural network. This network then produces a set of potential trajectories that are optimized to ensure feasibility.
The loss is calculated for all combinations of pursuer and evader trajectories, creating a Bimatrix Game. This game is solved to find the equilibrium point. The trajectory corresponding to this equilibrium point is chosen as the optimal trajectory.
We managed to implement this method on a physical testbed using micro-drones as the agents and a motion capture system to obtain the states. The environment was set up as per the original publication, a 2D dimensional pentagon Plane with a single pursuer and evader. We ran multiple tests and compared it to the original simulated results. In conclusion, we have successfully replicated the proposed method and demonstrated the feasibility on a physical testbed.
The tests, conducted in a 2D pentagon environment with a single pursuer versus a single evader, yielded the following outcomes:
freecompress-evader.mp4
freecompress-pursuer.mp4
freecompress-pursuer_evader_combined.mp4
In conclusion, this study successfully replicates and expands upon a method for learning mixed strategies in pursuit-evasion games with drone agents. Through the implementation using mini-drones, the proposed approach demonstrates its versatility and accuracy to the mathematical predictions.
Future plans include exploring different dynamic systems (e.g., Unicycle Dynamics, Bicycle Dynamics), exploring three-dimensional games, and multi-agent implementation and testing.
- Chung, Timothy H., Geoffrey A. Hollinger, and Volkan Isler. "Search and pursuit-evasion in mobile robotics: A survey." Autonomous robots 31 (2011): 299-316.
- Gould, Stephen, Richard Hartley, and Dylan Campbell. "Deep declarative networks." IEEE Transactions on Pattern Analysis and Machine Intelligence 44.8 (2021): 3988-4004.
- Peters, L., Ferranti, L., Stachniss, C., & Laine, F. (2022). Learning Mixed Strategies in Trajectory Games. ArXiv. /abs/2205.00291
Author: Avvienash Jaganathan