Control individual wheels

refactor
PgSocks 2 years ago
parent 8a34d18eac
commit a6cc1eca88

@ -14,7 +14,7 @@ set_wheel_speed (
req.wheel.wheel_speed[1] = w2; req.wheel.wheel_speed[1] = w2;
req.wheel.wheel_speed[2] = w3; req.wheel.wheel_speed[2] = w3;
req.wheel.wheel_speed[3] = w4; req.wheel.wheel_speed[3] = w4;
req_finalize(session, 0x3F, SET_WHEEL_SPEED_CMDID, host2byte(CHASSIS_HOST, CHASSIS_INDEX), true, sizeof(struct SetWheelSpeedReq), &req); req_finalize(session, 0x3F, SET_WHEEL_SPEED_CMDID, host2byte(CHASSIS_HOST, CHASSIS_INDEX), false, sizeof(struct SetWheelSpeedReq), &req);
req_send(session->dev_conn, &req, sizeof(struct SetWheelSpeedReq)); req_send(session->dev_conn, &req, sizeof(struct SetWheelSpeedReq));
} }

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

Loading…
Cancel
Save