Skip to content
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

Fix MoveIt Servo compilation on macOS #555

Merged
merged 13 commits into from
Jul 27, 2021
Merged

Fix MoveIt Servo compilation on macOS #555

merged 13 commits into from
Jul 27, 2021

Conversation

nkalupahana
Copy link
Contributor

@nkalupahana nkalupahana commented Jul 13, 2021

Description

This PR fixes MoveIt Servo compilation on macOS. Closes #491
Broken CI: https://github.com/nkalupahana/ros2-foxy-macos/runs/3026534213?check_suite_focus=true
Now working: https://github.com/nkalupahana/ros2-foxy-macos/runs/3053981174?check_suite_focus=true

Checklist

  • Required by CI: Code is auto formatted using clang-format
  • Extend the tutorials / documentation reference
  • Document API changes relevant to the user in the MIGRATION.md notes
  • Create tests, which fail without this PR reference
  • Include a screenshot if changing a GUI
  • While waiting for someone to review your request, please help review another open pull request to support the maintainers

@codecov
Copy link

codecov bot commented Jul 13, 2021

Codecov Report

Merging #555 (09c2338) into main (64535cb) will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #555      +/-   ##
==========================================
+ Coverage   46.71%   46.73%   +0.02%     
==========================================
  Files         184      184              
  Lines       19686    19686              
==========================================
+ Hits         9195     9198       +3     
+ Misses      10491    10488       -3     
Impacted Files Coverage Δ
...veit_servo/include/moveit_servo/servo_parameters.h 0.00% <ø> (ø)
...dl_kinematics_plugin/src/kdl_kinematics_plugin.cpp 75.85% <0.00%> (+1.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64535cb...09c2338. Read the comment docs.

Comment on lines 88 to 90
add_library(${POSE_TRACKING} SHARED src/pose_tracking.cpp src/servo_parameters.cpp)
ament_target_dependencies(${POSE_TRACKING} ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_link_libraries(${POSE_TRACKING} ${SERVO_LIB_NAME})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should link it against the already built library rather than adding the source files to the target

Suggested change
add_library(${POSE_TRACKING} SHARED src/pose_tracking.cpp src/servo_parameters.cpp)
ament_target_dependencies(${POSE_TRACKING} ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_link_libraries(${POSE_TRACKING} ${SERVO_LIB_NAME})
add_library(${POSE_TRACKING} SHARED src/pose_tracking.cpp)
ament_target_dependencies(${POSE_TRACKING} ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_link_libraries(${POSE_TRACKING} ${SERVO_LIB_NAME} ${SERVO_PARAM_LIB_NAME})

Copy link
Contributor Author

@nkalupahana nkalupahana Jul 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't link against the already-built library, because as you can see from the failing CI, this is a template issue -- the already-built library doesn't have the correct templated classes built in, which is why linker fails. Thus, the source has to be built each time (which is what my change does) to allow for any additional template classes that need to be built.

If this isn't okay, I think including the implementation (cpp) in the .h file would also work; that's the pattern I've seen for template classes in the past, at least. Let me know what you want to see.

Failing CI of this change: https://github.com/nkalupahana/ros2-foxy-macos/runs/3058543555?check_suite_focus=true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think including the implementation (cpp) in the .h file would also work; that's the pattern I've seen for template classes in the past, at least. Let me know what you want to see.

Yes, I think this should be the solution

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, so it looks like you can't just include the .cpp file because not everything in there is templated so if you include it, then you'll get duplicate symbols. To fix that, I just moved the template function into the .h file (the forward declaration is already in there, so I figured that wouldn't be too big of a deal). Let me know if this works!

CI: https://github.com/nkalupahana/ros2-foxy-macos/actions/runs/1027725851

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to recommend the rationale for this be added as a comment to this CMake file... just copy-paste your explanation here, into the code :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added! :)

// Must be declared here to ensure template class is built for required templates when included
template <typename T>
void declareOrGetParam(T& output_value, const std::string& param_name, const rclcpp::Node::SharedPtr& node,
const rclcpp::Logger& logger)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the default value parameter .?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, not sure. I'll fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think this is good.

Co-authored-by: Jafar Abdi <cafer.abdi@gmail.com>
@nkalupahana
Copy link
Contributor Author

@JafarAbdi any idea what's going on with CI? I don't think that failure is due to this PR.

@JafarAbdi
Copy link
Member

@JafarAbdi any idea what's going on with CI? I don't think that failure is due to this PR.

Look like the build farm is broken for rolling, I'll retrigger the workflow after few hours to see if it got fixed

@nkalupahana
Copy link
Contributor Author

@JafarAbdi looks like a slightly different CI issue, has this been reported elsewhere? I didn't see any issues for it on ros2_control.

@nkalupahana
Copy link
Contributor Author

@JafarAbdi rolling CI passed on 42ba2fa, but now it's broken again? Not sure what's going on. If it's okay with you, I think we should just merge this in -- rolling CI has now passed, and these breaks in the CI now have nothing to do with the PR :)

@davetcoleman
Copy link
Member

@tylerjw agrees we can merge this because rolling is broken...

Copy link
Member

@tylerjw tylerjw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not change the functionality and will be part of the code I'll be replacing with my parameters refactor. I'll merge this without rolling-testing passing (it is a ros infrastructure problem).

@tylerjw tylerjw merged commit cf5fb50 into moveit:main Jul 27, 2021
@nkalupahana nkalupahana deleted the patch-1 branch July 27, 2021 21:27
christianlandgraf pushed a commit to christianlandgraf/moveit2 that referenced this pull request Aug 12, 2021
* Update CMakeLists.txt

* Revert "Update CMakeLists.txt"

This reverts commit afa8c8d.

* move template function to .h

* re-added default_value

* Update moveit_ros/moveit_servo/include/moveit_servo/servo_parameters.h

Co-authored-by: Jafar Abdi <cafer.abdi@gmail.com>

* rerun CI

* rerun CI

* rerun CI

* rerun CI

* added note about duplicate symbols

Co-authored-by: Jafar Abdi <cafer.abdi@gmail.com>
Co-authored-by: Tyler Weaver <tyler@picknik.ai>
tylerjw added a commit to tylerjw/moveit2 that referenced this pull request Aug 27, 2021
* Update CMakeLists.txt

* Revert "Update CMakeLists.txt"

This reverts commit afa8c8d.

* move template function to .h

* re-added default_value

* Update moveit_ros/moveit_servo/include/moveit_servo/servo_parameters.h

Co-authored-by: Jafar Abdi <cafer.abdi@gmail.com>

* rerun CI

* rerun CI

* rerun CI

* rerun CI

* added note about duplicate symbols

Co-authored-by: Jafar Abdi <cafer.abdi@gmail.com>
Co-authored-by: Tyler Weaver <tyler@picknik.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macOS moveit_servo build issue
5 participants