torque.cpp

#include "CML_AmpDef.h"
#define AMPCT 8//总共的关节的总数
#include "CML.h"
#include "can_copley.h"
#include <cstdio>
#include <cstdlib>
#include <errno.h>
#include "std_msgs/Float32.h"
#include "std_msgs/Int8.h"
#include "std_msgs/Int16.h"
#include <math.h>
CML::uunit encoder_count_current=0;
int waiting_count=3000;
CML::Amp cml_amp[1];//关节
CML::CanOpen cml_can;
CML::CopleyCAN cml_copley;
double position = 1;//设置旋转的角度大小。
void anymoves(double pos);
void delay(unsigned int a);
int main()
{
    cml_copley.SetName("CAN1"); 
    cml_copley.SetBaud(1000000); 
    CML::AmpSettings setting;//amplifier settings
    setting.resetOnInit = true;//amplifier settings to be used
    cml_can.Open(cml_copley);//reference to the CANopen Network for this amp
 	
    cml_amp[0].Init(cml_can, 8, setting);//construct and initialize the amplifier object.

printf("move  \n");
CML::ProfileConfigTrap cml_mode;
cml_mode.vel = 2500;//速度
cml_mode.acc = 5000;//加速度
cml_mode.dec = 5000;//减速度
cml_amp[0].DoMove(cml_mode, true);
cml_amp[0].SetAmpMode(CML::AMPMODE_CAN_TORQUE);
cml_amp[0].StartMove(true);
cml_amp[0].SetTorqueTarget(300);
sleep(1000);
//
// 

 
printf(" down\n");
}

你可能感兴趣的:(torque.cpp)