MCPcopy Create free account
hub / github.com/InternRobotics/OpenHomie / HandControl

Method HandControl

HomieDeploy/unitree_sdk2/hand_control.cpp:64–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62 float hand_action[14] = {0};
63 public:
64 HandControl(int val){
65
66 unitree::robot::ChannelFactory::Instance()->Init(0);
67 lhandcmd_publisher.reset(new unitree::robot::ChannelPublisher<unitree_hg::msg::dds_::HandCmd_>(ldds_namespace + "/cmd"));
68 lhandstate_subscriber.reset(new unitree::robot::ChannelSubscriber<unitree_hg::msg::dds_::HandState_>(lsub_namespace));
69 lhandcmd_publisher->InitChannel();
70 lstate.motor_state().resize(MOTOR_MAX);
71 lstate.press_sensor_state().resize(SENSOR_MAX);
72 msg.motor_cmd().resize(MOTOR_MAX);
73
74 rhandcmd_publisher.reset(new unitree::robot::ChannelPublisher<unitree_hg::msg::dds_::HandCmd_>(rdds_namespace + "/cmd"));
75 rhandstate_subscriber.reset(new unitree::robot::ChannelSubscriber<unitree_hg::msg::dds_::HandState_>(rsub_namespace));
76 rhandcmd_publisher->InitChannel();
77 rstate.motor_state().resize(MOTOR_MAX);
78 rstate.press_sensor_state().resize(SENSOR_MAX);
79 _simpleLCM.subscribe("hand_action", &HandControl::handleHandLCM, this);
80 _simple_LCM_thread = std::thread(&HandControl::simpleLCMThread, this);
81 _simple_hand_thread = std::thread(&HandControl::simplehandThread, this);
82 for (int item = 0; item < 7; item++){
83 hand_action_simple.act[item] = minTorqueLimits_left[item];
84 hand_action_simple.act[item+7] = maxTorqueLimits_right[item];
85 }
86 hand_action_simple.act[0] = 0.0;
87 hand_action_simple.act[1] = maxTorqueLimits_left[1];
88 hand_action_simple.act[2] = maxTorqueLimits_left[2];
89 hand_action_simple.act[7] = 0.0;
90 hand_action_simple.act[8] = minTorqueLimits_right[1];
91 hand_action_simple.act[9] = minTorqueLimits_right[2];
92
93
94 }
95 void rotateMotors(bool isLeftHand) {
96 const float* maxTorqueLimits = isLeftHand ? maxTorqueLimits_left : maxTorqueLimits_right;
97 const float* minTorqueLimits = isLeftHand ? minTorqueLimits_left : minTorqueLimits_right;

Callers

nothing calls this directly

Calls 6

press_sensor_stateMethod · 0.80
InitMethod · 0.45
resetMethod · 0.45
InitChannelMethod · 0.45
motor_stateMethod · 0.45
motor_cmdMethod · 0.45

Tested by

no test coverage detected