clydemcqueen / tello_ros

C++ ROS2 driver for DJI Tello drones
BSD 3-Clause "New" or "Revised" License
193 stars 65 forks source link

ModuleNotFoundError: No module named 'transformations' (gazebo spawn drone issue) [solved] #75

Closed jeonsion closed 1 year ago

jeonsion commented 1 year ago

i faced issue at inject_entity.py (/root/tello_ws/install/tello_gazebo/lib/tello_gazebo/inject_entity.py) and i can't solve use "pip install" command

ModuleNotFoundError: No module named 'transformations'

and i would like to share the solution for you who try to spawn tello_urdf in gazebo

solution1) add below method in inject_entity.py

def quaternion_from_euler(roll, pitch, yaw):
    """
    Converts euler roll, pitch, yaw to quaternion (w in last place)
    quat = [x, y, z, w]
    Bellow should be replaced when porting for ROS 2 Python tf_conversions is done.
    """
    cy = math.cos(yaw * 0.5)
    sy = math.sin(yaw * 0.5)
    cp = math.cos(pitch * 0.5)
    sp = math.sin(pitch * 0.5)
    cr = math.cos(roll * 0.5)
    sr = math.sin(roll * 0.5)

    q = [0] * 4
    q[0] = cy * cp * cr + sy * sp * sr
    q[1] = cy * cp * sr - sy * sp * cr
    q[2] = sy * cp * sr + cy * sp * cr
    q[3] = sy * cp * cr - cy * sp * sr

    return q

solution2) include tranformation.py file in the same path as injcet_entity.py https://github.com/ros/geometry/blob/noetic-devel/tf/src/tf/transformations.py#L1100