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

Henschel.X's profile - activity

2020-07-14 05:42:58 -0500 received badge  Famous Question (source)
2019-02-25 21:05:00 -0500 received badge  Nice Question (source)
2018-07-06 11:25:22 -0500 received badge  Famous Question (source)
2018-05-10 10:33:47 -0500 received badge  Famous Question (source)
2017-04-18 03:23:49 -0500 received badge  Famous Question (source)
2017-03-27 12:50:46 -0500 marked best answer How to use OpenCV to process image

Hi! Everyone!

I'm a beginner of ROS, and now I've been focusing on imaging processing on ROS, My robot is Turtlebot, and I use the kinect as the camera, so basically what I need to do is to find the changes in the same background, so I followed the tutorials and started to use Gazebo now, and I tested the kinect all is fine. So my question is, I am pretty lost since there is no example or demo for image processing on wiki, I am wondering what is my first step? and what should I do after that.

If there is any good website for image processing on ROS to follow, that would be perfect! Thank you so much!

2017-02-01 01:18:21 -0500 received badge  Famous Question (source)
2017-01-23 11:16:43 -0500 received badge  Taxonomist
2016-12-02 05:43:34 -0500 received badge  Popular Question (source)
2016-10-24 20:51:24 -0500 received badge  Notable Question (source)
2016-09-19 04:30:25 -0500 received badge  Notable Question (source)
2016-06-06 15:48:37 -0500 received badge  Famous Question (source)
2016-05-10 01:28:06 -0500 received badge  Notable Question (source)
2016-05-09 18:47:31 -0500 received badge  Popular Question (source)
2016-04-13 00:46:37 -0500 received badge  Famous Question (source)
2016-04-12 05:00:26 -0500 received badge  Notable Question (source)
2016-04-11 20:20:27 -0500 commented answer Turtlebot arm Catkin error

Should I follow the Indigo version tutorials on wiki? or fuerte version?

2016-04-11 20:16:26 -0500 received badge  Popular Question (source)
2016-04-10 23:39:07 -0500 commented answer Turtlebot arm Catkin error

Yeah, but I don't know if I need to install sth about MoveIt bcz of the error comments. Have you work with sth similar before? Plz guide me. Thank you so much!!

2016-04-08 20:55:32 -0500 asked a question Turtlebot arm Catkin error

My ros version is Hydro, and I cannot find any tutorials for Hydro so I followed groove version on wiki, but when I get to the catkin make part, the terminal comes with these error, Can any one guide me how to fix it plz.

CMake Error at /opt/ros/hydro/share/catkin/cmake/catkin_package.cmake:159 (message):
  catkin_package() DEPENDS on 'moveit_core' which must be find_package()-ed
  before.  If it is a catkin package it can be declared as CATKIN_DEPENDS
  instead without find_package()-ing it.
Call Stack (most recent call first):
  /opt/ros/hydro/share/catkin/cmake/catkin_package.cmake:98 (_catkin_package)
  turtlebot_arm/turtlebot_arm_block_manipulation/CMakeLists.txt:23 (catkin_package)


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

I found out that when I run git clone https://github.com/corot/turtlebot_arm it was copied from github 'indigo' branch, I don't know. Plz some one help me.

2016-04-06 06:01:07 -0500 commented answer [TurtleBot] Getting Colored Images from navigation mode

I followed the answer to copy code from amcl_demo.launch and set false to true, but when I roslaunch my new launch file, it just gives me warnning, "waiting transform from......". Have you met this situation?

2016-04-06 05:53:17 -0500 commented question [TurtleBot] Getting Colored Images from navigation mode

I followed the answer to copy code from amcl_demo.launch and set false to true, but when I roslaunch my new launch file, it just gives me warnning, "waiting transform from......". Have you met this situation?

2016-03-24 20:45:16 -0500 commented question Problem of saving depth image

yes, but because those numbers from 1 to 7 are all int. so when I see it on Matlab it lacks detail.

2016-03-23 23:23:44 -0500 asked a question Problem of saving depth image

I try to use the code below to save one frame of depth iamge from topic /camera/depth/image_raw, but the problem is I could only get a image looks black. When I read it in Matlab, the matrix elements are basically from number 1 to 7, I guess that's why it looks black. But when I rosrun the image_view (camera/depth/image_raw), it looks just fine. I guess probably it's the problem of encoding, can someone guide me what to do to save image just like the image_view showed to me. plz, thank you!

from __future__ import print_function
import sys
import rospy
import cv2
import cv
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError

class TakePhoto:
    def __init__(self):

        self.bridge = CvBridge()
        self.image_received = False

        # Connect image topic
        img_topic = "/camera/depth/image_raw"
        self.image_sub = rospy.Subscriber(img_topic, Image, self.callback)

        # Allow up to one second to connection
        rospy.sleep(1)

    def callback(self, data):

        # Convert image to OpenCV format
        try:
            cv_image = self.bridge.imgmsg_to_cv2(data,'16UC1')
        except CvBridgeError as e:
            print(e)

        self.image_received = True
        self.image = cv_image

    def take_picture(self, img_title):
        if self.image_received:
            # Save an image
            cv2.imwrite(img_title, self.image)
            return True
        else:
            return False

if __name__ == '__main__':

    # Initialize
    rospy.init_node('take_photo', anonymous=False)
    camera = TakePhoto()

    # Take a photo

    # Use '_image_title' parameter from command line
    # Default value is 'photo.jpg'
    img_title = rospy.get_param('~image_title', 'photo16U.jpg')

    if camera.take_picture(img_title):
        rospy.loginfo("Saved image " + img_title)
    else:
        rospy.loginfo("No images received")

    # Sleep to give the last log messages time to be sent
    rospy.sleep(1)
2016-03-23 02:27:11 -0500 commented question Get data values from depth image

My project is kind of similar with yours, but the time I see it, it is 2016 lol. I met the same problem just as you do.

2016-03-22 07:18:56 -0500 asked a question Fail to subscribe amcl_pose

The code is like this

#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/core/core.hpp> 
#include <opencv2/highgui/highgui.hpp> 
#include <ros/ros.h>
#include <tf/transform_listener.h>
#include <geometry_msgs/Twist.h>
#include <geometry_msgs/Pose.h>
#include <geometry_msgs/PoseWithCovarianceStamped.h>
//#include <move_base_msgs/MoveBaseActionGoal.h>
using namespace cv;
using namespace std;

void PoseCallback(const geometry_msgs::PoseWithCovarianceStamped& msg)
{
     ROS_INFO("hi");
     tf::Vector3 position;
     tf::Quaternion q;
     position = tf::Vector3(msg.pose.pose.position.x,msg.pose.pose.position.y,msg.pose.pose.position.z);
     ROS_INFO("hi");
     q=tf::Quaternion(msg.pose.pose.orientation.x,msg.pose.pose.orientation.y,
                      msg.pose.pose.orientation.z,msg.pose.pose.orientation.w);
}

int main(int argc, char** argv)
{
        ros::init(argc, argv, "frame");
        ros::NodeHandle n;
        ros::Subscriber sub = n.subscribe("/acml_pose", 1, PoseCallback);
        ros::spin();
        //the rest is computation
    float x1 = -1;
    float y1 = -1;
    float x2 = -1;
    float y2 = 0;
    float x_1 = 0;
    float y_1 = 0;
    float x_2 = sin(CV_PI / 6);
    float y_2 = cos(CV_PI / 6);
    Mat t2 = Mat::zeros(2, 1, CV_32F);
    t2.at<float>(0, 0) = x_1 - x_2;
    t2.at<float>(1, 0) = y_1 - y_2;
    Mat t1 = Mat::zeros(2, 2, CV_32F);
    t1.at<float>(0, 0) = x1 - x2;
    t1.at<float>(0, 1) = y2 - y1;
    t1.at<float>(1, 0) = y1 - y2;
    t1.at<float>(1, 1) = x1 - x2;
    Mat theta = Mat::zeros(2, 1, CV_32F);
    theta = t1.inv()*t2;
    Mat theta_v = Mat::zeros(2, 1, CV_32F);
    theta_v.at<float>(0, 0) = theta.at<float>(1, 0);
    theta_v.at<float>(1, 0) = theta.at<float>(0, 0);
    Mat f1 = Mat::zeros(2, 1, CV_32F);
    f1.at<float>(0, 0) = x_1;
    f1.at<float>(1, 0) = y_1;
    Mat f2 = Mat::zeros(2, 2, CV_32F);
    f2.at<float>(0, 0) = y1;
    f2.at<float>(0, 1) = -x1;
    f2.at<float>(1, 0) = -x1;
    f2.at<float>(1, 1) = -y1;
    Mat trans = Mat::zeros(2, 1, CV_32F);
    trans = f1 + f2*theta_v;
    Mat transformation = Mat::zeros(4, 4, CV_32F);
    transformation.at<float>(0, 0) = theta.at<float>(0, 0);
    transformation.at<float>(0, 1) = -theta.at<float>(1, 0);
    transformation.at<float>(0, 2) = 0;
    transformation.at<float>(0, 3) = trans.at<float>(0, 0);
    transformation.at<float>(1, 0) = theta.at<float>(1, 0);
    transformation.at<float>(1, 1) = theta.at<float>(0, 0);
    transformation.at<float>(1, 2) = 0;
    transformation.at<float>(1, 3) = trans.at<float>(1, 0);
    transformation.at<float>(2, 0) = 0;
    transformation.at<float>(2, 1) = 0;
    transformation.at<float>(2, 2) = 1;
    transformation.at<float>(2, 3) = 0;
    transformation.at<float>(3, 0) = 0;
    transformation.at<float>(3, 1) = 0;
    transformation.at<float>(3, 2) = 0;
    transformation.at<float>(3, 3) = 1;
    return 0;
}

I run this node, and nothing gives back, no ROS_INFO "hi". And according to the rostopic echo /amcl_pose, it says no subscriber. Can someone plz tell me where goes wrong plz. I just need to get the position and Quaternion of my turtlebot. Thanks

2016-03-22 02:43:40 -0500 received badge  Notable Question (source)
2016-03-21 20:48:08 -0500 commented answer StampedTransform getting Position instead of Relative Position

Hi! I met the same problem just like you, I changed "odom" with "map", instead, I got this error "map" passed to lookupTransform argument target_frame does not exist. Can you tell me what should I do ? I don't even know what odom means. CuzI just started to learn ROS ;(,Thx anyway

2016-03-21 11:14:28 -0500 received badge  Popular Question (source)
2016-03-21 05:17:29 -0500 asked a question How to get the position and ERY of turtlebot?

I'm following this tutorials: [ http://learn.turtlebot.com/2015/02/03... ] ,and I can get the position and ERY of my turtlebot based on the map frame, but I want to get those number from one moment t=t0 (position[xo,y0,z0],ERY[a0,b0,c0]) in my node written by C++. I know what I should do is subscribe tf. And according to wiki tutorials, tranformListener can automatically subscribe all the information from tf, like this tf::TransformListener listener; but aftrer that I just don't know what to do. All I need is the position and ERY of the current location of my turtlebot. Thank you guys!

2016-03-21 03:28:03 -0500 commented question How to transform between the quaternions ( or ERYs)

Thank you so much !

2016-03-17 21:08:26 -0500 asked a question How to transform between the quaternions ( or ERYs)

I know I can transform my quaternion to ERY, and it seems easier to transform between ERYs because it's more direct. For example, I have a vector X (x,y,z) and its ERY is (0,0,a), and I have another vector Y(x',y',z') and ERY is (0,0,b), if I want to get Y by doing RX+T, can I get the rotation matrix R and transformation matrix T by using TF's function? Or if its not possible, how can I compute this? Thx a lot!

2016-03-17 20:13:09 -0500 received badge  Commentator
2016-03-17 20:13:09 -0500 commented answer rotate a quaternion

For example, I have a vector X (x,y,z) and its ERY is (0,0,a), and I have another vector Y(x',y',z') and ERY is (0,0,b), if I want to get Y by doing RX+T, can I get the rotation matrix R and transformation matrix T by using TF's function? Or if its not possible, how can I compute this? Thx a lot!

2016-03-16 21:36:06 -0500 commented answer Problem of using Turtlebot to process image.

oh OK, I didn't know that.... Thanks a lot!

2016-03-16 09:52:16 -0500 received badge  Notable Question (source)
2016-03-16 04:54:12 -0500 received badge  Popular Question (source)
2016-03-15 21:06:08 -0500 asked a question Can I use matlab function in ROS node written by C++?

I encountered some problem with image registration on ROS, I have already realized the function on matlab, and I know it's possible to include mex.h in C++ to use matlab functions, so can I do the same when I write the node using C++ on ROS? Like the same for Opencv? Thank you guys a lot!

2016-03-15 20:28:11 -0500 commented answer Problem of using Turtlebot to process image.

I have to use the old function cvCvtColor to convert RGB image to gray scale image, but Mat won't work for this, but I figure it out the problem, I have to replace my file name with the path, otherwise it cannot find the image.

2016-03-15 05:42:44 -0500 received badge  Popular Question (source)
2016-03-15 05:35:42 -0500 commented question Problem of using Turtlebot to process image.

I don't know. I just guess it may need that. I plan to do as you said too, get image from ROS, convert it to Opencv Image, do the processing and change it back, I just don't know what else should I do.

2016-03-15 05:33:17 -0500 answered a question Problem of using Turtlebot to process image.

I used several ROS_INFO, and it came with this error, I don't know what it means.

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /tmp/buildd/ros-hydro-opencv2-2.4.9-2precise-20141231-1923/modules/imgproc/src/color.cpp, line 3737 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/buildd/ros-hydro-opencv2-2.4.9-2precise-20141231-1923/modules/imgproc/src/color.cpp:3737: error: (-215) scn == 3 || scn == 4 in function cvtColor

2016-03-15 03:17:03 -0500 received badge  Student (source)
2016-03-15 02:46:12 -0500 asked a question Problem of using Turtlebot to process image.

Hi, everyone ! I'm doing image processing using turtlebot right now, and I have completed programming on VS Windows, it is going perfect, but when I transformed it to ROS, it just went wrong. I am new in this area so I don't know what to do it right, I followed the tutorials and some simple example, and I successfully generated the exe file, but when I rosrun my node, the terminal says 'segmentation fault '.

Here is my program, it's pretty simple even though it looks long:

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

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
        ros::init(argc, argv, "environment_changes");
        ros::NodeHandle ench;
    //ParametersSetting
    unsigned char t = 50;                                           //difference threashold
    int w = 50;                                             //window for checking
    int output = 0;                                         //output for whether there are changes
    double  threashold = (2 * w - 1)*(2 * w - 1)*0.92;      //threashold for whether there are changes
    double  r = 0.05;                                       //rate of elimated size
    double  X = 0;                                          //x of the centre
    double  Y = 0;                                          //y of the centre
    int p = 0;                                              //number of the changed space
    int i;                                                  //rows
    int j;                                                  //cols

    //LoadImage
    IplImage * image_ref;
    IplImage * image_trans;
    image_ref = cvLoadImage("test1.jpg");
    image_trans = cvLoadImage("test2.jpg");

    //ChangeToGray
    IplImage * image_ref_gray;
    IplImage * image_trans_gray;
    image_ref_gray = cvCreateImage(cvGetSize(image_ref), image_ref ->depth ,1);
    image_trans_gray = cvCreateImage(cvGetSize(image_trans), image_trans -> depth ,1);
    cvCvtColor(image_ref, image_ref_gray, CV_RGB2GRAY);
    cvCvtColor(image_trans, image_trans_gray, CV_RGB2GRAY);

    //ShowImage
    cvNamedWindow("test1", 1);
    cvNamedWindow("test2", 1);
    cvShowImage("test1", image_ref_gray);
    cvShowImage("test2", image_trans_gray);
    waitKey(0);

    //ComputeTheImage
    IplImage * image_sub;
    image_sub = cvCreateImage(cvGetSize(image_ref_gray), image_ref_gray->depth, 1);
    Mat ref;
    Mat trans;
    Mat sub;
    ref = Mat(image_ref_gray);
    trans = Mat(image_trans_gray);
    sub = Mat(image_sub);
    absdiff(trans, ref, sub);
        i = sub.rows;
    j = sub.cols;
    int m;
    int n;
    for (m = round(i*r); m <= round(i*(1 - r)); m++){
        for (n = round(j*r); n <= round(j*(1 - r)); n++){
            if (sub.at<uchar>(m, n) >= t){
                sub.at<uchar>(m, n) = 255;
                X = X + m;
                Y = Y + n;
                p = p + 1;
            }
        }
    }
    X = X / p;
    Y = Y / p;
    cout << X << " " << Y << endl;
    * image_sub = IplImage(sub);
    cvNamedWindow("test3", 1);
    cvShowImage("test3", image_sub);
    waitKey(0);

    //ReleaseTheSpace
    cvDestroyWindow("test3");
    cvDestroyWindow("test2");
    cvDestroyWindow("test1");
    cvReleaseImage(&image_sub);
    cvReleaseImage(&image_trans_gray);
    cvReleaseImage(&image_ref_gray);
    cvReleaseImage(&image_trans);
    cvReleaseImage(&image_ref);

    return 0;
}

right now I simply just do the image load and processing and then show it without dealing with Turtlebot. Can somebody tell me what to do plz!! Thank you guys sooooo much!

2016-03-14 06:53:00 -0500 received badge  Supporter (source)