智能小车无线控制程序

//头文件

#pragma once
#include "BaseSocket.h"
#include <afxtempl.h>
struct ChassisAction
{
char way;
char hSpeed;
char lSpeed;
char time;
};


typedef CArray<ChassisAction, ChassisAction&> ChassisArray;


class CCobotAIA1 :
public CBaseSocket
{
public:
CCobotAIA1();
~CCobotAIA1();
BOOL Platform_Up(char speed = 0x21);
BOOL Platform_Down(char speed = 0x21);
BOOL Platform_Left(char speed = 0x21);
BOOL Platform_Right(char speed = 0x21);
BOOL Platform_LeftUp(char speed = 0x21);
BOOL Platform_LeftDown(char speed = 0x21);
BOOL Platform_RightUp(char speed = 0x21);
BOOL Platform_RightDown(char speed = 0x21);
BOOL Platform_Stop();
BOOL Lift_Up();
BOOL Lift_Down();
BOOL Lift_Stop();
void Chassis_Forward(char hSpeed=0xFF, char lSpeed=0x38);
void Chassis_Back(char hSpeed = 0x00, char lSpeed = 0xC8);
void Chassis_LeftForward(char hSpeed = 0xFF, char lSpeed = 0x38);
void Chassis_RightForward(char hSpeed = 0xFF, char lSpeed = 0x38);
void Chassis_LeftBack(char hSpeed = 0x00, char lSpeed = 0xC8);
void Chassis_RightBack(char hSpeed = 0x00, char lSpeed = 0xC8);
void Chassis_Stop();
void Chassis_Left();
void Chassis_Right();
BOOL SetAlarmLampState(BOOL bAlarm = 1);
BOOL SetAlarmSoundState(BOOL bAlarm);
BOOL SetHeadLightState(BOOL bOpen);
BOOL SetTailLightState(BOOL bOpen);
BOOL SetRunningPlan(ChassisArray & chassisAry);
};

//cpp文件

#include "stdafx.h"
#include "CobotAIA1.h"


char g_pBuff[14] = {0};
BOOL g_bRun = FALSE;


UINT SendThread(LPVOID lp)
{
CCobotAIA1 *pCombot = (CCobotAIA1 *)lp;
while (g_bRun)
{
pCombot->SendSocketData(g_pBuff, 14);
Sleep(10);
}
return 0;
}


CCobotAIA1::CCobotAIA1()
{
}




CCobotAIA1::~CCobotAIA1()
{
}




BOOL CCobotAIA1::Platform_Up(char speed)
{
char chBuff[13];
chBuff[0] = 0xAA;
chBuff[1] = 0x00;
chBuff[2] = 0x95;
chBuff[3] = 0x00;
chBuff[4] = 0x07;
chBuff[5] = 0x00;
chBuff[6] = 0x00;
chBuff[7] = 0x00;
chBuff[8] = 0x00;
chBuff[9] = 0x00;
chBuff[10] = 0x08;
//chBuff[11] = 0x21;
chBuff[11] = speed;
chBuff[12] = 0x29;


return SendSocketData(chBuff, 13);
}




BOOL CCobotAIA1::Platform_Down(char speed)
{
char chBuff[13];
chBuff[0] = 0xAA;
chBuff[1] = 0x00;
chBuff[2] = 0x95;
chBuff[3] = 0x00;
chBuff[4] = 0x07;
chBuff[5] = 0x00;
chBuff[6] = 0x00;
chBuff[7] = 0x00;
chBuff[8] = 0x00;
chBuff[9] = 0x00;
chBuff[10] = 0x10;
//chBuff[11] = 0x21;
chBuff[11] = speed;
chBuff[12] = 0x31;


return SendSocketData(chBuff, 13);
}




BOOL CCobotAIA1::Platform_Left(char speed)
{
char chBuff[13];
chBuff[0] = 0xAA;
chBuff[1] = 0x00;
chBuff[2] = 0x95;
chBuff[3] = 0x00;
chBuff[4] = 0x07;
chBuff[5] = 0x00;
chBuff[6] = 0x00;
chBuff[7] = 0x00;
chBuff[8] = 0x00;
chBuff[9] = 0x00;
chBuff[10] = 0x04;
//chBuff[11] = 0x21;
chBuff[11] = speed;
chBuff[12] = 0x25;


return SendSocketData(chBuff, 13);
}




BOOL CCobotAIA1::Platform_Right(char speed)
{
char chBuff[13];
chBuff[0] = 0xAA;
chBuff[1] = 0x00;
chBuff[2] = 0x95;
chBuff[3] = 0x00;
chBuff[4] = 0x07;

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值