command载入到芯片中

master
45coll 2021-10-11 15:07:48 +08:00
parent b4dbfe735f
commit b7e28f468b
13 changed files with 12588 additions and 9 deletions

View File

@ -2,8 +2,8 @@
void Command::run(char* str){
for(int i=0; i < call_count; i++){
if(isSentinel(call_ids[i],str)){ // case : call_ids = "T2" str = "T215.15"
call_list[i](str+strlen(call_ids[i])); // get 15.15 input function
if(isSentinel(call_ids[i],str)){ // case : call_ids = "T2" str = "T215.155"
call_list[i](str+strlen(call_ids[i])); // get 15.155 input function
break;
}
}

View File

@ -1,11 +1,19 @@
#include "Command.h"
Command command;//声明一个自己的该类的对象
//命令设置
float target_velocity = 0;
Command comm;//声明一个自己的该类的对象
void doTarget(char* cmd) { comm.scalar(&target_velocity, cmd); }
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
comm.add("T",doTarget);
}
void loop() {
// put your main code here, to run repeatedly:
comm.run("T233.2548");
Serial.println(target_velocity);
}

View File

@ -66,15 +66,19 @@ BLDCDriver3PWM driver = BLDCDriver3PWM(32, 33, 25, 22);
//命令设置
Command command;
Command comm;
double target_velocity = 0;
double target_angle = 91;
double target_voltage = 0;
void do_K1(char* cmd) { comm.scalar(&LQR_K1, cmd); }
void onPacketCallBack(AsyncUDPPacket packet)
{
char* da;
da= (char*)(packet.data());
Serial.println(da);
comm.run(da);
Serial.println(LQR_K1);
// target_velocity = atoi();
// Serial.print("数据内容: ");
// Serial.println(target_velocity);
@ -84,7 +88,8 @@ void onPacketCallBack(AsyncUDPPacket packet)
// instantiate the commander
void setup() {
Serial.begin(115200);
//命令设置
comm.add("K1",do_K1);
// kalman mpu6050 init
Wire.begin(19, 18,400000);// Set I2C frequency to 400kHz
@ -261,7 +266,7 @@ void loop() {
}
#endif
#if 1
#if 0
Serial.print(kalAngleZ);Serial.print("\t");

View File

@ -16,7 +16,7 @@ def udp_recv(udp_socket):
recv_data = udp_socket.recv(1024)
recv_data = recv_data.decode('utf-8')
udp_data = recv_data
print('收到信息为:%s'%recv_data)
# print('收到信息为:%s'%recv_data)
def main():
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #创建套接字

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.