basic cmd_vel
This commit is contained in:
parent
95f81b71c5
commit
50767ebc27
@ -49,6 +49,16 @@ private:
|
|||||||
void cmd_vel_callback(const geometry_msgs::msg::Twist::SharedPtr msg) const
|
void cmd_vel_callback(const geometry_msgs::msg::Twist::SharedPtr msg) const
|
||||||
{
|
{
|
||||||
RCLCPP_INFO(this->get_logger(), "cmd_vel: %f", msg->linear.x);
|
RCLCPP_INFO(this->get_logger(), "cmd_vel: %f", msg->linear.x);
|
||||||
|
float x, y, z;
|
||||||
|
x = msg->linear.x;
|
||||||
|
y = msg->linear.y;
|
||||||
|
z = msg->angular.z;
|
||||||
|
this->robot->lock();
|
||||||
|
this->robot->setVel(x * 1e3);
|
||||||
|
if (robot->hasLatVel())
|
||||||
|
robot->setLatVel(y * 1e3);
|
||||||
|
robot->setRotVel(z * 180 / M_PI);
|
||||||
|
robot->unlock();
|
||||||
}
|
}
|
||||||
rclcpp::Subscription<geometry_msgs::msg::Twist>::SharedPtr cmd_vel_sub_;
|
rclcpp::Subscription<geometry_msgs::msg::Twist>::SharedPtr cmd_vel_sub_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user