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

Hi,

I finally found a solution. It took me so long before finding these documentations so helpfull: PoseArray.h and geometry_msgs::PoseArray_< ContainerAllocator > Struct Template Reference

And with that I discover somes functions that I could use to solve my problem. I just add one line :

Hi,

I finally found a solution. It took me so long before finding these documentations so helpfull: PoseArray.h and geometry_msgs::PoseArray_< ContainerAllocator > Struct Template Reference

And with that I discover somes functions that I could use to solve my problem. I just add one line made this modifications :

// Callback which will save the estimated local position of the Apriltag
//geometry_msgs::PoseArray APtag_est_pos;
void APtag_est_pos_cb(const geometry_msgs::PoseArray::ConstPtr& AP_est_pos){
    //ROS_INFO("CALLBACK AP");
    APtag_est_pos = *AP_est_pos;
    int n_AP = 0; // Or you can use it as a global variable
    n_AP = AP_est_pos->poses.size();
    ROS_INFO("n=%d", n_AP);
    if(n_AP>0){  
        ROS_INFO("APtag est pos=[%f, %f, %f]",  AP_est_pos->poses[0].position.x,
                                                AP_est_pos->poses[0].position.y,
                                                AP_est_pos->poses[0].position.z);
    }
}

Now it's working even with 2,3 AP detected. With the variable n_AP, you can switch between AP.

I hope it could be helpful for others to not wasting time searching so simple thing...

Best regards.

Hi,

I finally found a solution. It took me so long before finding these documentations so helpfull: PoseArray.h and geometry_msgs::PoseArray_< ContainerAllocator > Struct Template Reference

And with With that I discover somes some functions that I could use to solve my problem. I just made this modifications :

// Callback which will save the estimated local position of the Apriltag
//geometry_msgs::PoseArray APtag_est_pos;
void APtag_est_pos_cb(const geometry_msgs::PoseArray::ConstPtr& AP_est_pos){
    //ROS_INFO("CALLBACK AP");
    APtag_est_pos = *AP_est_pos;
    int n_AP = 0; // Or you can use it as a global variable
    n_AP = AP_est_pos->poses.size();
    ROS_INFO("n=%d", n_AP);
    if(n_AP>0){  
        ROS_INFO("APtag est pos=[%f, %f, %f]",  AP_est_pos->poses[0].position.x,
                                                AP_est_pos->poses[0].position.y,
                                                AP_est_pos->poses[0].position.z);
    }
}

Now it's working even with 2,3 AP detected. With the variable n_AP, you can switch between AP.

I hope it could be helpful for others to not wasting time searching so simple thing...

Best regards.

Hi,

I finally found a solution. It took me so long before finding these documentations so helpfull: PoseArray.h and geometry_msgs::PoseArray_< ContainerAllocator > Struct Template Reference

With that I discover some functions that I could use to solve my problem. I just made this modifications :

// Callback which will save the estimated local position of the Apriltag
//geometry_msgs::PoseArray APtag_est_pos;
void APtag_est_pos_cb(const geometry_msgs::PoseArray::ConstPtr& AP_est_pos){
    //ROS_INFO("CALLBACK AP");
    APtag_est_pos = *AP_est_pos;
    int n_AP = 0; // Or you can use it as a global variable
    n_AP = AP_est_pos->poses.size();
    ROS_INFO("n=%d", n_AP);
    if(n_AP>0){  
        ROS_INFO("APtag est pos=[%f, %f, %f]",  AP_est_pos->poses[0].position.x,
                                                AP_est_pos->poses[0].position.y,
                                                AP_est_pos->poses[0].position.z);
    }
}

Now it's working even with 2,3 AP detected. With the variable n_AP, you can switch between AP.AP by using poses[n_AP-1] but don't forget to check there is one otherwise you will go in a wrong memory space.

I hope it could be helpful for others to not wasting time searching so simple thing...

Best regards.