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

Revision history [back]

click to hide/show revision 1
initial version

I have little experience with wxWidgets, but I can give a general answer for using ROS subscribers/publishers within a GUI framework.

First read http://answers.ros.org/question/2853/significance-of-rosspinonce#4581 and the roscpp overview of callbacks and spinning. This is an example of "Integrating ROS with framework X."

Using ROS requires two things:

  • Initialization: Call ros::init(...), create a ros::NodeHandle, and create any ros::Publisher's or ros::Subscriber's you need.
  • Event handling: Periodically (on the order of 10ms) call ros::spinOnce() to handle callbacks for any just-arrived messages.

In a simple ROS node, you'd do all that in your main(). Set up your ROS communication, and then call ros::spin() to handle events until the node shuts down.

Some GUI frameworks (like wxWidgets) claim main() entirely for themselves, so you have to slot these tasks into whatever hooks the framework gives you. In the framework's "On Init" hook, do your ROS initialization, and then set up a timer event (using whatever mechanism the framework provides) that calls ros::spinOnce().