hjstn / miniDjiController

Python VJoy interface for Mavic Mini RC. Inspired (and with help from) Matsemann/mDjiController and slaterbbx/mDjiController.
Apache License 2.0
27 stars 12 forks source link

Also Works for Mavic 2 Pro remote controller but with Latency Issue #9

Open PanterSoft opened 11 months ago

PanterSoft commented 11 months ago

Hello I tried this with the mavic 2 Remote Control and the sticks also work as expected the only issue I am encounter is that over time when I am using the controller the Stick commands are more and more getting laggy

Does someone have the same issue and Knows how to fix this ?

Miniontoby commented 10 months ago

Did you comment out the print lines? So the lines 59 and 87.

Cause printing to console makes it really have a lot of latency.

PanterSoft commented 10 months ago

@Miniontoby

Yes I tried that and it only gave me a small improvement. but it still got worse over time

Miniontoby commented 10 months ago

If you look at the code that exists in IvanYaky/DJI_RC-N1_SIMULATOR_FLY_DCL -> main.py L191-192, then you will see this code:

    # enable simulator mode for RC (without this stick positions are sent very slow by RC)
    send_duml(s, 0x0a, 0x06, 0x40, 0x06, 0x24, bytearray.fromhex('01'))

This snippet actually uses a function to create a message, but it translates into 550e04660a06eb3440062401d9ec. This you can use in an:

s.write(bytearray.fromhex('550e04660a06eb3440062401d9ec'))

But where do I put that?

Put it, with 4 spaces in front, after line 53 as it is in main.py at the moment of writing.

resulting into:

(...)

try:
    # enable simulator mode for RC (without this stick positions are sent very slow by RC)
    s.write(bytearray.fromhex('550e04660a06eb3440062401d9ec'))
    while True:
        # Ping device (to get new data).

(...)

Of course, this has ONLY been tested for the RC-N1 and could be different for the Mavic 2 Pro controller.

If that would be the case, then you could (if you have the knowledge [or if we just do it together remotely]) just mitm/reverse-engineer it yourself, just like the others did to make this possible. [I have Discord if you want me to help]

PanterSoft commented 10 months ago

Hello @Miniontoby

I am not at home at the moment where my controller is.

I would love to reverse engineer it with your help as soon as I am at home and got my controller on hand. As I am pretty new to reverse Engineering I would need the help.

Miniontoby commented 10 months ago

First just try the code I supplied, if it doesn't work, let me know where I can find you. (Perhaps Discord or even IRC)

K177ok commented 10 months ago

А на Mavic Pro почему-то не работает, хотя очень надо!(

K177ok commented 10 months ago

Traceback (most recent call last): File "C:\Users\k177o\Desktop\DJI SIM\MiniDJIController\main.py", line 6, in import serial, pyvjoy, argparse ModuleNotFoundError: No module named 'serial'

K177ok commented 10 months ago

It seems like I've done something in python for the first time in my life. Remote control from Mavic PRO - works! But there is a big delay, which gets even worse with each click. I tried inserting the data suggested above, but it didn't help. It didn't work out to comment out either. I will be glad to help.

Miniontoby commented 10 months ago

Traceback (most recent call last): File "C:\Users\k177o\Desktop\DJI SIM\MiniDJIController\main.py", line 6, in import serial, pyvjoy, argparse ModuleNotFoundError: No module named 'serial'

You need to installl the deps first: pip install -r requirements.txt

Miniontoby commented 10 months ago

It seems like I've done something in python for the first time in my life. Remote control from Mavic PRO - works! But there is a big delay, which gets even worse with each click. I tried inserting the data suggested above, but it didn't help. It didn't work out to comment out either. I will be glad to help.

You should put an # before EVERY print code lines after the while line, this will reduce the lag (a little bit, it will still get more delay after a while)

K177ok commented 10 months ago

It seems like I've done something in python for the first time in my life. Remote control from Mavic PRO - works! But there is a big delay, which gets even worse with each click. I tried inserting the data suggested above, but it didn't help. It didn't work out to comment out either. I will be glad to help.

You should put an # before EVERY print code lines after the while line, this will reduce the lag (a little bit, it will still get more delay after a while)

Unfortunately, the latency after the first iteration grows with each click. Increases to 3-5 seconds :(

Miniontoby commented 10 months ago

yeah, I personally don't have the according controller for this, so I cannot try to fix it myself

K177ok commented 10 months ago

myself

Maybe we can try to do it together? For example, via AnyDesk? :)

Miniontoby commented 10 months ago

I would prefer Zoom or VNC Viewer. Those I already have installed and those I trust and those I know that work.