42 #include <geometry_msgs/msg/twist_stamped.hpp>
43 #include <std_srvs/srv/trigger.hpp>
44 #include <rclcpp/client.hpp>
45 #include <rclcpp/executors.hpp>
46 #include <rclcpp/logger.hpp>
47 #include <rclcpp/node.hpp>
48 #include <rclcpp/node_options.hpp>
49 #include <rclcpp/publisher.hpp>
50 #include <rclcpp/qos_event.hpp>
51 #include <rclcpp/time.hpp>
52 #include <rclcpp/utilities.hpp>
54 using namespace std::chrono_literals;
56 int main(
int argc,
char** argv)
58 rclcpp::init(argc, argv);
59 static const rclcpp::Logger LOGGER = rclcpp::get_logger(
"moveit_servo.publish_fake_jog_commands.cpp");
62 rclcpp::NodeOptions node_options;
63 auto node = std::make_shared<rclcpp::Node>(
"publish_fake_jog_commands", node_options);
66 rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr servo_start_client =
67 node->create_client<std_srvs::srv::Trigger>(
"/servo_node/start_servo");
68 servo_start_client->wait_for_service(1s);
69 servo_start_client->async_send_request(std::make_shared<std_srvs::srv::Trigger::Request>());
72 auto pub = node->create_publisher<geometry_msgs::msg::TwistStamped>(
"/servo_node/delta_twist_cmds", 10);
73 std::weak_ptr<std::remove_pointer<decltype(pub.get())>
::type> captured_pub = pub;
74 std::weak_ptr<std::remove_pointer<decltype(node.get())>
::type> captured_node = node;
75 auto callback = [captured_pub, captured_node]() ->
void {
76 auto pub_ptr = captured_pub.lock();
77 auto node_ptr = captured_node.lock();
78 if (!pub_ptr || !node_ptr)
82 auto msg = std::make_unique<geometry_msgs::msg::TwistStamped>();
83 msg->header.stamp = node_ptr->now();
84 msg->header.frame_id =
"panda_link0";
85 msg->twist.linear.x = 0.3;
86 msg->twist.angular.z = 0.5;
87 pub_ptr->publish(std::move(msg));
89 auto timer = node->create_wall_timer(50ms, callback);
int main(int argc, char **argv)