-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
Dds prototype #17779
Dds prototype #17779
Conversation
} | ||
|
||
if (this->use_serial) { | ||
this->fd=open("/dev/ttyUSB1", O_RDWR | O_NOCTTY | O_NONBLOCK); |
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.
You should get a serial object from the hal that way you ensure that the port is configured correctly
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.
Also this should be made available on other serial ports as well... maybe check how other libraries are implemented and the parameter system that sets them up.
// initialise serial ports |
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.
Rough pass only.
libraries/AP_XRCE_Client/AP_INS.cpp
Outdated
|
||
bool AP_INS_serialize_topic(ucdrBuffer* writer, const AP_INS* topic) | ||
{ | ||
(void) ucdr_serialize_int32_t(writer, topic->accel_count); |
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 casting-to-void is a bit of a red flag for me. If it is warranted then it deserves a comment.
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 looks like the examples in the XRCE-DDS also do this by some poor convention even though there is a perfectly good return code to consume and pass up to the application. After stripping down this implementation, I'll make sure the error codes get passed up.
Quick question - Is C++17, specifically [[nodiscard]]
allowed here?
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 can submit a PR upstream - this serialization function is actually adapted from the generated code from MicroXRCEDDSGen. I agree, we should not discard write issues.
- Submit PR upstream to not void cast
- Add submodule for fastddgen
- Remove manually written serialization instead with autogenerated files using waf
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.
eProsima/Micro-XRCE-DDS-Gen#45
Created issue and submitted PR.
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 now part of our generator. Resolved.
libraries/AP_XRCE_Client/AP_INS.h
Outdated
* @brief This struct represents the structure AP_INS defined by the user in the IDL file. | ||
* @ingroup AP_INS | ||
*/ | ||
typedef struct AP_INS |
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.
Any reason you need a typedef
?
if (this->use_serial) { | ||
this->fd=open("/dev/ttyUSB1", O_RDWR | O_NOCTTY | O_NONBLOCK); |
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.
if (this->use_serial) { | |
this->fd=open("/dev/ttyUSB1", O_RDWR | O_NOCTTY | O_NONBLOCK); | |
if (use_serial) { | |
fd = open("/dev/ttyUSB1", O_RDWR | O_NOCTTY | O_NONBLOCK); |
(as @jmachuca77 says, use the serial manager instead; you can still use a real serial device easily enough)
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's being used now.
else { | ||
if(!uxr_init_udp_transport(&this->udp_transport,UXR_IPv4,ip,port)) { | ||
return false; | ||
} | ||
uxr_init_session(&this->session, &this->udp_transport.comm, 0xAAAABBBB); |
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 do not want to support UDP with this at this time - simplify the PR by always assuming use_serial
Also... dispense with this->
in member functions.
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.
Done and Done.
bool AP_XRCE_Client::create() | ||
{ | ||
|
||
if(_csem->take(5)){ |
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.
taking-with-timeout is almost always something you do not want to do.
Also, usually you want to be doing WITH_SEMAPHORE(_csem)
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.
Done (already)
if(_csem->take(5)){ | ||
if(this->connected) | ||
{ |
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.
Avoid indenting
if(_csem->take(5)){ | |
if(this->connected) | |
{ | |
if(!_csem->take(5)){ | |
return; | |
} | |
if(!this->connected) | |
return; | |
} |
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.
Everything is formatted with astyle
on the PR.
uxrObjectId dwriter_id ; | ||
uint16_t dwriter_req ; |
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.
uxrObjectId dwriter_id ; | |
uint16_t dwriter_req ; | |
uxrObjectId dwriter_id; | |
uint16_t dwriter_req; |
and everywhere else
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.
Format is resolved with astyle
On Wed, 16 Jun 2021, Pierre Kancir wrote:
You should see this as the mavlink xml, it is the definition to generate the AP_INS.cpp code that is auto generated
We don't commit the generated code in ArduPilot :-)
|
Adding to the conversation so we can keep track and for easier discussion. This needs to be added to the waf build system. |
af7d461
to
ca2728d
Compare
it looks like we will need to do config.h.in processing |
@arshPratap I've added the waf rules for config.h generation here: |
d07b90f
to
bfce51a
Compare
a8c1c7b
to
3c9882f
Compare
This is a very good work, i am wondering why you opted out to use XRCE client directly and not use https://github.com/micro-ROS/micro_ros_setup for example like https://github.com/micro-ROS/micro_ros_arduino |
Hello, is there any progress regarding implementing direct DDS ROS2 communication with ardupilot? Thank you. |
Hi @eMrazSVK ! I am so sorry I wasnt able to work on this in the recent time due to my current predicaments, but I would love to resume working on it and collaborating if you are intereseted! You can mail me : [email protected] for further information.In the mean time I would love if you could take a look here : https://github.com/arshPratap/ardupilot_ros2 |
Thank you for your quick response @arshPratap. If I decided to collaborate on this, could you give me just a really rough estimate of how much time would be needed to fully implement this? Are we speaking weeks, months or years? Thank you once again. |
I am not sure on the time frame as I believe there are few things currently in this project that I believe need to be taken care of first :
But I believe that this PR has been idle for a long time and I would love to see this merged as soon as possible. Also the fact that since you are interested to collaborate on this , makes me think we can work on this faster and i think we can have a month's time as a nice deadline on this. @eMrazSVK Let me know what you think...and lets start the work immediately |
We generate the code now in |
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.
partial review only.
Seems ok. build looks constraint.
test build are ok
documentation is readable for dev!
libraries/AP_DDS/AP_DDS_Client.cpp
Outdated
|
||
void AP_DDS_Client::update_topic(builtin_interfaces_msg_Time* msg) | ||
{ | ||
if (msg != nullptr) { |
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.
Early return here rather than indent. Possibly doing an internal error first?
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.
update_topic
is called at a very high rate. Is it OK to do internal errors at that high rate?
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.
Now that it's passed by reference, this is no longer an error condition.
libraries/AP_DDS/AP_DDS_Client.cpp
Outdated
|
||
#include "AP_DDS_Topic_Table.h" | ||
|
||
void AP_DDS_Client::update_topic(builtin_interfaces_msg_Time* msg) |
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.
Why not take a reference instead?!
void AP_DDS_Client::update_topic(builtin_interfaces_msg_Time* msg) | |
void AP_DDS_Client::update_topic(builtin_interfaces_msg_Time& msg) |
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.
Done in fc514d56571d59e90a906fd36699ae0219e68973
Once CI passes the current build, I'll do a final cleanup on the commit history and tag for merge on build success. All PR feedback is now done. Re-tested fine after final cleanup. |
msg.sec = utc_usec / 1000000ULL; | ||
msg.nanosec = (utc_usec % 1000000ULL) * 1000UL; |
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.
msg.sec = utc_usec / 1000000ULL; | |
msg.nanosec = (utc_usec % 1000000ULL) * 1000UL; | |
msg = { | |
utc_usec / 1000000ULL, | |
(utc_usec % 1000000ULL) * 1000UL | |
}; |
Just a suggestion that you play with this. It means the structure is fully initialised on return, and gives you some type-checking too.
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 sadly loses the context of the first element being seconds and the second element being nanoseconds. Unless you could use C++20's aggregate initialization that supports designated initializers. Maybe there a way to get the best of both worlds 🔍
* Use interal forks Signed-off-by: Ryan Friedman <[email protected]> Co-authored-by: Arsh Pratap <[email protected]> Co-authored-by: Andrew Tridgell <[email protected]> Co-authored-by: Russ Webber <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]> Co-authored-by: Arsh Pratap <[email protected]> Co-authored-by: Andrew Tridgell <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]> Co-authored-by: Rhys Mainwaring <[email protected]> Co-authored-by: Arsh Pratap <[email protected]> Co-authored-by: Andrew Tridgell <[email protected]>
* Use clang to verify no unused files * Add a topic table to prepare for code generating interfaces * Generated IDL's to to a generated directory in build * Use black to format python files * Populate a ROS time maessage with Linux epoch time for ROS time * Add workarounds for PoseStamped and TwistStamped with manual mods to IDL Signed-off-by: Ryan Friedman <[email protected]> Co-authored-by: Rhys Mainwaring <[email protected]> Co-authored-by: Arsh Pratap <[email protected]> Co-authored-by: Andrew Tridgell <[email protected]> Co-authored-by: Russ Webber <[email protected]> Co-authored-by: Peter Barker <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]> Co-authored-by: Arsh Pratap <[email protected]> Co-authored-by: Andrew Tridgell <[email protected]> Co-authored-by: Russ Webber <[email protected]>
* Had to ignore pre-commit hooks for isort and mypy since there are unrelated broken issues in the file Signed-off-by: Ryan Friedman <[email protected]> Co-authored-by: Arsh Pratap <[email protected]> Co-authored-by: Andrew Tridgell <[email protected]>
* Disabled by default Signed-off-by: Ryan Friedman <[email protected]> Co-authored-by: Arsh Pratap <[email protected]> Co-authored-by: Andrew Tridgell <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]> Co-authored-by: Pierre Kancir <[email protected]>
🎊 🥳 |
Hello Ardupilot community!
This PR is work in progress and consists of the prototype code that aims to provide DDS functionality to Ardupilot for effective communication with ROS2 and Native DDS implementations
Added 2 IDL files
Added the eProsima XRCE Client lib as submodule
Provides Ardupilot an XRCE client to communicate with DDS/ROS2 through :
Serial(Main focus)
UDP(Only for testing,to be removed in final version)
Current Issues
Thanks !