Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calibration Gimbal Phantom 4 Series #99

Open
jebtir opened this Issue Dec 11, 2018 · 21 comments

Comments

Projects
None yet
3 participants
@jebtir
Copy link

commented Dec 11, 2018

HI, I am from Brazil and I am looking for a person who sell the Software for calibration of Gimbal's DJI. I say calibration, when you change some module ESC of the engines. Example: ESC Yaw/Roll Gimbal Phantom 4 or Phantom 4 Pro and the Gimbal goes crooked. I saw that you made a gimbal Spark calibration Software available, would you sell some to calibrate gimbal from the other Drones?

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Dec 11, 2018

The method for calibrating each model is probably different. I don't know how to do this exactly, that would require some research. I'm not sure if I'll be looking into that.

Spark has a pre-made auto calibration function which is easy to trigger. Previous platforms seem to have less automated solution, but I never looked at details.

@jebtir

This comment has been minimized.

Copy link
Author

commented Dec 11, 2018

And how much would you charge to make a script for calibration of Gimbal's Phantom 4 series, Phantom 3 and perhaps inspire? I pay you to do that, I don't want it for free!

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Dec 11, 2018

We would have to go with one platform at a time.
Also, you'd have to be involved in testing what various packets do. From the platforms you mentioned, I only have Ph3, and its gimbal is properly aligned - so not a good test subject.

About paying for the task - I'm not sure if I want to go this way; the time I can spend on this is limited. But I do accept donations.

Sign to Slack - we may talk further there; see Slack link in top menu here:
http://dji.retroroms.info/

I will try to find time for some initial research on the subject.

@jebtir

This comment has been minimized.

Copy link
Author

commented Dec 11, 2018

The site to be faced with stability issues. I can not access the same! Could you pass your email or WhatsApp? I will help in what possible (testing with drones). About the donations, I will donate yes.

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Dec 11, 2018

The "hardware" channel on Slack is the place where many people discuss mods and repairs for DJI products.

But if you can't access it - we can talk here. I don't use any other messaging apps.

@jebtir

This comment has been minimized.

Copy link
Author

commented Dec 11, 2018

I'm trying to access it, but I can't. What do you need to give the tip foot in the software for calibration? I have all the drones here to test....

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Dec 11, 2018

First I will look at gimbal module (m0400) for various platforms. I have the ones for Ph3, Ph4 and Inspire, but I don't think I have one for Ph2 Vision - and it could be helpful.

I will be searching for m0400 modules which are larger in size - this may indicate a version with more debugging messages left in the code.

I need to get a basic understanding of how the firmware works, then I'll get to figuring out the packets which can be sent to it.

@jebtir

This comment has been minimized.

Copy link
Author

commented Dec 11, 2018

I have a great friend who also program in Python, if you need any other help, I can talk to him... I can help with the tests, since I have no advanced knowledge of software.

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Dec 11, 2018

It will take some time before I have anything to test. I still need to finish current tasks.

Anyway, at some point I'll want you to run comm_serialtalk.py - so you may want to prepare for it, to the point where the example instruction from README works.

And you can try searching Ph2 firmwares for me.

@jebtir

This comment has been minimized.

Copy link
Author

commented Dec 11, 2018

Here on the website of DJI has some firmware of the Phantom 2 Plus which is the latest version of PH2

https://www.dji.com/phantom-2-vision-plus/info#downloads

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Dec 26, 2018

Here are ALL packets on which Phantom 3 Gimbal reacts. The table comes from version P3X_FW_V01.11.0030_m0400:

function cmdid cmdset
packet_exec_gimb_push_aetr
Sets 4 values from packet within gimbal RAM, each in range 364..1684: Aileron, Elevator, Throttle and Rudder. Supports payload encryption. No ACK possible.
0x06 Gimbal
packet_exec_gimb_control
Sets 3 values from packet within gimbal RAM, each in range 364..1684; meaning of them is unknown. Supports payload encryption. No ACK possible.
0x01 Gimbal
packet_exec_spec_special_app_control
Sets some values (10 bytes) from packet within gimbal RAM; unknown. No ACK possible.
0x01 Special
packet_exec_flyc_posture
Sets aircraft posture (4 float values) from packet within gimbal RAM; sent periodically during flight by Flight Controller. Supports payload encryption.
0x42 FlightCtrl
packet_exec_gimb_ext_ctrl_accel
Sets 3 angular values from packet within gimbal RAM; sets angular accelerations of each axis.
0x0C Gimbal
packet_exec_gimb_thirdp_magn
Sets 3 values from packet; does some processing on the values, influences many values stored in RAM. Maybe calibrates the gimbal for work with third party magnetometer?
0x0E Gimbal
packet_exec_gimb_calibration
Triggers auto-calibration, the same which can be triggered by mobile app. Calibrates only 2 axes.
0x08 Gimbal
packet_exec_gimb_adjust_roll
Receives a value from packet and shifts internal roll adjustment by it. The adjustment is not saved into persistent storage.
0x07 Gimbal
packet_exec_gener_version_inquiry
When received, the gimbal responds with a packet containing hardware and software versions.
0x01 Universal
packet_exec_gener_enter_loader
When received, the gimbal software sets startup parameters so that it starts to bootloader mode, and reboots the chip. This is initial step of a firmware update.
0x07 Universal
packet_exec_gener_update_confirm
Used during firmware update.
0x08 Universal
packet_exec_gener_update_transmit
Used during firmware update.
0x09 Universal
packet_exec_gener_update_finish
Used during firmware update.
0x0A Universal
packet_exec_gener_reboot_chip
When received, the gimbal mcu reboots.
0x0B Universal
packet_exec_gener_get_device_state
In response to this request, gimbal returns a dword value representing its state. It looks like this state value is not really used and has no real meaning.
0x0C Universal
packet_exec_gener_set_device_version
Its main purpose is to convince the device about which versions of SW and HW it should report; though only some of the set values are really used for reporting. It has additional magic value triggers which allow to overwrite internal storage, including calibration data. Very suspicious. Potentially very powerful.
0x0D Universal
packet_exec_gener_encrypt_config
Used for factory encryption pairing. Consists of 3 sub-commands: GetChipState, GetModuleState, Config.
0x30 Universal
packet_exec_gimb_cmd20
Sets 3 values from packet within gimbal RAM; meaning of them is unknown. No ACK possible.
0x20 Gimbal
packet_exec_gimb_ext_ctrl_degree
Sets 3 angular values and 3 additional values from packet within gimbal RAM. Resets values from packet 0x20 to 1 if ACK was requested (do you even design, Dji?).
0x0A Gimbal
packet_exec_gimb_get_ext_ctrl_status
In response to this request, gimbal returns a flag field and int value representing current ctrl status.
0x0B Gimbal
packet_exec_gimb_suspend_resume
Allow to suspend or resume gimbal motion when correct magic value is provided as payload. Sets a single flag in RAM. No ACK possible.
0x0D Gimbal
packet_exec_gimb_get_user_param
Given indexes of gimbal user params, returns a list of their values. Values have different size depending on their type. There are 12 gimbal user params defined in the firmware; they work in a similar way as FlyC Params.
0x10 Gimbal
packet_exec_gimb_set_user_param
Allows to set new values of gimbal user params. Index and size of each param must be provided. Also resets values from packet 0x20 to 1.
0x0F Gimbal
packet_exec_gimb_save_user_param
Stores values from user_param list, and additional values like the roll adjustment, to persistent storage. Requires one byte payload to send an ACK, but that byte value is not used (because why not.). Besides returning status code, also sets values from packet 0x20 to different numbers on success and on failure.
0x11 Gimbal
packet_exec_gimb_cmd21
Sets values of unknown 3-element list within RAM. Each list entry consists of 3 integers. No ACK possible.
0x21 Gimbal
packet_exec_gimb_resume_default_param
Restores values of all user params to defaults from persistent storage. Resets values from packet 0x20 to 1.
0x13 Gimbal
packet_exec_gimb_cmd14
Sets 3 angular values and 1 additional value from packet within gimbal RAM. Also contains flags field which influences which fields are set. Meaning of values is unknown. No ACK possible.
0x14 Gimbal

Now we can test what each of these does and find out which is used to calibration or position setting.

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Dec 29, 2018

Disclamer: This can damage the gimbal. I don't know what it does. I will just provide packets which look like they might trigger calibration or control the yaw arm.

Now, first check if taking to gimbal even works (this command is safe):

./comm_serialtalk.py COM5 -vv --receiver_type=Gimbal --seq_num=12341 --ack_type=ACK_After_Exec --cmd_set=General --cmd_id=1

If it does (versions are shown in response), then we can get to business.

I will provide proper commands as soon as I finish figuring them out. The idea I have is to enter work mode 5 - it looks like a different version of auto-calibration routine (which is work mode 3).

@jebtir

This comment has been minimized.

Copy link
Author

commented Dec 29, 2018

Hey, buddy. How you doing, huh? Very good! I will test this command on some Phantom 3

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Dec 29, 2018

Please do.

My idea of switching to work mode 5 is not as easy as I anticipated - all packets which allow to control work mode are masking it to 2 bits (allowing only modes 0..3).

I am searching for alternatives.

Also, I don't have any firmware from Ph2 - that would require quite some work to get, as the FW is downloadable through Ph2 Assistant. So I think I'll skip it.

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Jan 9, 2019

Update:
I got all firmwares for Ph2, am looking at them now; will get back to looking at Ph3 gimbal code when I'm done with them.

@jebtir

This comment has been minimized.

Copy link
Author

commented Jan 9, 2019

Tell me, my friend, how was your year-end? I wish you much health, peace and a lot of money that year. I arrived on a trip today, I was at the relatives ' house. I'm going to test the Phantom 3 code tomorrow, and I'll give you a return.

@jebtir

This comment has been minimized.

Copy link
Author

commented Jan 25, 2019

Hi, how are you? I went to work. I'm going to take the test this week on a Phantom 3 Pro. It would be interesting if I had any other way to talk to you, I have a good proposition for this project.

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Jan 25, 2019

You can write me an e-mail.
mefistotelis@gmail.com

I am still working on pre-Ph3 firmwares; have limited time for that, so it takes quite long.

@cimona

This comment has been minimized.

Copy link

commented Jan 25, 2019

@jebtir jebtir closed this Apr 18, 2019

@jebtir jebtir reopened this Apr 18, 2019

@jebtir

This comment has been minimized.

Copy link
Author

commented Apr 18, 2019

Hey, did you abandon the "project? "

@mefistotelis

This comment has been minimized.

Copy link
Collaborator

commented Apr 18, 2019

I am not working on it now. May be back when I have more time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.