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

GabrielBagon44's profile - activity

2022-10-25 07:59:41 -0500 received badge  Good Question (source)
2022-07-10 20:05:48 -0500 received badge  Nice Question (source)
2021-07-06 14:22:47 -0500 marked best answer how to use tf2 to transform PoseStamped messages from one frame to another?

Hi I am new to ROS so I apologize if my questions seem all over the place. I am simulating an autonomous quadcopter in gazebo, using aruco marker detection for landing. As pictured below, I have a map frame which is connected to the camera frame (base_link) which is then linked to the marker_frame. My goal is to transform the PoseStamped messages from the marker frame to the frame of the quadcopter model. And so, I have a few general inquries.

TF_Tree

  • [fcu] <---> [fcu_frd] (connected to each other)
  • [map]--->[base_link]--->[marker_frame]
  • [local_origin]--->[local_origin_ned]

(For some reason there are 3 separate trees)

Questions

  1. I am confused as to how I am to transform the PoseStamped message from the Marker frame into the quadcopter frame. Correct me if I am wrong but is the local_origin_ned the frame for the quadcopter?
  2. I have created a broadcaster node that transforms the posestamped message from the marker frame to the camera frame however, I am not sure I am transforming the information right. Is this even the right way to start? I am quite confused. (pasted below)

I am using ros kinetic on ubuntu 16.04. Again, sorry for the unorganized thoughts, and thanks in advance.

#include <ros/ros.h>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2_ros/transform_broadcaster.h>
#include <geometry_msgs/TransformStamped.h>
#include <geometry_msgs/PoseStamped.h>
void callback(const geometry_msgs::PoseStamped& msg){
    static tf2_ros::TransformBroadcaster br; 
    geometry_msgs::TransformStamped transformStamped; 
    transformStamped.header.stamp = ros::Time::now(); 
    transformStamped.header.frame_id = "base_link" ;
    transformStamped.child_frame_id = "marker_frame";

    transformStamped.transform.translation.x = msg.pose.position.x; 
    transformStamped.transform.translation.y = msg.pose.position.y; 
    transformStamped.transform.translation.z = msg.pose.position.z; 
        transformStamped.transform.rotation.x = msg.pose.orientation.x;
        transformStamped.transform.rotation.y = msg.pose.orientation.y;
        transformStamped.transform.rotation.z = msg.pose.orientation.z;
        transformStamped.transform.rotation.w = msg.pose.orientation.w;

    br.sendTransform(transformStamped); 
}

int main(int argc, char** argv){
    ros::init(argc,argv,"broadcast_cm");
    ros::NodeHandle nh; 
    ros::Subscriber sub = nh.subscribe("aruco_single/pose", 100, &callback);
    ros::spin();
    return 0; 
}

Listener Node

#include <ros/ros.h>
#include <tf2_ros/transform_listener.h>
#include <geometry_msgs/TransformStamped.h>
#include <geometry_msgs/PoseStamped.h>
#include <tf2_ros/buffer_interface.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
geometry_msgs::PoseStamped poseIn;
geometry_msgs::PoseStamped poseOut;
bool received; 

ros::Duration timeout; 
void callback(const geometry_msgs::PoseStamped& msg){
    poseIn = msg; 
    received= true; 
}

int main(int argc, char** argv){
    ros::init(argc, argv, "listener_test");
    ros::NodeHandle nh;
    ros::Subscriber sub = nh.subscribe("aruco_single/pose", 100, &callback); 
    tf2_ros::Buffer tfBuffer;
    tf2_ros::TransformListener tfListener(tfBuffer);

    ros::Rate rate(10.0); //rate 10 
    sleep(1);

    while (nh.ok()){
        try{
            if(received){poseOut = tfBuffer.transform(poseIn, "map", ros::Duration(0.0));}
        }
        catch (tf2::TransformException &ex) {
            ROS_WARN("%s",ex.what());
            ros::Duration(1.0).sleep();
                continue;
        }
    rate.sleep();
    ros::spinOnce();
    }
    return 0;
}
2020-09-08 02:24:39 -0500 received badge  Famous Question (source)
2020-02-18 16:17:23 -0500 marked best answer tf2 transform error: Lookup would require extrapolation into the past

Hi, I am currently trying to simulate a quadcopter in gazebo using mavros and px4 sitl. In this simulation, the quadcopter will identify an aruco marker, then attempt to center itself with that marker. To do so, I needed to transform the marker frame (on the ground) to the frame of the quadcopter itself (map). I have checked to see if all the frames I am working with are from the same tf but when I run the code, I get the error pictured below.

Using ROS kinetic, on ubuntu 16.04.

tf tree

these are two separate trees.

  • local_origin]-->[local_origin_ned]-->[fcu_frd]-->[fcu]
  • [map]-->[base_link]-->[marker_frame] (This is the tf I am working with)

Code

#include <ros/ros.h>
#include <tf2_ros/transform_listener.h>
#include <geometry_msgs/TransformStamped.h>
#include <geometry_msgs/PoseStamped.h>
#include <tf2_ros/buffer_interface.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
geometry_msgs::PoseStamped poseIn;
geometry_msgs::PoseStamped poseOut;
bool received; 

ros::Duration timeout; 
void callback(const geometry_msgs::PoseStamped& msg){
    poseIn = msg; 
    received= true; 
}

int main(int argc, char** argv){
    ros::init(argc, argv, "listener_test");
    ros::NodeHandle nh;
    ros::Subscriber sub = nh.subscribe("aruco_single/pose", 100, &callback); 
    tf2_ros::Buffer tfBuffer;
    tf2_ros::TransformListener tfListener(tfBuffer);

    ros::Rate rate(10.0); //rate 10 
    sleep(1);

    while (nh.ok()){
        try{
            if(received){poseOut = tfBuffer.transform(poseIn, "map", ros::Duration(0.0));}
        }
        catch (tf2::TransformException &ex) {
            ROS_WARN("%s",ex.what());
            ros::Duration(1.0).sleep();
                continue;
        }
    rate.sleep();
    ros::spinOnce();
    }
    return 0;
}

Error

[ WARN] [1560275941.431970740, 1406.020000000]: Lookup would require extrapolation into the past.  Requested time 1405.716000000 but the earliest data is at time 1560275940.551247808, when looking up transform from frame [base_link] to frame [map]
2019-10-10 04:37:50 -0500 received badge  Famous Question (source)
2019-09-24 09:32:24 -0500 received badge  Notable Question (source)
2019-09-24 09:32:24 -0500 received badge  Popular Question (source)
2019-08-08 08:03:13 -0500 received badge  Notable Question (source)
2019-08-01 05:35:26 -0500 received badge  Famous Question (source)
2019-08-01 05:35:26 -0500 received badge  Notable Question (source)
2019-07-08 13:57:55 -0500 asked a question Mocap_optitrack and mavros, no local_position/pose

Mocap_optitrack and mavros, no local_position/pose Hi, I am running a motion capture node in order to obtain pose data f

2019-07-08 13:18:19 -0500 edited answer rosrun cant find package when using catkin_make_isolated.

Hi, you can navigate to the catkin_ws cd ~/catkin_ws then, source ./devel_isolated/setup.bash then you can try doi

2019-07-08 13:08:30 -0500 commented answer rosrun cant find package when using catkin_make_isolated.

if this doesn't work you might have to check if you have added it as an executable

2019-07-08 13:07:24 -0500 edited answer rosrun cant find package when using catkin_make_isolated.

Hi, you can navigate to the catkin_ws cd ~/catkin_ws then, source ./devel/setup.bash then you can try doing rosrun

2019-07-08 13:07:01 -0500 answered a question rosrun cant find package when using catkin_make_isolated.

Hi, you can navigate try this cd ~/catkin_ws then, source ./devel/setup.bash then you can try doing rosrun again.

2019-07-08 13:07:01 -0500 received badge  Rapid Responder (source)
2019-06-21 17:49:30 -0500 received badge  Popular Question (source)
2019-06-21 12:11:05 -0500 commented question Clearpath Jackal - launch error: unable to open port

yeah, I thought it might have been an unplugged cable as well. However, it is not apparent to me, so I have sent a reque

2019-06-20 14:42:36 -0500 commented question Clearpath Jackal - launch error: unable to open port

No, I do not see it when I search through ls /dev

2019-06-20 12:01:38 -0500 commented question Clearpath Jackal - launch error: unable to open port

oh yes, sorry about that, updated now.

2019-06-20 12:01:18 -0500 edited question Clearpath Jackal - launch error: unable to open port

Clearpath Jackal - launch error: unable to open port Hi, I am running Ubuntu 16.04 with ROS kinetic on a ClearPath jac

2019-06-20 09:08:22 -0500 received badge  Famous Question (source)
2019-06-20 09:08:22 -0500 received badge  Notable Question (source)
2019-06-20 08:30:36 -0500 edited question Clearpath Jackal - launch error: unable to open port

Clearpath Jackal - launch error: unable to open port Hi, I am running Ubuntu 16.04 with ROS kinetic on a ClearPath jac

2019-06-20 08:27:18 -0500 edited question Clearpath Jackal - launch error: unable to open port

Clearpath Jackal - launch error: unable to open port Hi, I am running Ubuntu 16.04 with ROS kinetic on a ClearPath jac

2019-06-20 08:22:02 -0500 asked a question Clearpath Jackal - launch error: unable to open port

Clearpath Jackal - launch error: unable to open port Hi, I am running Ubuntu 16.04 with ROS kinetic on a ClearPath jac

2019-06-18 08:12:28 -0500 received badge  Popular Question (source)
2019-06-17 12:01:51 -0500 commented question tf2 transform error: Lookup would require extrapolation into the past

Awesome everything seems to be functioning now! Thank you very much for sticking with me through this, I have learned a

2019-06-17 10:35:12 -0500 commented question tf2 transform error: Lookup would require extrapolation into the past

ok so, it seems to be working when I enable it in multiple launch files. The only problem now is that the same error occ

2019-06-17 10:33:57 -0500 commented question tf2 transform error: Lookup would require extrapolation into the past

ok so, it seems to be working when I enable it in multiple launch files. The only problem now is that the same error occ

2019-06-17 10:09:48 -0500 asked a question use_sim_time not working

use_sim_time not working Background Hi, I am currently working on gazebo to simulate the flight and landing of a quadco

2019-06-17 07:36:37 -0500 received badge  Enthusiast
2019-06-14 09:46:15 -0500 received badge  Popular Question (source)
2019-06-13 12:33:06 -0500 commented question tf2 transform error: Lookup would require extrapolation into the past

hmm I have it enabled in my gazebo launch file as shown, however it doesn't seem to be doing any good. From what I read

2019-06-13 12:31:43 -0500 commented question tf2 transform error: Lookup would require extrapolation into the past

hmm I have it enabled in my gazebo launch file as shown, however it doesn't seem to be doing any good. From what I read

2019-06-13 12:31:22 -0500 commented question tf2 transform error: Lookup would require extrapolation into the past

hmm I have it enabled in my gazebo launch file as shown, however it doesn't seem to be doing any good. From what I read

2019-06-13 12:04:11 -0500 marked best answer How to set use_sim_time

Hi, I am wondering how you can set use_sim_time to true, or enable it for my nodes. Do I have to do it within my nodes? or in my launch file? Also, is this something you must do for all your nodes and/or launch files? Thanks.