kuavo-humanoid-sdk 1.1.3a1240__py3-none-any.whl → 1.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of kuavo-humanoid-sdk might be problematic. Click here for more details.

@@ -5,7 +5,9 @@ import numpy as np
5
5
  from typing import Tuple
6
6
  from kuavo_humanoid_sdk.common.logger import SDKLogger
7
7
  from kuavo_humanoid_sdk.common.websocket_kuavo_sdk import WebSocketKuavoSDK
8
- from kuavo_humanoid_sdk.interfaces.data_types import KuavoArmCtrlMode, KuavoIKParams, KuavoPose
8
+ from kuavo_humanoid_sdk.interfaces.data_types import (KuavoArmCtrlMode, KuavoIKParams, KuavoPose,
9
+ KuavoManipulationMpcControlFlow, KuavoManipulationMpcCtrlMode
10
+ ,KuavoManipulationMpcFrame)
9
11
  from kuavo_humanoid_sdk.kuavo.core.ros.sat_utils import RotatingRectangle
10
12
  from kuavo_humanoid_sdk.kuavo.core.ros.param import EndEffectorType
11
13
 
@@ -16,14 +18,18 @@ try:
16
18
  from kuavo_humanoid_sdk.msg.kuavo_msgs.msg import (gestureTask,robotHandPosition, robotHeadMotionData, armTargetPoses, switchGaitByName,
17
19
  footPose, footPoseTargetTrajectories, dexhandCommand)
18
20
  from kuavo_humanoid_sdk.msg.kuavo_msgs.srv import (gestureExecute, gestureExecuteRequest,gestureList, gestureListRequest,
19
- controlLejuClaw, controlLejuClawRequest, changeArmCtrlMode, changeArmCtrlModeRequest)
20
- from kuavo_humanoid_sdk.msg.kuavo_msgs.msg import twoArmHandPoseCmd, ikSolveParam
21
+ controlLejuClaw, controlLejuClawRequest, changeArmCtrlMode, changeArmCtrlModeRequest,
22
+ changeTorsoCtrlMode, changeTorsoCtrlModeRequest, setMmCtrlFrame, setMmCtrlFrameRequest,
23
+ setTagId, setTagIdRequest)
24
+ from kuavo_humanoid_sdk.msg.kuavo_msgs.msg import twoArmHandPoseCmd, ikSolveParam, armHandPose
21
25
  from kuavo_humanoid_sdk.msg.kuavo_msgs.srv import twoArmHandPoseCmdSrv, fkSrv
26
+ from std_srvs.srv import SetBool, SetBoolRequest
22
27
  except:
23
28
  pass
24
29
 
25
30
 
26
31
 
32
+
27
33
  class ControlEndEffector:
28
34
  def __init__(self, eef_type: str = EndEffectorType.QIANGNAO):
29
35
  self._eef_type = eef_type
@@ -387,6 +393,7 @@ class ControlRobotArm:
387
393
  def __init__(self):
388
394
  self._pub_ctrl_arm_traj = rospy.Publisher('/kuavo_arm_traj', JointState, queue_size=10)
389
395
  self._pub_ctrl_arm_target_poses = rospy.Publisher('/kuavo_arm_target_poses', armTargetPoses, queue_size=10)
396
+ self._pub_ctrl_hand_pose_cmd = rospy.Publisher('/mm/two_arm_hand_pose_cmd', twoArmHandPoseCmd, queue_size=10)
390
397
 
391
398
  def connect(self, timeout:float=1.0)-> bool:
392
399
  start_time = rospy.Time.now()
@@ -429,6 +436,153 @@ class ControlRobotArm:
429
436
  except Exception as e:
430
437
  SDKLogger.error(f"publish arm target poses: {e}")
431
438
  return False
439
+ def pub_end_effector_pose_cmd(self, left_pose: KuavoPose, right_pose: KuavoPose, frame: KuavoManipulationMpcFrame)->bool:
440
+ try:
441
+ msg = twoArmHandPoseCmd()
442
+ left_pose_msg = armHandPose()
443
+ left_pose_msg.pos_xyz = left_pose.position
444
+ left_pose_msg.quat_xyzw = left_pose.orientation
445
+ right_pose_msg = armHandPose()
446
+ right_pose_msg.pos_xyz = right_pose.position
447
+ right_pose_msg.quat_xyzw = right_pose.orientation
448
+ msg.hand_poses.left_pose = left_pose_msg
449
+ msg.hand_poses.right_pose = right_pose_msg
450
+ if frame.value not in [0, 1, 2, 3, 4]:
451
+ SDKLogger.error(f"Invalid frame: {frame}")
452
+ return False
453
+ msg.frame = frame.value
454
+ self._pub_ctrl_hand_pose_cmd.publish(msg)
455
+ return True
456
+ except Exception as e:
457
+ SDKLogger.error(f"publish arm target poses: {e}")
458
+ return False
459
+
460
+ def srv_change_manipulation_mpc_frame(self, frame: KuavoManipulationMpcFrame)->bool:
461
+ try:
462
+ service_name = '/set_mm_ctrl_frame'
463
+ rospy.wait_for_service(service_name, timeout=2.0)
464
+ set_frame_srv = rospy.ServiceProxy(service_name, setMmCtrlFrame)
465
+
466
+ req = setMmCtrlFrameRequest()
467
+ req.frame = frame.value
468
+
469
+ resp = set_frame_srv(req)
470
+ if not resp.result:
471
+ SDKLogger.error(f"Failed to change manipulation mpc frame to {frame}: {resp.message}")
472
+ return resp.result
473
+ except rospy.ServiceException as e:
474
+ SDKLogger.error(f"Service call to {service_name} failed: {e}")
475
+ except rospy.ROSException as e: # For timeout from wait_for_service
476
+ SDKLogger.error(f"Failed to connect to service {service_name}: {e}")
477
+ except Exception as e:
478
+ SDKLogger.error(f"Failed to change manipulation mpc frame: {e}")
479
+ return False
480
+
481
+ def srv_change_manipulation_mpc_ctrl_mode(self, ctrl_mode: KuavoManipulationMpcCtrlMode)->bool:
482
+ try:
483
+ service_name = '/mobile_manipulator_mpc_control'
484
+ rospy.wait_for_service(service_name, timeout=2.0)
485
+ set_mode_srv = rospy.ServiceProxy(service_name, changeTorsoCtrlMode)
486
+
487
+ req = changeTorsoCtrlModeRequest()
488
+ req.control_mode = ctrl_mode.value
489
+
490
+ resp = set_mode_srv(req)
491
+ if not resp.result:
492
+ SDKLogger.error(f"Failed to change manipulation mpc control mode to {ctrl_mode}: {resp.message}")
493
+ return resp.result
494
+ except rospy.ServiceException as e:
495
+ SDKLogger.error(f"Service call to {service_name} failed: {e}")
496
+ except rospy.ROSException as e: # For timeout from wait_for_service
497
+ SDKLogger.error(f"Failed to connect to service {service_name}: {e}")
498
+ except Exception as e:
499
+ SDKLogger.error(f"Failed to change manipulation mpc control mode: {e}")
500
+ return False
501
+
502
+ def srv_change_manipulation_mpc_control_flow(self, ctrl_flow: KuavoManipulationMpcControlFlow)-> bool:
503
+ try:
504
+ service_name = '/enable_mm_wbc_arm_trajectory_control'
505
+ rospy.wait_for_service(service_name, timeout=2.0)
506
+ set_mode_srv = rospy.ServiceProxy(service_name, changeArmCtrlMode)
507
+
508
+ req = changeArmCtrlModeRequest()
509
+ req.control_mode = ctrl_flow.value
510
+
511
+ resp = set_mode_srv(req)
512
+ if not resp.result:
513
+ SDKLogger.error(f"Failed to change manipulation mpc wbc arm trajectory control to {ctrl_flow}: {resp.message}")
514
+ return resp.result
515
+ except rospy.ServiceException as e:
516
+ SDKLogger.error(f"Service call to {service_name} failed: {e}")
517
+ except rospy.ROSException as e: # For timeout from wait_for_service
518
+ SDKLogger.error(f"Failed to connect to service {service_name}: {e}")
519
+ except Exception as e:
520
+ SDKLogger.error(f"Failed to change manipulation mpc control flow: {e}")
521
+ return False
522
+
523
+ def srv_get_manipulation_mpc_ctrl_mode(self, )->KuavoManipulationMpcCtrlMode:
524
+ try:
525
+ service_name = '/mobile_manipulator_get_mpc_control_mode'
526
+ rospy.wait_for_service(service_name, timeout=2.0)
527
+ get_mode_srv = rospy.ServiceProxy(service_name, changeTorsoCtrlMode)
528
+
529
+ req = changeTorsoCtrlModeRequest()
530
+
531
+ resp = get_mode_srv(req)
532
+ if not resp.result:
533
+ SDKLogger.error(f"Failed to get manipulation mpc control mode: {resp.message}")
534
+ return KuavoManipulationMpcCtrlMode.ERROR
535
+ return KuavoManipulationMpcCtrlMode(resp.mode)
536
+ except rospy.ServiceException as e:
537
+ SDKLogger.error(f"Service call to {service_name} failed: {e}")
538
+ except rospy.ROSException as e: # For timeout from wait_for_service
539
+ SDKLogger.error(f"Failed to connect to service {service_name}: {e}")
540
+ except Exception as e:
541
+ SDKLogger.error(f"Failed to get manipulation mpc control mode: {e}")
542
+ return KuavoManipulationMpcCtrlMode.ERROR
543
+
544
+ def srv_get_manipulation_mpc_frame(self, )->KuavoManipulationMpcFrame:
545
+ try:
546
+ service_name = '/get_mm_ctrl_frame'
547
+ rospy.wait_for_service(service_name, timeout=2.0)
548
+ get_frame_srv = rospy.ServiceProxy(service_name, setMmCtrlFrame)
549
+
550
+ req = setMmCtrlFrameRequest()
551
+
552
+ resp = get_frame_srv(req)
553
+ if not resp.result:
554
+ SDKLogger.error(f"Failed to get manipulation mpc frame: {resp.message}")
555
+ return KuavoManipulationMpcFrame.ERROR
556
+ return KuavoManipulationMpcFrame(resp.currentFrame)
557
+ except rospy.ServiceException as e:
558
+ SDKLogger.error(f"Service call to {service_name} failed: {e}")
559
+ except rospy.ROSException as e: # For timeout from wait_for_service
560
+ SDKLogger.error(f"Failed to connect to service {service_name}: {e}")
561
+ except Exception as e:
562
+ SDKLogger.error(f"Failed to get manipulation mpc frame: {e}")
563
+ return KuavoManipulationMpcFrame.ERROR
564
+
565
+ def srv_get_manipulation_mpc_control_flow(self, )->KuavoManipulationMpcControlFlow:
566
+ try:
567
+ service_name = '/get_mm_wbc_arm_trajectory_control'
568
+ rospy.wait_for_service(service_name, timeout=2.0)
569
+ get_mode_srv = rospy.ServiceProxy(service_name, changeArmCtrlMode)
570
+
571
+ req = changeArmCtrlModeRequest()
572
+
573
+ resp = get_mode_srv(req)
574
+ if not resp.result:
575
+ SDKLogger.error(f"Failed to get manipulation mpc wbc arm trajectory control mode: {resp.message}")
576
+ return KuavoManipulationMpcControlFlow.ERROR
577
+ return KuavoManipulationMpcControlFlow(resp.mode)
578
+ except rospy.ServiceException as e:
579
+ SDKLogger.error(f"Service call to {service_name} failed: {e}")
580
+ except rospy.ROSException as e: # For timeout from wait_for_service
581
+ SDKLogger.error(f"Failed to connect to service {service_name}: {e}")
582
+ except Exception as e:
583
+ SDKLogger.error(f"Failed to get manipulation mpc wbc arm trajectory control mode: {e}")
584
+ return KuavoManipulationMpcControlFlow.ERROR
585
+
432
586
 
433
587
  def srv_change_arm_ctrl_mode(self, mode: KuavoArmCtrlMode)->bool:
434
588
  try:
@@ -461,7 +615,7 @@ class ControlRobotArm:
461
615
  class ControlRobotHead:
462
616
  def __init__(self):
463
617
  self._pub_ctrl_robot_head = rospy.Publisher('/robot_head_motion_data', robotHeadMotionData, queue_size=10)
464
-
618
+
465
619
  def connect(self, timeout:float=1.0)->bool:
466
620
  start_time = rospy.Time.now()
467
621
  publishers = [
@@ -484,6 +638,168 @@ class ControlRobotHead:
484
638
  SDKLogger.error(f"[Error] publish robot head: {e}")
485
639
  return False
486
640
 
641
+ def srv_enable_head_tracking(self, target_id: int)->bool:
642
+ """Enable the head tracking for a specific tag ID.
643
+
644
+ Args:
645
+ target_id: The ID of the tag to track
646
+
647
+ Returns:
648
+ bool: True if successful, False otherwise
649
+ """
650
+ try:
651
+ # 首先设置追踪目标ID
652
+ service_name = '/set_target_tag_id'
653
+ rospy.wait_for_service(service_name, timeout=2.0)
654
+ set_tag_id_srv = rospy.ServiceProxy(service_name, setTagId)
655
+
656
+ req = setTagIdRequest()
657
+ req.tag_id = target_id
658
+
659
+ resp = set_tag_id_srv(req)
660
+ if not resp.success:
661
+ SDKLogger.error(f"Failed to set target tag ID: {resp.message}")
662
+ return False
663
+
664
+ SDKLogger.info(f"Successfully set target tag ID to {target_id}: {resp.message}")
665
+
666
+ # 然后启动连续追踪
667
+ service_name = '/continuous_track'
668
+ rospy.wait_for_service(service_name, timeout=2.0)
669
+ continuous_track_srv = rospy.ServiceProxy(service_name, SetBool)
670
+
671
+ req = SetBoolRequest()
672
+ req.data = True
673
+
674
+ resp = continuous_track_srv(req)
675
+ if not resp.success:
676
+ SDKLogger.error(f"Failed to start continuous tracking: {resp.message}")
677
+ return False
678
+
679
+ SDKLogger.info(f"Successfully started continuous tracking: {resp.message}")
680
+ return True
681
+
682
+ except rospy.ServiceException as e:
683
+ SDKLogger.error(f"Service call failed: {e}")
684
+ except rospy.ROSException as e:
685
+ SDKLogger.error(f"Failed to connect to service: {e}")
686
+ except Exception as e:
687
+ SDKLogger.error(f"Failed to enable head tracking: {e}")
688
+
689
+ return False
690
+
691
+ def srv_disable_head_tracking(self)->bool:
692
+ """Disable the head tracking.
693
+
694
+ Returns:
695
+ bool: True if successful, False otherwise
696
+ """
697
+ try:
698
+ service_name = '/continuous_track'
699
+ rospy.wait_for_service(service_name, timeout=2.0)
700
+ continuous_track_srv = rospy.ServiceProxy(service_name, SetBool)
701
+
702
+ req = SetBoolRequest()
703
+ req.data = False
704
+
705
+ resp = continuous_track_srv(req)
706
+ if not resp.success:
707
+ SDKLogger.error(f"Failed to stop continuous tracking: {resp.message}")
708
+ return False
709
+
710
+ SDKLogger.info(f"Successfully stopped continuous tracking: {resp.message}")
711
+ return True
712
+
713
+ except rospy.ServiceException as e:
714
+ SDKLogger.error(f"Service call failed: {e}")
715
+ except rospy.ROSException as e:
716
+ SDKLogger.error(f"Failed to connect to service: {e}")
717
+ except Exception as e:
718
+ SDKLogger.error(f"Failed to disable head tracking: {e}")
719
+
720
+ return False
721
+
722
+ def srv_enable_head_tracking(self, target_id: int)->bool:
723
+ """Enable the head tracking for a specific tag ID.
724
+
725
+ Args:
726
+ target_id: The ID of the tag to track
727
+
728
+ Returns:
729
+ bool: True if successful, False otherwise
730
+ """
731
+ try:
732
+ # 首先设置追踪目标ID
733
+ service_name = '/set_target_tag_id'
734
+ rospy.wait_for_service(service_name, timeout=2.0)
735
+ set_tag_id_srv = rospy.ServiceProxy(service_name, setTagId)
736
+
737
+ req = setTagIdRequest()
738
+ req.tag_id = target_id
739
+
740
+ resp = set_tag_id_srv(req)
741
+ if not resp.success:
742
+ SDKLogger.error(f"Failed to set target tag ID: {resp.message}")
743
+ return False
744
+
745
+ SDKLogger.info(f"Successfully set target tag ID to {target_id}: {resp.message}")
746
+
747
+ # 然后启动连续追踪
748
+ service_name = '/continuous_track'
749
+ rospy.wait_for_service(service_name, timeout=2.0)
750
+ continuous_track_srv = rospy.ServiceProxy(service_name, SetBool)
751
+
752
+ req = SetBoolRequest()
753
+ req.data = True
754
+
755
+ resp = continuous_track_srv(req)
756
+ if not resp.success:
757
+ SDKLogger.error(f"Failed to start continuous tracking: {resp.message}")
758
+ return False
759
+
760
+ SDKLogger.info(f"Successfully started continuous tracking: {resp.message}")
761
+ return True
762
+
763
+ except rospy.ServiceException as e:
764
+ SDKLogger.error(f"Service call failed: {e}")
765
+ except rospy.ROSException as e:
766
+ SDKLogger.error(f"Failed to connect to service: {e}")
767
+ except Exception as e:
768
+ SDKLogger.error(f"Failed to enable head tracking: {e}")
769
+
770
+ return False
771
+
772
+ def srv_disable_head_tracking(self)->bool:
773
+ """Disable the head tracking.
774
+
775
+ Returns:
776
+ bool: True if successful, False otherwise
777
+ """
778
+ try:
779
+ service_name = '/continuous_track'
780
+ rospy.wait_for_service(service_name, timeout=2.0)
781
+ continuous_track_srv = rospy.ServiceProxy(service_name, SetBool)
782
+
783
+ req = SetBoolRequest()
784
+ req.data = False
785
+
786
+ resp = continuous_track_srv(req)
787
+ if not resp.success:
788
+ SDKLogger.error(f"Failed to stop continuous tracking: {resp.message}")
789
+ return False
790
+
791
+ SDKLogger.info(f"Successfully stopped continuous tracking: {resp.message}")
792
+ return True
793
+
794
+ except rospy.ServiceException as e:
795
+ SDKLogger.error(f"Service call failed: {e}")
796
+ except rospy.ROSException as e:
797
+ SDKLogger.error(f"Failed to connect to service: {e}")
798
+ except Exception as e:
799
+ SDKLogger.error(f"Failed to disable head tracking: {e}")
800
+
801
+ return False
802
+
487
803
  """ Control Robot Head """
488
804
  class ControlRobotHeadWebsocket:
489
805
  def __init__(self):
@@ -531,6 +847,7 @@ class ControlRobotMotion:
531
847
  def __init__(self):
532
848
  self._pub_cmd_vel = rospy.Publisher('/cmd_vel', Twist, queue_size=10)
533
849
  self._pub_cmd_pose = rospy.Publisher('/cmd_pose', Twist, queue_size=10)
850
+ self._pub_cmd_pose_world = rospy.Publisher('/cmd_pose_world', Twist, queue_size=10)
534
851
  self._pub_joy = rospy.Publisher('/joy', Joy, queue_size=10)
535
852
  self._pub_switch_gait = rospy.Publisher('/humanoid_switch_gait_by_name', switchGaitByName, queue_size=10)
536
853
  self._pub_step_ctrl = rospy.Publisher('/humanoid_mpc_foot_pose_target_trajectories', footPoseTargetTrajectories, queue_size=10)
@@ -542,7 +859,8 @@ class ControlRobotMotion:
542
859
  (self._pub_cmd_vel, "cmd_vel publisher"),
543
860
  (self._pub_cmd_pose, "cmd_pose publisher"),
544
861
  (self._pub_step_ctrl, "step_ctrl publisher"),
545
- (self._pub_switch_gait, "switch_gait publisher")
862
+ (self._pub_switch_gait, "switch_gait publisher"),
863
+ (self._pub_cmd_pose_world, "cmd_pose_world publisher"),
546
864
  ]
547
865
 
548
866
  success = True
@@ -574,8 +892,16 @@ class ControlRobotMotion:
574
892
  except Exception as e:
575
893
  SDKLogger.error(f"[Error] publish cmd pose: {e}")
576
894
  return False
577
-
578
- def _create_joy_msg(self):
895
+
896
+ def pub_cmd_pose_world(self, twist:Twist)->bool:
897
+ try:
898
+ self._pub_cmd_pose_world.publish(twist)
899
+ return True
900
+ except Exception as e:
901
+ SDKLogger.error(f"[Error] publish cmd pose world: {e}")
902
+ return False
903
+
904
+ def _create_joy_msg(self)->Joy:
579
905
  joy_msg = Joy()
580
906
  joy_msg.axes = [0.0] * 8 # Initialize 8 axes
581
907
  joy_msg.buttons = [0] * 16 # Initialize 16 buttons
@@ -1020,19 +1346,39 @@ class KuavoRobotControl:
1020
1346
  SDKLogger.debug(f"Control robot head: {yaw}, {pitch}")
1021
1347
  return self.kuavo_head_control.pub_control_robot_head(yaw, pitch)
1022
1348
 
1023
-
1024
- def control_robot_arm_traj(self, joint_data:list)->bool:
1349
+ def enable_head_tracking(self, target_id: int)->bool:
1350
+ """Enable the head tracking for a specific tag ID.
1351
+
1352
+ Args:
1353
+ target_id: The ID of the tag to track
1354
+
1355
+ Returns:
1356
+ bool: True if successful, False otherwise
1025
1357
  """
1026
- Control robot arm trajectory
1358
+ SDKLogger.debug(f"Enable head tracking: {target_id}")
1359
+ return self.kuavo_head_control.srv_enable_head_tracking(target_id)
1360
+
1361
+ def disable_head_tracking(self)->bool:
1362
+ """Disable the head tracking.
1363
+
1364
+ Returns:
1365
+ bool: True if successful, False otherwise
1366
+ """
1367
+ SDKLogger.debug(f"Disable head tracking")
1368
+ return self.kuavo_head_control.srv_disable_head_tracking()
1369
+
1370
+ def control_robot_arm_joint_positions(self, joint_data:list)->bool:
1371
+ """
1372
+ Control robot arm joint positions
1027
1373
  Arguments:
1028
1374
  - joint_data: list of joint data (degrees)
1029
1375
  """
1030
1376
  # SDKLogger.debug(f"[ROS] Control robot arm trajectory: {joint_data}")
1031
1377
  return self.kuavo_arm_control.pub_control_robot_arm_traj(joint_data)
1032
1378
 
1033
- def control_robot_arm_target_poses(self, times:list, joint_q:list)->bool:
1379
+ def control_robot_arm_joint_trajectory(self, times:list, joint_q:list)->bool:
1034
1380
  """
1035
- Control robot arm target poses
1381
+ Control robot arm joint trajectory
1036
1382
  Arguments:
1037
1383
  - times: list of times (seconds)
1038
1384
  - joint_q: list of joint data (degrees)
@@ -1044,6 +1390,58 @@ class KuavoRobotControl:
1044
1390
 
1045
1391
  return self.kuavo_arm_control.pub_arm_target_poses(times=times, joint_q=joint_q)
1046
1392
 
1393
+ def control_robot_end_effector_pose(self, left_pose: KuavoPose, right_pose: KuavoPose, frame: KuavoManipulationMpcFrame)->bool:
1394
+ """
1395
+ Control robot end effector pose
1396
+ Arguments:
1397
+ - left_pose: left end effector pose
1398
+ - right_pose: right end effector pose
1399
+ - frame: frame of the end effector pose, 0: keep current frame, 1: world frame, 2: local frame, 3: VR frame, 4: manipulation world frame
1400
+ """
1401
+ return self.kuavo_arm_control.pub_end_effector_pose_cmd(left_pose, right_pose, frame)
1402
+
1403
+ def change_manipulation_mpc_frame(self, frame: KuavoManipulationMpcFrame)->bool:
1404
+ """
1405
+ Change manipulation mpc frame
1406
+ Arguments:
1407
+ - frame: frame of the manipulation mpc
1408
+ """
1409
+ return self.kuavo_arm_control.srv_change_manipulation_mpc_frame(frame)
1410
+
1411
+ def change_manipulation_mpc_ctrl_mode(self, ctrl_mode: KuavoManipulationMpcCtrlMode)->bool:
1412
+ """
1413
+ Change manipulation mpc control mode
1414
+ Arguments:
1415
+ - control_mode: control mode of the manipulation mpc
1416
+ """
1417
+ return self.kuavo_arm_control.srv_change_manipulation_mpc_ctrl_mode(ctrl_mode)
1418
+
1419
+ def change_manipulation_mpc_control_flow(self, ctrl_flow: KuavoManipulationMpcControlFlow)->bool:
1420
+ """
1421
+ Change manipulation mpc wbc arm traj control mode, control signal will be sent to wbc directly
1422
+ Arguments:
1423
+ - control_mode: control mode of the manipulation mpc wbc arm traj
1424
+ """
1425
+ return self.kuavo_arm_control.srv_change_manipulation_mpc_control_flow(ctrl_flow)
1426
+
1427
+ def get_manipulation_mpc_ctrl_mode(self)->KuavoManipulationMpcCtrlMode:
1428
+ """
1429
+ Get manipulation mpc control mode
1430
+ """
1431
+ return self.kuavo_arm_control.srv_get_manipulation_mpc_ctrl_mode()
1432
+
1433
+ def get_manipulation_mpc_frame(self)-> KuavoManipulationMpcFrame:
1434
+ """
1435
+ Get manipulation mpc frame
1436
+ """
1437
+ return self.kuavo_arm_control.srv_get_manipulation_mpc_frame()
1438
+
1439
+ def get_manipulation_mpc_control_flow(self)->KuavoManipulationMpcControlFlow:
1440
+ """
1441
+ Get manipulation mpc wbc arm traj control mode
1442
+ """
1443
+ return self.kuavo_arm_control.srv_get_manipulation_mpc_control_flow()
1444
+
1047
1445
  def change_robot_arm_ctrl_mode(self, mode:KuavoArmCtrlMode)->bool:
1048
1446
  """
1049
1447
  Change robot arm control mode
@@ -1085,6 +1483,28 @@ class KuavoRobotControl:
1085
1483
  com_msg.angular.y = pitch
1086
1484
  return self.kuavo_motion_control.pub_cmd_pose(com_msg)
1087
1485
 
1486
+ def control_command_pose_world(self, target_pose_x:float, target_pose_y:float, target_pose_z:float, target_pose_yaw:float)->bool:
1487
+ """
1488
+ odom下的机器人cmd_pose_world
1489
+ """
1490
+ com_msg = Twist()
1491
+ com_msg.linear.x = target_pose_x
1492
+ com_msg.linear.y = target_pose_y
1493
+ com_msg.linear.z = target_pose_z
1494
+ com_msg.angular.z = target_pose_yaw
1495
+ return self.kuavo_motion_control.pub_cmd_pose_world(com_msg)
1496
+
1497
+ def control_command_pose(self, target_pose_x:float, target_pose_y:float, target_pose_z:float, target_pose_yaw:float)->bool:
1498
+ """
1499
+ base_link下的机器人cmd_pose
1500
+ """
1501
+ com_msg = Twist()
1502
+ com_msg.linear.x = target_pose_x
1503
+ com_msg.linear.y = target_pose_y
1504
+ com_msg.linear.z = target_pose_z
1505
+ com_msg.angular.z = target_pose_yaw
1506
+ return self.kuavo_motion_control.pub_cmd_pose(com_msg)
1507
+
1088
1508
  def step_control(self, body_poses:list, dt:float, is_left_first_default:bool=True, collision_check:bool=True)->bool:
1089
1509
  """
1090
1510
  Step control
@@ -1437,4 +1857,18 @@ def get_multiple_steps_msg(body_poses:list, dt:float, is_left_first:bool=True, c
1437
1857
  # print("foot_idx_traj:", foot_idx_traj)
1438
1858
  # print("foot_traj:", foot_traj)
1439
1859
  # print("torso_traj:", torso_traj)
1440
- return get_foot_pose_traj_msg(time_traj, foot_idx_traj, foot_traj, torso_traj)
1860
+ return get_foot_pose_traj_msg(time_traj, foot_idx_traj, foot_traj, torso_traj)
1861
+ """ ------------------------------------------------------------------------------"""
1862
+
1863
+
1864
+ # if __name__ == "__main__":
1865
+ # control = KuavoRobotControl()
1866
+ # control.change_manipulation_mpc_frame(KuavoManipulationMpcFrame.KeepCurrentFrame)
1867
+ # control.change_manipulation_mpc_ctrl_mode(KuavoManipulationMpcCtrlMode.ArmOnly)
1868
+ # control.change_manipulation_mpc_control_flow(KuavoManipulationMpcControlFlow.DirectToWbc)
1869
+ # print(control.get_manipulation_mpc_ctrl_mode())
1870
+ # print(control.get_manipulation_mpc_frame())
1871
+ # print(control.get_manipulation_mpc_control_flow())
1872
+ # control.change_manipulation_mpc_frame(KuavoManipulationMpcFrame.WorldFrame)
1873
+ # control.change_robot_arm_ctrl_mode(KuavoArmCtrlMode.ExternalControl)
1874
+ # control.control_robot_end_effector_pose(KuavoPose(position=[0.3, 0.4, 0.9], orientation=[0.0, 0.0, 0.0, 1.0]), KuavoPose(position=[0.3, -0.5, 1.0], orientation=[0.0, 0.0, 0.0, 1.0]), KuavoManipulationMpcFrame.WorldFrame)