Robotics StackExchange | Archived questions

why can not get the local velocity??

i want to get the vehicle velocity,and using velocity to control vehicle. i used

ros::Subscriber velocity_sub = nh.subscribe<geometry_msgs::TwistStamped>("mavros/local_position/velocity", 10, velocityCallBack); 

to subscribe the data , and this is the callback function:

void velocityCallBack(const geometry_msgs::TwistStamped::ConstPtr& msg)
{
    double vx = msg->twist.linear.x; 
    double vy = msg->twist.linear.y; 
    double vz = msg->twist.linear.z; 

    ROS_INFO("Velocity: [vx=%f, vy=%f, vz=%f]", vx, vy, vz);
}

and ros::spinOnce() is used in main function. i don't know why there are not any out put. ardupilot frame ware

Asked by yosuga on 2023-04-26 03:54:23 UTC

Comments

Post please ALL the code, otherwise it is pratically impossible to help you. Furthermore, open a terminal and type ros topic echo <msg> to see, whether the data is sent or not. By the way: spinOnce(), if not used correctly, runs only once...

Asked by Andromeda on 2023-04-27 16:04:47 UTC

Answers