Pexeus / LTE-Car

42 stars 12 forks source link

How to control using keyboard #12

Closed fantasaga closed 5 months ago

fantasaga commented 6 months ago

Yeah so its working fine, its fun, but all the time i was using Crossfire to control. Going through buildings as far as 90m away doesnt work well, but i dont have a frikin gamepad. So how can i make it so i can control the RC car through the website using keyboard ?

Pexeus commented 6 months ago

All you need to do is modify this file: https://github.com/Pexeus/LTE-Car/blob/main/server/client/src/control/gamepad.js

Im Confident you can do this with the help of ChatGPT, even if you dont have any programming experience. Just make sure you make the right keys do the right stuff!

otherwise, any cheap PS4 Gamepad should do.

Also im still waiting to see a video of the car driving around ;)

fantasaga commented 6 months ago

https://drive.google.com/file/d/1EFm597-kXJag_1JsX8PHhZYlsIhYda3W/view?usp=sharing, https://drive.google.com/file/d/1qAC6nMYyVDx3F1feEZcdyq3K5bNU16hd/view?usp=sharing ^^^ some vids I took yesterday. one is from the PC (its the video recorder lag) and one is from the HD camera. Oh and should I modify anything in the onboard side

fantasaga commented 6 months ago

Would this work? (From gpt4)

const gpControls = {
    axes: {
        0: 0, // Assuming axis 0 is for left and right
    },
    paddles: {},
    buttons: {
        padLeft: false,
        padRight: false
    }
}

// Function to adjust axis value within -1 to 1 range
function adjustAxis(value) {
    return Math.max(-1, Math.min(1, value));
}

document.addEventListener("keydown", function(e) {
    switch (e.keyCode) {
        case 37: // Left arrow key
            gpControls.axes[0] = adjustAxis(gpControls.axes[0] - 0.1);
            break;
        case 39: // Right arrow key
            gpControls.axes[0] = adjustAxis(gpControls.axes[0] + 0.1);
            break;
        case 38: // Up arrow key
            gpConf.buttons.padLeft = true;
            break;
        case 40: // Down arrow key
            gpConf.buttons.padRight = true;
            break;
    }
});

document.addEventListener("keyup", function(e) {
    switch (e.keyCode) {
        case 38: // Up arrow key
            gpConf.buttons.padLeft = false;
            break;
        case 40: // Down arrow key
            gpConf.buttons.padRight = false;
            break;
        case 37: // Left arrow key
        case 39: // Right arrow key
            gpControls.axes[0] = 0;
            break;
    }
});

function updateControls() {
    // Update logic based on gpControls and gpConf
    // ...

    setTimeout(updateControls, 100);
}

updateControls();
fantasaga commented 6 months ago

It doesnt work plz help

fantasaga commented 6 months ago

Can the website show 60fps video ? Im about to close this bcs i have a ps4 gamepad

Pexeus commented 6 months ago

Sorry for the late Response! The website can display 60fps without any problems, just make sure that you have enough bandwidth :D

Pexeus commented 6 months ago

https://drive.google.com/file/d/1EFm597-kXJag_1JsX8PHhZYlsIhYda3W/view?usp=sharing, https://drive.google.com/file/d/1qAC6nMYyVDx3F1feEZcdyq3K5bNU16hd/view?usp=sharing ^^^ some vids I took yesterday. one is from the PC (its the video recorder lag) and one is from the HD camera. Oh and should I modify anything in the onboard side

So cool! Thanks for sharing! Btw, if you wanna go next level, check this out: https://github.com/Pexeus/flight

fantasaga commented 6 months ago

Yeah the fps says 60 but its feeling like 30, i have 60mbps wifi on the PC side. For that flight thing im probably going to do bcs i have a wing lying around. I can also show you another video, thistime i went through the whole quarter around my house. 🏎💻♥

fantasaga commented 5 months ago

Got a cheap ps4 gamepad, thanks now it works though the latency is way to high.

Pexeus commented 5 months ago

@fantasaga Sorry for the late respnse. Id recommend setting the quality/fps very low to begin with and try how the latency feels. Also sure show me all the videos u have! Are u ok with me putting one of them in the readme so others can see them?

fantasaga commented 4 months ago

Certainly, tho i have better ones that went more far.

fantasaga commented 4 months ago

But please only show the recording from the actual FPV stream, not from the DJI recording.