1

Following the DroneKit instructions, I was able to run the hello.py code from their QuickStart guide: http://python.dronekit.io/guide/quick_start.html.

However, when I try to run their basic mission example, I get the setBaudrate error in the title:

$ python mission_basic.py --connect=/dev/tty.usbmodem1411

Connecting to vehicle on: /dev/tty.usbmodem1411
Traceback (most recent call last):
  File "mission_basic.py", line 23, in <module>
    vehicle = connect(args.connect, wait_ready=True)
  File "/Library/Python/2.7/site-packages/dronekit/__init__.py", line 2344, in connect
    handler = MAVConnection(ip, baud=baud, source_system=source_system)
  File "/Library/Python/2.7/site-packages/dronekit/mavlink.py", line 37, in __init__
    self.master = mavutil.mavlink_connection(ip, baud=baud, source_system=source_system)
  File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 1106, in mavlink_connection
    return mavserial(device, baud=baud, source_system=source_system, autoreconnect=autoreconnect, use_native=use_native)  
  File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 735, in __init__
    self.set_baudrate(self.baud)
  File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 746, in set_baudrate
    self.port.setBaudrate(baudrate)
AttributeError: 'Serial' object has no attribute 'setBaudrate'

Note: tty.usbmodem1411 is my USB cable running straight from my Mac running Yosemite to the APM. I have also tried with the 3DR telemetry kit with the same results. I have also tried adding in the baud rate option with the same result.


UPDATE: Using the link's patch that 陳昭宇 gave resolved my baud rate issue; however, I still had an issue with never finding a heartbeat. This issue was also because of the pyserial update. Using the older pyserial solution that Tim Ryan provided fixed both problems.

LBoeg
  • 23
  • 1
  • 7

3 Answers3

6

Fin, it looks like pySerial 3.0 was released in the past week which changes its API. pymavlink (used by DroneKit-Python) requires pySerial 2.0. I've filed an issue and will work to resolve it.

In the meantime, try pip install "pySerial>=2.0,<=2.9999" and see if this resolves your problem.

Cerin
  • 60,957
  • 96
  • 316
  • 522
Tim Ryan
  • 96
  • 3
  • This seems to be the problem. I elected to patch it using 陳昭宇's link above. Thanks for the response. – LBoeg Jan 07 '16 at 19:44
  • See update above. The new pyserial creates more problems than just the baud rate issue. Installing this version worked. – LBoeg Jan 08 '16 at 01:09
1

In the new python setBaudrate() looks removed from class SerialBase. Please refer a similar issue of mavlink.

陳昭宇
  • 11
  • 1
-1

Shot in the dark here, so apologies if this doesn't fix your problem, but I've suspicions that it will.

You need to install FTDI Drivers (https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/mac)

I had similar issues creating a serial connection over USB, using python, between my Arduino and my Mac running Mavericks and subsequently El Capitan. (Worked out of the box on Ubuntu, if you're afraid to mess with your fancy Mac) Expect this to break after an OSX upgrade. (Thanks Apple) It will also only work on the USB port that you specified during this process. So choose wisely ;)

Hope this helps. I lost days to this issue.

Fin
  • 173
  • 1
  • 6
  • Thanks for the quick response. Unfortunately, I don't think this is my issue. I work with Arduino's on my Mac pretty often, and I've never had an issue with the drivers; however, I have never used python for the serial connection. So just in case, I followed the steps on the tutorial in the link to install their drivers, but I had no luck. Same result as before... Thanks, again. – LBoeg Jan 05 '16 at 00:53