From a6cc1eca8840ea519ebde282c94e291da87cdd57 Mon Sep 17 00:00:00 2001 From: PgSocks Date: Wed, 4 Jan 2023 18:54:51 -0600 Subject: [PATCH] Control individual wheels --- src/modules/chassis.c | 2 +- src/sdl.c | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/modules/chassis.c b/src/modules/chassis.c index 44b2faa..876a709 100644 --- a/src/modules/chassis.c +++ b/src/modules/chassis.c @@ -14,7 +14,7 @@ set_wheel_speed ( req.wheel.wheel_speed[1] = w2; req.wheel.wheel_speed[2] = w3; 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)); } diff --git a/src/sdl.c b/src/sdl.c index 714575f..42555f9 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -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); } }