why can not get the local velocity??

asked 2023-04-26 03:54:23 -0500

yosuga gravatar image

updated 2023-04-27 16:03:22 -0500

Andromeda gravatar image

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

edit retag flag offensive close merge delete

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...

Andromeda gravatar image Andromeda  ( 2023-04-27 16:04:47 -0500 )edit