@@ -112,33 +112,30 @@ def run(
112112
113113 initial_time = time .time ()
114114 while (time .time () - initial_time ) < 1 :
115- pass
116-
117- position_msg = self .connection .recv_match (type = "LOCAL_POSITION_NED" , blocking = True )
118- attitude_msg = self .connection .recv_match (type = "ATTITUDE" , blocking = True )
119-
120- if position_msg is not None :
121- self .telemetry_data .x = position_msg .x
122- self .telemetry_data .y = position_msg .y
123- self .telemetry_data .z = position_msg .z
124- self .telemetry_data .x_velocity = position_msg .vx
125- self .telemetry_data .y_velocity = position_msg .vy
126- self .telemetry_data .z_velocity = position_msg .vz
127-
128- if attitude_msg is not None :
129- self .telemetry_data .roll = attitude_msg .roll
130- self .telemetry_data .pitch = attitude_msg .pitch
131- self .telemetry_data .yaw = attitude_msg .yaw
132- self .telemetry_data .roll_speed = attitude_msg .rollspeed
133- self .telemetry_data .pitch_speed = attitude_msg .pitchspeed
134- self .telemetry_data .yaw_speed = attitude_msg .yawspeed
135-
136- if attitude_msg is not None and position_msg is not None :
137- self .telemetry_data .time_since_boot = max (
138- attitude_msg .time_boot_ms , position_msg .time_boot_ms
139- )
140- return f"Telemetry Data: { self .telemetry_data } "
141- # return "Messages not received in time"
115+ position_msg = self .connection .recv_match (type = "LOCAL_POSITION_NED" , blocking = True )
116+ attitude_msg = self .connection .recv_match (type = "ATTITUDE" , blocking = True )
117+
118+ if position_msg is not None :
119+ self .telemetry_data .x = position_msg .x
120+ self .telemetry_data .y = position_msg .y
121+ self .telemetry_data .z = position_msg .z
122+ self .telemetry_data .x_velocity = position_msg .vx
123+ self .telemetry_data .y_velocity = position_msg .vy
124+ self .telemetry_data .z_velocity = position_msg .vz
125+
126+ if attitude_msg is not None :
127+ self .telemetry_data .roll = attitude_msg .roll
128+ self .telemetry_data .pitch = attitude_msg .pitch
129+ self .telemetry_data .yaw = attitude_msg .yaw
130+ self .telemetry_data .roll_speed = attitude_msg .rollspeed
131+ self .telemetry_data .pitch_speed = attitude_msg .pitchspeed
132+ self .telemetry_data .yaw_speed = attitude_msg .yawspeed
133+
134+ if attitude_msg is not None and position_msg is not None :
135+ self .telemetry_data .time_since_boot = max (
136+ attitude_msg .time_boot_ms , position_msg .time_boot_ms
137+ )
138+ return f"Telemetry Data: { self .telemetry_data } "
142139
143140 return "Failed to Receive Data"
144141
0 commit comments