command载入到芯片中
parent
b4dbfe735f
commit
b7e28f468b
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
void Command::run(char* str){
|
void Command::run(char* str){
|
||||||
for(int i=0; i < call_count; i++){
|
for(int i=0; i < call_count; i++){
|
||||||
if(isSentinel(call_ids[i],str)){ // case : call_ids = "T2" str = "T215.15"
|
if(isSentinel(call_ids[i],str)){ // case : call_ids = "T2" str = "T215.155"
|
||||||
call_list[i](str+strlen(call_ids[i])); // get 15.15 input function
|
call_list[i](str+strlen(call_ids[i])); // get 15.155 input function
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
Command command;//声明一个自己的该类的对象
|
|
||||||
|
|
||||||
|
//命令设置
|
||||||
|
float target_velocity = 0;
|
||||||
|
Command comm;//声明一个自己的该类的对象
|
||||||
|
void doTarget(char* cmd) { comm.scalar(&target_velocity, cmd); }
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
|
Serial.begin(115200);
|
||||||
|
comm.add("T",doTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// put your main code here, to run repeatedly:
|
// put your main code here, to run repeatedly:
|
||||||
|
comm.run("T233.2548");
|
||||||
|
Serial.println(target_velocity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,15 +66,19 @@ BLDCDriver3PWM driver = BLDCDriver3PWM(32, 33, 25, 22);
|
||||||
|
|
||||||
|
|
||||||
//命令设置
|
//命令设置
|
||||||
Command command;
|
Command comm;
|
||||||
double target_velocity = 0;
|
double target_velocity = 0;
|
||||||
double target_angle = 91;
|
double target_angle = 91;
|
||||||
double target_voltage = 0;
|
double target_voltage = 0;
|
||||||
|
void do_K1(char* cmd) { comm.scalar(&LQR_K1, cmd); }
|
||||||
|
|
||||||
void onPacketCallBack(AsyncUDPPacket packet)
|
void onPacketCallBack(AsyncUDPPacket packet)
|
||||||
{
|
{
|
||||||
char* da;
|
char* da;
|
||||||
da= (char*)(packet.data());
|
da= (char*)(packet.data());
|
||||||
Serial.println(da);
|
Serial.println(da);
|
||||||
|
comm.run(da);
|
||||||
|
Serial.println(LQR_K1);
|
||||||
// target_velocity = atoi();
|
// target_velocity = atoi();
|
||||||
// Serial.print("数据内容: ");
|
// Serial.print("数据内容: ");
|
||||||
// Serial.println(target_velocity);
|
// Serial.println(target_velocity);
|
||||||
|
@ -84,7 +88,8 @@ void onPacketCallBack(AsyncUDPPacket packet)
|
||||||
// instantiate the commander
|
// instantiate the commander
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
//命令设置
|
||||||
|
comm.add("K1",do_K1);
|
||||||
|
|
||||||
// kalman mpu6050 init
|
// kalman mpu6050 init
|
||||||
Wire.begin(19, 18,400000);// Set I2C frequency to 400kHz
|
Wire.begin(19, 18,400000);// Set I2C frequency to 400kHz
|
||||||
|
@ -261,7 +266,7 @@ void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if 1
|
#if 0
|
||||||
|
|
||||||
Serial.print(kalAngleZ);Serial.print("\t");
|
Serial.print(kalAngleZ);Serial.print("\t");
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -16,7 +16,7 @@ def udp_recv(udp_socket):
|
||||||
recv_data = udp_socket.recv(1024)
|
recv_data = udp_socket.recv(1024)
|
||||||
recv_data = recv_data.decode('utf-8')
|
recv_data = recv_data.decode('utf-8')
|
||||||
udp_data = recv_data
|
udp_data = recv_data
|
||||||
print('收到信息为:%s'%recv_data)
|
# print('收到信息为:%s'%recv_data)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #创建套接字
|
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.
Loading…
Reference in New Issue