Communicate with the MRT Autopilot Mavlink API
Project description
MRT Autopilot Python3 API
This repository contains the Python3 API for the MRT Autopilot.
Installation
pip3 install mrtautopilot
Usage
Example usage:
#!/usr/bin/env python3
import logging
import selectors
import mrtautopilot
# example for send_protobuf_proxy
from mrtproto import autopilot_pb2
PROTO_ID = 0x5433 # defined by protocol
def main():
mavlink = mrtautopilot.MavlinkThread()
proto = autopilot_pb2.VehicleData()
proto.position.latitude_deg = 38.3
proto.position.longitude_deg = -77.1
def got_low_bandwidth():
d: mrtautopilot.LowBandwidth = mavlink.low_bandwidth_queue.get_nowait()
logging.info(f"Got Vehicle Data: {d.latitude_deg}, {d.longitude_deg}")
try:
sel = selectors.DefaultSelector()
sel.register(
mavlink.low_bandwidth_queue_fileobj,
selectors.EVENT_READ,
got_low_bandwidth,
)
count = 0
mavlink.start()
while True:
mavlink.send_heartbeat()
count += 1
if count == 5:
mavlink.send_protobuf_proxy(PROTO_ID, proto.SerializeToString())
if count == 6:
m = mrtautopilot.mission
mavlink.send_mission(
m.Mission(
fault_config=m.FaultConfig(
fault_responses={},
loiter_radius_m=30,
loiter_duration_s=365 * 24 * 60 * 60,
response_speed_mps=3,
),
rally_points=[],
fence=[],
mission_items=[
m.Waypoint(lat_deg=38.31, lon_deg=-77.02, speed_mps=6),
m.Waypoint(lat_deg=38.31, lon_deg=-77.00, speed_mps=6),
m.Waypoint(lat_deg=38.34, lon_deg=-77.00, speed_mps=7),
m.DriftLoiter(
lat_deg=38.34, lon_deg=-77.00, speed_mps=3, radius_m=50
),
],
)
)
if count == 10:
mavlink.set_motor_enablement(True)
mavlink.send_waypoint(38.3, -77.1, 3.0)
if count == 20:
mavlink.set_motor_enablement(False)
mavlink.send_autopilot_stop()
for key, mask in sel.select():
key.data()
finally:
mavlink.stop()
def setup_logging():
logging.basicConfig(
format="%(asctime)s.%(msecs)03d | %(threadName)s | %(levelname)8s | %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
logger = logging.getLogger()
logger.setLevel(logging.INFO)
if __name__ == "__main__":
setup_logging()
try:
main()
except KeyboardInterrupt:
pass
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mrtautopilot-13.tar.gz.
File metadata
- Download URL: mrtautopilot-13.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1646bcfb0ab4b09d6557271b2f702d90c9c275c06d6b1f8f71fe3c4ff443ba28
|
|
| MD5 |
262717f8113675458d9376e27ea242cc
|
|
| BLAKE2b-256 |
046ce849a6922c1c7f83d0354d05694154b8d209433204a70215791228506346
|
Provenance
The following attestation bundles were made for mrtautopilot-13.tar.gz:
Publisher:
pypi.yml on magothy/mrtautopilot-py3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mrtautopilot-13.tar.gz -
Subject digest:
1646bcfb0ab4b09d6557271b2f702d90c9c275c06d6b1f8f71fe3c4ff443ba28 - Sigstore transparency entry: 230676029
- Sigstore integration time:
-
Permalink:
magothy/mrtautopilot-py3@8256613d404564b555cb12127d2ff08a8e5c8ff8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/magothy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@8256613d404564b555cb12127d2ff08a8e5c8ff8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mrtautopilot-13-py3-none-any.whl.
File metadata
- Download URL: mrtautopilot-13-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ef49f34f31d07be5ee68a9476372b33a55295b0c619f5aff951aac9e1a2a783
|
|
| MD5 |
dc2cebabf75f97e13e1efabb59b75f1e
|
|
| BLAKE2b-256 |
c7d3ee321fd6c99525e262507560a742e10b86dbc4e81beacf6ed6ab4668a21d
|
Provenance
The following attestation bundles were made for mrtautopilot-13-py3-none-any.whl:
Publisher:
pypi.yml on magothy/mrtautopilot-py3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mrtautopilot-13-py3-none-any.whl -
Subject digest:
3ef49f34f31d07be5ee68a9476372b33a55295b0c619f5aff951aac9e1a2a783 - Sigstore transparency entry: 230676036
- Sigstore integration time:
-
Permalink:
magothy/mrtautopilot-py3@8256613d404564b555cb12127d2ff08a8e5c8ff8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/magothy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@8256613d404564b555cb12127d2ff08a8e5c8ff8 -
Trigger Event:
push
-
Statement type: