1 Star 0 Fork 0

sirli/AxleRobotOld

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gugaomotor.h 3.40 KB
一键复制 编辑 原始数据 按行查看 历史
sirli 提交于 2021-02-24 01:25 . base files
#ifndef GUGAOMOTOR_H
#define GUGAOMOTOR_H
#include"../single_card/gts.h"
#include<qstring.h>
#include<qdebug.h>
#include<QPushButton>
#include <QObject>
enum Axle //电机轴号
{
Axle1=1,
Axle2=2,
Axle3=3,
Axle4=4,
Axle5=5,
Axle6=6,
Axle7=7,
Axle8=8
};
struct Position
{
Position():Xpos(0),Ypos(0),Zpos(0),Upos(0) {}
double Xpos;
double Ypos;
double Zpos;
double Upos;
};
typedef struct Point
{
Point():crd(1),Fifo(0), Radius(200.0),Speed(10.0),
ASpeed(1.5), EndSpeed(0),CircleDir(0),
double1(0.0),double2(0.0),bool1(false),bool2(false),
int1(0),int2(0),str1(""),str2("") {}
short crd; //坐标系
short Fifo; //缓存区
// double Xpos;
// double Ypos;
// double Zpos;
// double Rpos;
Position Pos;
double Radius; //半径
double Speed;
double ASpeed;
double EndSpeed;
short CircleDir; //方向; 逆时针为 1, 顺时针为 0
bool bool1;
bool bool2;
int int1;
int int2;
double double1;
double double2;
QString str1;
QString str2;
} Point;
struct HomePara
{
HomePara():HomeSpeed(200),SEARCH_HOME(200000),HOME_OFFSET(2000),
SEARCH_INDEX(20000),INDEX_OFFSET(2000) {}
int Direction[4]; //0:负方向,1:正方向,2:屏蔽该轴
double HomeSpeed; // 回零速度
long SEARCH_HOME; // 定义home回零搜索距离
long HOME_OFFSET; // 定义到home捕获位置的偏移量
long SEARCH_INDEX; // 定义index回零搜索距离
long INDEX_OFFSET; // 定义到index捕获位置的偏移量
};
struct MovoPara
{
MovoPara():Power(false),Ratio(4)
{
for(int i=0;i<4;i++)
{
ManualSpeed[i]=10;
AutoSpeed[i]=20;
}
}
bool Power; //高低速模式,true:low; false:high
int Ratio; //高低速比率
double ManualSpeed[4]; //指高速
double AutoSpeed[4]; //指高速
};
struct MotorPara
{
MotorPara()
{
MotorTrapPrm.acc=0.25;
MotorTrapPrm.dec=0.125;
MotorTrapPrm.smoothTime=25;
MotorTrapPrm.velStart=1;
}
// int MoveMode; //0:relative, 1:abstive
TrapPrm MotorTrapPrm; //点位运动模式参数
HomePara m_HomePara;
MovoPara m_MovoPara;
};
class GuGaoMotor : public QObject
{
Q_OBJECT
public:
explicit GuGaoMotor(QObject *parent = 0);
~GuGaoMotor();
void CommandHandler(QString CmdStr, short CmdResult);//命令执行状态显示
int LoadSetting(char *CfgStr); //加载配置和上伺服,CfgStr:配置文件的地址
int Home(int Axle=1); //sinle back to zero
int HomeIndex(int Axle=1); //single back to zere with "z" signal
int SetCraPrm(TCrdPrm CrdPrm); //建立二维坐标系
int MoveRelative(long position,double speed,int Axle=1);//单轴相对运动
int MoveABS(long position,double speed,int Axle=1); //单轴绝对运动
int MoveJop(double speed,QPushButton *btn ,int Axle=1 );//单轴JOP, btn is from ui;
int MoveLine(Point m_Point); //XY直线插补
int MoveArcR(Point m_Point); //半径描述圆插补
int MoveArcC(Point m_Point ,double X_center,double Y_center); //圆心描述圆插补
Position GetAxlePos(); //获取轴位置坐标
signals:
void SigCommandHandler(QString);
};
#endif // GUGAOMOTOR_H
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lixin3216/AxleRobotOld.git
git@gitee.com:lixin3216/AxleRobotOld.git
lixin3216
AxleRobotOld
AxleRobotOld
master

搜索帮助