We have a Ur5e robot which we want to use. The basic connection and all works good currently we are trying to create a ROS2 CPP Node and use MoveIt to have some high level motion planning. At the moment we run always eventually into the same Error while building the package:
fatal error: moveit/macros/class_forward.hpp: No such file or directory
40 | #include <moveit/macros/class_forward.hpp>
We are using various variants of cpp code looking all something like this:
#include <rclcpp/rclcpp.hpp>
#include <moveit/move_group_interface/move_group_interface.h>
int main(int argc, char* argv[])
{
rclcpp::init(argc, argv);
auto node = std::make_shared<rclcpp::Node>("ur5e_moveit_control");
// Use a static executor instead of multi-threading
rclcpp::executors::StaticSingleThreadedExecutor executor;
executor.add_node(node);
auto move_group_interface = moveit::planning_interface::MoveGroupInterface(node, "ur_manipulator");
move_group_interface.setMaxVelocityScalingFactor(0.1);
move_group_interface.setMaxAccelerationScalingFactor(0.1);
// Set target position - use a safe home position
std::vector<double> target_joints = {0.0, -1.57, 1.57, -1.57, -1.57, 0.0};
move_group_interface.setJointValueTarget(target_joints);
// Plan and execute
moveit::planning_interface::MoveGroupInterface::Plan motion_plan;
if(move_group_interface.plan(motion_plan) == moveit::core::MoveItErrorCode::SUCCESS) {
RCLCPP_INFO(node->get_logger(), "Planning successful! Executing...");
move_group_interface.execute(motion_plan);
} else {
RCLCPP_ERROR(node->get_logger(), "Planning failed!");
}
rclcpp::shutdown();
return 0;
}
Our CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.8)
project(ur5e_control)
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(moveit_ros_planning_interface REQUIRED)
find_package(moveit_core REQUIRED)
find_package(moveit_ros_planning REQUIRED)
find_package(moveit_ros_move_group REQUIRED)
add_executable(ur5e_moveit_control src/ur5e_moveit_control.cpp)
# target_include_directories(ur5e_moveit_control PRIVATE
# ${Boost_INCLUDE_DIRS}
# )
ament_target_dependencies(ur5e_moveit_control
rclcpp
moveit_ros_planning_interface
moveit_core
moveit_ros_planning
moveit_ros_move_group
)
install(TARGETS ur5e_moveit_control
DESTINATION lib/${PROJECT_NAME}
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()
And our package.xml looks the following:
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ur5e_control</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="e.kunstner@student.maastrichtuniversity.nl">UMRobotics</maintainer>
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>rclcpp</depend>
<depend>moveit_ros_planning_interface</depend>
<depend>moveit_core</depend>
<depend>moveit_ros_planning</depend>
<depend>moveit_ros_move_group</depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Is there anything we are missing are we doing something completely wrong.
For now the goal would just be to have a simple motion to the given point later we also want to have a bit more complicated motion planning.