Ask Your Question

choog's profile - activity

2019-01-21 12:53:15 -0600 marked best answer reading a specific tf frame

Hello,

Does anyone know if there is a function that lets you read a specific tf frame such as:

.readFrame("/base_link" , time(latest info published), //frame reference);

I need to be able to read a specific frame. I know you can do: tf::StampedTransform transform; .lookUpTransform("target frame", "original frame" , time , transform);

The reason why I don't want a lookUpTransform is because I am actually not trying to take the transform of anything here. Unless I am not understanding something here, I would appreciate some feed back here.

This is what I have so far. Please give me some feed back on the frames that I am using. Because to my understanding The "base_link" frame should be transformed to the "map" frame, If I have a .yaml map file running on top of the navigation stack right?

  #include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <geometry_msgs/TransformStamped.h>
#include <tf/transform_listener.h>
#include <tf/transform_broadcaster.h>
#include <tf/transform_broadcaster.h>

using namespace std;

int main(int argc, char** argv) {
    ros::init(argc, argv, "readTFframe");
    ros::NodeHandle nh;
        tf::Transform leader_base_link;
    tf::Quaternion q;
    tf::Vector3 v;  
    tf::TransformListener listener;
    geometry_msgs::TransformStamped transformConverter;

    ros::Time current_time, last_time;
        current_time = ros::Time::now();
        last_time = ros::Time::now();

    ros::Publisher pub = nh.advertise<geometry_msgs::TransformStamped>("/leader/tf", 1);

    static tf::TransformBroadcaster br;

    double yaw; 


ros::Rate loopRate(10);
while(ros::ok()){
    tf::StampedTransform transform;
    current_time = ros::Time::now();


    try {
                        listener.waitForTransform("base_link", "base_footprint", ros::Time(0), ros::Duration(10.0));
            listener.lookupTransform("base_link", "base_footprint", ros::Time(0), transform);
        }
        catch (tf::TransformException &ex) {
            ROS_ERROR("%s",ex.what());
        }
    yaw =   tf::getYaw(transform.getRotation()); 
        v.setValue(transform.getOrigin().x() , transform.getOrigin().y() , transform.getOrigin().z());

    leader_base_link.setOrigin(v);
    q.setRPY(0.0, 0.0, yaw);
    leader_base_link.setRotation(q );
    br.sendTransform(tf::StampedTransform(leader_base_link, ros::Time::now(), "base_footprint", "leader_base_link"));

/*
    ROS_INFO_STREAM("X pose " <<  transform.getOrigin().x() );
    ROS_INFO_STREAM("Y pose " << transform.getOrigin().y() );
    ROS_INFO_STREAM("Z pose " << transform.getOrigin().z() );
    ROS_INFO_STREAM("Yaw "<< yaw );
*/  
double th = yaw;
 geometry_msgs::Quaternion odom_quat = tf::createQuaternionMsgFromYaw(th);
    transformConverter.header.stamp = current_time; 
    transformConverter.header.frame_id = "base_footprint";
    transformConverter.child_frame_id = "base_link";
    transformConverter.transform.translation.x = transform.getOrigin().x();
    transformConverter.transform.translation.y = transform.getOrigin().y();
    transformConverter.transform.translation.z = transform.getOrigin().z();
    transformConverter.transform.rotation = odom_quat;
    ROS_INFO_STREAM("X pose " <<  transformConverter.transform.translation.x );
    ROS_INFO_STREAM("Y pose " << transformConverter.transform.translation.y);
    ROS_INFO_STREAM("Z pose " << transformConverter.transform.translation.z );
    ROS_INFO_STREAM("Yaw "<< yaw );

    loopRate.sleep();
}

    return 0;
}

This is my current code when I run it I can see that the values are being passed to the transformConverter transform that is converting the desired transform from tf::StampedTransform to geometry_msgs::TransformStamped . This way it can be published on the topic /leader/tf. The only thing is I can see the values are passed through ROS_INFO. But they are not being published now on the topic.

2017-09-19 07:37:54 -0600 received badge  Famous Question (source)
2016-11-29 13:01:40 -0600 marked best answer CMake error with move_base_msgs

Hello,

I am trying to run this tutorial http://wiki.ros.org/navigation/Tutori... . For some reason I keep getting this error: By the way I am running groovy and ubuntu 12.04

    CMake Error at /opt/ros/groovy/share/catkin/cmake/catkinConfig.cmake:72 (find_package):
  Could not find a configuration file for package move_base_msgs.

  Set move_base_msgs_DIR to the directory containing a CMake configuration
  file for move_base_msgs.  The file will have one of the following names:

    move_base_msgsConfig.cmake
    move_base_msgs-config.cmake

Call Stack (most recent call first):
  simple_navigation_goals/CMakeLists.txt:7 (find_package)


-- Configuring incomplete, errors occurred!
Invoking "cmake" failed

I run rospack find move_base_msgs and it finds the package under :

ubuntu@ubuntu:~/catkin_ws$ rospack find move_base_msgs
/opt/ros/groovy/stacks/navigation/move_base_msgs

I have looked for the config file cmake is asking for but I don't see it anywhere. even tried reinstalling the navigation package completely to see if there was a file that I deleted by accident:

ubuntu@ubuntu:~/catkin_ws$ sudo apt-get install ros-groovy-navigation
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ros-groovy-navigation is already the newest version.
ros-groovy-navigation set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 167 not upgraded.
ubuntu@ubuntu:~/catkin_ws$

Nothing though, I still get the CMake error after doing this.

If anyone has any insight as to what is wrong please let me know.

This is my simple_navigation_goalsConfig-version.cmake

# generated from catkin/cmake/template/pkgConfig-version.cmake.in
set(PACKAGE_VERSION "0.0.0")

set(PACKAGE_VERSION_EXACT False)
set(PACKAGE_VERSION_COMPATIBLE False)

if("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}")
  set(PACKAGE_VERSION_EXACT True)
  set(PACKAGE_VERSION_COMPATIBLE True)
endif()

if("${PACKAGE_FIND_VERSION}" VERSION_LESS "${PACKAGE_VERSION}")
  set(PACKAGE_VERSION_COMPATIBLE True)
endif()

This is my simple_navigation_goalsConfig.cmake

# generated from catkin/cmake/template/pkgConfig.cmake.in

# append elements to a list and remove existing duplicates from the list
# copied from catkin/cmake/list_append_deduplicate.cmake to keep pkgConfig
# self contained
macro(_list_append_deduplicate listname)
  if(NOT "${ARGN}" STREQUAL "")
    if(${listname})
      list(REMOVE_ITEM ${listname} ${ARGN})
    endif()
    list(APPEND ${listname} ${ARGN})
  endif()
endmacro()

# append elements to a list if they are not already in the list
# copied from catkin/cmake/list_append_unique.cmake to keep pkgConfig
# self contained
macro(_list_append_unique listname)
  foreach(_item ${ARGN})
    list(FIND ${listname} ${_item} _index)
    if(_index EQUAL -1)
      list(APPEND ${listname} ${_item})
    endif()
  endforeach()
endmacro()

# pack a list of libraries with optional build configuration keywords
# copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig
# self contained
macro(_pack_libraries_with_build_configuration VAR)
  set(${VAR} "")
  set(_argn ${ARGN})
  list(LENGTH _argn _count)
  set(_index 0)
  while(${_index} LESS ${_count})
    list(GET _argn ${_index} lib)
    if("${lib}" MATCHES "^debug|optimized|general$")
      math(EXPR _index "${_index} + 1")
      if(${_index} EQUAL ${_count})
        message(FATAL_ERROR "_pack_libraries_with_build_configuration() the list of libraries '${ARGN}' ends with '${lib}' which is a build configuration keyword and must be followed by a library")
      endif()
      list(GET _argn ${_index} library)
      list(APPEND ${VAR} "${lib}${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}${library}")
    else()
      list(APPEND ${VAR} "${lib}")
    endif()
    math(EXPR _index "${_index} + 1")
  endwhile()
endmacro()

# unpack a list of libraries with optional build configuration keyword prefixes
# copied from catkin/cmake/catkin_libraries.cmake to keep ...
(more)
2016-11-29 13:01:40 -0600 received badge  Enlightened (source)
2016-11-29 13:01:40 -0600 received badge  Good Answer (source)
2016-10-04 20:54:17 -0600 received badge  Taxonomist
2016-09-12 10:03:54 -0600 received badge  Famous Question (source)
2016-08-04 15:16:37 -0600 marked best answer no match for call to ‘(ros::Publisher) (geometry_msgs::TransformStamped&)’

Hello, I am getting this error:

In function ‘int main(int, char**)’: /home/turtlebot/catkin_ws/src/turtlebot_formation/src/readTFframe.cpp:70:24: error: no match for call to ‘(ros::Publisher) (geometry_msgs::TransformStamped&)’

I can clear see that the two types are compatible but for some reason cmake is telling me that no match all to (geometry_msgs::TransformStamped&) exists. If anyone can help me solve this issue it would be greatly appreciated.

#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <geometry_msgs/TransformStamped.h>
#include <tf/transform_listener.h>
#include <tf/transform_broadcaster.h>
#include <tf/transform_broadcaster.h>

using namespace std;

int main(int argc, char** argv) {
    ros::init(argc, argv, "readTFframe");
    ros::NodeHandle nh;
        tf::Transform leader_base_link;
    tf::Quaternion q;
    tf::Vector3 v;  
    tf::TransformListener listener;
    geometry_msgs::TransformStamped transformConverter;

    ros::Time current_time, last_time;
        current_time = ros::Time::now();
        last_time = ros::Time::now();

    ros::Publisher pub = nh.advertise<geometry_msgs::TransformStamped>("/leader/tf", 1000); //error because of this

    static tf::TransformBroadcaster br;

    double yaw; 


ros::Rate loopRate(10);
while(ros::ok()){
    tf::StampedTransform transform;
    current_time = ros::Time::now();


    try {
                        listener.waitForTransform("base_link", "base_footprint", ros::Time(0), ros::Duration(10.0));
            listener.lookupTransform("base_link", "base_footprint", ros::Time(0), transform);
        }
        catch (tf::TransformException &ex) {
            ROS_ERROR("%s",ex.what());
        }
    yaw =   tf::getYaw(transform.getRotation()); 
        v.setValue(transform.getOrigin().x() , transform.getOrigin().y() , transform.getOrigin().z());

    leader_base_link.setOrigin(v);
    q.setRPY(0.0, 0.0, yaw);
    leader_base_link.setRotation(q );
    br.sendTransform(tf::StampedTransform(leader_base_link,     ros::Time::now(), "base_footprint", "leader_base_link"));

    double th = yaw;
    geometry_msgs::Quaternion odom_quat = tf::createQuaternionMsgFromYaw(th);
    transformConverter.header.stamp = current_time; 
    transformConverter.header.frame_id = "base_footprint";
        transformConverter.child_frame_id = "base_link";
    transformConverter.transform.translation.x = transform.getOrigin().x();
    transformConverter.transform.translation.y = transform.getOrigin().y();
    transformConverter.transform.translation.z = transform.getOrigin().z();
    transformConverter.transform.rotation = odom_quat;
    ROS_INFO_STREAM("X pose " <<  transformConverter.transform.translation.x );
    ROS_INFO_STREAM("Y pose " << transformConverter.transform.translation.y);
    ROS_INFO_STREAM("Z pose " << transformConverter.transform.translation.z );
    ROS_INFO_STREAM("Yaw "<< yaw );
    pub(transformConverter);  //error here
    loopRate.sleep();
}

    return 0;
}
2016-07-04 05:46:22 -0600 received badge  Famous Question (source)
2016-03-21 20:20:03 -0600 received badge  Famous Question (source)
2015-11-13 08:21:52 -0600 received badge  Famous Question (source)
2015-11-13 08:21:52 -0600 received badge  Notable Question (source)
2015-06-18 05:19:07 -0600 received badge  Notable Question (source)
2015-05-06 08:04:06 -0600 received badge  Famous Question (source)
2015-04-22 17:06:14 -0600 received badge  Popular Question (source)
2015-04-22 17:06:14 -0600 received badge  Notable Question (source)
2015-04-15 12:20:49 -0600 commented answer Contacting Turtlebot Distributor (I Heart Engineering).

The only problem with that logic is that we had a total of 4 that were in storage for a while and there is only 2 that have this battery issue. I did some research on the model of asus laptop that was shipped to us and other people had lemons. Therefore it leads to a defective conclusion.

2015-04-15 12:18:21 -0600 received badge  Notable Question (source)
2015-04-14 16:16:06 -0600 received badge  Popular Question (source)
2015-04-14 14:09:57 -0600 asked a question Contacting Turtlebot Distributor (I Heart Engineering).

Hello,

I am having an issue with some of the equipment that my organization purchased through I Heart Engineering. Apparently I Heart Engineering has closed down and I am having a hard time getting in contact with them for warranty and support.

Is anyone else having this issue? What did you do to get in contact with them? Or does anyone have any suggestions for me?

The problem was not user error, the devices we ordered and received came with Asus x200 laptops. Those laptops have defective batteries, we didn't know they didn't work because we neglected to test them 6 months ago when we received them for the first time.We took the equipment out last week for a test drive to come and find out the batteries don't work. So now we have about two laptops without batteries that came through I Heart Engineering.

Thank you.

2015-03-27 15:59:39 -0600 received badge  Famous Question (source)
2015-03-24 15:31:43 -0600 received badge  Famous Question (source)
2015-03-18 13:34:17 -0600 received badge  Notable Question (source)
2015-03-18 13:30:17 -0600 received badge  Famous Question (source)
2015-03-16 11:02:20 -0600 received badge  Famous Question (source)
2015-03-12 04:55:49 -0600 received badge  Notable Question (source)
2015-02-02 08:02:18 -0600 received badge  Popular Question (source)
2015-01-30 11:55:42 -0600 commented answer StampedTransform getting Position instead of Relative Position

That worked. I figured that is what you meant and it tried. Thanks a lot.

2015-01-30 11:50:37 -0600 commented answer StampedTransform getting Position instead of Relative Position

listener.waitForTransform( "map","base_footprint", ros::Time(0), ros::Duration(10.0)); listener.lookupTransform( "map", "base_footprint",ros::Time(0), transformOdom);

as such?

2015-01-30 11:43:26 -0600 asked a question StampedTransform getting Position instead of Relative Position

HI, I am trying to log some data. The code works like intended except I am receiving the Relative Position instead of the Position.

tf::StampedTransform transformOdom;
current_time = ros::Time::now();

try {
        listener.waitForTransform( "odom","base_footprint", ros::Time(0), ros::Duration(10.0));
    listener.lookupTransform( "odom", "base_footprint",ros::Time(0), transformOdom);
    }
    catch (tf::TransformException &ex) {
        ROS_ERROR("%s",ex.what());
    }

//For debugging purposes
ROS_INFO_STREAM("X pose " <<  transformOdom.getOrigin().x() );
ROS_INFO_STREAM("Y pose " << transformOdom.getOrigin().y());

fileToWrite.open ("log.txt", ios_base::app);
fileToWrite << "X: " << transformOdom.getOrigin().x() << " Y: " << transformOdom.getOrigin().y()<< "\n";
fileToWrite.close();

Here is where you can see the two different positions from the visualization software

Does anyone know how to get the position of the robot instead of the relative position?

Thanks, choog

2014-12-30 06:59:20 -0600 received badge  Notable Question (source)
2014-12-30 06:59:20 -0600 received badge  Notable Question (source)
2014-12-29 13:58:58 -0600 received badge  Popular Question (source)
2014-11-07 09:53:28 -0600 received badge  Famous Question (source)
2014-11-07 02:36:43 -0600 received badge  Notable Question (source)
2014-10-02 15:46:44 -0600 received badge  Popular Question (source)
2014-10-02 13:39:47 -0600 commented answer transform broadcaster orientation problem

Thank you that actually fixed the problem. Now time for the Odom frame.

2014-10-02 13:39:13 -0600 marked best answer transform broadcaster orientation problem

Hello,

I am using a turtlebot 2 with ros-groovy. I have successfully wrote a publisher that takes the base_link and broadcasts that info. I am working on writing a broadcaster for the base_footprint. Also my base_link broadcaster works perfect. That is why I just followed the same format for that. But I don't understand why this logic is happening.

The base_foot print broadcaster seems to be messing up though. The broadcaster is able to keep the correct distance but when I start turning the robot things go bad. What goes wrong is that as the robot starts turning the base_footprint frame starts revolving around the fixed map frame (0,0,0). What I would expect is that whenever the turtlebot turns in the z direction that the base_footprint stays with the robot model on rviz like it is suppose to. If anyone could help it would be appreciated. Straight line When robot starts turning

I have 2 examples there of what Is going on so you can get an idea.

while(ros::ok()){
    tf::StampedTransform transform;  //for the base_link
    tf::StampedTransform transformFP; //for the base_footprint
    current_time = ros::Time::now();

//This is for the base_link frame which works great this block of code just gets the transform and that transform is 
//broadcasted as leader_base_link to the tf tree.

    try {
                        listener.waitForTransform("base_link", "base_footprint", ros::Time(0), ros::Duration(10.0));
            listener.lookupTransform("base_link", "base_footprint", ros::Time(0), transform);
        }
        catch (tf::TransformException &ex) {
            ROS_ERROR("%s",ex.what());
        }
    yaw =   tf::getYaw(transform.getRotation()); 
        v.setValue(transform.getOrigin().x() , transform.getOrigin().y() , transform.getOrigin().z());

    leader_base_link.setOrigin(v);
    q.setRPY(0.0, 0.0, yaw);
    leader_base_link.setRotation(q );
    br.sendTransform(tf::StampedTransform(leader_base_link,     ros::Time::now(), "base_footprint", "leader_base_link"));

    double th = yaw;
    geometry_msgs::Quaternion odom_quat = tf::createQuaternionMsgFromYaw(th);
    transformConverter.header.stamp = current_time; 
    transformConverter.header.frame_id = "base_footprint";
        transformConverter.child_frame_id = "base_link";
    transformConverter.transform.translation.x = transform.getOrigin().x();
    transformConverter.transform.translation.y = transform.getOrigin().y();
    transformConverter.transform.translation.z = transform.getOrigin().z();
    transformConverter.transform.rotation = odom_quat;





 /*This is where the base_footprint is being created I also believe this is where the code is messing up.
    As the robot turns in the yaw angle the position of the base_footprint starts translating into a + or - direction but the  distance is kept . As you can see in the picture that is what happens when the robot turns in a 180 degrees. The base_footprint gets shifted in 180 degrees  This is following the same exact code as the base_link that works fine as well*/    
            try {
                        listener.waitForTransform("base_footprint", "odom", ros::Time(0), ros::Duration(10.0));
                listener.lookupTransform("base_footprint", "odom", ros::Time(0), transformFP);
            }
        catch (tf::TransformException &ex) {
            ROS_ERROR("%s",ex.what());
        }

*/  double tryYaw = atan2( (2*transformFP.getRotation().w()*transformFP.getRotation().z() ),                           (transformFP.getRotation().w()*transformFP.getRotation().w() - transformFP.getRotation().z()*transformFP.getRotation().z()));       This is another equation I tried but it basically does the same exact stuff. */



//this is where the yaw angle gets calculated.
yaw2 =  tf::getYaw(transformFP.getRotation()); 
            v.setValue(transformFP.getOrigin().x() , transformFP.getOrigin().y() , transformFP.getOrigin().z());

    leader_footprint.setOrigin(v);
    q ...
(more)
2014-10-01 14:23:32 -0600 commented question transform broadcaster orientation problem

and so is the orientation. The top picture is what goes wrong when the robot turns.