refactor: move_joint in thread
This commit is contained in:
parent
5801133ea5
commit
4053193523
1 changed files with 15 additions and 1 deletions
16
gello.py
16
gello.py
|
@ -34,6 +34,7 @@ class RobotControllerNode(Node):
|
|||
self.robot_client = RobotClient(HOST, PORT)
|
||||
self.get_logger().info("Robot client connected")
|
||||
self.waiting_for_gripper = False
|
||||
self.wait_for_move_joint = False
|
||||
|
||||
self.robot_client.set_end_max_line_velc(0.6)
|
||||
self.robot_client.set_end_max_line_acc(0.8)
|
||||
|
@ -112,9 +113,22 @@ class RobotControllerNode(Node):
|
|||
except Exception as e:
|
||||
self.get_logger().error(f"Exception in gripper thread: {str(e)}")
|
||||
|
||||
def handle_move_joint(self, target: list[float]):
|
||||
successed =self.robot_client.move_joint(target)
|
||||
if successed:
|
||||
self.wait_for_move_joint = not successed
|
||||
self.get_logger().info("Move joint successed")
|
||||
|
||||
def run_sequence(self):
|
||||
print(f"STEP #{self.sequence_step}")
|
||||
self.robot_client.move_joint(list(self.last_gello.position[:-1]))
|
||||
if not self.wait_for_move_joint:
|
||||
self.wait_for_move_joint = True
|
||||
threading.Thread(
|
||||
target=self.handle_move_joint,
|
||||
args=(list(self.last_gello.position[:-1])),
|
||||
daemon=True
|
||||
)
|
||||
self.sequence_step += 1
|
||||
if not self.waiting_for_gripper:
|
||||
self.waiting_for_gripper = True
|
||||
threading.Thread(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue