|
|
|
@ -60,7 +60,7 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
|
|
|
|
|
bool quit = false;
|
|
|
|
|
Uint32 time = SDL_GetTicks();
|
|
|
|
|
float x = 0, y = 0, z = 0;
|
|
|
|
|
float x = 0, y = 0;
|
|
|
|
|
while(!quit) {
|
|
|
|
|
SDL_Event event;
|
|
|
|
|
while(SDL_PollEvent(&event)) {
|
|
|
|
@ -70,19 +70,19 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
switch(event.key.keysym.scancode) {
|
|
|
|
|
case SDL_SCANCODE_LEFT:
|
|
|
|
|
case SDL_SCANCODE_A:
|
|
|
|
|
x = event.type == SDL_KEYUP ? 0 : -1;
|
|
|
|
|
x = event.type == SDL_KEYUP ? 0 : 250;
|
|
|
|
|
break;
|
|
|
|
|
case SDL_SCANCODE_RIGHT:
|
|
|
|
|
case SDL_SCANCODE_D:
|
|
|
|
|
x = event.type == SDL_KEYUP ? 0 : 1;
|
|
|
|
|
x = event.type == SDL_KEYUP ? 0 : -250;
|
|
|
|
|
break;
|
|
|
|
|
case SDL_SCANCODE_UP:
|
|
|
|
|
case SDL_SCANCODE_W:
|
|
|
|
|
y = event.type == SDL_KEYUP ? 0 : 1;
|
|
|
|
|
y = event.type == SDL_KEYUP ? 0 : 250;
|
|
|
|
|
break;
|
|
|
|
|
case SDL_SCANCODE_DOWN:
|
|
|
|
|
case SDL_SCANCODE_S:
|
|
|
|
|
y = event.type == SDL_KEYUP ? 0 : -1;
|
|
|
|
|
y = event.type == SDL_KEYUP ? 0 : -250;
|
|
|
|
|
break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
@ -98,12 +98,8 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
{
|
|
|
|
|
time = currtime;
|
|
|
|
|
sdk_heartbeat(client);
|
|
|
|
|
//poll_message(client, &msg);
|
|
|
|
|
//if(msg.header.cmdid != SDK_HEARTBEAT_CMDID || msg.resp.heartbeat.retcode) {
|
|
|
|
|
// fprintf(stderr, "Did not receive heartbeat\n");
|
|
|
|
|
// return 1;
|
|
|
|
|
//}
|
|
|
|
|
chassis_speed_mode(client, x, y, z );
|
|
|
|
|
float w1 = y + x, w2 = y - x, w3 = y - x, w4 = y + x;
|
|
|
|
|
set_wheel_speed(client, w1, -w2, -w3, w4);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|