comoc / TelloForUnity

Ryze Tech/DJI Tello application development resources for Unity
The Unlicense
41 stars 19 forks source link

Conversion of position and orientation to Unity coordinate system #6

Open joshferns opened 6 years ago

joshferns commented 6 years ago

Hello, I've found this to be a good way of converting the position and orientation received by TelloLib to that of Unity's coordinate system.

Maybe after testing, methods for conversion could be added to the repo.

One thing I've noticed is the height data received from TelloLib seems erratic in my case, not really sure why.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TelloLib;

public class TelloPoseReceiver : MonoBehaviour {

    public Vector3 m_position;
    public Quaternion m_rotation;

    void Start ()
    {
        Tello.onUpdate += Tello_onUpdate;
    }

    private void Tello_onUpdate(int cmdId)
    {
        m_position = new Vector3(Tello.state.posX, Tello.state.posZ, Tello.state.posY);
        m_rotation = new Quaternion(-Tello.state.quatX, Tello.state.quatZ, Tello.state.quatY, Tello.state.quatW);
    }

    private void Update()
    {
        transform.SetPositionAndRotation(m_position, m_rotation);
        //transform.rotation = m_rotation;
        //transform.position = m_position;
    }

    private void OnApplicationQuit()
    {
        Tello.onUpdate -= Tello_onUpdate;
    }
}
carter-james89 commented 6 years ago

So I have a pretty good start on tracking with my TelloLibForUnity project. I'd like to add all that to my fork of this project though. Still having trouble cloning a fork with GitHub desktop though. Curious if that is on my end, or a setting @comoc needs to change.

I also noticed height is a little erratic, and seems to be updated less frequently than the position data. Here I am tracking both position (red cube) and height (blue cube). This is very basic 2D tracking but I plan to make it in all three dimensions.

https://youtu.be/Q3n4X1Q4HsM?t=73

One major problem is that it doesn't seem to track position during takeoff, so when hover the position is wrong, and needs to be reset. 0,0,0 is when you power the tello on. lots more info here.

https://tellopilots.com/threads/accurate-tello-position-data.1969/

carter-james89 commented 6 years ago

So I have basic 3D tracking up and running. Also all inputs run through the input manager for fine tuning. I'm curious @comoc what would you like me to do with my project. I need access to make my own branch or fork, else I'm just gonna upload my own Repo.

https://www.youtube.com/watch?v=9oibKtb8_hk

joshferns commented 6 years ago

@carter-james89 this looks really good, The video you posted the tellopilots forum is even better. Any plans on updating your repo with the 3D tracking?

carter-james89 commented 6 years ago

Thanks. I'm waiting to see if @comoc wants me to to collaborate in this project, or start my own. Either way @joshferns I can send it to you if you want to try.

If you don't have a flightstick the keyboard will work just fine.

comoc commented 6 years ago

Hi guys, Thank you for sharing the great works! I really wanted to implement some tracking functionality into my project.

@carter-james89 Could you fork my project and send me a pull request based on it which is including your implementations? Otherwise, can I fork your TelloLibForUnity project?

carter-james89 commented 6 years ago

I tried making a fork but it said I didn't have permission to pull. In git desktop.

Here's the better video.

https://youtu.be/KrBYfsxCI60

comoc commented 6 years ago

Amazing video! You are really great!

Have you ever tried to click the fork button on my project page yet? Not so, this instruction may help you. https://help.github.com/articles/fork-a-repo/

joshferns commented 6 years ago

Hi @carter-james89 any progress here? If it's possible, could you send me your current project in the mean time? I've been itching to try out the tracking. Thanks.

carter-james89 commented 5 years ago

hey @joshferns sorry for the delay. I was in LA all last week and the thing just wasn't ready for other people to try. @comoc I just kept getting the same permissions complaint for a fork so I ended up creating my own repository. I credit this one at the top of my git readme as well as my tello thread.

https://tellopilots.com/threads/unity-controller-for-tello-3d-tracking-tello-simulator-flight-stick-support.2288/

comoc commented 5 years ago

@carter-james89 Thank you for sharing that! Your work is really awesome! I'm very happy to help you.

Sorry for the fork problem. Just for future reference, could you please send me a screen shot or error message after you clicked the Fork button on my TelloForUnity project page? I've tried to create and login with my another new account, then I clicked the Fork button on TelloForUnity project. After that, I succeeded to fork them with no error. Here is the result: image