Ardupilot mobility
ArdupilotMobilityHandler serves as an alternate mobility implementation for traditional mobility commands.
gradysim.simulator.handler.ardupilot_mobility.ArdupilotMobilityHandler
Bases: IAsyncNodeHandler
Introduces mobility into the simulatuon by communicating with a SITL-based simulation of the Node. Works by sending requests to UAV API library which connects to the Ardupilot software. It implements telemetry by constantly making requests to 'telemetry/ned' at a fixed rate and translating mobility commands into HTTP requests to UAV API
Source code in gradysim/simulator/handler/ardupilot_mobility.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 | |
__init__(configuration=ArdupilotMobilityConfiguration())
Constructor for the Ardupilot mobility handler
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration |
ArdupilotMobilityConfiguration
|
Configuration for the Ardupilot mobility handle. This includes parameters used in |
ArdupilotMobilityConfiguration()
|
Source code in gradysim/simulator/handler/ardupilot_mobility.py
finalize()
Ends simulation by finalizing report and shutting down drones.
Source code in gradysim/simulator/handler/ardupilot_mobility.py
handle_command(command, node)
Performs a mobility command in the SITL-based simulation. This method is called by the node's provider to transmit it's mobility command to the ardupilot mobility handler and then to the node's UAV API.
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/ardupilot_mobility.py
initialize()
Drives every drone to its starting point concurrently, initializes the report and starts the recurrent telemetry events. If any drone fails, every drone is shut down.
Source code in gradysim/simulator/handler/ardupilot_mobility.py
register_node(node)
Instantiates Drone object equivalent to the Node provided. Starts the UAV API process associated with this instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node |
Node
|
the Node instance that will be registered in the handler |
required |
Source code in gradysim/simulator/handler/ardupilot_mobility.py
gradysim.simulator.handler.ardupilot_mobility.ArdupilotMobilityConfiguration
dataclass
Configuration class for the Ardupilot mobility handler
Source code in gradysim/simulator/handler/ardupilot_mobility.py
ardupilot_path: str = None
class-attribute
instance-attribute
Path for cloned ardupilot repository. Used for SITL initialization when in simulated mode
default_speed: float = 10
class-attribute
instance-attribute
Default starting airspeed of a node in m/s
generate_report: bool = True
class-attribute
instance-attribute
Whether to output a report in the end of the simulation or not
ground_station_ip: str = None
class-attribute
instance-attribute
If provided and simulate_drones is True, this ip is used in UAV API to connect a GroundStation software to the simulated vehicle
mavlink_streamrate: int = 10
class-attribute
instance-attribute
Rate in Hz of the MAVLink telemetry streams requested from the autopilot, passed to UAV API when it is spawned. It bounds how fresh telemetry can be. Under SITL the effective rate is this value times the SITL speedup. Only used in simulated mode.
reference_coordinates: Tuple[float, float, float] = (0, 0, 0)
class-attribute
instance-attribute
These coordinates are used as a reference frame to convert geographical coordinates to cartesian coordinates. They will be used as the center of the scene and all geographical coordinates will be converted relative to it.
simulate_drones: bool = True
class-attribute
instance-attribute
Wheter to use SITL or connect to real vehicle
simulation_startup_speedup: int = 5
class-attribute
instance-attribute
SITL speedup used while drones are set up (UAV API spawn, takeoff and reaching the initial position), passed to UAV API when it is spawned. Once all drones are ready, SITL is set to match the simulation's real_time factor. Only used in simulated mode. Capped so that mavlink_streamrate × speedup stays at or below 50 Hz per drone.
starting_api_port: int = 8000
class-attribute
instance-attribute
The port in which UAV API of Node 0 will run. Following nodes use the ports in sequence by the formula port_of_node_{node_id} = starting_api_port + {node_id}
uav_api_log_console: bool = False
class-attribute
instance-attribute
Whether to show UAV API and SITL output in the console. When False their output is discarded, UAV API still writes its log file (see uav_api_log_path). Used in simulated mode.
uav_api_log_path: str = None
class-attribute
instance-attribute
Path in which UAV API will save log files. Used in simulated mode.
uav_api_startup_timeout: float = 120
class-attribute
instance-attribute
Maximum time in seconds a drone's UAV API has to start accepting requests, and each setup step (arm, takeoff, reaching the initial position) has to complete.
update_rate: float = 0.1
class-attribute
instance-attribute
Interval in simulation seconds between Ardupilot telemetry updates