amymcgovern / pyparrot

Python interface for Parrot Drones
MIT License
274 stars 128 forks source link

Anafi support #188

Closed sagarjogadhenu closed 4 years ago

sagarjogadhenu commented 4 years ago

Added Anafi support and did basic testing with Anafi as well as Bebop. Tested connection, takeoff, landing and move functions. Haven't tested video functions yet.

Known issue: extract_sensor_values sometimes reports no data for Anafi. I have commented out the error print for now but otherwise things seem to work normally.

Note: I have added all xml files from ardrone3 sdk but not sure if all of those are required.

amymcgovern commented 4 years ago

This is awesome! Thank you!!

sagarjogadhenu commented 4 years ago

Thank you Amy for merging. I am still working on fixing the video aspect. It works with is_bebop set to false but currently the ipaddress is hardcoded so I am looking at retrieving the ip address from drone object. I am also looking at adding feature support, especially to control Anafi gimbal. Let me know if you have suggestions on this.

Happy new year!

On Wed, Jan 1, 2020 at 5:44 PM amymcgovern notifications@github.com wrote:

This is awesome! Thank you!!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/amymcgovern/pyparrot/pull/188?email_source=notifications&email_token=AHTXWR7PVWGJC7JPVANEXGDQ3VBJDA5CNFSM4KBXQOO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH5Q6AA#issuecomment-570101504, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHTXWRYSOCXN6KYN5IJEUNTQ3VBJDANCNFSM4KBXQOOQ .

WVandergrift commented 4 years ago

@sagarjogadhenu It looks like you have gimbal control working in your fork now. Would you be willing to create a pull request to start the process of getting those changes merged in? Thank you @sagarjogadhenu and @amymcgovern for all of your work on this great project!

sagarjogadhenu commented 4 years ago

Hi,

I didn't have time to parse the gimbal xml file with the current code since the datatype mapping seems to be different (I found it hard way by capturing Olympe messages through wireshark). In essence I have the following code for gimbal setting. You should be able to take it from here and make it better to commit to pyparrot github Hope it helps. All the best.

I added the following method to Anafi.py. Best.

def set_gimbal_target(self, gimbal_id, mode, yaw_ref, yaw, pitch_ref, pitch, roll_ref, roll):

    """

    set camera gimbal

    :param gimbal_id: # set to zero

    :param mode:      # possible values are 'position' and 'velocity'

    :yaw_ref          # Yaw frame of reference

    :yaw              # yaw in degrees

    :pitch_ref        # pitch frame of refernce

    :pitch            # pitch in degrees

    :roll_ref         # roll frame of reference

    :roll             # roll in degrees

    """

    my_file = self.command_parser.gimbal_commands

    project_id = int(my_file.feature['id'])

    class_id = 0

    for child in my_file.feature.msgs:

      for subchild in child.cmd:

         if subchild['name'] == "set_target":

           cmd_id = int(subchild['id'])

           print(cmd_id)

    # hardcoded for now

    mode_enum = 0

    yaw_ref_enum = 2

    pitch_ref_enum = 2

    roll_ref_enum = 2

    cmd_tuple = [project_id, class_id, cmd_id]

    param_tuple = [gimbal_id, mode_enum, yaw_ref_enum, yaw,

pitch_ref_enum, pitch, roll_ref_enum, roll]

    param_type_tuple = ['u8', 'u32','u32', 'float', 'u32', 'float',

'u32', 'float']

    return self.drone_connection.send_param_command_packet(cmd_tuple,

param_tuple, param_type_tuple, ack=False)

On Fri, Apr 24, 2020 at 8:34 AM Will Vandergrift notifications@github.com wrote:

@sagarjogadhenu https://github.com/sagarjogadhenu It looks like you have gimbal control working in your fork now. Would you be willing to create a pull request to start the process of getting those changes merged in? Thank you @sagarjogadhenu https://github.com/sagarjogadhenu and @amymcgovern https://github.com/amymcgovern for all of your work on this great project!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/amymcgovern/pyparrot/pull/188#issuecomment-619084304, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHTXWR66A2TTE7WE3337TA3ROGWRNANCNFSM4KBXQOOQ .

sagarjogadhenu commented 4 years ago

You may also need this change to DroneCommandParser.py

self.gimbal_commands = untangle.parse(join(dir)path, 'gimbal.xml'))

On Sat, Apr 25, 2020 at 6:29 PM Sagar Jogadhenu sagar.jogadhenu@gmail.com wrote:

Hi,

I didn't have time to parse the gimbal xml file with the current code since the datatype mapping seems to be different (I found it hard way by capturing Olympe messages through wireshark). In essence I have the following code for gimbal setting. You should be able to take it from here and make it better to commit to pyparrot github Hope it helps. All the best.

I added the following method to Anafi.py. Best.

def set_gimbal_target(self, gimbal_id, mode, yaw_ref, yaw, pitch_ref, pitch, roll_ref, roll):

    """

    set camera gimbal

    :param gimbal_id: # set to zero

    :param mode:      # possible values are 'position' and 'velocity'

    :yaw_ref          # Yaw frame of reference

    :yaw              # yaw in degrees

    :pitch_ref        # pitch frame of refernce

    :pitch            # pitch in degrees

    :roll_ref         # roll frame of reference

    :roll             # roll in degrees

    """

    my_file = self.command_parser.gimbal_commands

    project_id = int(my_file.feature['id'])

    class_id = 0

    for child in my_file.feature.msgs:

      for subchild in child.cmd:

         if subchild['name'] == "set_target":

           cmd_id = int(subchild['id'])

           print(cmd_id)

    # hardcoded for now

    mode_enum = 0

    yaw_ref_enum = 2

    pitch_ref_enum = 2

    roll_ref_enum = 2

    cmd_tuple = [project_id, class_id, cmd_id]

    param_tuple = [gimbal_id, mode_enum, yaw_ref_enum, yaw,

pitch_ref_enum, pitch, roll_ref_enum, roll]

    param_type_tuple = ['u8', 'u32','u32', 'float', 'u32', 'float',

'u32', 'float']

    return self.drone_connection.send_param_command_packet(cmd_tuple,

param_tuple, param_type_tuple, ack=False)

On Fri, Apr 24, 2020 at 8:34 AM Will Vandergrift notifications@github.com wrote:

@sagarjogadhenu https://github.com/sagarjogadhenu It looks like you have gimbal control working in your fork now. Would you be willing to create a pull request to start the process of getting those changes merged in? Thank you @sagarjogadhenu https://github.com/sagarjogadhenu and @amymcgovern https://github.com/amymcgovern for all of your work on this great project!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/amymcgovern/pyparrot/pull/188#issuecomment-619084304, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHTXWR66A2TTE7WE3337TA3ROGWRNANCNFSM4KBXQOOQ .