44#include <gtest/gtest.h>
45#include <moveit_msgs/msg/servo_status.hpp>
46#include <moveit_msgs/srv/servo_command_type.hpp>
48#include <rclcpp/client.hpp>
49#include <rclcpp/node.hpp>
50#include <rclcpp/publisher.hpp>
51#include <rclcpp/qos.hpp>
52#include <sensor_msgs/msg/joint_state.hpp>
53#include <trajectory_msgs/msg/joint_trajectory.hpp>
58 void statusCallback(
const moveit_msgs::msg::ServoStatus::ConstSharedPtr& msg)
84 "/servo_node/status", rclcpp::SystemDefaultsQoS(),
85 [
this](
const moveit_msgs::msg::ServoStatus::ConstSharedPtr& msg) {
return statusCallback(msg); });
88 "/joint_states", rclcpp::SystemDefaultsQoS(),
89 [
this](
const sensor_msgs::msg::JointState::ConstSharedPtr& msg) {
return jointStateCallback(msg); });
92 "/panda_arm_controller/joint_trajectory", rclcpp::SystemDefaultsQoS(),
93 [
this](
const trajectory_msgs::msg::JointTrajectory::ConstSharedPtr& msg) {
return trajectoryCallback(msg); });
96 servo_test_node_->create_client<moveit_msgs::srv::ServoCommandType>(
"/servo_node/switch_command_type");
121 RCLCPP_ERROR(logger,
"Interrupted while waiting for the service. Exiting.");
122 std::exit(EXIT_FAILURE);
125 rclcpp::sleep_for(std::chrono::milliseconds(500));
127 RCLCPP_INFO(logger,
"MoveIt Servo input switching service ready!");
133 auto wait_timeout = rclcpp::Duration::from_seconds(5);
138 rclcpp::sleep_for(std::chrono::milliseconds(500));
140 if (elapsed_time >= wait_timeout)
142 RCLCPP_ERROR(logger,
"Timed out waiting for joint states");
167 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_