CANbus for Ardupilot with UAVCAN and UC4H

and there is actually also already this section:

@Marc_Dornan: great! thx

@ppoirier: haha … I constantly forget the dyn node allocator and am then puzzled what’s wrong now suddenly with my bootloader… LOL. It’s a really great tool, but it has its points one needs to get used to.
You’re welcome. I actually liked much your step by step approach and picturesque reporting of where you are. Exemplary.
If you want to be brave you could do the GPS now, since it appears to be sitting close to the UC4H node anyways. From the UC4H side it’s not very convenient but not too bad: You “just” need to configure the gps manually to work at 115200 bps, ubloxcenter or ArduPilot can do it. Then set GpsRate = 200 and Uart1ChannelId = -1 and you should see the gnss.fix messages coming up. As said, not my recommended use of the gps, but maybe entertaining to also see these messages at least once in life.

1 Like

DJI reliability would suggest otherwise.

It’s a shame this isn’t opensource, but otherwise great job @olliw42. I’m looking forward to the upcoming uavcan devices from Proficnc etc.

1 Like

Yes im hoping the canbus for the GPS is availabe very soon on MP and that Proficnc and others come out with other canbus goodies eg lidar

Yes, in fact the Believer airframe I’ve experience with suffers a lack of pins in the wing connector already . . . being able to control two ESCs, two servos, and an airspeed sensor (QuadPlane setup) with one pair of wires leaves pins free for e.g. lighting power lines. I’d forgotten this struggle when addressing it in my response.

This is something that slipped my mind, and to be honest have yet to experiment with it. I’ve not seen any explicit references to how ArduPilot handles the same device on two separate buses (I assume failover has yet to be implemented). But once that feature is implemented (e.g. for Zubax GNSS 2 [disregarding current issues]) it will make yet another strong case for UAVCAN over alternatives like RS485.

redundant wiring by itself is not a feature of CAN bus, I mean you could have two UARTS going to a GPS, two s.bus lines, two I2Cs going to a magnetometer, etc. … that concept could in principle be applied to any bus.
However, CAN bus has a sort of intrinsic redundancy, in that it has two differential lines which by definition each carry the same information, and in fact, at least if one reads up CAN specifications, it is supposed to also work if one of the CANH or CANL lines break. I have never tested that in practice though, maybe would be worthwhile to do this.
The further aspect of CAN is this differential signals, which by principle makes it less vulnerable to a number of interferences (not all of course), especially if you twist the pair which is easy to do (not talking even about shielding). This differential principle is applied in many areas in many variations with much success. It’s very cool. In the CAN case it also has some aspects usually attributed to optical isolators in that it can accept very high common mode voltages. This I’ve exploited e.g. in my motor pod mod for the 3DR Solo.
I believe that these are the two main aspects which are referred to when one is calling CAN “reliable”. And which indeed make CAN different.

Hello Olli,

Tried the GPS but the node get stuck in INITIALIZATION with this
44 17:55:29.879 DEBUG uc4h-gpsmag tnl1 not initialized
gps not initialized
mag hmc5883l inited
44 17:55:30.378 DEBUG uc4h-gpsmag tnl1 tx 0
tnl1 rx 0
gps tx 0

The GPS is configured as NEMA at 115 kbauds and can read clear text.
When I activate tunnel (0 instead of -1) an can see the tx counter incrementing.
… I am missing parts to build the UartBridge… going to try directly on the Flight Controller

edit: No GPS…Well, I tried :slight_smile:

this is basically what I see on a Termnal
,080119,N64
$GNVTG,N
2E
$GNGGA,233303.40,0,00,99.99,7E
$GNGSA,A,1,99.99,99.99,99.99
2E
$GNGSA,A,1,99.99,99.99,99.992E
$GPGSV,3,1,11,05,00,341,07,33,303,08,45,188,09,46,265,7D
$GPGSV,3,2,11,16,57,056,21,16,048,23,42,221,26,31,071,30
73
$GPGSV,3,3,11,27,67,141,30,02,301,31,03,122,4A
$GLGSV,1,1,02,74,50,072,90,32
5C
$GNGLL,233303.40,V,N
52

many thx for trying. I believe I have to apologize to you for waisting your time on this.
I haven’t used this gps for nearly 3/4 year, only tunnel for me, and might have been too confident. I just looked at things and it actually seems that the baudrate should be 57600bps, that’s what the code says and I went back all versions and it seems to have been 57600 all the time. I’m a bit puzzled by this, but it seems that both my memory and the information I give on my web page are wrong. if you find time you could try 57600, however, you may prefer to just wait until I have tested this myself again, ASAP.

The NEMA looks good. The process is such that then gps is enabled the node starts in state INITIALIZATION, since the gps first needs to be detected and configured, which takes a bit longer than for mags&baros. The detection goes by looking for the GNGGA messages, it when switches to ubx and does some settings, and then goes into OPERATIONAL. Pretty standard. Since you have the GNGGA it should trigger. Maybe it’s really just as simple as the baudrate, but as said I will test myself again ASAP.

Sorry again.

Don’t worry Olli , you didn’t ask me to jump down a cliff…,yet LOL!!

I’ll give it a try tomorrow and report

1 Like

:slight_smile:
although suggesting to try the gnss.Fix path is pretty close to it :smiley:
I actually tried to get to the bottom of that, and found this post of me 15 months ago:
https://www.rcgroups.com/forums/showpost.php?p=38472727&postcount=102
HAHAHA … that’s the best part of it “It’s actually wired I use 57600 and not 115200” … in the new code which also will do the QMC I will - at last - change to 115200 … I’m still laughing over this

OK tested I have GPS signal working :slight_smile:
Now I want to connect to my PixHawk, is it juts a matter of having the UAVCAN enabled and GPS type to 9 or there are other settings involved ?

edit:
And what about the Uart1ChannelId ? Do I leave it at -1 or I enable tunelling by setting to 0 ?

OK tested I have GPS signal working

GREAT :slight_smile:
it only needed the correct information LOL

Now I want to connect to my PixHawk, is it juts a matter of having the UAVCAN enabled and GPS type to 9 or there are other settings involved ?

As promised I won’t comment on the ArduPilot side of using the gnss.Fix message. It’s not just meanness on my side, but that it used to be a can of worms, i.e. when I did it it took me quite some experimenting to arrive at something working, but I have not followed up any development, and I didn’t make the effort to memorize things. CAN enabled and 9 sounds a good start, but that’s all I feel comfortable to contribute here

And what about the Uart1ChannelId ? Do I leave it at -1 or I enable tunelling by setting to 0 ?

-1. You only can use either gnss.Fix or the gps tunnel (it’s on the same pins). Setting ChannleId>=0 would enable the tunnel, but also disables gnss.Fix (i.e the GpsRate setting would become irrelevant)

Fair enough , I understand that you have to set your ‘‘territorial limits’’ so you can focus on the product and not spreading out to the different uses cases.

And I can read the reference on your blog (near bottom) : http://www.olliw.eu/2017/uavcan-for-hobbyists/
GPS Mag Baro Node

For the GPS it is highly recommended that the UAVCAN tunnel is used (Uart1 ChannelId >= 0), and not the UAVCAN uavcan.equipment.gnss.Fix message (this requires using BetaCopter). Using the latter works fine (I flew with it for a year or so ), but it is somewhat clumsy. I stopped developing it further once I saw that the tunnel approach is going to come. It’s (only) advantage is compatibility with current ArduPilot. If it shall be used, please note: The GPS needs to be configured to 115200 bps by hand, using e.g. the ublox software tool. Description of how to do that can be found in e.g. the rcgroups discussion thread.

I guess this is whee you will change to 57600 :wink:

As for tunnel = How & Where do we terminate ? (On a node or on the FC) ?

@mike may I benefit from your experience on that matter ?
How did you setted the GPS to work : As gnss.Fix or the gps tunnel ?
And do you have any configurations to share ?

Regards

you have to set your ‘‘territorial limits’’ so you can focus on the product and not spreading out to the different uses cases.

well, frankly, this is not exactly the reason, it’s rather that AP’s gnss.Fix handling is not totally trouble-free … not saying it’s all AP’s fault, the gnss.Fix message is also not ideal, and it also lies in the nature of the matter. IMHO as always.

I guess this is whee you will change to 57600

I will change the code to do what it should have done already 15 months ago, to use 115200

As for tunnel = How & Where do we terminate ? (On a node or on the FC) ?

it’s exactly the same wiring you have now, i.e. GPS <-Tx/Rx wires-> RxTx on node <-CANbus-> pixhawk.
The difference is that you set ChannelId>=0, need to load BetaCopter, and set the parameters of one of its SERIALTNL’s to use the GPS protocol (exactly as you would do it with a GPS on an UART for the SERIAL parameter), plus set its ChannelId parameter to the same value you’ve entered in the node. And of course GPSType=2 as usual. (you also can set baudrates to 115200, if you want, but it’s going to be auto-configured, so should not matter at all)
It’s shown in this video: https://www.youtube.com/watch?v=Sw24wAIoemA, start at 3:40

OK
Not having looked at BetaCopter, is this branch could be merged in Master in order to get UAVCAN as a mainstream product in ArduPilot community ?

We may start a different thread if you consider we diverge, but this questions has to be adressed.

Regards

IMHO would be useful to not have such discussions here, but to keep this thread more focused on the usage side of the story

Patrick, I wrote a whole article on configuring Ardupilot for UAVCAN:

I had no problem with my GNSS conversion using a HERE.
Halfway down this page I posted notes on my GPS conversion:
https://www.rcgroups.com/forums/showthread.php?2971848-The-Holy-Grail-of-DIY-QUADS-FrankenSolo

OlliW has tried, for years, to get Betacopter into master but among many issues he does not use GIT, because his tools are easier to use for him. His code needs to be massaged to conform, which is work nobody was willing to do.

Thanks Mike, I have read this and you used Arducopter 3.6dev (Not Betacopter ) as I was expecting to do the same with the GPS/MAG node…

Ok now I see your reference on the rcgroup thread:
“So I loaded up OlliW’s Betacopter fork of ArduCopter and after a bit of troubleshooting got all the UAVCAN settings correct in Mission Planner.”

I"ll look what I can do to get Betacopter into master.

3 Likes

Really really GREAT work from you…as usual.

Corrado

good luck :wink:

2 Likes

Appreciate your interest.