z1_sdk/examples/highcmd_development.cpp

24 lines
637 B
C++
Raw Normal View History

#include "unitree_arm_sdk/control/unitreeArm.h"
2022-11-14 13:07:47 +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;
for(int i=0; i<duration; i++)
{
arm.q = lastPos*(1-i/duration) + targetPos*(i/duration);
arm.qd = (targetPos-lastPos)/(duration*0.002);
usleep(2000);
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);
2022-11-14 13:07:47 +08:00
return 0;
}