@@ -64,13 +64,14 @@ def get_positions(ip: str) -> None:
64
64
@cli .command ()
65
65
@click .argument ("id" , type = int )
66
66
@click .argument ("position" , type = float )
67
+ @click .option ("--speed" , "-s" , type = float , default = 0 , help = "Movement speed in degrees per second (0 = max speed)" )
67
68
@click .argument ("ip" , default = DEFAULT_IP )
68
- def set_position (id : int , position : float , ip : str ) -> None :
69
+ def set_position (id : int , position : float , speed : float , ip : str ) -> None :
69
70
"""Set position for a specific servo."""
70
71
hal = HAL (ip )
71
72
try :
72
- hal .servo .set_positions ([( id , position )] )
73
- click .echo (f"Position set for servo { id } to { position } " )
73
+ hal .servo .set_position ( id , position , speed )
74
+ click .echo (f"Position set for servo { id } to { position } ° at speed { speed if speed > 0 else 'max' } deg/s " )
74
75
except Exception as e :
75
76
click .echo (f"An error occurred: { str (e )} " )
76
77
finally :
@@ -281,7 +282,7 @@ def get_imu_data(ip: str) -> None:
281
282
click .echo (f" X: { imu_data ['gyro' ]['x' ]:.2f} " )
282
283
click .echo (f" Y: { imu_data ['gyro' ]['y' ]:.2f} " )
283
284
click .echo (f" Z: { imu_data ['gyro' ]['z' ]:.2f} " )
284
- click .echo ("\n Accelerometer (g ):" )
285
+ click .echo ("\n Accelerometer (m/s^2 ):" )
285
286
click .echo (f" X: { imu_data ['accel' ]['x' ]:.2f} " )
286
287
click .echo (f" Y: { imu_data ['accel' ]['y' ]:.2f} " )
287
288
click .echo (f" Z: { imu_data ['accel' ]['z' ]:.2f} " )
@@ -290,5 +291,31 @@ def get_imu_data(ip: str) -> None:
290
291
finally :
291
292
hal .close ()
292
293
294
+ @cli .command ()
295
+ @click .argument ("ip" , default = DEFAULT_IP )
296
+ def enable_movement (ip : str ) -> None :
297
+ """Enable movement for all servos."""
298
+ hal = HAL (ip )
299
+ try :
300
+ hal .servo .enable_movement ()
301
+ click .echo ("Movement enabled for all servos" )
302
+ except Exception as e :
303
+ click .echo (f"An error occurred: { str (e )} " )
304
+ finally :
305
+ hal .close ()
306
+
307
+ @cli .command ()
308
+ @click .argument ("ip" , default = DEFAULT_IP )
309
+ def disable_movement (ip : str ) -> None :
310
+ """Disable movement for all servos."""
311
+ hal = HAL (ip )
312
+ try :
313
+ hal .servo .disable_movement ()
314
+ click .echo ("Movement disabled for all servos" )
315
+ except Exception as e :
316
+ click .echo (f"An error occurred: { str (e )} " )
317
+ finally :
318
+ hal .close ()
319
+
293
320
if __name__ == "__main__" :
294
321
cli ()
0 commit comments