A comprehensive 2D robot path planning and simulation environment built with Python and Pygame. This interactive simulation allows you to plan robot trajectories, visualize paths, and simulate realistic robot movement with customizable physics parameters.
- Click-to-Navigate: Click anywhere on the map to set target coordinates
- Real-time Coordinates: Mouse position displayed in millimeters (mm)
- Multi-Waypoint Paths: Create complex trajectories with multiple waypoints
- Visual Path Display: Arrows show planned trajectory between waypoints
- Undo Functionality: Remove waypoints with a single click
- 4-Level Parameter Control:
- Linear Velocity (0-3 levels)
- Angular Velocity (0-3 levels)
- Linear Acceleration (0-3 levels)
- Angular Acceleration (0-3 levels)
- Precision Angle Control: Interactive wheel for exact angle setting (0-360ยฐ)
- Direction Toggle: Switch between forward and backward movement
- Manual Positioning: Drag robot to any position on the map
- Smooth Movement: Physics-based acceleration and velocity
- Automatic Path Following: Robot follows planned waypoints sequentially
- Real-time Control: Play, pause, and reset functionality
- Visual Feedback: Live robot orientation and position updates
- Path Export: Save trajectories to JSON format
- Coordinate Conversion: Seamless pixel-to-millimeter mapping
- Session Persistence: Maintain paths between simulation runs
- Python 3.x
- Pygame library
- Required Assets:
ensi_map.png- Map background imagemy_robot.png- Robot sprite image
- Clone the repository:
git clone https://github.com/INSATEURO2026/Simulation.git
cd Simulation- Install dependencies:
pip install pygame- Verify assets: Ensure these files are present:
ensi_map.png(map background)my_robot.png(robot sprite)new_sim.py(main simulation)
python new_sim.pyThe simulation launches in fullscreen mode
- Linear Velocity: Controls forward/backward speed (4 levels: 0-3)
- Angular Velocity: Controls rotation speed (4 levels: 0-3)
- Linear Acceleration: Controls movement acceleration (4 levels: 0-3)
- Angular Acceleration: Controls rotational acceleration (4 levels: 0-3)
- Target X: Manual X-coordinate entry (millimeters)
- Target Y: Manual Y-coordinate entry (millimeters)
- Target Angle: Direct angle input (degrees)
- Angle Wheel: Visual angle selector - drag the red knob around the circle
- Direction Toggle:
- ๐ข Green = Forward movement
- ๐ด Red = Backward movement
- Validate: Add current settings as a waypoint to the path
- UNDO: Remove the most recent waypoint
- Save: Export complete path to
path_points.json - PLAY
โถ๏ธ : Begin automatic path execution - PAUSE โธ๏ธ: Halt robot movement
- RESET ๐: Return robot to starting position
- Left Click: Set target coordinates and move robot instantly
- Drag Robot: Click and hold robot to reposition manually
- Coordinate Display: Real-time mouse position in mm
- ESC: Exit fullscreen mode
The simulation uses a metric coordinate system:
- Map Dimensions: 1800mm ร 1200mm
- Origin (0,0): Bottom-left corner
- X-Axis: Left โ Right (0 to 1800mm)
- Y-Axis: Bottom โ Top (0 to 1200mm)
- Angles: 0ยฐ = East, 90ยฐ = North, 180ยฐ = West, 270ยฐ = South
Simulation/
โโโ new_sim.py # Main simulation application
โโโ ensi_map.png # Map background image
โโโ my_robot.png # Robot sprite image
โโโ README.md # Documentation (this file)
โโโ LICENSE # License information
โโโ path_points.json # Generated path data (after saving)
| Class | Purpose |
|---|---|
Robot |
Handles movement, rendering, and path following logic |
Slider4State |
4-position parameter control slider |
InputBox |
Text input fields for coordinate entry |
ToggleSwitch |
Binary direction control switch |
Button |
Interactive action buttons |
AngleWheel |
Circular angle selection control |
Saved paths use JSON format with waypoint arrays:
[
[x_mm, y_mm, angle_degrees, is_forward, linear_vel, angular_vel, linear_acc, angular_acc],
[450.5, 600.2, 90.0, true, 2, 1, 3, 0],
...
]- Frame Rate: 60 FPS for smooth animation
- Screen Resolution: 1080ร720 pixels (fullscreen)
- Control Panel: 300px width
- Map Area: 780px width (auto-scaled)
- Movement Speed: 2 pixels/frame
- Rotation Speed: 3 degrees/frame
- Replace
ensi_map.pngwith your map image - Update coordinate scaling in code if dimensions differ from 1800ร1200mm
- Map will auto-scale to fit available display area
- Replace
my_robot.pngwith custom sprite - Adjust
robot_scale_factor(currently 0.1) for size - Robot automatically rotates to show orientation
Modify these variables in new_sim.py:
movement_speed: Robot movement raterotation_speed: Robot rotation rate- Scale factors for display sizing
๐ผ๏ธ Images Not Loading
- Verify
ensi_map.pngandmy_robot.pngexist in project directory - Check file permissions and formats (PNG supported)
๐ฆ Pygame Import Error
pip install pygame
# or
pip install --upgrade pygame๐ฅ๏ธ Fullscreen Problems
- Press
ESCto exit fullscreen - Try running on different display if issues persist
๐พ Path Save Issues
- Check write permissions in project directory
- Ensure sufficient disk space
- Close other applications using the directory
โก Performance Issues
- Reduce map image size if experiencing lag
- Close unnecessary applications
- Check system requirements
- Sequential Waypoints: Plan step-by-step movements
- Loop Paths: Create closed-loop trajectories
- Complex Maneuvers: Combine forward/backward movements
- Precision Positioning: Use coordinate inputs for exact placement
- Interactive Mode: Real-time path creation and editing
- Playback Mode: Watch planned paths execute automatically
- Manual Mode: Direct robot control via dragging
- Obstacle Detection: Add collision avoidance
- Multi-Robot Support: Simulate multiple robots simultaneously
- Path Optimization: Automatic trajectory smoothing
- Hardware Integration: Connect to real robots
- Advanced Physics: Momentum, friction, and inertia simulation
- Custom Map Editor: Built-in map creation tools
- Sensor Simulation: Virtual sensors and data logging
- 3D Visualization: Upgrade to 3D simulation environment
- Obstacle course templates
- Robot behavior algorithms
- Custom UI themes
- Performance optimizations
This project is licensed under the terms specified in the LICENSE file.
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow Python PEP 8 style guidelines
- Add docstrings for new functions and classes
- Test thoroughly before submitting
- Update documentation for new features
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: This README and inline code comments
Built with โค๏ธ for robotics education and research
For the latest updates and detailed documentation, visit our GitHub repository