# Autonomous problem

**URL:** <https://discuss.bluerobotics.com/t/autonomous-problem/10425>\
**Category:** Blue Robotics Software\
**Created:** [August 14, 2021, 7:33pm UTC](https://discuss.bluerobotics.com/t/autonomous-problem/10425 "2021-08-14T19:33:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![enis.getmez](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/enis.getmez/32/5893_2.png) [@enis.getmez](https://discuss.bluerobotics.com/u/enis.getmez)\
**Post date:** [August 14, 2021, 7:33pm UTC](https://discuss.bluerobotics.com/t/autonomous-problem/10425/1 "2021-08-14T19:33:34Z")

</div>

hello, we are uploading a code to our robot to go straight. We run the code on the raspberry pi. we use the send\_rc\_channels\_pwm function for this. Instead of the movements we send, the robot turns around and makes meaningless movements. Can you help me?

My code is :

```auto
# Import mavutil
from pymavlink import mavutil
import time
# connection 
master = mavutil.mavlink_connection(
            '/dev/ttyACM0',
            baud=115200)# 

#arm robot
master.arducopter_arm()

time.sleep(3)

master.mav.set_mode_send(
    master.target_system,
    mavutil.mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
    0) # stabilize mode
time.sleep(3)

def set_rc_channel_pwm(id, pwm=1500):

    if id < 1:
        print("Channel does not exist.")
        return
    if id < 9:
        rc_channel_values = [65535 for _ in range(8)]
        rc_channel_values[id - 1] = pwm
        master.mav.rc_channels_override_send(
            master.target_system,
            master.target_component,
            *rc_channel_values)

#forward
value = 1550
set_rc_channel_pwm(5, value)
time.sleep(5)

master.mav.command_long_send(
    master.target_system,
    master.target_component,
    mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM,
    0,
    0, 0, 0, 0, 0, 0, 0) #disarm

```

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [August 16, 2021, 1:49am UTC](https://discuss.bluerobotics.com/t/autonomous-problem/10425/2 "2021-08-16T01:49:18Z")

</div>

Hi @enis.getmez,

Is there a reason this is via private message instead of as a public post? I’ll still see it if it’s public, and that also means others can chime in (possibly before I get to it), and others in the community can benefit from the solution afterwards as well.

I’m unsure what your custom flight mode does, so it’s not possible for me to tell you why the ROV isn’t moving as you expect.

This post is likely relevant:

> [@Question on Signal Sending with Time Intervals by Pymavlinks](https://discuss.bluerobotics.com/t/question-on-signal-sending-with-time-intervals-by-pymavlinks/7562/2):
>
> Hi, Check the safety section of the documentation. The autopilot employs a some failsafe mechanisms to keep you and your equipement safe, as well as to prevent your ROV from running away from you during experiments. All system components that communicate via MAVLink are expected to send a HEARTBEAT message at a constant rate of at least 1 Hz. If the autopilot does not receive a heartbeat from your application after this interval, it will trigger a [failsafe](https://www.ardusub.com/operators-manual/failsafes.html). When the autopilot is being comma…

Given this is a direct serial connection to the autopilot board I assume you’re trying to do this autonomously, and also likely not using our companion computer image - is that correct?

A few side-notes:

- you can use `master.`[`motors_armed_wai`t](https://github.com/ArduPilot/pymavlink/blob/master/mavutil.py#L829)`()` to wait until arming has succeeded (instead of waiting for a fixed period that provides no guarantees about the autopilot state, and could be unnecessarily long)
- you can use `master.arducopter_disarm()` to disarm if you want to
- it may be worth adding a `master.motors_disarmed_wait()` to the end of your program to make sure the disarming was actually successful.

---

<div class="post-metadata">

**Author:** ![enis.getmez](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/enis.getmez/32/5893_2.png) [@enis.getmez](https://discuss.bluerobotics.com/u/enis.getmez)\
**Post date:** [August 22, 2021, 12:04pm UTC](https://discuss.bluerobotics.com/t/autonomous-problem/10425/3 "2021-08-22T12:04:09Z")

</div>

Hi, I have sent a private message assuming you can see it faster as we need urgent help.

I am sorry for the late reply. We solved the problem.

Sending manual control instead of rc commands solved the problem.

Thank you for your attention.

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [August 23, 2021, 12:01am UTC](https://discuss.bluerobotics.com/t/autonomous-problem/10425/4 "2021-08-23T00:01:19Z")

</div>



---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [August 23, 2021, 12:02am UTC](https://discuss.bluerobotics.com/t/autonomous-problem/10425/5 "2021-08-23T00:02:57Z")

</div>

Glad you managed to solve the problem 🙂

> [@enis.getmez](#):
>
> I have sent a private message assuming you can see it faster as we need urgent help.

I’ve now made it a public topic so others can benefit from the solution 🙂
