-
Notifications
You must be signed in to change notification settings - Fork 60
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
Refactor driver library to follow patterns from PickNikRobotics/ros2_epick_gripper #34
Conversation
Codecov Report
@@ Coverage Diff @@
## main #34 +/- ##
==========================================
+ Coverage 0.00% 20.77% +20.77%
==========================================
Files 5 20 +15
Lines 352 597 +245
Branches 0 240 +240
==========================================
+ Hits 0 124 +124
+ Misses 352 341 -11
- Partials 0 132 +132
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
find_package(ament_cmake_gtest REQUIRED) | ||
find_package(ament_cmake_gmock REQUIRED) | ||
find_package(ament_lint_auto REQUIRED) | ||
find_package(ros2_control_test_assets REQUIRED) |
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 needs to be added to the package.xml as a <test_depend>
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. Thanks.
From the logs it looks like the test assets were installed, but that file still not found.. https://github.com/PickNikRobotics/ros2_robotiq_gripper/actions/runs/6084786368/job/16507440934
|
This reverts commit f26c1f3e0fffd9cd1cc603adde5b3265962f96f8.
This reverts commit 4bf404b2d78818853054658aefc81247ee7f69d7.
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 a huge PR so I just took a first pass and left some comments.
IIRC we shouldn't set the VERSION of a ROS package in the CMakeLists.txt as this is set in the package.xml and it should match, with the version in the package.xml being the source of truth
- humble | ||
- iron | ||
- master |
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 must be an old/outdated file or one that was autogenerated or accidentally copied while setting up this repo.
This repo doesn't have humble/iron/master branches only main
@@ -13,6 +13,10 @@ | |||
<ros2_control name="${name}" type="system"> | |||
<!-- Plugins --> | |||
<hardware> | |||
|
|||
<!-- Set use_dummy to true to connect to a dummy driver for testing purposes. --> | |||
<param name="use_dummy">false</param> |
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.
Should this be use_mock
I thought there was a discussion to unify the language in another project
Co-authored-by: Alex Moriarty <[email protected]>
Co-authored-by: Alex Moriarty <[email protected]>
Co-authored-by: Alex Moriarty <[email protected]>
Co-authored-by: Alex Moriarty <[email protected]>
Co-authored-by: Alex Moriarty <[email protected]>
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 hope github saves my files viewed when i finish this review and leave the comments so far.
with: | ||
distribution: rolling | ||
linter: cpplint | ||
arguments: "--linelength=121 --filter=-whitespace/newline" |
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 is this 121 ? that seems strange.
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.
There is a bug in the clang formatter. Sometimes a line is cut at 121 and this causes this linter to fail.
I experienced this bug in one single line of code: hardware_interface.cpp line 73.
If you have any suggestions let me know, maybe I'm missing something.
@@ -10,10 +10,11 @@ find_package(ament_cmake REQUIRED) | |||
|
|||
install( | |||
DIRECTORY | |||
urdf | |||
config |
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 is the controller configuration being moved from the robotiq_driver/config
-> robotiq_description/config
?
And why is the controller the launch for the controllers also being moved into the robotiq_description
?
I think the description should have only the urdf but now that I look at the package.xml
in robotiq_description
I see that we've already messed up the dependencies and seperation a bit because the description depends on rviz2
which it should not.
I need to think about this.
What I want to avoid is the driver itself depending on any gui or simulation dependencies... which already seems to not be the case 😞 I didn't notice this when originally taking over this repo and opening it... but it would be great if someone could install the driver without needing to install rviz.
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.
So, in my opinion, the driver (robotiq_driver) should not know who controls it, that's why I moved the controller config out of it.
On the other hand, the description package (robotiq_description) which contains the robot launch file should know both about the driver and the controller (robotiq_controllers), because you want to use it to start a working robot.
I also think that the urdf in the description package should be of a robot example, not a real robot which may differ a lot from the example. Because the description package knows about the robot and contains the launch file, it seemed natural to add a dependency to rviz too.
@@ -67,6 +64,11 @@ def generate_launch_description(): | |||
description="Absolute path to rviz config file", | |||
) | |||
) | |||
args.append( | |||
launch.actions.DeclareLaunchArgument( | |||
name="launch_rviz", default_value="false", description="Launch RViz?" |
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 previous comment maybe we should remove this, or stick it somewhere else so that rviz is not a transitive dependency of the driver?
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 need to find an agreement or check with somebody else in the team. To me, the driver is the one in the robotiq_driver package. The robotiq_description describes how to use the driver.
include/robotiq_driver/fake/fake_driver.hpp | ||
include/robotiq_driver/crc_utils.hpp | ||
include/robotiq_driver/data_utils.hpp | ||
include/robotiq_driver/default_driver.hpp | ||
include/robotiq_driver/default_driver_factory.hpp | ||
include/robotiq_driver/default_serial.hpp | ||
include/robotiq_driver/default_serial_factory.hpp | ||
include/robotiq_driver/driver.hpp | ||
include/robotiq_driver/driver_exception.hpp | ||
include/robotiq_driver/driver_factory.hpp | ||
include/robotiq_driver/hardware_interface.hpp | ||
include/robotiq_driver/serial.hpp | ||
include/robotiq_driver/serial_factory.hpp | ||
include/robotiq_driver/visibility_control.hpp | ||
src/crc_utils.cpp | ||
src/data_utils.cpp | ||
src/hardware_interface.cpp | ||
src/robotiq_gripper_interface.cpp | ||
src/default_driver.cpp | ||
src/default_driver_factory.cpp | ||
src/fake/fake_driver.cpp | ||
src/default_serial.cpp | ||
src/default_serial_factory.cpp |
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 take it the files listed here are the meat of this PR and the rest of the changes in the PR are actually minor formatting changes and style changes but it's very hard to tell with such a large 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.
I haven't changed the logic of how the driver works, I broke it apart into smaller pieces to allow testing without being connected to the hardware. Originally it was a monolithic project with no tests and with the hard requirement of having hardware at hand.
I intentionally followed the structure of the Epick Gripper so that later we can merge the two drivers into the same repo and extract common code. For example, all the serial communication is common to both.
I definitely made the mistake of formatting the code later which makes the PR hard to read.
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.
Sorry this was just a note to self when I was reviewing I wanted to check the main changes parts in more detain.
I definitely agree we should get he Epick Grippper merged into one repo that would be great.
* <!-- Set use_dummy to true to connect to a dummy driver. --> | ||
* <param name="use_dummy">true</param> | ||
*/ | ||
class FakeDriver : public Driver |
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.
Here there is a mismatch between the param an the thing Fake vs Dummy. I think Fake should be used instead of Dummy but you also have a tests/mock/mock_driver.hpp so is this a Fake or a Mock driver?
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.
From the point of view of the client, the HardwareInterface, a Fake is a simplified replacement for the real thing. A Mock is a class in which I want to test its expectations.
"use_fake" would be probably more accurate. The reason I used "use_dummy" is because it is used in the Dynamixel ROS2 drivers: https://github.com/dynamixel-community/dynamixel_hardware/blob/d84511db57094e3aeb5c09181517649e40172a67/dynamixel_hardware/include/dynamixel_hardware/dynamixel_hardware.hpp#L106
<package format="3"> | ||
<name>robotiq_hardware_tests</name> | ||
<version>0.0.1</version> | ||
<description>ROS2 driver for the Robotiq gripper.</description> |
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.
What does this package actually do? who is the intended user? should it be robotiq_hardware_utils
is it simple commands for checking that hardware is functioning as expected? or is it tests that don't need to be distributed via a ros package but could just be internal to the robotiq_driver package for development but not packages and installed for end users?
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.
They are commands (to be run in the terminal) to check that the hardware is properly connected and working as expected.
If you think "robotiq_hardware_utils" is more appropriate I do not mind renaming it.
Co-authored-by: Alex Moriarty <[email protected]>
# See https://docs.ros.org/en/foxy/How-To-Guides/Ament-CMake-Documentation.html | ||
|
||
cmake_minimum_required(VERSION 3.8) | ||
project(robotiq_hardware_tests VERSION 0.0.1 LANGUAGES CXX) |
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 VERSION number should be set in the package.xml and IIRC it should match the other versions else the ros release tools complain.
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.
Removed.
The monolithic code has been broken apart to introduce tests.
The serial connection creation has been moved from the driver constructor to the hardware interface configure method.
A lot of code has been refactored with the intention of bringing the Epick gripper into this same repository and reusing some common code.