question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting state from "moveToChanged"

See original GitHub issue

Hello, first, thank you for the code! It’s really helping me with my thesis.

I’m working with a Bebop 2 and have a question about moving the drone to GPS coordinates. I’ve made some code that uses the “moveTo” command to make the drone reach a specific coordinate. I was wondering if I could ask the bebop whether it has reached its destination coordinate. I currently have no way of knowing when the drone actually reaches that point. Since I noticed in the code that you ask for “AllStates” (in common.xml, common class, AllStates cmd), I thought you might know how to go about this.

I’ve figured out there is a command that seems to poll for a “moveToChanged” state. Refer to the following code (in ardrone3.xml, PilotingState class, moveToChanged cmd):

<cmd name="moveToChanged" id="12">
    <comment
        title="Move to changed"
        desc="The drone moves or moved to a given location."
        support="090c:4.3.0"
        triggered="by [MoveTo](#1-0-10) or when the drone did reach the given position."/>
    <arg name="latitude" type="double">
        Latitude of the location (in degrees) to reach
    </arg>
    <arg name="longitude" type="double">
        Longitude of the location (in degrees) to reach
    </arg>
    <arg name="altitude" type="double">
        Altitude above sea level (in m) to reach
    </arg>
    <arg name="orientation_mode" type="enum">
        Orientation mode of the move to
        <enum name="NONE">
            The drone won't change its orientation
        </enum>
        <enum name="TO_TARGET">
            The drone will make a rotation to look in direction of the given location
        </enum>
        <enum name="HEADING_START">
            The drone will orientate itself to the given heading before moving to the location
        </enum>
        <enum name="HEADING_DURING">
            The drone will orientate itself to the given heading while moving to the location
        </enum>
    </arg>
    <arg name="heading" type="float">
        Heading (relative to the North in degrees).
        This value is only used if the orientation mode is HEADING_START or HEADING_DURING
    </arg>
    <arg name="status" type="enum">
        Status of the move to
        <enum name="RUNNING">
            The drone is actually flying to the given position
        </enum>
        <enum name="DONE">
            The drone has reached the target
        </enum>
        <enum name="CANCELED">
            The move to has been canceled, either by a CancelMoveTo command
            or when a disconnection appears.
        </enum>
        <enum name="ERROR">
            The move to has not been finished or started because of an error.
        </enum>
    </arg>
</cmd>

However, in contrast to the AllStates cmd, this cmd seems to require arguments (refer the the snippet below).

<cmd name="AllStates" id="0" timeout="RETRY">
    <comment
        title="Ask for all states"
        desc="Ask for all states.\n\n
        **Please note that you should not send this command if you are using the\n
        libARController API as this library is handling the connection process for you.**"
        support="drones"
        result="The product will trigger all states events (such as [FlyingState](#1-4-1) for the Bebop).\n
        Then, it will trigger [AllStatesEnd](#0-5-0)."/>
</cmd>

I tried to pass no arguments, to see what it gives. In following snippet you can see how I did this.

def ask_for_move_to_status(self):
    command_tuple = self.command_parser.get_command_tuple("ardrone3", "PilotingState", "moveToChanged")
    return self.drone_connection.send_noparam_command_packet_ack(command_tuple)

This doesn’t really return anything. I was wondering if you know whether the “moveToChanged” cmd is a valid way for retrieving the state. If so, then should I pass parameters and what should I pass? Or how would I go about this? Any help or advice would be much appreciated! Thanks in advance.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
CedricMingneaucommented, Oct 12, 2019

@Cozmo25 I wrote this function (and it worked for me):

def move_to_coord(self, latitude, longitude, altitude, heading):
        (command_tuple, enum_tuple) = self.command_parser.get_command_tuple_with_enum(
            "ardrone3", "Piloting", "moveTo", "NONE")
        self.drone_connection.send_coord_command(command_tuple, latitude, longitude, altitude, enum_tuple, heading)

First I let the drone take off (by using bebop.safe_takeoff()), then I could use move_to_coord() along with some coordinates. Please don’t ask me anything specific about the code, as it has been a while since I’ve played around with it 😅

1reaction
amymcgoverncommented, May 16, 2018

The sensors dictionary has everything the drone sends back! I save it EVERY time it sends stuff. I only made special variables for the ones I used a lot. I may well add more this summer as we are moving to a bebop project from a mambo only project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ardrone3.Piloting and SpeedSettings - 7.4 - Parrot
Result: Event moveToChanged() is triggered with state canceled. ... You can get a state pending if the drone is not ready to start...
Read more >
List of ardrone3 States and Corresponding ROS Parameters ...
To know the real resolution, you should get it from the frame. Ardrone3PilotingStateFlatTrimChanged: Drone acknowledges that flat trim was correctly processed.
Read more >
UIGestureRecognizer subclass-- touchesMoved automatically ...
I am trying to create a UIGestureRecognizer subclass, and in touchesMoved I have no code, yet state is being set to .changed ....
Read more >
Agricultural Drone Survey Application Technical Manual
FlyingStateChanged(state="hovering", _timeout=5)# wait 5 seconds for hovering state. ).wait() ... moveToChanged,FlyingStateChanged, PositionChanged.
Read more >
The s&box wiki - S&box Wiki
No huge globally breaking changes are expected. It could happen, but we're taking care to mark things obsolete and give you time to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found