Angle calculation inside a timerCallback() function

asked 2014-04-28 21:56:11 -0500

RB gravatar image

updated 2014-04-29 18:34:00 -0500

Hi, I am using ROS fuerte version on Ubuntu 10.04.

From one node, I am subscribing to "move_base_simple/goal" topic and "amcl_pose" topic. Now, I want to process these messages to calculate angle between current robot position and goal position.

You can view the source cpp file below (highlighted the required portion)

http://pastebin.com/heJYgG2E

header File: 1 http://pastebin.com/nysZxued header File: 2 http://pastebin.com/3W2KkFM7

Question1. ANGLE Calculation must be inside void CmdVelMux::timerCallback(const ros::TimerEvent& event, unsigned int idx) function. PoseWithCovarianceStamped messages are passed to a callback function, void CmdVelMux::currentPosCallback(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& msg) and PoseStamped messages are passed to a void CmdVelMux::goalPosCallback(const geometry_msgs::PoseStamped::ConstPtr& msg).

There must be a relation between timerCallback and these two functions.

How to do that?

Updated based on my comment PLZ help Modified src file http://pastebin.com/GuMcS1nc Modified header file http://pastebin.com/cdawwNsQ

Question2: But, when I am running the node, I want to see whether I am able to extract the messages or not? But, after running the node using launch file, I can't see anything written inside ROS_DEBUG or printf in that particular terminal? How to print the content of geometry messages in the terminal?

Thanks advance

edit retag flag offensive close merge delete

Comments

If we create two data members of the class and then copy the messages from callback functions and later on it can be utilized by other member function like timerCallback to calculate actual angle. But I don't know whether data member will contain recent messages or not?

RB gravatar image RB  ( 2014-04-29 07:28:19 -0500 )edit