z1_sdk/examples/highcmd_development.cpp

29 lines
775 B
C++
Raw Normal View History

#include "unitree_arm_sdk/control/unitreeArm.h"
2022-11-14 13:07:47 +08:00
2023-07-12 20:11:26 +08:00
int main()
{
2023-01-28 16:02:16 +08:00
UNITREE_ARM::unitreeArm arm(true);
arm.sendRecvThread->start();
arm.backToStart();
arm.startTrack(UNITREE_ARM::ArmFSMState::JOINTCTRL);
double duration = 1000.;
Vec6 targetPos, lastPos;
lastPos = arm.lowstate->getQ();
targetPos << 0.0, 1.5, -1.0, -0.54, 0.0, 0.0;
2023-07-12 20:11:26 +08:00
UNITREE_ARM::Timer timer(arm._ctrlComp->dt);
2023-01-28 16:02:16 +08:00
for(int i=0; i<duration; i++)
{
arm.q = lastPos*(1-i/duration) + targetPos*(i/duration);
2023-02-02 18:25:14 +08:00
arm.qd = (targetPos-lastPos)/(duration*arm._ctrlComp->dt);
2023-09-20 17:18:58 +08:00
arm.setArmCmd(arm.q, arm.qd);
2023-07-12 20:11:26 +08:00
timer.sleep();
2022-11-14 13:07:47 +08:00
}
2023-01-28 16:02:16 +08:00
2022-11-14 13:07:47 +08:00
arm.backToStart();
2023-01-28 16:02:16 +08:00
arm.setFsm(UNITREE_ARM::ArmFSMState::PASSIVE);
2023-02-02 18:25:14 +08:00
arm.sendRecvThread->shutdown();
2022-11-14 13:07:47 +08:00
return 0;
2023-09-20 17:18:58 +08:00
}