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

Barbosa's profile - activity

2016-10-10 15:23:32 -0500 received badge  Good Question (source)
2015-07-14 19:12:37 -0500 received badge  Nice Question (source)
2014-10-02 02:56:58 -0500 received badge  Notable Question (source)
2013-05-24 05:54:35 -0500 received badge  Popular Question (source)
2013-01-17 08:08:52 -0500 received badge  Taxonomist
2013-01-11 07:18:10 -0500 received badge  Famous Question (source)
2012-12-15 01:54:52 -0500 commented answer tf::TransformBroadcaster in callback

This worked fine. thank you!

2012-12-14 05:53:28 -0500 received badge  Famous Question (source)
2012-12-02 12:35:34 -0500 asked a question ApproximateTime corrupt data

Hello guys,

I am subscribing to a topic with a normal subscriber (used only for testing) and also subsribing with another approximateTime synchronizer subscriber (from message_filters) and the thing is, although the topics are being received, one of them has corrupted data.... it is a geometry_msgs::PoseStamped. While rostopic echo (and also the normal subscriber) print the normal values such as position.x= 0.5, the synchronized subscriber receives (or prints, i'm using %f) 56243784258694623847252734942351.000.

Has anyone had the same problem or has any ideas of why is this happening?

2012-11-24 05:18:18 -0500 received badge  Notable Question (source)
2012-10-29 04:10:57 -0500 commented answer tf::TransformBroadcaster in callback

I will try this simpler way of doing it! Thanks!

2012-10-29 04:10:23 -0500 commented answer tf::TransformBroadcaster in callback

I think this will help, thanks a lot. I did try this approach too but I was having some trouble with errors, maybe now this will help clear them out.

2012-10-25 02:27:31 -0500 received badge  Notable Question (source)
2012-10-23 20:53:09 -0500 received badge  Popular Question (source)
2012-10-23 15:34:33 -0500 received badge  Popular Question (source)
2012-10-22 19:26:44 -0500 received badge  Student (source)
2012-10-22 13:15:45 -0500 asked a question tf::TransformBroadcaster in callback

Hi,

So I was trying to have a transform published over tf as a result of a callback call, which made me think I had to have a tf::TransformBroadcaster as a global variable. However these can't be declared before the ros::NodeHandle is created.

I have tried using a boost::shared_ptr and almost got the hang of it but I still didn't quite understand how to use these boost pointers. Here's what I tried to do:

boost::shared_ptr<tf::TransformBroadcaster> pose_broadcaster;
void poseCallback(const nav_msgs::Odometry& pose){

    geometry_msgs::TransformStamped pose_trans;
    pose_trans.header.stamp = pose.header.stamp;
    pose_trans.header.frame_id = "odometry_frame"; 
    pose_trans.child_frame_id = "base_link";

    pose_trans.transform.translation.x = pose.pose.pose.position.x;
    pose_trans.transform.translation.y = pose.pose.pose.position.y;
    pose_trans.transform.translation.z = pose.pose.pose.position.z;
    pose_trans.transform.rotation = pose.pose.pose.orientation;
    ROS_INFO("Sending TF broadcast");
    pose_broadcaster.sendTransform(pose_trans);


}
int main(){
    ros::init(argc, argv, "pioneer_tf");
    ros::NodeHandle n;
    ros::Subscriber pose_sub=n.subscribe("pose", 1000, poseCallback);
    boost::shared_ptr<tf::TransformBroadcaster> ptr;
    pose_broadcaster= boost::shared_ptr<tf::TransformBroadcaster>(ptr);//problem here
   ros::spin();
}

I obviously got it wrong in the initialization of the pointer, what's the right way of doing it in this case?

--- EDIT ---

This problem is solved now, but I have a similar issue at the moment with a transformListener

It is basically the same set up, with a global variable (pointer declared as global and initialized in main) and the listener being called in a callback. The thing is, even though it compiles, the callback is never called, but if I comment the line where it is called inside the callback, it works and does everything normally... Any ideas of why the callback might not be called?

--- EDIT2 ---

This problem is totally solved. It was just a matter of making the TF buffer bigger and using a try/catch.

2012-10-17 00:08:50 -0500 received badge  Famous Question (source)
2012-10-08 12:30:53 -0500 received badge  Notable Question (source)
2012-10-07 21:45:09 -0500 received badge  Popular Question (source)
2012-10-07 13:14:31 -0500 asked a question Using depth_image_proc with different data.

Hi,

I am attempting to use my own rgb and depth images in depth_image_proc instead of those provided by openni.launch. What I want to do is to perform some color segmentation before building a point cloud. By following some examples here's what I've come up with:

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>


namespace enc = sensor_msgs::image_encodings;

using namespace cv;
using namespace std;

static const char WINDOW[] = "Image window";

class ImageConverter
{
  ros::NodeHandle nh_;
  image_transport::ImageTransport it_;
  image_transport::Subscriber image_sub_, depth_sub_;
  image_transport::Publisher image_pub_, depth_pub_;
  Mat dst;//=Mat::zeros(cv_ptr->image.size(), cv_ptr->image.type());

public:
  ImageConverter()
    : it_(nh_)
  {
    image_pub_ = it_.advertise("out", 1);
    depth_pub_=it_.advertise("depth_filtered",1);
    image_sub_ = it_.subscribe("/camera/rgb/image_color", 1, &ImageConverter::imageCb, this);
    depth_sub_ = it_.subscribe("/camera/depth/image_raw", 1, &ImageConverter::depthCb, this),
    cv::namedWindow(WINDOW);
    dst=Mat::zeros(480, 640, 16);
  }

  ~ImageConverter()
  {
    cv::destroyWindow(WINDOW);
  }
  string getImgType(int imgTypeInt)
{
    int numImgTypes = 35; // 7 base types, with five channel options each (none or C1, ..., C4)

    int enum_ints[] =       {CV_8U,  CV_8UC1,  CV_8UC2,  CV_8UC3,  CV_8UC4,
                             CV_8S,  CV_8SC1,  CV_8SC2,  CV_8SC3,  CV_8SC4,
                             CV_16U, CV_8UC1,  CV_8UC2,  CV_8UC3,  CV_8UC4,
                             CV_16S, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4,
                             CV_32S, CV_32SC1, CV_32SC2, CV_32SC3, CV_32SC4,
                             CV_32F, CV_32FC1, CV_32FC2, CV_32FC3, CV_32FC4,
                             CV_64F, CV_64FC1, CV_64FC2, CV_64FC3, CV_64FC4};

    string enum_strings[] = {"CV_8U",  "CV_8UC1",  "CV_8UC2",  "CV_8UC3",  "CV_8UC4",
                             "CV_8S",  "CV_8SC1",  "CV_8SC2",  "CV_8SC3",  "CV_8SC4",
                             "CV_16U", "CV_8UC1",  "CV_8UC2",  "CV_8UC3",  "CV_8UC4",
                             "CV_16S", "CV_16SC1", "CV_16SC2", "CV_16SC3", "CV_16SC4",
                             "CV_32S", "CV_32SC1", "CV_32SC2", "CV_32SC3", "CV_32SC4",
                             "CV_32F"  "CV_32FC1", "CV_32FC2", "CV_32FC3", "CV_32FC4",
                             "CV_64F", "CV_64FC1", "CV_64FC2", "CV_64FC3", "CV_64FC4"};

    for(int i=0; i<numImgTypes; i++)
    {
        if(imgTypeInt == enum_ints[i]) return enum_strings[i];
    }
    return "unknown image type";
}

  void imageCb(const sensor_msgs::ImageConstPtr& msg)
  {
    cv_bridge::CvImagePtr cv_ptr;
    try
    {
      cv_ptr = cv_bridge::toCvCopy(msg, enc::BGR8);
    }
    catch (cv_bridge::Exception& e)
    {
      ROS_ERROR("cv_bridge exception: %s", e.what());
      return;
    }

   Mat hsv;
   Mat src=cv_ptr->image;
    cv::cvtColor(cv_ptr->image, hsv, CV_BGR2HSV);

    Mat bw;
    ROS_INFO("Creating mask with color segmentation");
        cv::inRange(hsv, Scalar(60,100, 50), Scalar(86,170, 255), bw);


    vector<vector<Point> > contours;
    Mat smthg=bw.clone();
    ROS_INFO("Finding countours to be filled");
    cv::findContours(smthg, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);

     dst = Mat::zeros(cv_ptr->image.size(), cv_ptr->image.type());

    cv::drawContours(dst, contours, -1, Scalar::all(255), CV_FILLED);

    Mat result=dst & src;

    cv::imshow("mask", bw);


    cv::imshow("rgb_filtered", result);



    cv::imshow(WINDOW, cv_ptr->image);
    cv::waitKey(1);

    image_pub_.publish(cv_ptr->toImageMsg());
  }

void depthCb(const sensor_msgs::ImageConstPtr& msg)
  {
    cv_bridge::CvImageConstPtr cv_ptr;
    try
    {
      cv_ptr = cv_bridge::toCvShare(msg, enc::TYPE_16UC1);
    }
    catch (cv_bridge::Exception& e)
    {
      ROS_ERROR("cv_bridge exception: %s", e.what());
      return;
    }

     ROS_INFO("Applying mask to depth image");
   Mat m=Mat(cv_ptr->image.size(), cv_ptr->image.type());


   cvtColor(dst,m,CV_RGB2GRAY);


   Mat result=Mat(cv_ptr->image.size(), cv_ptr->image.type());
   cv_ptr->image.copyTo(result, m); //TESTE

    cv::imshow("depth_filtered", result);

    cv::imshow("depth_image", cv_ptr->image);
    cv::waitKey(1);

    depth_pub_.publish(cv_ptr->toImageMsg());
  }

};

int main(int argc, char** argv)
{
  ros::init(argc, argv, "image_converter");
  ImageConverter ic;
  ros::spin();
  return 0;
}

I know this setup is not the best but I ... (more)

2012-10-03 07:16:12 -0500 asked a question depth image to CV_16UC1

Hi, I am currently trying to capture images and localizing a colored landmark in the kinect frame. I first tried detecting the color in a downsampled pointcloud but that was just too slow, and so now I am doing color segmentation with OpenCV hoping that i can also mask a depth image with which I can build a smaller point cloud.

Here is my current problem.

    void depthCb(const sensor_msgs::ImageConstPtr& msg)
  {
    cv_bridge::CvImageConstPtr cv_ptr;
    try
    {
      cv_ptr = cv_bridge::toCvShare(msg, enc::TYPE_16UC1);
    }
    catch (cv_bridge::Exception& e)
    {
      ROS_ERROR("cv_bridge exception: %s", e.what());
      return;
    }

     //dst is the mask resultant from color segmentation, class member
   Mat result= dst & src;
    cv::imshow("depth_filtered", result);

    cv::imshow("depth_image", cv_ptr->image);
    cv::waitKey(3);

    image_pub_.publish(cv_ptr->toImageMsg());
  }

This is a callback for the depth raw data. When I run this I get an exception

[ERROR] [1349283297.431785349]: cv_bridge exception: Unsupported conversion from [16UC1] to [mono16]

I chose to convert to mono16 because I tought it was basically the same thing since the kinect image is 16UC1. I was trying to avoid writting the code to convert this, so it would be nice if there was any existing solution.

I am sort of new to openCV as well as ROS itself so if you have any ideas of how to overcome this particular obstacle or if you know of a better method to achieve my goal, please share. Thanks in advance.

EDIT

This worked, but it kind of slowed down the code

void depthCb(const sensor_msgs::ImageConstPtr& msg)
  {
    cv_bridge::CvImageConstPtr cv_ptr;
    try
    {
      cv_ptr = cv_bridge::toCvShare(msg, enc::TYPE_16UC1);
    }
    catch (cv_bridge::Exception& e)
    {
      ROS_ERROR("cv_bridge exception: %s", e.what());
      return;
    }

     ROS_INFO("Applying mask to depth image");
   Mat m=Mat(cv_ptr->image.size(), cv_ptr->image.type());

   cvtColor(dst,m,CV_RGB2GRAY); 
   Mat result=Mat(cv_ptr->image.size(), cv_ptr->image.type());
   cv_ptr->image.copyTo(result, m); 

    cv::imshow("depth_filtered", result);
    cv::imshow("depth_image", cv_ptr->image);
    cv::waitKey(1);

  }
2012-09-16 05:09:29 -0500 received badge  Popular Question (source)
2012-09-16 05:09:29 -0500 received badge  Famous Question (source)
2012-09-16 05:09:29 -0500 received badge  Notable Question (source)
2012-05-14 05:18:09 -0500 received badge  Supporter (source)
2012-05-14 05:18:09 -0500 marked best answer File reading and roslaunch

Hello,

I built a node which simply reads a file and builds a vector of data from it. However, when i tried running the node from roslaunch instead of rosrun, according to the log file, it ca n longer open the said data.txt file, causing my node to shutdown. I tried moving the file around but the problem persists. Here is the code

ifstream vel("ros_workspace/odometry/traj.txt");
  if(!vel.is_open()
{
    ROS_INFO("file not found!");
    ros::shutdown();
  }

I am new to ROS and not very familiar with the PATHS, don't even know if the problem comes from there, so this might be a very simple question.

Thanks! Barbosa

2012-05-14 05:17:59 -0500 received badge  Scholar (source)