Skip to content

Commit 0de560b

Browse files
committed
Update simulator
1 parent 3efa094 commit 0de560b

File tree

9 files changed

+175
-158
lines changed

9 files changed

+175
-158
lines changed

antares/Cargo.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

antares/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ async-trait = "0.1.88"
1111
tokio-tungstenite = "0.26.2"
1212
futures-util = "0.3.31"
1313
futures = "0.3.31"
14-
axum = "0.8.4"
14+
axum = { version = "0.8.4", features = [
15+
"json",
16+
"macros",
17+
"tokio",
18+
"http1",
19+
"tower-log",
20+
] }
1521
tokio = { version = "1", features = ["full"] }
1622
hyper = { version = "1", features = ["full"] }
1723
serde = { version = "1", features = ["derive"] }
1824
clap = { version = "4.5.37", features = ["derive"] }
25+
tower-http = { version = "0.6.2", features = ["cors"] }

antares/README.md

Lines changed: 43 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,62 @@
1-
# Naval Radar - Simulator
1+
# Antares Simulator
22

3-
The Naval Radar Simulator is a robust project designed to simulate radar systems, generate radar data, and emulate real-world scenarios involving radar detection and tracking.
3+
**Antares** is a high-performance simulation engine for naval radar scenarios, written in Rust. It generates dynamic environments with ships, emitters, and wave conditions, and feeds simulated radar data to subscribers via TCP and WebSocket. The simulator is designed for modular experimentation, real-time control, and seamless integration with visualization tools such as [Antares Web](https://thesoftwaredesignlab.github.io/ANTARES/antares-web).
44

5-
## **Features**
5+
## Prerequisites
66

7-
- **Configurable Radar Simulation**:
8-
- Define radar parameters like range, resolution, and target detection.
9-
- **Dynamic Simulation**:
10-
- Simulates target movements (linear, random, circular, stationary) and environmental effects.
11-
- **Communication Protocol**:
12-
- Implements TCP interfaces for communication between radar components.
13-
- **Realistic Tracking**:
14-
- Includes tracking algorithms for managing targets.
7+
Make sure you have [Rust](https://www.rust-lang.org/tools/install) installed. You can install Rust and Cargo using:
158

16-
## **Setup Instructions**
17-
18-
1. **Install Rust**
19-
Make sure you have Rust and cargo installed. If not, you can install them following the instructions on the [Rust website](https://www.rust-lang.org/tools/install).
20-
21-
2. **Go to the Project Directory**
22-
23-
```bash
24-
cd naval-radar-simulator
25-
```
26-
27-
3. **Build the Project**
28-
There are 2 ways to build the project:
29-
30-
- **Development Build**:
31-
```bash
32-
cargo build
33-
```
34-
- **Release Build**:
35-
```bash
36-
cargo build --release
37-
```
38-
39-
It is recommended to use the release build for better performance. Use the development build for debugging and testing.
40-
41-
4. **Run the Simulator**
42-
Run the simulator with a configuration file:
43-
44-
For the release build:
9+
```bash
10+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
11+
```
4512

46-
```bash
47-
./target/release/naval-radar-simulator <config-file>
48-
```
13+
## Running the Simulator
4914

50-
For the development build:
15+
To launch the simulator with the default settings:
5116

52-
```bash
53-
cargo run -- <config-file>
54-
```
17+
```bash
18+
cargo run
19+
```
5520

56-
Replace `<config-file>` with the path to your TOML configuration file.
21+
To run the simulator with a custom configuration:
5722

58-
## **Configuration File**
23+
```bash
24+
cargo run -- --config path/to/config.toml
25+
```
5926

60-
The simulator uses a TOML configuration file to define settings such as radar range, simulation parameters, and environment details. A sample configuration file might look like this:
27+
You can use `config.example.toml` as a starting point.
6128

62-
```toml
63-
[radar]
29+
## Building for Release
6430

65-
[radar.protocol]
66-
host = "0.0.0.0"
67-
num_workers_tci = 1
68-
num_workers_tdi = 1
31+
For optimized builds suitable for production or deployment:
6932

70-
[radar.detector]
71-
range = 100.0
72-
speed = 10.0
73-
angle = 0.0
74-
start_coordinates = [4.0, -72.0]
33+
```bash
34+
cargo build --release
35+
```
7536

76-
[simulation]
77-
emission_interval = 20
37+
## Project Structure
7838

79-
[simulation.ships]
80-
line = [{ initial_position = [-50.0, 50.0], angle = 0.785, speed = 5.0 }]
81-
circle = [{ initial_position = [50.0, -50.0], radius = 20.0, speed = 5.0 }]
82-
random = [{ initial_position = [-50.0, -50.0], max_speed = 20.0 }]
83-
stationary = [{ initial_position = [50.0, 50.0] }]
8439
```
85-
86-
## **Directory Structure**
87-
88-
The directory structure organizes the project for clarity and scalability:
89-
90-
```plaintext
91-
src
92-
├── config.rs # Manages configuration structures and settings
93-
├── controller.rs # Manages the Controller struct, starting the radar and simulation
94-
├── lib.rs # Main library file with module definitions
95-
├── main.rs # Entry point for the simulator
96-
├── radar/ # Radar simulation logic
97-
│ ├── config.rs # Configuration for radar-specific settings
98-
│ ├── detector/ # Radar detection logic
99-
│ │ ├── detector.rs # Core detection algorithms
100-
│ │ ├── mod.rs # Detector module entry point
101-
│ │ └── plot.rs # Handles radar plot generation
102-
│ ├── mod.rs # Radar module entry point
103-
│ ├── protocol/ # Radar communication protocol
104-
│ │ ├── constants/ # Constants used in protocol definitions
105-
│ │ │ ├── client_command.rs
106-
│ │ │ ├── error_message.rs
107-
│ │ │ ├── interface_ports.rs
108-
│ │ │ ├── mod.rs
109-
│ │ │ └── server_command.rs
110-
│ │ ├── mod.rs # Protocol module entry point
111-
│ │ └── tcp_interfaces/
112-
│ │ ├── base_track_interface.rs
113-
│ │ ├── mod.rs
114-
│ │ ├── track_control_interface.rs
115-
│ │ └── track_data_interface.rs
116-
│ ├── radar.rs # Core radar logic
117-
│ └── tracker/ # Radar tracking algorithms
118-
│ ├── mod.rs
119-
│ ├── track.rs
120-
│ └── tracker.rs
121-
├── simulation/ # Simulation logic for the radar
122-
│ ├── config.rs # Configuration for the simulation module
123-
│ ├── emitters/ # Handles simulated emitters like ships or targets
124-
│ │ ├── emitter.rs
125-
│ │ ├── mod.rs
126-
│ │ └── ship.rs
127-
│ ├── environment/ # Simulated environmental effects
128-
│ │ ├── mod.rs
129-
│ │ └── wave.rs
130-
│ ├── mod.rs # Simulation module entry point
131-
│ ├── movement/ # Movement strategies for targets
132-
│ │ ├── circle.rs
133-
│ │ ├── line.rs
134-
│ │ ├── mod.rs
135-
│ │ ├── random.rs
136-
│ │ ├── stationary.rs
137-
│ │ └── strategy.rs
138-
│ └── simulation.rs # Core simulation logic
139-
└── utils/ # Utility functions and reusable structures
140-
├── escape_ascii.rs # ASCII character processing utilities
141-
├── mod.rs # Utils module entry point
142-
└── thread_pool.rs # Thread pool implementation for concurrency
40+
antares/
41+
├── src/ # Source code
42+
│ ├── config.rs # Global configuration loader
43+
│ ├── controller.rs # Simulation runtime controller
44+
│ ├── main.rs # Entry point
45+
│ ├── radar/ # Radar logic and broadcasting
46+
│ │ ├── detector/ # Radar detection and plotting
47+
│ │ ├── tracker/ # Track generation and filtering
48+
│ │ ├── broadcaster/ # Data output via TCP/WebSocket
49+
│ ├── simulation/ # Simulation models
50+
│ │ ├── emitters/ # Emitter and ship definitions
51+
│ │ ├── environment/ # Environmental effects (e.g. waves)
52+
│ │ ├── movement/ # Movement patterns and strategies
53+
│ │ └── simulation.rs # Simulation loop
54+
├── Cargo.toml # Project metadata and dependencies
55+
└── Cargo.lock # Version lockfile
14356
```
14457

145-
## **Other Dependencies**
58+
## Learn More
59+
60+
For demos, examples, and system overview, visit the official platform website:
61+
👉 [https://thesoftwaredesignlab.github.io/ANTARES/antares-simulator](https://thesoftwaredesignlab.github.io/ANTARES/antares-simulator)
14662

147-
- **`chrono`**: Handles date and time functionality.
148-
- **`rand`**: Generates random numbers for simulation randomness.
149-
- **`serde` and `serde_derive`**: Serializes and deserializes data structures.
150-
- **`toml`**: Parses TOML configuration files.
151-
- **`std::thread`**: For multi-threaded processing.

antares/config.example.toml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# ============================
2+
# Antares Simulation Config
3+
# ============================
4+
5+
[antares.simulation]
6+
emission_interval = 20
7+
controller_bind_addr = "0.0.0.0:17394"
8+
9+
# ============================
10+
# Ships to add at startup
11+
# ============================
12+
13+
[[antares.simulation.initial_ships]]
14+
type = "line"
15+
initial_position = [0.0, 0.0]
16+
angle = 0.785 # radians (approx. 45 degrees)
17+
speed = 5.0
18+
19+
[[antares.simulation.initial_ships]]
20+
type = "circle"
21+
initial_position = [30.0, -30.0]
22+
radius = 20.0
23+
speed = 4.0
24+
25+
[[antares.simulation.initial_ships]]
26+
type = "random"
27+
initial_position = [-20.0, 20.0]
28+
max_speed = 10.0
29+
30+
[[antares.simulation.initial_ships]]
31+
type = "stationary"
32+
initial_position = [50.0, 50.0]
33+
34+
# ============================
35+
# Antares Radar Config
36+
# ============================
37+
38+
[antares.radar]
39+
bind_addr = "0.0.0.0:17396"
40+
41+
[antares.radar.detector]
42+
range = 1000.0
43+
speed = 0.0
44+
angle = 0.0
45+
start_coordinates = [4.0, -72.0]
46+
47+
[antares.radar.broadcast]
48+
type = "tcp"

antares/src/config.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@
55
//!
66
77
use super::{RadarConfig, SimulationConfig};
8-
use serde::Deserialize;
8+
use serde::{Deserialize, Serialize};
99

10-
#[derive(Debug, Deserialize)]
10+
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
1111
pub struct Config {
12-
pub simulation: SimulationConfig,
13-
pub radar: RadarConfig,
12+
pub antares: AntaresConfig,
1413
}
1514

16-
impl Default for Config {
17-
fn default() -> Self {
18-
Self {
19-
simulation: SimulationConfig::default(),
20-
radar: RadarConfig::default(),
21-
}
22-
}
15+
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
16+
pub struct AntaresConfig {
17+
pub simulation: SimulationConfig,
18+
pub radar: RadarConfig,
2319
}

antares/src/controller.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ use std::sync::Arc;
88
use tokio::sync::mpsc;
99

1010
pub struct Controller {
11+
config: Config,
1112
radar: Arc<Radar>,
1213
simulation: Arc<Simulation>,
1314
}
1415

1516
impl Controller {
1617
pub fn new(config: Config) -> Controller {
1718
Controller {
18-
radar: Arc::new(Radar::new(config.radar)),
19-
simulation: Arc::new(Simulation::new(config.simulation)),
19+
config: config.clone(),
20+
radar: Arc::new(Radar::new(config.antares.radar)),
21+
simulation: Arc::new(Simulation::new(config.antares.simulation)),
2022
}
2123
}
2224

@@ -42,4 +44,8 @@ impl Controller {
4244
pub fn add_ship(&self, ship_data: ShipConfig) {
4345
self.simulation.add_ship(ship_data);
4446
}
47+
48+
pub fn get_config(&self) -> Config {
49+
self.config.clone()
50+
}
4551
}

0 commit comments

Comments
 (0)