I am trying to externally control my ur10e (RS485) on ubuntu 22.04 with ros2 humble and moveit2. I have been able to visualize the robot live on Rviz using the ur_robot_driver and launching the ros2 launch ur_moveit_config ur_moveit.launch.py ur_type:=ur5e launch_rviz:=true
. I have also been able to create trajectories through rviz and that works great.
Now however, I was following the ompl_constrained_planning tutorial and found that I couldnt send my goal poses as I do not have a ur10e specific urdf and srdf. I have the ur.srdf.xacro and ur.urdf.xacro that can be found in ur_moveit_config and ur_robot_driver respectively but I am not sure whether I can use these? I have also tried making my own urdf file now but cannot see what goes wrong when I try to launch.
I have also tried to create my own launch file to specify a robot_description and a robot_description_semantic but to no avail. This is some sample code that I tried to use:
static const auto LOGGER = rclcpp::get_logger("ur10e_ompl_constrained");
int main(int argc, char** argv)
{
using namespace std::chrono_literals;
rclcpp::init(argc, argv);
rclcpp::NodeOptions node_options;
node_options.automatically_declare_parameters_from_overrides(true);
auto node = rclcpp::Node::make_shared("ur10e_ompl_constrained_node", node_options);
rclcpp::executors::SingleThreadedExecutor executor;
executor.add_node(node);
auto spinner = std::thread([&executor]() { executor.spin(); });
moveit::planning_interface::MoveGroupInterface move_group_interface(node, "ur_manipulator");
rclcpp::sleep_for(1s);
auto current_pose = move_group_interface.getCurrentPose();
auto get_relative_pose = [current_pose](double x, double y, double z) {
auto target_pose = current_pose;
target_pose.pose.position.x += x;
target_pose.pose.position.y += y;
target_pose.pose.position.z += z;
return target_pose;
};
auto reset_demo = [&move_group_interface]() {
move_group_interface.clearPathConstraints();
};
reset_demo();
//////////////////////////////////////////////////////////////
target_pose = get_relative_pose(0.0, 0.3, -0.3);
moveit_msgs::msg::PositionConstraint line_constraint;
line_constraint.header.frame_id = move_group_interface.getPoseReferenceFrame();
line_constraint.link_name = move_group_interface.getEndEffectorLink();
shape_msgs::msg::SolidPrimitive line;
line.type = shape_msgs::msg::SolidPrimitive::BOX;
line.dimensions = { 0.0005, 0.0005, 1.0 };
line_constraint.constraint_region.primitives.emplace_back(line);
geometry_msgs::msg::Pose line_pose;
line_pose.position.x = current_pose.pose.position.x;
line_pose.position.y = current_pose.pose.position.y;
line_pose.position.z = current_pose.pose.position.z;
line_pose.orientation.x = sin(M_PI_4 / 2);
line_pose.orientation.y = 0.0;
line_pose.orientation.z = 0.0;
line_pose.orientation.w = cos(M_PI_4 / 2);
line_constraint.constraint_region.primitive_poses.emplace_back(line_pose);
line_constraint.weight = 1.0;
moveit_msgs::msg::Constraints line_constraints;
line_constraints.position_constraints.emplace_back(line_constraint);
line_constraints.name = "use_equality_constraints";
move_group_interface.setPathConstraints(line_constraints);
move_group_interface.setPoseTarget(target_pose);
success = (move_group_interface.plan(plan) == moveit::core::MoveItErrorCode::SUCCESS);
RCLCPP_INFO(LOGGER, "Plan with line constraint %s", success ? "" : "FAILED");
reset_demo();
How can I send these pose goals to the robot and I understand that this methodology includes collision avoidance? I think the problem may be that the move group that I am making a node with is not associated with my real robot. If I dont use the urdf could I possibly send constrained pose goals without collision avoidance? Thank you so much for any help!