generated from athackst/vscode_ros2_workspace
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Humble fiducial pose integration into pdf_beamtime (#42)
* feat: wip tf_server * feat: half-baked derived action server * feat: add gripper open and close * feat: add place * feat: add gripper client calls * fix: working gripper+place * fix: correct coords in launch files * fix: working return * fix: lint errors * feat: add joint return coords * fix: corrected joint poses * feat: separate fsm * fix: add flag to force pickup before return * fix: add goal abort when return * fix: change goal accept condt.
- Loading branch information
1 parent
86764da
commit 3343f13
Showing
18 changed files
with
1,359 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pdf_beamtime_server: | ||
ros__parameters: | ||
home_angles: [-0.11536, -1.783732, 0.38816, -1.75492, 0.11484, 3.14159] #For real robot | ||
pickup_approach_angles: [5.1180035, -1.3447762, 2.08776285, -0.76043996, 3.48838958, 3.14159] | ||
gripper_present: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/pdf_beamtime/include/pdf_beamtime/pdf_beamtime_fidpose_server.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/*Copyright 2024 Brookhaven National Laboratory | ||
BSD 3 Clause License. See LICENSE.txt for details.*/ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <pdf_beamtime/pdf_beamtime_server.hpp> | ||
#include <pdf_beamtime/tf_utilities.hpp> | ||
#include <pdf_beamtime_interfaces/action/fid_pose_control_msg.hpp> | ||
|
||
/// @brief Create the obstacle environment and an simple action server for the robot to move | ||
class PdfBeamtimeFidPoseServer : public PdfBeamtimeServer | ||
{ | ||
public: | ||
using FidPoseControlMsg = pdf_beamtime_interfaces::action::FidPoseControlMsg; | ||
|
||
explicit PdfBeamtimeFidPoseServer( | ||
const std::string & move_group_name, const rclcpp::NodeOptions & options, | ||
std::string action_name); | ||
|
||
private: | ||
moveit::core::MoveItErrorCode run_fsm( | ||
std::shared_ptr<const pdf_beamtime_interfaces::action::FidPoseControlMsg_Goal> goal); | ||
|
||
moveit::core::MoveItErrorCode run_return_fsm( | ||
std::shared_ptr<const pdf_beamtime_interfaces::action::FidPoseControlMsg_Goal> goal); | ||
|
||
/// @brief Pointer to the inner state machine object | ||
TFUtilities * tf_utilities_; | ||
std::vector<double, std::allocator<double>> adjusted_pickup_; | ||
std::vector<double, std::allocator<double>> adjusted_place_; | ||
|
||
/// @brief holds the current goal to be used by return_sample() function | ||
std::shared_ptr<const pdf_beamtime_interfaces::action::FidPoseControlMsg_Goal> fidpose_goal; | ||
|
||
/// @brief records pickup approach state | ||
std::vector<double, std::allocator<double>> pickup_approach_; | ||
|
||
rclcpp_action::Server<FidPoseControlMsg>::SharedPtr fidpose_action_server_; | ||
|
||
void fidpose_handle_accepted( | ||
const std::shared_ptr<rclcpp_action::ServerGoalHandle<FidPoseControlMsg>> goal_handle); | ||
rclcpp_action::GoalResponse fidpose_handle_goal( | ||
const rclcpp_action::GoalUUID & uuid, | ||
std::shared_ptr<const FidPoseControlMsg::Goal> goal); | ||
rclcpp_action::CancelResponse fidpose_handle_cancel( | ||
const std::shared_ptr<rclcpp_action::ServerGoalHandle<FidPoseControlMsg>> goal_handle); | ||
|
||
virtual void execute( | ||
const std::shared_ptr<rclcpp_action::ServerGoalHandle<FidPoseControlMsg>> goal_handle); | ||
|
||
moveit::core::MoveItErrorCode return_sample(); | ||
void execute_cleanup(); | ||
|
||
bool pickup_pose_saved = false; | ||
std::vector<double> pre_pickup_approach_joints_; | ||
std::vector<double> pickup_joints_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*Copyright 2024 Brookhaven National Laboratory | ||
BSD 3 Clause License. See LICENSE.txt for details.*/ | ||
#pragma once | ||
|
||
#include <moveit/move_group_interface/move_group_interface.h> | ||
#include <moveit/planning_scene_interface/planning_scene_interface.h> | ||
#include <tf2_ros/buffer.h> | ||
#include <tf2_ros/transform_listener.h> | ||
#include <tf2/LinearMath/Quaternion.h> | ||
#include <tf2/LinearMath/Matrix3x3.h> | ||
|
||
#include <string> | ||
#include <memory> | ||
#include <vector> | ||
#include <utility> | ||
|
||
#include <geometry_msgs/msg/transform_stamped.hpp> | ||
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
#include <rclcpp/node.hpp> | ||
|
||
class TFUtilities | ||
{ | ||
private: | ||
rclcpp::Node::SharedPtr node_; | ||
rclcpp::Logger tf_util_logger_; | ||
std::shared_ptr<tf2_ros::TransformListener> tf_listener_{nullptr}; | ||
std::unique_ptr<tf2_ros::Buffer> tf_buffer_; | ||
|
||
std::shared_ptr<rclcpp::SyncParametersClient> parameters_client_; | ||
|
||
std::string world_frame, sample_frame, grasping_point_on_gripper_frame, wrist_2_frame, | ||
pre_pickup_approach_point_frame; | ||
|
||
public: | ||
explicit TFUtilities(const rclcpp::Node::SharedPtr node); | ||
|
||
/// @brief converts degrees to radians | ||
double degreesToRadians(double degrees); | ||
|
||
std::pair<double, double> get_wrist_elbow_alignment( | ||
moveit::planning_interface::MoveGroupInterface & mgi); | ||
|
||
std::vector<geometry_msgs::msg::Pose> get_pickup_action_z_adj( | ||
moveit::planning_interface::MoveGroupInterface & mgi); | ||
|
||
std::vector<geometry_msgs::msg::Pose> get_pickup_action_pre_pickup( | ||
moveit::planning_interface::MoveGroupInterface & mgi); | ||
|
||
std::vector<geometry_msgs::msg::Pose> get_pickup_action_pickup( | ||
moveit::planning_interface::MoveGroupInterface & mgi); | ||
}; |
22 changes: 22 additions & 0 deletions
22
src/pdf_beamtime/launch/pdf_beamtime_fidpose_server.launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from launch import LaunchDescription | ||
from launch.substitutions import PathJoinSubstitution | ||
from launch_ros.actions import Node | ||
from launch_ros.substitutions import FindPackageShare | ||
|
||
|
||
def generate_launch_description(): | ||
"""Launch the node obstacle_builder with a parameter file.""" | ||
action_cmd = Node( | ||
package="pdf_beamtime", | ||
executable="pdf_beamtime_fidpose_server", | ||
parameters=[ | ||
PathJoinSubstitution([FindPackageShare("pdf_beamtime"), "config", "obstacles.yaml"]), | ||
PathJoinSubstitution([FindPackageShare("pdf_beamtime"), "config", "joint_poses.yaml"]), | ||
], | ||
output="screen", | ||
) | ||
|
||
ld = LaunchDescription() | ||
ld.add_action(action_cmd) | ||
|
||
return ld |
Oops, something went wrong.