24#include <sensor_msgs/msg/laser_scan.hpp>
26#include <geometry_msgs/msg/twist.hpp>
28#include <angles/angles.h>
32namespace cl_nav2zclient
42 rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr
cmd_vel_pub_;
63 cmd_vel_pub_ = nh->create_publisher<geometry_msgs::msg::Twist>(
"/cmd_vel", 1);
68 geometry_msgs::msg::Twist cmd_vel;
71 geometry_msgs::msg::PoseStamped currentPose = pose->toPoseStampedMsg();
73 rclcpp::Rate loop_rate(10);
74 double countAngle = 0;
75 auto prevyaw = tf2::getYaw(currentPose.pose.orientation);
79 currentPose = pose->toPoseStampedMsg();
80 tf2::fromMsg(currentPose.pose.orientation, q);
81 auto currentYaw = tf2::getYaw(currentPose.pose.orientation);
82 auto deltaAngle = angles::shortest_angular_distance(prevyaw, currentYaw);
83 countAngle += deltaAngle;
86 double angular_error =
targetYaw_ - countAngle ;
88 auto omega = angular_error *
k_betta_;
95 RCLCPP_INFO_STREAM(
getLogger(),
"["<<
getName() <<
"] delta angle: " << deltaAngle);
96 RCLCPP_INFO_STREAM(
getLogger(),
"["<<
getName() <<
"] cummulated angle: " << countAngle);
104 "["<<
getName() <<
"] command angular speed: " << cmd_vel.angular.z);
111 cmd_vel.linear.x = 0;
112 cmd_vel.angular.z = 0;
116 this->cmd_vel_pub_->publish(cmd_vel);
std::string getName() const
virtual rclcpp::Logger getLogger()
virtual rclcpp::Node::SharedPtr getNode()
void requiresComponent(SmaccComponentType *&storage)
rclcpp::Publisher< geometry_msgs::msg::Twist >::SharedPtr cmd_vel_pub_
CbPureSpinning(double targetYaw, double max_angular_yaw_speed=0.5)
double max_angular_yaw_speed_
double yaw_goal_tolerance_rads_