@@ -24,6 +24,7 @@ def __init__(
2424 current_pos : LocalPositionNED ,
2525 waypoints : list [Waypoint ],
2626 boot_time_ms : int ,
27+ log_func = lambda msg : print (msg ),
2728 mission_phase : str = "cruise" ,
2829 target_system : int = 1 ,
2930 target_component : int = 0 ,
@@ -35,6 +36,7 @@ def __init__(
3536 self .mission_phase = mission_phase
3637 self .target_system = target_system
3738 self .target_component = target_component
39+ self .log_func = log_func
3840
3941 # Base speed for mission phase
4042 self .base_speed = self .SPEED_PROFILES .get (mission_phase , 10.0 )
@@ -68,7 +70,7 @@ def calculate_velocity_vector(
6870 velocity = unit_direction * target_speed
6971
7072 # Slow down when close to/approaching waypoint
71- if distance < 45 .0 :
73+ if distance < 15 .0 :
7274 velocity /= 3.0
7375
7476 return velocity
@@ -121,9 +123,9 @@ def run(self, sender, receiver):
121123 for i in range (len (self .waypoints )):
122124 waypoint = self .waypoints [i ]
123125 waypoint_coords = np .array ([waypoint .x , waypoint .y , waypoint .z ])
124- optimal_speed = self . get_optimal_speed_for_waypoint ( i )
126+ optimal_speed = waypoint . speed
125127
126- print (
128+ self . log_func (
127129 f"[VelocityControl] Waypoint { i + 1 } /{ len (self .waypoints )} @ { optimal_speed :.1f} m/s"
128130 )
129131
@@ -134,7 +136,7 @@ def run(self, sender, receiver):
134136 )
135137
136138 if distance_to_waypoint <= waypoint .radius :
137- print (f"[VelocityControl] Reached waypoint { i + 1 } " )
139+ self . log_func (f"[VelocityControl] Reached waypoint { i + 1 } " )
138140 self .velocity_msg .load (np .array ([0.0 , 0.0 , 0.0 ]))
139141 sender .send_msg (self .velocity_msg )
140142 break
0 commit comments