ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

After execution Call back function program doesnt return to orignal execution?

asked 2012-05-06 13:43:26 -0600

anonymous user

Anonymous

updated 2014-01-28 17:12:13 -0600

ngrennan gravatar image

Suppose I have following program :

Global Variables
void  main (..)
{
  declared nodes.. and stuff

  while(1)
  {
      do X stuff.. 

      publish a topic..
  }
} 

void callback()
{
    process data.. 
}

I am not able to publish a topic, after first call back is called.. Is it some error in my code or, I am missing some return statement.. ?

Actually am using Odometry Sample Program and have linked it with roserial program. So the only modification to sample odometry program I have made is that have added a subscriber and a callback method which sets vx vy etc variables... The problem is the odom and base_link frames no longer exists.. ? I dont know whats wrong :(

edit retag flag offensive close merge delete

Comments

We need more details. Do you call ros::spin or ros::spinOnce anywhere? Could you generate a minimal example that has the same issue or post your code?

Eric Perko gravatar image Eric Perko  ( 2012-05-06 16:25:37 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-05-06 14:57:19 -0600

weiin gravatar image

If you are asking about doing callbacks in ROS, use ros::spinOnce() instead of ros::spin() in your while loop. See this tutorial: link text

edit flag offensive delete link more

Comments

1

The odometry sample program mentioned above did not call ros::spinOnce(). It should, so I fixed it.

joq gravatar image joq  ( 2012-05-06 16:57:57 -0600 )edit
0

answered 2012-05-06 15:02:09 -0600

anonymous user

Anonymous

updated 2012-05-06 16:03:46 -0600

Actually am using Odometry Sample Program and have linked it with roserial program. So the only modification to sample odometry program I have made is that have added a subscriber and a callback method which sets vx vy etc variables... The problem is the odom and base_link frames no longer exists.. ? I dont know whats wrong :(

edit flag offensive delete link more

Comments

1

As the answers may be reordered, it would be better to post this as a comment to my answer, or as an edit to your own question. It would be good to edit your question to describe your problem more clearly, otherwise it's hard for others to help (and check that your links are correct!)

weiin gravatar image weiin  ( 2012-05-06 15:12:40 -0600 )edit

Sorry , pasted a wrong link .. rectified it.. And am not able to comment on others answers.. still new to this answers.ros.. sorry about the issues..

anonymous userAnonymous ( 2012-05-06 16:06:22 -0600 )edit

Ok, joq updated the sample program, that should work now. It would be good nevertheless, to work through the publishing/subscribing tutorial that I linked. I went through that a few times when learning ROS.

weiin gravatar image weiin  ( 2012-05-06 17:45:53 -0600 )edit

Question Tools

Stats

Asked: 2012-05-06 13:43:26 -0600

Seen: 709 times

Last updated: May 06 '12