# Revision history [back]

I think it's more common to use subscribers instead of threads, as mentioned in the comments. I'll share an example code fragment for your reference.

// global variables definition
double vx;
double vy;
double vth;

void callback_function(const geometry_msgs::Twist::ConstPtr& msg)
{
vx = msg->linear.x;
vy = 0.0;
vth = msg->angular.z;
}

int main(int argc, char** argv){
// ...
double x = 0.0;
double y = 0.0;
double th = 0.0;