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

If your node is started before the topic is running, you can create a subscriber and a static boolean in your callback (assuming you're working in C++ and ROS1) :

static bool isFirstTime = true;
static geometry_msgs::Pose firstPose

static void callbackSubscriber(const geometry_msgs::Pose::ConstPtr& msg)
{
    if(isFirstTime)
    {
        isFirstTime = false;
        firstPose = msg;
    }
}

Disclaimer : I haven't tested, just wrote it off to give a global idea. Not sure this is a "clean" solution too.