Skip to content

Commit

Permalink
Print attitude and disable heading message (#1)
Browse files Browse the repository at this point in the history
* Disable heading message

* print rpy

* Minor fixes

* Remove unused line
  • Loading branch information
abhaybd authored Aug 31, 2023
1 parent 3b8c109 commit f70b82c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ArduPilotDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import websockets
import json
import argparse
import math

# This if is required because dronekit is not up to date for python 3.10
if sys.version_info.major == 3 and sys.version_info.minor >= 10:
Expand Down Expand Up @@ -101,6 +102,10 @@ def orientation_callback(self, _, attitude):
if curr_time >= last_data_send_times["orientation"] + 1./args.frequency:
if args.debug:
print(attitude)
else:
pitch_deg = attitude.pitch * 180 / math.pi
roll_deg = attitude.roll * 180 / math.pi
print(f"\33[2K\rroll={roll_deg: 4.0f}, pitch={pitch_deg: 4.0f}", end="")
last_data_send_times["orientation"] = curr_time
asyncio.run(send_orientation_message(websocket, attitude.roll, attitude.pitch, attitude.yaw))

Expand All @@ -114,7 +119,7 @@ def heading_callback(self, _, heading):

ardupilot.add_attribute_listener("location.global_frame", gps_callback)
ardupilot.add_attribute_listener("attitude", orientation_callback)
ardupilot.add_attribute_listener("heading", heading_callback)
# ardupilot.add_attribute_listener("heading", heading_callback)

try:
while True:
Expand All @@ -123,7 +128,7 @@ def heading_callback(self, _, heading):
print(e)
ardupilot.remove_attribute_listener("location.global_frame", gps_callback)
ardupilot.remove_attribute_listener("attitude", orientation_callback)
ardupilot.remove_attribute_listener("heading", heading_callback)
# ardupilot.remove_attribute_listener("heading", heading_callback)
continue

def main():
Expand Down

0 comments on commit f70b82c

Please sign in to comment.