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

chiongsterx's profile - activity

2017-07-19 12:37:39 -0500 received badge  Notable Question (source)
2017-07-19 12:37:39 -0500 received badge  Famous Question (source)
2016-05-11 07:59:47 -0500 received badge  Famous Question (source)
2015-06-15 03:23:45 -0500 received badge  Famous Question (source)
2015-04-17 07:51:05 -0500 received badge  Popular Question (source)
2015-03-13 17:07:54 -0500 received badge  Famous Question (source)
2015-01-20 09:45:28 -0500 received badge  Notable Question (source)
2015-01-20 09:45:28 -0500 received badge  Popular Question (source)
2015-01-19 02:30:28 -0500 asked a question How to output the following result to terminal?

Hi i am using this code (position calculation) from: http://robotica.unileon.es/mediawiki/... and i was wondering, how could i show the output the result in the terminal.

#include <ros/ros.h>
#include <std_msgs/Float32MultiArray.h>
#include <opencv2/opencv.hpp>
#include <QTransform>
#include <geometry_msgs/Point.h>
#include <std_msgs/Int16.h>
#include <find_object_2d/PointObjects.h>
#include <find_object_2d/Point_id.h>

#define dZ0 450
#define alfa 40
#define h 310
#define d 50
#define PI 3.14159265


 void objectsDetectedCallback(const std_msgs::Float32MultiArray& msg)
{
int x,y,z;
ros::NodeHandle nh;
ros::Publisher position_pub_=nh.advertise<find_object_2d::PointObjects>("point", 1);

find_object_2d::PointObjects p_objects;
find_object_2d::Point_id objeto;

p_objects.objeto = std::vector<find_object_2d::Point_id>(msg.data.size()/12);

for(unsigned int i=0; i<msg.data.size(); i+=12)
{
    // get data
    int id = (int)msg.data[i];
    float objectWidth = msg.data[i+1];
    float objectHeight = msg.data[i+2];

    // Find corners Qt
    QTransform qtHomography(msg.data[i+3], msg.data[i+4], msg.data[i+5],
                            msg.data[i+6], msg.data[i+7], msg.data[i+8],
                            msg.data[i+9], msg.data[i+10], msg.data[i+11]);

    QPointF qtTopLeft = qtHomography.map(QPointF(0,0));
    QPointF qtTopRight = qtHomography.map(QPointF(objectWidth,0));
    QPointF qtBottomLeft = qtHomography.map(QPointF(0,objectHeight));
    QPointF qtBottomRight = qtHomography.map(QPointF(objectWidth,objectHeight));

    geometry_msgs::Point punto;

    float widthTop = sqrt(pow(qtTopRight.x() - qtTopLeft.x(),2) + pow(qtTopRight.y() - qtTopLeft.y(),2));
    float widthBottom = sqrt(pow(qtBottomRight.x() - qtBottomLeft.x(),2) + pow(qtBottomRight.y() - qtBottomLeft.y(),2));
    float heightLeft = sqrt(pow(qtBottomLeft.x() - qtTopLeft.x(),2) + pow(qtBottomLeft.y() - qtTopLeft.y(),2));
    float heightRight = sqrt(pow(qtBottomRight.x() - qtTopRight.x(),2) + pow(qtBottomRight.y() - qtTopRight.y(),2));

    float dArea_0 = (objectHeight*objectWidth) - (((widthTop + widthBottom)/2) * ((heightLeft + heightRight)/2));

    float dZ_0 = dZ0 + (dArea_0/10);

    float dY_0 = (((480/2) - (((qtTopLeft.y() + qtTopRight.y())/2) + ((heightLeft + heightRight)/4)))*dZ_0)/585;                

    float beta_0 = atan2(dY_0,dZ_0);        

    objectHeight = objectHeight/cos((alfa*PI)/180);

    float height = ((heightLeft + heightRight)/2)/cos(((alfa*PI)/180)-beta_0);                    

    float dArea = (objectHeight*objectWidth) - (((widthTop + widthBottom)/2) * height);

    float dZ = dZ0 + (dArea/38);

    float dX = (((640/2) - (((qtTopLeft.x() + qtBottomLeft.x())/2) + ((widthTop + widthBottom)/4)))*dZ)/585;

    float dY = (((480/2) - (((qtTopLeft.y() + qtTopRight.y())/2) + ((heightLeft + heightRight)/4)))*dZ)/585;

    float beta = atan2(dY,dZ);

    punto.x = dX;
    punto.y = h-((dZ/cos(beta))*sin(((alfa*PI)/180)-beta));
    punto.z = ((dZ/cos(beta))*cos(((alfa*PI)/180)-beta))-d;
    ROS_INFO("x: %f y: %f z: %f", punto.x,punto.y,punto.z);

    //Validate detection
    int paralelepipedo;

    if (abs(widthTop - widthBottom) < 20 && abs(heightLeft - heightRight) < 15)
    {
                    paralelepipedo = 1;
            }
            else
            {
                    paralelepipedo = 0;
            }

    if (paralelepipedo == 1)
    {       
                    objeto.punto = punto;
                    objeto.id = id;

                    p_objects.objeto[i/12] = objeto;
    }

}

position_pub_.publish(p_objects);

}


int main(int argc, char** argv)
{
  ros::init(argc, argv, "objects_detected");

ros::NodeHandle nh;
ros::Subscriber subs = nh.subscribe("objects", 1, objectsDetectedCallback);

ros::Publisher position_pub_=nh.advertise<find_object_2d::PointObjects>("point", 1);  

ros::spin();


return 0;
}

As shown in the code, i added ROS_INFO("x: %f y: %f z: %f", punto.x,punto.y,punto.z ... (more)

2015-01-18 01:54:33 -0500 received badge  Notable Question (source)
2014-10-09 21:40:34 -0500 received badge  Famous Question (source)
2014-10-08 01:59:00 -0500 received badge  Notable Question (source)
2014-10-07 21:25:13 -0500 received badge  Popular Question (source)
2014-10-07 09:46:51 -0500 asked a question How do i know tabletop object detector uses what method to link the object recognition and the position together

Hi could someone please tell me how http://wiki.ros.org/tabletop_object_d... link the object recognition and the position together. i don't quite understand the wiki.

2014-10-07 09:30:55 -0500 asked a question How do i use Openni to detect position of object?

Is there any tutorial or sample source code to show me how do i use pcl to get depth point of object and detect the object base on colour??

2014-10-06 02:57:44 -0500 received badge  Popular Question (source)
2014-10-05 09:08:42 -0500 asked a question Opencv for position detection

To do position detection, do i need to use Openni's depth map to do the calculations? (using asus xtrion pro live) i detect object base on colour, now i need to detect the object's position relative to the robot.

2014-09-26 00:58:26 -0500 received badge  Famous Question (source)
2014-09-25 03:37:19 -0500 commented answer Hi i want to use external camera to capture image rather than in build camera

yes i did ran catkin_make after editing and saving the file. However it still opens the default webcam

2014-09-25 03:07:16 -0500 commented answer Hi i want to use external camera to capture image rather than in build camera

Hi i tried changing the cap(0) to cap(1) but it still accesses the default device. Any idea on what should i do?

2014-09-19 05:28:45 -0500 received badge  Famous Question (source)
2014-09-18 01:18:01 -0500 commented answer How do i use ros TF to capture object position based on colour and calculate relative distance?

Oh yes, i'm using this website's colour detection and tracking to detect the object. http://opencv-srf.blogspot.ro/2010/09... Right now i need to figure out how to do position detection. It would be great if you could teach me on that. Thanks for the help!

2014-09-18 01:16:00 -0500 commented answer How do i use ros TF to capture object position based on colour and calculate relative distance?

Hi yes thanks for all that information. Regarding what i'm trying to achieve, it is to actually allow the camera to detect on object based on the colour. After that, the camera will calculate the distance of object from camera.

2014-09-18 01:10:07 -0500 received badge  Notable Question (source)
2014-09-18 01:10:07 -0500 received badge  Popular Question (source)
2014-09-17 07:17:49 -0500 commented answer How do i use ros TF to capture object position based on colour and calculate relative distance?

Oh... i didn't know that... so i have get opencv to calculate distance and position?? May i know whether there is any tutorial on that? Sorry not that good at opencv.

2014-09-17 04:28:42 -0500 asked a question How do i use ros TF to capture object position based on colour and calculate relative distance?

Hi im currently doing position detection. By using Opencv color(red) detection i detect the red object and now i want to publish it in the tf and show where and the distance between the object and camera.

2014-09-16 10:18:04 -0500 received badge  Notable Question (source)
2014-09-16 04:59:17 -0500 received badge  Popular Question (source)
2014-09-15 01:26:45 -0500 asked a question Hi i want to use external camera to capture image rather than in build camera

This is the current part that i'm using. How do i edit it so i can capture video from external camera?? I'm using Asus xtion pro live.

#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using namespace cv;
using namespace std;

 int main( int argc, char** argv )
 {
    VideoCapture cap(0); //capture the video from web cam

     if ( !cap.isOpened() )  // if not success, exit program
 {
     cout << "Cannot open the web cam" << endl;
 return -1;
}
   }
2014-09-10 01:05:15 -0500 received badge  Famous Question (source)
2014-08-28 02:02:55 -0500 received badge  Popular Question (source)
2014-08-28 02:02:55 -0500 received badge  Notable Question (source)
2014-08-25 03:41:59 -0500 asked a question rviz to detect and calculate object relative position from robot

Hi im currently using camera - asus xtrion pro live to detect the object through opencv - colour detection. im not sure how to use rviz to detect and calculate object position relative to the robot. Help please..

2014-08-21 10:02:36 -0500 received badge  Notable Question (source)
2014-08-21 00:36:09 -0500 received badge  Enthusiast
2014-08-20 09:19:27 -0500 received badge  Popular Question (source)
2014-08-20 03:06:43 -0500 asked a question Position detection calculate object position relative to the robot

I was wondering what are need for position detection. Im using a Asus xtrion camera. eg: packages,nodes,etc..

2014-08-15 06:13:20 -0500 received badge  Notable Question (source)
2014-08-05 04:01:57 -0500 received badge  Scholar (source)
2014-08-05 04:01:51 -0500 received badge  Supporter (source)
2014-08-01 23:04:34 -0500 received badge  Popular Question (source)
2014-07-30 08:02:17 -0500 received badge  Organizer (source)
2014-07-30 08:00:51 -0500 asked a question Compilation error /usr/bin/ld: cannot find -l&

This is the error i received when compiling and i am not sure how to fix this error.

[100%] Building CXX object vision/CMakeFiles/vision1.dir/src/vision.cpp.o
Linking CXX executable /home/chiongsterx/catkin_ws/devel/lib/vision/vision1
/usr/bin/ld: cannot find -l&
collect2: ld returned 1 exit status
make[2]: *** [/home/chiongsterx/catkin_ws/devel/lib/vision/vision1] Error 1
make[1]: *** [vision/CMakeFiles/vision1.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed

This is my cmakelists. Not sure whethere package is placed correctly

find_package(catkin REQUIRED COMPONENTS
 roscpp
 rospy
 std_msgs
 cv_bridge
 image_geometry

)
find_package(OpenCV REQUIRED

)
include_directories(
${catkin_INCLUDE_DIRS} & ${OpenCV_INCLUDE_DIRS}
)
add_executable(vision1 src/vision.cpp)
target_link_libraries(vision1
   ${catkin_LIBRARIES} & ${OpenCV_LIBRARIES}
)
2014-07-28 09:45:10 -0500 received badge  Student (source)