Huibean
(Huibean Luo)
April 24, 2024, 9:45am
1
base on previous post from @tridge Serial over DroneCAN support
using AP_Periph as Serial tunnel
I have create a example script using pydronecan that can do Guided mode control over CAN bus from companion computer
example script is in the PR link
dronecan:master
← Huibean:add-mavlink-tunnel-example
opened 09:31AM - 24 Apr 24 UTC
add a example to use ardupilot dronecan serial tunnel to do mavlink GUIDED contr… ol
using Copter-4.5.1 for testing
params setup(using SITL or Pixhawk)
CAN_P1_DRIVER 1.0 # First driver
CAN_D1_PROTOCOL 1.0 # DroneCAN
CAN_D1_UC_S1_BD 115200.0
CAN_D1_UC_S1_IDX 1.0 # Serial1
CAN_D1_UC_S1_NOD 88.0
CAN_D1_UC_S1_PRO 2.0 # MAVLink2
startup the script will route the tunnel data to a tcp connection
./examples/mavlink_tunnel.py --node-id 88 --tcp-host 'localhost' --tcp-port 5790 mcast:0
replace mcast:0 to the actual can intferfce ie. slcan0
#!/usr/bin/env bash
# this script sets up SITL to be able to attach to real CAN devices
# once run, you can configure SITL for CAN just like a real board, with the CAN parameters
#
# CAN_P1_DRIVER=1
# CAN_D1_PROTOCOL=1
# once running you can also attach uavcan_gui_tool to vcan0 to monitor the CAN bus
[ $# -eq 1 ] || {
echo "Usage: can_sitl.sh DEVICE"
echo "for example can_sitl.sh /dev/serial/by-id/usb-Zubax_Robotics_Zubax_Babel_3700330018514D563935392000000000-if00"
exit 1
}
DEVPATH="$1"
if readlink $DEVPATH > /dev/null; then
DEVNAME=$(basename $(readlink $DEVPATH))
else
This file has been truncated. show original
in another terminal
mavproxy.py --master tcp:127.0.0.1:5790
or using any supported GCS
2 Likes
@Huibean Did you need to make any changes to the SRx values? I’m finding the Targetted message clogging up the CANBUS. thanks
Huibean
(Huibean Luo)
July 26, 2024, 2:49am
3
@davidbitton You need to adjust message update rate depend on you bandwidth usage
I found that I needed to increase the pool size. i saw in MatekL431-Serial that the default pool size is bumped up to 12,000. Where is the update rate setting? Thanks.
Huibean
(Huibean Luo)
July 27, 2024, 5:03am
5
you need to set data stream rate when you set up mavlink connection, or just simply request all and use SRC params to adjust Messages (common) · MAVLink Developer Guide
1 Like
Since the UART is virtual, which SRx values do I use?
Huibean
(Huibean Luo)
August 12, 2024, 6:12am
7
have you check the S1_IDX
just an FYI. If you limit the Subscriber to only 9 lines of output, you’ll only see one message.