Skip to content

Instantly share code, notes, and snippets.

@ericjohnson97
Created March 19, 2023 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericjohnson97/674452558c2426557e19cf50cb297ab6 to your computer and use it in GitHub Desktop.
Save ericjohnson97/674452558c2426557e19cf50cb297ab6 to your computer and use it in GitHub Desktop.
import requests
import argparse
import json
import time
def print_message(url, sysid=1, compid=1, message="GLOBAL_POSITION_INT"):
url = f"https://{url}/mavlink/vehicles/{sysid}/components/{compid}/messages/{message}"
# make a request to the mavlink2rest server
r = requests.get(url)
# parse the response
data = json.loads(r.text)
# print the data
print(json.dumps(data, indent=2))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='mavlink2rest example')
parser.add_argument('--host', default='sim.intelligentquads.com', help='host url')
parser.add_argument('--uuid', required=True, help='uuid for intelligentquads simulation')
parser.add_argument('--sysid', default=1, help='sysid')
parser.add_argument('--compid', default=1, help='compid')
parser.add_argument('--message', default='GLOBAL_POSITION_INT', help='message')
args = parser.parse_args()
url = f"{args.host}/{args.uuid}"
print_message(url, args.sysid, args.compid, args.message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment