Skip to content

Conversion of position and orientation to Unity coordinate system #6

Description

@joshferns

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;
   }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions