We are trying to develop a code for a student project in a HITL configuration, but the DroneCore documentation says that serial is not yet supported. We don’t have the material to communicate with the flight controller using UDP, do you have an idea on how we could manage to run something equivalent to the Fly Mission example using a serial connection ?
Hi Julian,
I have just downloaded and built the Dronecode SDK but I have a problem using the serial connection on Linux.
If I connect through the usb port and use the command line “./takeoff_and_land serial:///dev/ttyACM0:115200”, my laptop connects to the drone and I get the following messages:
[10:36:36|Debug] New: System ID: 1 Comp ID: 1 (dronecore_impl.cpp:292)
[10:36:36|Debug] Component Autopilot added. (system_impl.cpp:339)
[10:36:37|Debug] Found 1 component(s). (system_impl.cpp:466)
[10:36:37|Debug] Discovered 3545547880866527033 (system_impl.cpp:468)
Discovered system with UUID: 3545547880866527033
Vehicle is getting ready to arm
On the contrary, if I use the SiK and the command “./takeoff_and_land serial:///dev/ttyUSB0:57600”, I get:
Waiting to discover system...
No system found, exiting.
Am I missing something? I hope you could help me find what’s wrong…
Thank you so much!
Thank you for your reply. QGroundControl works over ttyUSB0 (I don’t have to configure the connection, it works by itself) and this is the mavlink status output:
nsh> mavlink status
instance #0:
GCS heartbeat: 265703 us ago
mavlink chan: #0
type: 3DR RADIO
rssi: 188
remote rssi: 189
txbuf: 100
noise: 44
remote noise: 68
rx errors: 1
fixed: 0
flow control: ON
rates:
tx: 0.562 kB/s
txerr: 0.000 kB/s
rx: 0.042 kB/s
rate mult: 0.557
accepting commands: YES, FTP enabled: NO
transmitting enabled: YES
mode: Normal
MAVLink version: 2
transport protocol: serial (/dev/ttyS1 @57600)
ping statistics:
last: 2326.47 ms
mean: 1400.85 ms
max: 2340.97 ms
min: 116.64 ms
dropped packets: 0
instance #1:
mavlink chan: #1
no telem status.
flow control: OFF
rates:
tx: 14.794 kB/s
txerr: 0.000 kB/s
rx: 0.000 kB/s
rate mult: 1.000
accepting commands: YES, FTP enabled: YES
transmitting enabled: YES
mode: Onboard
MAVLink version: 1
transport protocol: serial (/dev/ttyS2 @921600)
ping statistics:
last: -0.00 ms
mean: -0.00 ms
max: -3038453144258059580735488.00 ms
min: 0.00 ms
dropped packets: 789591659
Suddenly, after I used the “mavlink_shell.py” script, the Dronecode example started working… but it says:
> [12:19:21|Error] Error: more than one system found: (dronecore_impl.cpp:219)
I have another question:“How can I enable Mavlink 2 for the TELEM2 port,too?”
I would like to use Dronecode also on my companion computer but the mavlink version is 1 on the TELEM2 port and it returs “No system found”.
Thank you!
[12:19:21|Error] Error: more than one system found: (dronecore_impl.cpp:219)
Do you have some other system sending mavlink heartbeats with another system ID? E.g. SITL or a companion computer sending mavlink? Or another drone in the network broadcasting?
Hi,
I set MAV_PROTO_VER to 2 and now both the instances are “MAVLink version: 2”.
Anyhow, if I launch “./takeoff_and_land serial:///dev/ttyUSB1:921600”, the example doesn’t work: it says “No system found, exiting”. The device ttyUSB1 is a usb-to-tty (FTD1232) adapter that I connected to TELEM2.
The SYS_COMPANION parameter is set to 921600. Should I change the bitrate? It seems that it cannot catch the heartbeat, am I right?
Thank you
P.S.: I lowered the bitrate to 57600 but the result is still the same. On the contrary, the QGroundControl works even through TELEM2@57600.
Hm, and this is on the onboard computer? Do you have the permissions? Can you check if screen /dev/ttyUSB1 57600 works and spits out some binary characters (aka mavlink)?
Actually I am not using the onboard computer yet…I have both the Sik Radio and the usb-to-ttl adapter connected to the same laptop on two different usb ports… so, the permissions should be the same.
I checked with picocom.
This is ttyusb0:
picocom v2.2
port is : /dev/ttyUSB0
flowcontrol : none
baudrate is : 57600
parity is : none
databits are : 8
stopbits are : 1
escape is : C-a
local echo is : no
noinit is : no
noreset is : no
nolock is : yes
send_cmd is : sz -vv
receive_cmd is : rz -vv -E
imap is :
omap is :
emap is : crcrlf,delbs,
port is : /dev/ttyUSB1
flowcontrol : none
baudrate is : 921600
parity is : none
databits are : 8
stopbits are : 1
escape is : C-a
local echo is : no
noinit is : no
noreset is : no
nolock is : yes
send_cmd is : sz -vv
receive_cmd is : rz -vv -E
imap is :
omap is :
emap is : crcrlf,delbs,
Ok, so I set SYS_COMPANION to 57600 and was able to connect to Telem2 of my Pixhawk using the example:
./fly_mission serial:///dev/ttyUSB0:57600
as well as the integration tests (change add_udp_connection() to add_serial_connection("/dev/ttyUSB0", 57600).
make && build/default/integration_tests/integration_tests_runner -- --gtest_filter="SitlTest.TelemetryAsync"
I then tried to set SYS_COMPANION to 921600 and it did not work, neither with the SDK nor with QGC. Note that I had to disable the “Pixhawk” auto-connection in QGC, otherwise it would just connect via USB. I then manually added a serial connection at the port and baudrate in QGC and it did not work but show a strange error:
My best guess is that baudrate 921600 on a Pixhawk (currently) doesn’t work. I suggest you try to use 57600 for SYS_COMPANION and try again.
Hi Julian,
thank you, I changed the baudrate and it finally worked!
Then I changed SYS_COMPANION back to 921600 and I wrote a little piece of code using native mavlink protocol to test the baudrate.
It works @921600, too. I have been able to get the HEARTBEAT message and read the mavlink version.
I uploaded the code here: https://drive.google.com/file/d/1c19xJRxGyuMYAmCYUWdiZ5OLO-k3-58v/view?usp=sharing