diff --git a/src/ar3_config/launch/dev.launch.py b/src/ar3_config/launch/dev.launch.py
index 0315854..2007552 100644
--- a/src/ar3_config/launch/dev.launch.py
+++ b/src/ar3_config/launch/dev.launch.py
@@ -44,14 +44,10 @@ def generate_launch_description():
Node(
package='move_group_interface',
- executable='move_group_interface_ndde',
- output='screen',
- ),
- Node(
- package='move_group_interface',
- executable='client_node',
+ executable='move_group_interface_node',
output='screen',
),
+
Node(
package='joystickmove',
executable='move',
diff --git a/src/move_group_interface/CMakeLists.txt b/src/move_group_interface/CMakeLists.txt
index 8f743a1..57cf172 100644
--- a/src/move_group_interface/CMakeLists.txt
+++ b/src/move_group_interface/CMakeLists.txt
@@ -19,22 +19,23 @@ endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
+find_package(moveit_ros_planning_interface REQUIRED)
find_package(rosidl_default_generators REQUIRED)
# Create service stuff
-rosidl_generate_interfaces(${PROJECT_NAME}
- "srv/MovePose.srv"
- DEPENDENCIES geometry_msgs
-)
+#rosidl_generate_interfaces(${PROJECT_NAME}
+# "srv/MovePose.srv"
+# DEPENDENCIES geometry_msgs
+#)
# move_group_node
add_executable(move_group_interface_node src/move_group_interface_node.cpp)
-ament_target_dependencies(move_group_interface_node rclcpp geometry_msgs)
-rosidl_target_interfaces(move_group_interface_node ${PROJECT_NAME} "rosidl_typesupport_cpp")
+ament_target_dependencies(move_group_interface_node rclcpp geometry_msgs moveit_ros_planning_interface)
+#rosidl_target_interfaces(move_group_interface_node ${PROJECT_NAME} "rosidl_typesupport_cpp")
-add_executable(client_node src/client_node.cpp)
-ament_target_dependencies(client_node rclcpp)
-rosidl_target_interfaces(client_node ${PROJECT_NAME} "rosidl_typesupport_cpp")
+#add_executable(client_node src/client_node.cpp)
+#ament_target_dependencies(client_node rclcpp)
+#rosidl_target_interfaces(client_node ${PROJECT_NAME} "rosidl_typesupport_cpp")
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
@@ -48,7 +49,7 @@ if(BUILD_TESTING)
endif()
# Mark executables for installation
-install(TARGETS move_group_interface_node client_node
+install(TARGETS move_group_interface_node
DESTINATION lib/${PROJECT_NAME})
ament_package()
diff --git a/src/move_group_interface/package.xml b/src/move_group_interface/package.xml
index 433f16e..c7c0137 100644
--- a/src/move_group_interface/package.xml
+++ b/src/move_group_interface/package.xml
@@ -14,6 +14,7 @@
rosidl_default_runtime
rclcpp
geometry_msgs
+ moveit_ros_planning_interface
ament_lint_auto
ament_lint_common
diff --git a/src/move_group_interface/src/client_node.cpp b/src/move_group_interface/src/client_node.cpp
deleted file mode 100644
index 2102782..0000000
--- a/src/move_group_interface/src/client_node.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include
-#include
-#include "geometry_msgs/msg/pose_stamped.hpp"
-
-class ScanNPlan : public rclcpp::Node {
-public:
- ScanNPlan() : Node("scan_n_plan") {
- move_client_ = this->create_client("update_pose");
- pose_sub_ = this->create_subscription(
- "move_pose",
- rclcpp::QoS(1),
- std::bind(&ScanNPlan::moveCallback, this, std::placeholders::_1)
- );
- }
-
- void moveCallback(geometry_msgs::msg::PoseStamped::SharedPtr msg) {
- RCLCPP_INFO(get_logger(), "Attempting to move to pose");
-
- // Wait for service to be available
- if (!move_client_->wait_for_service(std::chrono::seconds(5))) {
- RCLCPP_ERROR(get_logger(), "Unable to find move_pose service. Start move_pose first.");
- return;
- }
-
- // Create a request for the MovePose service call
- auto request = std::make_shared();
- request->pose = msg;
- auto future = move_client_->async_send_request(request);
-
- if (rclcpp::spin_until_future_complete(this->get_node_base_interface(), future) != rclcpp::executor::FutureReturnCode::SUCCESS) {
- RCLCPP_ERROR(this->get_logger(), "Failed to receive MovePose service response");
- return;
- }
-
- auto response = future.get();
- if (!response->success) {
- RCLCPP_ERROR(this->get_logger(), "MovePose service failed");
- return;
- }
-
- // Successfully moved
-
- /*
- RCLCPP_INFO(this->get_logger(), "Moved to pose: x: %f, y: %f, z: %f - x: %f, y: %f, z: %f, w: %f",
- response->pose.position.x,
- response->pose.position.y,
- response->pose.position.z,
-
- response->pose.orientation.x,
- response->pose.orientation.y,
- response->pose.orientation.z,
- response->pose.orientation.w
- );
- */
- }
-private:
- rclcpp::Client::SharedPtr move_client_;
- rclcpp::Subscription::SharedPtr pose_sub_;
-};
-
-int main(int argc, char **argv) {
- rclcpp::init(argc, argv);
-
- /*
- auto app = std::make_shared();
- app->start();
- */
-
- rclcpp::shutdown();
- return 0;
-}
diff --git a/src/move_group_interface/src/move_group_interface_node.cpp b/src/move_group_interface/src/move_group_interface_node.cpp
index 6a7349f..7257f0c 100644
--- a/src/move_group_interface/src/move_group_interface_node.cpp
+++ b/src/move_group_interface/src/move_group_interface_node.cpp
@@ -1,122 +1,93 @@
+// https://github.com/ros-planning/moveit2_tutorials/blob/main/doc/examples/moveit_cpp/src/moveit_cpp_tutorial.cpp
+
#include
#include
+#include
// MoveitCpp
#include
#include
-// https://github.com/ros-planning/moveit_visual_tools/tree/foxy
-// #include
-
-#include
-
#include "geometry_msgs/msg/pose_stamped.hpp"
-// namespace rvt = rviz_visual_tools;
+const std::string PLANNING_GROUP = "ar3_arm";
-const std::string PLANNING_GROUP = "base_link";
+class ScanNPlan : public rclcpp::Node {
+public:
+ ScanNPlan() : Node("scan_n_plan") {
+ // create the node and start it
+ nh_ = std::make_shared("scan_n_plan");
-class Localizer : public rclcpp::Node {
- public:
- Localizer() : Node("move_group_interface_node") {//, last_msg_{nullptr} {
- /*
- pose_sub_ = this->create_subscription(
- "move_pose",
- rclcpp::QoS(1),
- std::bind(&Localizer::moveCallback, this, std::placeholders::_1)
- );
- */
-
- server_ = this->create_service(
- "update_pose",
- std::bind(&Localizer::movePose, this, std::placeholders::_1, std::placeholders::_2)
- );
- }
+ // spin the node
+ executor_ = std::make_shared();
+ executor_->add_node(nh_);
/*
- void moveCallback(geometry_msgs::msg::PoseStamped::SharedPtr msg) {
- last_msg_ = msg;
- }
+ RCLCPP_INFO(nh_->get_logger(), "scan and plan in constructor");
+ auto spin = [this]() {
+ while(rclcpp::ok()) {
+ executor_->spin_once();
+ RCLCPP_INFO(nh_->get_logger(), "scan and plan still running");
+ }
+ };
+ thread_executor_spin_ = std::thread(spin);
*/
- void movePose(move_group_interface::srv::MovePose::Request::SharedPtr req,
- move_group_interface::srv::MovePose::Response::SharedPtr res) {
- // Read last message
- geometry_msgs::msg::PoseStamped::SharedPtr p = req->pose; // last_msg_;
+ // create subscriber
+ pose_sub_ = nh_->create_subscription(
+ "move_pose",
+ rclcpp::QoS(1),
+ std::bind(&ScanNPlan::moveCallback, this, std::placeholders::_1)
+ );
+ }
- if (!p) {
- RCLCPP_ERROR(this->get_logger(), "no data");
- res->success = false;
- return;
- }
+private:
+ void moveCallback(geometry_msgs::msg::PoseStamped::SharedPtr p) {
+ auto moveit_cpp_ptr = std::make_shared(nh_);
- // https://moveit.picknik.ai/galactic/doc/examples/moveit_cpp/moveitcpp_tutorial.html
+ //auto psm = std::make_shared("robot_description");
+ //psm->startSceneMonitor();
+ moveit_cpp_ptr->getPlanningSceneMonitor()->providePlanningSceneService();
- // set up with current position
- auto moveit_cpp_ptr = std::make_shared(this);
- moveit_cpp_ptr->getPlanningSceneMonitor()->providePlanningSceneService();
- auto planning_components = std::make_shared(PLANNING_GROUP, moveit_cpp_ptr);
- auto robot_model_ptr = moveit_cpp_ptr->getRobotModel();
- auto robot_start_state = planning_components->getStartState();
- // auto joint_model_group_ptr = robot_model_ptr->getJointModelGroup(PLANNING_GROUP);
+ // planning_scene_monitor::LockedPlanningSceneRW scene{moveit_cpp_ptr->getPlanningSceneMonitor()};
- // set up visualizations
- /*
- moveit_visual_tools::MoveItVisualTools visual_tools(node, "base_link", "move_group_interface", moveit_cpp_ptr->getPlanningSceneMonitor());
- visual_tools.deleteAllMarkers();
- visual_tools.loadRemoteControl();
+ auto planning_components = std::make_shared(PLANNING_GROUP, moveit_cpp_ptr);
+ auto robot_model_ptr = moveit_cpp_ptr->getRobotModel();
+ auto robot_start_state = planning_components->getStartState();
- Eigen::Isometry3d text_pose = Eigen::Isometry3d::Identity();
- text_pose.translation().z() = 1.75;
+ planning_components->setStartStateToCurrentState();
- visual_tools.trigger();
- */
+ // set the goal to the request pose
+ planning_components->setGoal(*p, "base_link");
- // just in case
- planning_components->setStartStateToCurrentState();
+ // actually plan
+ auto plan_solution = planning_components->plan();
- // set the goal to the request pose
- planning_components->setGoal(p, "ar3_arm");
-
- // actually plan
- auto plan_solution = planning_components->plan();
-
- // plan is valid
- if (plan_solution) {
- // display the robot in rviz
- /*
- visual_tools.publishAxisLabeled(robot_start_state->getGlobalLinkTransform("base_link"), "start_pose");
- visual_tools.publishText(text_pose, "Start Pose", rvt::WHITE, rvt::XLARGE);
-
- visual_tools.publishAxisLabeled(target_pose1.pose, "target_pose");
- visual_tools.publishText(text_pose, "Goal Pose", rvt::WHITE, rvt::XLARGE);
-
- visual_tools.publishTrajectoryLine(plan_solution.trajectory, joint_model_group_ptr);
- visual_tools.trigger();
- */
-
- // Execute plan
- planning_components->execute();
- }
-
- // set response variables to updated robot states
- res->header = p->header; // TODO: change these to current state (post move)
- res->pose = p->pose;
- res->success = true;
+ // plan is valid
+ if (plan_solution) {
+ planning_components->execute();
}
+ }
+private:
+ rclcpp::Subscription::SharedPtr pose_sub_;
- // rclcpp::Subscription::SharedPtr pose_sub_;
- // geometry_msgs::msg::PoseStamped::SharedPtr last_msg_;
- rclcpp::Service::SharedPtr server_;
+ //please
+ rclcpp::Node::SharedPtr nh_;
+ rclcpp::executors::SingleThreadedExecutor::SharedPtr executor_;
+ std::thread thread_executor_spin_;
};
int main(int argc, char* argv[]) {
rclcpp::init(argc, argv);
- auto node = std::make_shared();
-
+ auto node = std::make_shared();
RCLCPP_INFO(node->get_logger(), "MoveGroup node started.");
rclcpp::spin(node);
+
+ RCLCPP_INFO(node->get_logger(), "Terminating MoveGroup");
+ rclcpp::shutdown();
+ return 0;
}
+