Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dev/mar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
local_pos = messages.LocalPositionNED()
device.add_listener(local_pos)

request_local_pos = protocols.RequestMessageProtocol(messages.IntervalMessageID.LOCAL_POSITION_NED, rate_hz=50.0)
request_local_pos = protocols.RequestMessageProtocol(
messages.IntervalMessageID.LOCAL_POSITION_NED, rate_hz=50.0
)
device.run_protocol(request_local_pos)

imu = messages.RawIMU()
device.add_listener(imu)

request_imu = protocols.RequestMessageProtocol(messages.IntervalMessageID.RAW_IMU, rate_hz=50.0)
request_imu = protocols.RequestMessageProtocol(
messages.IntervalMessageID.RAW_IMU, rate_hz=50.0
)
device.run_protocol(request_imu)

time.sleep(1)
Expand Down
8 changes: 5 additions & 3 deletions messages/attitude_target_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def __init__(
self.target_system = target_system
self.target_component = target_component

self.boot_time_ms = boot_time_ms # time since system boot in milliseconds (for sync)
self.boot_time_ms = (
boot_time_ms # time since system boot in milliseconds (for sync)
)

# quaternion (w, x, y, z)
self.q = np.array(q, dtype=float)
Expand Down Expand Up @@ -90,13 +92,13 @@ def set_ignore_body_rates(self, ignore: bool = True):

def set_ignore_attitude(self, ignore: bool = True):
if ignore:
self.type_mask |= (1 << 6)
self.type_mask |= 1 << 6
else:
self.type_mask &= ~(1 << 6)

def set_ignore_thrust(self, ignore: bool = True):
if ignore:
self.type_mask |= (1 << 7)
self.type_mask |= 1 << 7
else:
self.type_mask &= ~(1 << 7)

Expand Down
1 change: 0 additions & 1 deletion messages/raw_imu_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class RawIMU(MAVMessage):

def __init__(self):
super().__init__("RAW_IMU")
self.xac = 0.0
Expand Down
4 changes: 3 additions & 1 deletion protocols/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from mavcore.protocols.attitude_setpoint_protocol import AttitudeSetpointProtocol as AttitudeSetpointProtocol
from mavcore.protocols.attitude_setpoint_protocol import (
AttitudeSetpointProtocol as AttitudeSetpointProtocol,
)
from mavcore.protocols.battery_update_protocol import (
UpdateBatteryProtocol as UpdateBatteryProtocol,
)
Expand Down
11 changes: 6 additions & 5 deletions protocols/attitude_setpoint_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class AttitudeSetpointProtocol(MAVProtocol):

def __init__(
self,
current_pos: LocalPositionNED,
Expand All @@ -27,7 +26,11 @@ def __init__(
self.thrust = 0.1

self.setpoint_msg = SetpointAttitude(
self.target_system, self.target_component, self.boot_time_ms, self.q, self.thrust
self.target_system,
self.target_component,
self.boot_time_ms,
self.q,
self.thrust,
)

def run(self, sender, receiver):
Expand All @@ -38,6 +41,4 @@ def run(self, sender, receiver):
gs = np.linalg.norm([self.imu.xac, self.imu.yac, self.imu.zac])
if gs > highest:
highest = gs
#print(f"highest G: {highest}", flush=True)


# print(f"highest G: {highest}", flush=True)
2 changes: 1 addition & 1 deletion protocols/request_msg_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(
target_system: int = 1,
target_component: int = 0,
rate_hz: float = 4.0,
wait_for_ack: bool = True
wait_for_ack: bool = True,
):
super().__init__()
self.msg_id = msg_id
Expand Down