1+ import logging
12import math
23import time
34import traceback
@@ -85,7 +86,7 @@ def p_control_loop(cmd, current_x, current_y, current_obs, kp=0.5):
8586 current_target = target_positions [joint_name ]
8687 new_target = int (current_target + value )
8788 target_positions [joint_name ] = new_target
88- print (f"Update target position { joint_name } : { current_target } -> { new_target } " )
89+ logging . debug (f"Update target position { joint_name } : { current_target } -> { new_target } " )
8990
9091 if len (move_command_list ) > 0 :
9192 for key , value in move_command_list :
@@ -99,7 +100,7 @@ def p_control_loop(cmd, current_x, current_y, current_obs, kp=0.5):
99100 joint2_target , joint3_target = inverse_kinematics (current_x , current_y )
100101 target_positions ['arm_shoulder_lift' ] = joint2_target
101102 target_positions ['arm_elbow_flex' ] = joint3_target
102- print (
103+ logging . debug (
103104 f"Update x coordinate: { current_x :.4f} , Update y coordinate: { current_y :.4f} , joint2={ joint2_target :.3f} , joint3={ joint3_target :.3f} " )
104105
105106 # Apply pitch adjustment to wrist_flex
@@ -113,7 +114,7 @@ def p_control_loop(cmd, current_x, current_y, current_obs, kp=0.5):
113114 else :
114115 p_control_loop .step_counter = 0
115116 if p_control_loop .step_counter % 100 == 0 :
116- print (
117+ logging . debug (
117118 f"Current pitch adjustment: { pitch :.3f} , wrist_flex target: { target_positions ['arm_wrist_flex' ]:.3f} " )
118119
119120 # Extract current joint positions
@@ -142,7 +143,7 @@ def p_control_loop(cmd, current_x, current_y, current_obs, kp=0.5):
142143 if robot_action :
143144 return robot_action , current_x , current_y
144145 except Exception as e :
145- print (f"P control loop error: { e } " )
146+ logging . debug (f"P control loop error: { e } " )
146147 traceback .print_exc ()
147148 return {}, current_x , current_y
148149
0 commit comments