# AVR Autonomous Code Flight Path Not Working

**URL:** <https://forum.theavr.org/t/avr-autonomous-code-flight-path-not-working/759>\
**Category:** AVR Drone Software\
**Created:** [November 14, 2023, 11:05pm UTC](https://forum.theavr.org/t/avr-autonomous-code-flight-path-not-working/759 "2023-11-14T23:05:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![geox25](https://avatars.discourse-cdn.com/v4/letter/g/dfb087/32.png) [@geox25](https://forum.theavr.org/u/geox25)\
**Post date:** [November 14, 2023, 11:05pm UTC](https://forum.theavr.org/t/avr-autonomous-code-flight-path-not-working/759/1 "2023-11-14T23:05:12Z")

</div>

The sandbox connects to the MQTT broker just fine, and is able to log and run some setup code. It also is able to detect autonomous enable/disable just fine, but does not execute the flight path. Here is my code:

```py
    def path(self) -> None:
        logger.info("CAPTURING HOME & ARM")
        self.send_message("avr/fcm/capture_home", {})
        self.send_message("avr/fcm/arm", {})

        logger.info("UPLOADING MISSION")
        self.send_message("avr/fcm/upload_mission", {
            "waypoints": [
                { # takeoff
                    "type": "takeoff"
                },
                {
                    "type": "land"
                }
            ]
        })
        logger.info("STARTING MISSION")
        self.send_message("avr/fcm/start_mission", {})

```

I was considering replacing it with the following code which I will test on the drone tomorrow instead of using the missions:

```py
        box.send_message("avr/fcm/takeoff", {})
        box.send_message("avr/fcm/land", {})

```

Any insight? I think it’s possible I may be using the wrong MQTT topic or message formatting.

Thanks!

---

<div class="post-metadata">

**Author:** ![GioOC8](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@GioOC8](https://forum.theavr.org/u/GioOC8)\
**Post date:** [November 15, 2023, 1:02pm UTC](https://forum.theavr.org/t/avr-autonomous-code-flight-path-not-working/759/2 "2023-11-15T13:02:59Z")

</div>

You might be sending messages to the FCM too quickly.

---

<div class="post-metadata">

**Author:** ![geox25](https://avatars.discourse-cdn.com/v4/letter/g/dfb087/32.png) [@geox25](https://forum.theavr.org/u/geox25)\
**Post date:** [November 15, 2023, 5:13pm UTC](https://forum.theavr.org/t/avr-autonomous-code-flight-path-not-working/759/3 "2023-11-15T17:13:32Z")

</div>

I’m testing this in the sim right now, it connects just fine and starts running code but when it executes send\_message(“avr/fcm/takeoff”, {}) nothing happens even though there are no errors. I also added some pauses like you said. Anyone know how to get it to actually takeoff autonomously?

---

<div class="post-metadata">

**Author:** ![GioOC8](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@GioOC8](https://forum.theavr.org/u/GioOC8)\
**Post date:** [November 15, 2023, 7:23pm UTC](https://forum.theavr.org/t/avr-autonomous-code-flight-path-not-working/759/4 "2023-11-15T19:23:03Z")

</div>

For some reason it’s not in the documentation, but you need to put the altitude that you want to take off in the payload.  
{“avr/fcm/actions”, {“action”: “takeoff”, “alt”: }

---

<div class="post-metadata">

**Author:** ![geox25](https://avatars.discourse-cdn.com/v4/letter/g/dfb087/32.png) [@geox25](https://forum.theavr.org/u/geox25)\
**Post date:** [November 15, 2023, 7:38pm UTC](https://forum.theavr.org/t/avr-autonomous-code-flight-path-not-working/759/5 "2023-11-15T19:38:33Z")

</div>

Sorry but sometimes I have trouble trying to get it into the right python code form. Is this correct?

```python
self.send_message("avr/fcm/takeoff", {"alt": 3.12})

```

(Not sure if I should do it like that or send\_message(“avr/fcm/actions”, {“action”: “takeoff”, “alt”:3})  
Thanks so much for your help.

---

<div class="post-metadata">

**Author:** ![droneblocks](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.theavr.org/droneblocks/32/159_2.png) [@droneblocks](https://forum.theavr.org/u/droneblocks)\
**Post date:** [November 16, 2023, 6:15pm UTC](https://forum.theavr.org/t/avr-autonomous-code-flight-path-not-working/759/6 "2023-11-16T18:15:09Z")

</div>

I realize this is a bit tricky. Not sure if you watched my video describing some of the fundamentals:

[![](https://canada1.discourse-cdn.com/flex007/uploads/avr/original/1X/2c6cd64f3538b6148180cba96d49e9b6e46343b3.jpeg "AVR Autonomy Overview") ](https://www.youtube.com/watch?v=7mzvU93jVR0)

The topic should be `avr/fcm/actions` and the message is in JSON format like this:

```auto
{"action": "takeoff", "payload": { "alt": 1.5 }}

```

I’m going to update the documentation but one thing to keep in mind is that for any navigation commands I believe the default speed is 5m/s which is WAY TOO FAST for the AVR game court. This is a PX4 parameter that you should update to slow it down:

```auto
MPC_XY_VEL_MAX 

```

For all my testing I had it set to 0.25 m/s.

Good luck and let us know how it goes.
