New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added gps and mag UAVCAN support to SITL #8509
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excellent !
there will be plenties things to correct but that is good start !
The first step will be to splip you commit at least by directory.
After that I don't think that UAVCAN should be an hal subtype.
We don't want exception active too.
I will make more comments later.
About the usage. It allow SITL backend to access can bus with SLCAN right ? (i think it miss some check on waf for that, but it could be done later). As we already got support for CAN device in normal code, why update them in SITL backend ?
8a1492c
to
9bb1cd9
Compare
@d-v To help us on reviewing, start by separate your commit by functionnality ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I put some comments to address in order to sort things up !
From a general point of view, uavcan implementation should replace normal sensors !
ArduCopter/Parameters.cpp
Outdated
@@ -34,29 +34,29 @@ const AP_Param::Info Copter::var_info[] = { | |||
// @Description: This value is incremented when changes are made to the eeprom format | |||
// @User: Advanced | |||
// @ReadOnly: True | |||
GSCALAR(format_version, "SYSID_SW_MREV", 0), | |||
GSCALAR(format_version, "SYSID_SW_MREV", 0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the whitespaces change on parameter won't pass. So better revers those changes
Tools/ardupilotwaf/boards.py
Outdated
@@ -31,7 +31,7 @@ class Board: | |||
abstract = True | |||
|
|||
def __init__(self): | |||
self.with_uavcan = False | |||
self.with_uavcan = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for all board, and we don't want that. Just override it on SITL config
Tools/ardupilotwaf/boards.py
Outdated
@@ -110,7 +110,7 @@ def configure_env(self, cfg, env): | |||
|
|||
'-fdata-sections', | |||
'-ffunction-sections', | |||
'-fno-exceptions', | |||
'-fexceptions', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to use exception. revert that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look at how it is done on linux :
if self.with_uavcan:
cfg.define('UAVCAN_EXCEPTIONS', 0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't work :(
https://gist.github.com/d-v/508d4c66f548f3301f0384dd627828bf
Even with cfg.define(UAVCAN_EXCEPTIONS, 0)
Tools/ardupilotwaf/boards.py
Outdated
if self.with_uavcan: | ||
env.DEFINES.update( | ||
CONFIG_HAL_BOARD = 'HAL_BOARD_SITL', | ||
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_WITH_UAVCAN', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong
Tools/ardupilotwaf/boards.py
Outdated
if self.with_uavcan: | ||
env.INCLUDES += [ | ||
cfg.srcnode.find_dir('modules/uavcan/libuavcan_drivers/linux/include/').abspath(), | ||
cfg.srcnode.find_dir('modules/uavcan/libuavcan/include/').abspath() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is already define in board config
@@ -54,6 +54,7 @@ SIM_MAG_RND 0 | |||
SIM_GPS_GLITCH_X 0 | |||
SIM_GPS_GLITCH_Y 0 | |||
SIM_GPS_GLITCH_Z 0 | |||
GPS_TYPE 1.000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is already the case no?
@@ -566,6 +566,9 @@ def start_vehicle(binary, autotest, opts, stuff, loc): | |||
path = None | |||
if "default_params_filename" in stuff: | |||
paths = stuff["default_params_filename"] | |||
if opts.uavcan: | |||
suffix = paths.find(".") | |||
paths = paths[:suffix]+"-uavcan"+paths[suffix:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paths = paths[:suffix] + "-uavcan" + paths[suffix:]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my previos comment, it will be simplier to load only the config for uavacan instead of all params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@khancyr, I'm sorry I don't understand what you mean :(
libraries/AP_HAL_SITL/SITL_State.cpp
Outdated
@@ -80,15 +101,26 @@ void SITL_State::_sitl_setup(const char *home_str) | |||
_barometer = (AP_Baro *)AP_Param::find_object("GND_"); | |||
_ins = (AP_InertialSensor *)AP_Param::find_object("INS_"); | |||
_compass = (Compass *)AP_Param::find_object("COMPASS_"); | |||
#if HAL_WITH_UAVCAN | |||
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed as you are already on SITL namespace
Tools/ardupilotwaf/boards.py
Outdated
@@ -261,12 +269,26 @@ def configure_env(self, cfg, env): | |||
'SITL', | |||
] | |||
|
|||
env.GIT_SUBMODULES += [ | |||
'uavcan', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should check for SLCAN or whatever is the name for the linux implementation of CAN bus !
libraries/AP_Param/AP_Param.h
Outdated
bool configured(void) const | ||
{ | ||
#if HAL_WITH_UAVCAN | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't look good
@khancyr, thank you for all of the feedback it was really helpful especially on my first real PR. I'll incorporate these changes and update the PR. |
2edad43
to
d682502
Compare
Please take a look at the guidelines commit comments should start with the directory name. Also, you now have files in this PR, so something went crazy again. I'm sure a rebase would fix it |
@magicrub, thanks for the feedback -- sorry that this has been such a messy PR! I'm still working on one residual issue that I'm fairly certain will allow all the tests to pass. Once that's done I'll be able to clean up and break this up into a bunch of commits that are properly styled. Sorry about the confusion! |
68b0171
to
8e320de
Compare
ba2d729
to
f851a68
Compare
…rguments to SITL launch args. sitl_gps.cpp now sends data over CAN when CAN is enabled.
…in to spinOnce in AP_UAVCAN.cpp because spin was never exiting on Ubuntu
… feeding data we know is correct
d10a043
to
6fe953d
Compare
….py and script to set up vcan0 interface
i liked this old PR enough to try re-working it based on current ArduPilot. My rework of the code doesn't seem to compile right now when I add "--uavcan vcan0" to sim_vehicle.py , as a result of libuavcan incompatibilities with the linux can driver etc. anyway.... i'm wondering if the original author of this PR, or anyone else, is interested enough to help me figure out where my revised branch needs work... https://github.com/davidbuzz/ardupilot/tree/uavcan-sitl-buzz-wip ? |
We got a proper implementation using AP_Periph for those now. I am closing this. Thanks anyway |
Added gps and mag over UAVCAN simulation to SITL. Tested on bare metal ubuntu 16.04 LTS.
Added another launch arg to sim_vehicle.py: --uavcan . I tested on vcan0 under ArduPilot. When UAVCAN is enabled, sim_vehicle.py uses -uavcan.parm. I created copter-uavcan.parm but haven't done so for other vehicles. copter-uavcan.parm is essentially the same as copter.parm, just some uavcan-specific params used.
sim_vehicle.py --console --uavcan vcan0 -j4 is what I used to run SITL.
Many thanks to everyone who answered my questions on Gitter and Skype, I am really grateful for the help. Looking forward to hearing everyone's feedback!