Dynamic Velocity Mobility Handler
The Dynamic Velocity Mobility Handler is the mobility model for nodes that are controlled through velocity commands instead of waypoint targets.
For the conceptual overview of mobility command interpretation, telemetry flow, and handler switching, see How Mobility Works.
Use it when you need:
- bounded horizontal and vertical speed
- bounded horizontal and vertical acceleration
- optional first-order velocity tracking with
tau_xyandtau_z - telemetry that includes both position and current velocity
Related example:
showcases/dynamic-velocity-mobility/main.py
Package
gradysim.simulator.handler.mobility.dynamic_velocity
GrADyS-SIM NG Dynamic Velocity Mobility Handler
A dynamic velocity mobility handler for the GrADyS-SIM NG simulator, designed for distributed controllers that output velocity vectors.
Key features:
- Direct velocity control (no waypoints)
- Independent horizontal and vertical constraints
- Acceleration-limited velocity tracking
- Optional telemetry emission
DynamicVelocityMobilityConfiguration
dataclass
Configuration parameters for the Dynamic Velocity Mobility Handler.
Attributes:
| Name | Type | Description |
|---|---|---|
update_rate |
float
|
Time interval (in seconds) between mobility updates. Typical for trajectory-level quadrotor sims: 0.01–0.05 s. |
max_speed_xy |
float
|
Maximum horizontal speed (m/s). Applied to the norm of (vx, vy). Typical: 3–15 m/s (depends heavily on vehicle and mission). |
max_speed_z |
float
|
Maximum vertical speed (m/s). Applied to |vz|. Typical: 1–8 m/s. |
max_acc_xy |
float
|
Maximum horizontal acceleration (m/s²). Applied to the norm of (ax, ay). Typical: 2–8 m/s². |
max_acc_z |
float
|
Maximum vertical acceleration (m/s²). Applied to |az|. Typical: 2–10 m/s². |
tau_xy |
Optional[float]
|
Optional first-order time constant (seconds) for horizontal velocity tracking. When set, the model behaves like a 1st-order system + acceleration saturation: a* = (v_des - v) / tau_xy Typical: 0.3–0.8 s. |
tau_z |
Optional[float]
|
Optional first-order time constant (seconds) for vertical velocity tracking. Typical: 0.5–1.2 s. |
send_telemetry |
bool
|
If True, emit Telemetry messages after position updates. |
telemetry_decimation |
int
|
Emit telemetry every N mobility updates (default: 1). |
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/config.py
DynamicVelocityMobilityHandler
Bases: INodeHandler
Dynamic Velocity Mobility Handler for GrADyS-SIM NG.
This handler updates node positions based on velocity commands with realistic physical constraints (velocity and acceleration limits).
Key features:
- Direct velocity control (no waypoints)
- Independent horizontal and vertical constraints
- Acceleration-limited velocity tracking (optionally with 1st-order lag via tau)
- Optional telemetry emission
Usage
config = DynamicVelocityMobilityConfiguration( update_rate=0.1, max_speed_xy=10.0, max_speed_z=5.0, max_acc_xy=2.0, max_acc_z=1.0 ) handler = DynamicVelocityMobilityHandler(config)
In your protocol handler:
handler.set_velocity(node.identifier, (vx, vy, vz))
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
__init__(config)
Initialize the Dynamic Velocity Mobility Handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
DynamicVelocityMobilityConfiguration
|
Configuration parameters for mobility constraints and update rate. |
required |
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
after_simulation_step(iteration, time)
Called after each simulation step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iteration |
int
|
Current simulation iteration number |
required |
time |
float
|
Current simulation time |
required |
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
finalize()
handle_command(command, node)
Performs a mobility command. This method is called by the node's provider to transmit it's mobility command to the mobility handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command |
MobilityCommand
|
Command being issued |
required |
node |
Node
|
Node that issued the command |
required |
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
initialize()
Start the periodic mobility update loop.
Schedules the first mobility update event for all nodes.
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
inject(event_loop)
Inject the event loop into the handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_loop |
EventLoop
|
The event loop for scheduling periodic updates. |
required |
register_node(node)
Register a node with this handler (called when node is created).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node |
Node
|
The node instance to register. |
required |
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
apply_acceleration_limits(v_current, v_desired, dt, max_acc_xy, max_acc_z)
Limit velocity change based on acceleration constraints.
Applies independent horizontal and vertical acceleration limits:
- Horizontal: ||a_xy|| <= max_acc_xy
- Vertical: |a_z| <= max_acc_z
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v_current |
Tuple[float, float, float]
|
Current velocity (vx, vy, vz) in m/s. |
required |
v_desired |
Tuple[float, float, float]
|
Desired velocity (vx, vy, vz) in m/s. |
required |
dt |
float
|
Time step in seconds. |
required |
max_acc_xy |
float
|
Maximum horizontal acceleration in m/s². |
required |
max_acc_z |
float
|
Maximum vertical acceleration in m/s². |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
New velocity after applying acceleration limits. |
Example
v_cur = (0.0, 0.0, 0.0) v_des = (10.0, 10.0, 5.0) v_new = apply_acceleration_limits(v_cur, v_des, 0.1, 2.0, 1.0)
Horizontal component limited to 2.0 m/s² * 0.1 s = 0.2 m/s change
Vertical component limited to 1.0 m/s² * 0.1 s = 0.1 m/s change
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/core.py
apply_velocity_limits(v, max_speed_xy, max_speed_z)
Apply velocity saturation constraints.
Applies independent horizontal and vertical velocity limits:
- Horizontal: ||v_xy|| <= max_speed_xy
- Vertical: |v_z| <= max_speed_z
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v |
Tuple[float, float, float]
|
Velocity vector (vx, vy, vz) in m/s. |
required |
max_speed_xy |
float
|
Maximum horizontal speed in m/s. |
required |
max_speed_z |
float
|
Maximum vertical speed in m/s. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Saturated velocity vector. |
Example
v = (15.0, 15.0, 10.0) v_sat = apply_velocity_limits(v, 10.0, 5.0)
Horizontal norm is 21.21 m/s, scaled down to 10.0 m/s
Vertical component clamped to 5.0 m/s
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/core.py
integrate_position(position, velocity, dt)
Update position using simple Euler integration.
Implements: x_{k+1} = x_k + v_k * dt
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position |
Tuple[float, float, float]
|
Current position (x, y, z) in meters. |
required |
velocity |
Tuple[float, float, float]
|
Current velocity (vx, vy, vz) in m/s. |
required |
dt |
float
|
Time step in seconds. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
New position after integration step. |
Example
pos = (0.0, 0.0, 0.0) vel = (1.0, 2.0, 0.5) new_pos = integrate_position(pos, vel, 0.1) new_pos (0.1, 0.2, 0.05)
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/core.py
Handler
gradysim.simulator.handler.mobility.dynamic_velocity.handler.DynamicVelocityMobilityHandler
Bases: INodeHandler
Dynamic Velocity Mobility Handler for GrADyS-SIM NG.
This handler updates node positions based on velocity commands with realistic physical constraints (velocity and acceleration limits).
Key features:
- Direct velocity control (no waypoints)
- Independent horizontal and vertical constraints
- Acceleration-limited velocity tracking (optionally with 1st-order lag via tau)
- Optional telemetry emission
Usage
config = DynamicVelocityMobilityConfiguration( update_rate=0.1, max_speed_xy=10.0, max_speed_z=5.0, max_acc_xy=2.0, max_acc_z=1.0 ) handler = DynamicVelocityMobilityHandler(config)
In your protocol handler:
handler.set_velocity(node.identifier, (vx, vy, vz))
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
__init__(config)
Initialize the Dynamic Velocity Mobility Handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
DynamicVelocityMobilityConfiguration
|
Configuration parameters for mobility constraints and update rate. |
required |
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
after_simulation_step(iteration, time)
Called after each simulation step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iteration |
int
|
Current simulation iteration number |
required |
time |
float
|
Current simulation time |
required |
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
finalize()
handle_command(command, node)
Performs a mobility command. This method is called by the node's provider to transmit it's mobility command to the mobility handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command |
MobilityCommand
|
Command being issued |
required |
node |
Node
|
Node that issued the command |
required |
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
initialize()
Start the periodic mobility update loop.
Schedules the first mobility update event for all nodes.
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
inject(event_loop)
Inject the event loop into the handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_loop |
EventLoop
|
The event loop for scheduling periodic updates. |
required |
register_node(node)
Register a node with this handler (called when node is created).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node |
Node
|
The node instance to register. |
required |
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/handler.py
Configuration
gradysim.simulator.handler.mobility.dynamic_velocity.config.DynamicVelocityMobilityConfiguration
dataclass
Configuration parameters for the Dynamic Velocity Mobility Handler.
Attributes:
| Name | Type | Description |
|---|---|---|
update_rate |
float
|
Time interval (in seconds) between mobility updates. Typical for trajectory-level quadrotor sims: 0.01–0.05 s. |
max_speed_xy |
float
|
Maximum horizontal speed (m/s). Applied to the norm of (vx, vy). Typical: 3–15 m/s (depends heavily on vehicle and mission). |
max_speed_z |
float
|
Maximum vertical speed (m/s). Applied to |vz|. Typical: 1–8 m/s. |
max_acc_xy |
float
|
Maximum horizontal acceleration (m/s²). Applied to the norm of (ax, ay). Typical: 2–8 m/s². |
max_acc_z |
float
|
Maximum vertical acceleration (m/s²). Applied to |az|. Typical: 2–10 m/s². |
tau_xy |
Optional[float]
|
Optional first-order time constant (seconds) for horizontal velocity tracking. When set, the model behaves like a 1st-order system + acceleration saturation: a* = (v_des - v) / tau_xy Typical: 0.3–0.8 s. |
tau_z |
Optional[float]
|
Optional first-order time constant (seconds) for vertical velocity tracking. Typical: 0.5–1.2 s. |
send_telemetry |
bool
|
If True, emit Telemetry messages after position updates. |
telemetry_decimation |
int
|
Emit telemetry every N mobility updates (default: 1). |
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/config.py
Telemetry
gradysim.simulator.handler.mobility.dynamic_velocity.telemetry.DynamicVelocityTelemetry
dataclass
Bases: Telemetry
Telemetry message emitted by DynamicVelocityMobilityHandler after position updates.
This class extends the base Telemetry message with additional fields specifying the node's velocity, which is relevant information for protocols using dynamic velocity mobility.
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/telemetry.py
Core Utilities
gradysim.simulator.handler.mobility.dynamic_velocity.core
Pure mathematical functions for velocity-based mobility.
This module contains stateless mathematical operations for: - Acceleration limiting - Velocity saturation - Position integration
All functions operate on simple tuples and floats, making them easy to test and reuse independently of the simulation framework.
apply_acceleration_limits(v_current, v_desired, dt, max_acc_xy, max_acc_z)
Limit velocity change based on acceleration constraints.
Applies independent horizontal and vertical acceleration limits:
- Horizontal: ||a_xy|| <= max_acc_xy
- Vertical: |a_z| <= max_acc_z
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v_current |
Tuple[float, float, float]
|
Current velocity (vx, vy, vz) in m/s. |
required |
v_desired |
Tuple[float, float, float]
|
Desired velocity (vx, vy, vz) in m/s. |
required |
dt |
float
|
Time step in seconds. |
required |
max_acc_xy |
float
|
Maximum horizontal acceleration in m/s². |
required |
max_acc_z |
float
|
Maximum vertical acceleration in m/s². |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
New velocity after applying acceleration limits. |
Example
v_cur = (0.0, 0.0, 0.0) v_des = (10.0, 10.0, 5.0) v_new = apply_acceleration_limits(v_cur, v_des, 0.1, 2.0, 1.0)
Horizontal component limited to 2.0 m/s² * 0.1 s = 0.2 m/s change
Vertical component limited to 1.0 m/s² * 0.1 s = 0.1 m/s change
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/core.py
apply_velocity_limits(v, max_speed_xy, max_speed_z)
Apply velocity saturation constraints.
Applies independent horizontal and vertical velocity limits:
- Horizontal: ||v_xy|| <= max_speed_xy
- Vertical: |v_z| <= max_speed_z
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v |
Tuple[float, float, float]
|
Velocity vector (vx, vy, vz) in m/s. |
required |
max_speed_xy |
float
|
Maximum horizontal speed in m/s. |
required |
max_speed_z |
float
|
Maximum vertical speed in m/s. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Saturated velocity vector. |
Example
v = (15.0, 15.0, 10.0) v_sat = apply_velocity_limits(v, 10.0, 5.0)
Horizontal norm is 21.21 m/s, scaled down to 10.0 m/s
Vertical component clamped to 5.0 m/s
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/core.py
apply_velocity_tracking_first_order(v_current, v_desired, dt, max_acc_xy, max_acc_z, tau_xy, tau_z)
Track desired velocity using a 1st-order lag + acceleration saturation.
This is a trajectory-level quadrotor-friendly model:
a* = (v_des - v) / tau
a = sat(a*, max_acc)
v+ = v + a * dt
Horizontal saturation is applied on the norm of (ax, ay), while vertical saturation is applied on |az|.
When tau_xy/tau_z are None, this function falls back to the existing "acceleration-limited step" behavior for that axis.
Source code in gradysim/simulator/handler/mobility/dynamic_velocity/core.py
integrate_position(position, velocity, dt)
Update position using simple Euler integration.
Implements: x_{k+1} = x_k + v_k * dt
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position |
Tuple[float, float, float]
|
Current position (x, y, z) in meters. |
required |
velocity |
Tuple[float, float, float]
|
Current velocity (vx, vy, vz) in m/s. |
required |
dt |
float
|
Time step in seconds. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
New position after integration step. |
Example
pos = (0.0, 0.0, 0.0) vel = (1.0, 2.0, 0.5) new_pos = integrate_position(pos, vel, 0.1) new_pos (0.1, 0.2, 0.05)