42#include <gtest/gtest.h>
43#include <moveit_msgs/msg/servo_status.hpp>
44#include <moveit_msgs/srv/servo_command_type.hpp>
46#include <rclcpp/client.hpp>
47#include <rclcpp/node.hpp>
48#include <rclcpp/publisher.hpp>
49#include <rclcpp/qos.hpp>
50#include <sensor_msgs/msg/joint_state.hpp>
51#include <trajectory_msgs/msg/joint_trajectory.hpp>
56 void statusCallback(
const moveit_msgs::msg::ServoStatus::ConstSharedPtr& msg)
82 "/servo_node/status", rclcpp::SystemDefaultsQoS(),
83 [
this](
const moveit_msgs::msg::ServoStatus::ConstSharedPtr& msg) {
return statusCallback(msg); });
86 "/joint_states", rclcpp::SystemDefaultsQoS(),
87 [
this](
const sensor_msgs::msg::JointState::ConstSharedPtr& msg) {
return jointStateCallback(msg); });
90 "/panda_arm_controller/joint_trajectory", rclcpp::SystemDefaultsQoS(),
91 [
this](
const trajectory_msgs::msg::JointTrajectory::ConstSharedPtr& msg) {
return trajectoryCallback(msg); });
94 servo_test_node_->create_client<moveit_msgs::srv::ServoCommandType>(
"/servo_node/switch_command_type");
119 RCLCPP_ERROR(logger,
"Interrupted while waiting for the service. Exiting.");
120 std::exit(EXIT_FAILURE);
123 rclcpp::sleep_for(std::chrono::milliseconds(500));
125 RCLCPP_INFO(logger,
"MoveIt Servo input switching service ready!");
131 auto wait_timeout = rclcpp::Duration::from_seconds(5);
136 rclcpp::sleep_for(std::chrono::milliseconds(500));
138 if (elapsed_time >= wait_timeout)
140 RCLCPP_ERROR(logger,
"Timed out waiting for joint states");
165 std::atomic<moveit_servo::StatusCode>
status_;
trajectory_msgs::msg::JointTrajectory published_trajectory_
std::atomic< int > traj_count_
std::atomic< moveit_servo::StatusCode > status_
rclcpp::executors::SingleThreadedExecutor executor_
sensor_msgs::msg::JointState joint_states_
void waitForJointStates()
std::thread executor_thread_
std::atomic< int > status_count_
std::atomic< int > state_count_
rclcpp::Subscription< sensor_msgs::msg::JointState >::SharedPtr joint_state_subscriber_
void jointStateCallback(const sensor_msgs::msg::JointState::ConstSharedPtr &msg)
std::shared_ptr< rclcpp::Node > servo_test_node_
rclcpp::Subscription< moveit_msgs::msg::ServoStatus >::SharedPtr status_subscriber_
rclcpp::Client< moveit_msgs::srv::ServoCommandType >::SharedPtr switch_input_client_
void trajectoryCallback(const trajectory_msgs::msg::JointTrajectory::ConstSharedPtr &msg)
void statusCallback(const moveit_msgs::msg::ServoStatus::ConstSharedPtr &msg)
rclcpp::Subscription< trajectory_msgs::msg::JointTrajectory >::SharedPtr trajectory_subscriber_