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

San's profile - activity

2022-06-23 03:38:16 -0500 received badge  Good Answer (source)
2022-06-23 03:38:16 -0500 received badge  Enlightened (source)
2020-04-16 13:49:17 -0500 received badge  Nice Answer (source)
2019-08-15 03:05:08 -0500 received badge  Famous Question (source)
2018-11-29 08:55:25 -0500 received badge  Famous Question (source)
2018-02-28 08:14:50 -0500 received badge  Nice Question (source)
2018-02-28 08:14:37 -0500 received badge  Necromancer (source)
2018-02-28 08:14:37 -0500 received badge  Self-Learner (source)
2018-02-28 08:14:37 -0500 received badge  Teacher (source)
2018-01-29 16:18:44 -0500 received badge  Notable Question (source)
2018-01-29 16:18:44 -0500 received badge  Popular Question (source)
2017-02-19 01:57:05 -0500 received badge  Famous Question (source)
2017-02-19 01:57:05 -0500 received badge  Notable Question (source)
2017-02-12 12:44:12 -0500 received badge  Editor (source)
2017-02-12 12:42:57 -0500 asked a question markers LINE_STRIP not working with rospy

Hello community, I am trying to implement markers (LINE_STRIP) using python nodes. I was able to get SPHERE, CUBE and CYLINDER working but not LINE_STRIP, LINE_LIST. I would appreciate if someone can spot any missing implementation. Here is the code snippet:

gist

cpp implementation works fine but I need a python implementation and I didn't find any python tutorials on markers

2016-11-16 01:50:46 -0500 received badge  Notable Question (source)
2016-08-28 18:32:00 -0500 received badge  Popular Question (source)
2016-08-25 12:54:47 -0500 asked a question ROS service: problem passing parameters

My service file is as follows:

float64[] sample
---
float64[] classify_probs

When I try to pass a numpy array of type float64 to the server, It gives me an error which is:

in check_type
raise SerializationError('field %s must be a list or tuple type'%field_name)
genpy.message.SerializationError: field sample must be a list or tuple type

I understood that I have to pass a list or tuple, so I converted the numpy array to a list as

temp_sample = testData.tolist()

and now it gives me the following error:

_check_types
raise SerializationError(str(exc))
genpy.message.SerializationError: <class 'struct.error'>: 'required argument is not a float' when writing 'sample:

The tolist() method converts the numpy array to a list with nearest compatible python type (in this case, it is a float). My question: is it possible to preserve the float64 type when converting to a list?

I tried changing my service file to "float" and ROS is not allowing it. Only float32 and float64 are allowed. Any help in this regard is much appreciated.

2016-05-11 13:39:12 -0500 commented question Is there a way to convert LaserScan messages to Image message?

Hi srik11, I posted the answer, have a look.

2016-05-11 13:38:20 -0500 answered a question Is there a way to convert LaserScan messages to Image message?

Hello srik11 and all, If all you need is to convert laser scan msgs into an image and apply some cv algorithms, you don't even need PCL in between. This is how I did hallway detection from the laser data: (Note: This is not the only way. It works and does the job)

If you realized, the laser output is already in polar form i.e., (r, theta) [distance of object in a particular direction]. All you need to do is take an empty image (by which I mean an image with all white pixels) and using (r, theta) calculate (x, y) which is (r cos theta, r sin theta). Round of (x, y) and in the image, change the corresponding (x, y) pixel from white to black. Repeat this for all the (r, theta) pair from the laser scan. Please also note that you might want to shift the origin (laser origin is at the center and the image origin should always be on the top left corner - atleast for openCV image format). formulas for origin shift: X = x - h, Y = y - k.

You might want to scale the image down to a reasonable size for you to process it especially if your laser scanner range is high.

I hope this helps. Happy coding!

2016-05-11 13:20:18 -0500 received badge  Popular Question (source)
2016-05-10 21:17:00 -0500 received badge  Famous Question (source)
2016-03-01 05:56:23 -0500 received badge  Famous Question (source)
2016-03-01 00:26:46 -0500 marked best answer Detecting hallways using LaserScan data

Hello everyone, I am trying to detect hallways (two solid parallel lines) using laser data (sensor_msgs/LaserScan). Does anyone know of any ready to use ROS packages to get this job done.

If there are no ready to use packages, my other option is to use Hough transforms to detect straight lines and search for two parallel lines. To do this, I have converted sensor_msgs/LaserScan to sensor_msgs/PointCloud2. How do I access individual points so that I can discard the Z axis values and apply Hough transform by voting an accumulator. (I am assuming PointCloud2 is a message type and we can not access individual points) Do I need to convert it into some other form? If so how can I do that?

Any help is much appreciated. Thank you.

2016-03-01 00:26:46 -0500 received badge  Scholar (source)
2016-02-23 15:37:34 -0500 received badge  Enthusiast
2016-02-23 00:45:33 -0500 received badge  Notable Question (source)
2016-02-21 20:25:56 -0500 asked a question pointcloud to image conversion

Hello everyone, I am converting pointcloud to image and I can't view it in RVIZ. Am I converting it into image properly? My code is as follows:

#include <ros/ros.h>
#include <pcl/point_cloud.h>
#include <pcl_conversions/pcl_conversions.h>
#include <sensor_msgs/PointCloud2.h>
#include <sensor_msgs/Image.h>
main (int argc, char **argv)
{
ros::init (argc, argv, "pcl_create");

ros::NodeHandle nh;
ros::Publisher pcl_pub = nh.advertise<sensor_msgs::PointCloud2> ("pcl_output", 1);
ros::Publisher image_pub = nh.advertise<sensor_msgs::Image> ("/image_topic", 30);
pcl::PointCloud<pcl::PointXYZRGB> cloud;
sensor_msgs::PointCloud2 output;
sensor_msgs::Image image;

// Fill in the cloud data
cloud.width  = 10000;
cloud.height = 1;
cloud.points.resize(cloud.width * cloud.height);

for (size_t i = 0; i < cloud.points.size (); ++i)
{
    cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].r = 255;
    cloud.points[i].g = 255;
    cloud.points[i].b = 255;
}

//Convert the cloud to ROS message
pcl::toROSMsg(cloud, output);
pcl::toROSMsg (cloud, image); //convert the cloud
output.header.frame_id = "odom";
image.header.frame_id = "odom";

ros::Rate loop_rate(1);
while (ros::ok())
{
    pcl_pub.publish(output);
    image_pub.publish (image); //publish our cloud image
    ros::spinOnce();
    loop_rate.sleep();
}

return 0;
}

Rviz output is as follows: image description

2016-02-21 05:26:57 -0500 received badge  Student (source)
2016-02-21 04:02:57 -0500 received badge  Popular Question (source)
2016-02-20 20:59:20 -0500 asked a question Is there a way to convert LaserScan messages to Image message?

Hello I am trying to convert laser scan data into images so that I can find "Lines". Following are the snippets from my code:

pcl::PointCloud<pcl::PointXYZRGB> cloudp;
sensor_msgs::Image image;

conversion

pcl::toROSMsg (cloudp, image); //convert the cloud


cloudxyz_.publish(cloudp);
image_pub_.publish (image); //publish our cloud image

When I run it, "Failed to find match for field 'rgb' " is the error I get. When I use rviz, all I see is an Image which is full of black color. My laser gives is 2D data (i.e, z in point cloud is 0) and I need a 2D image so that I can apply CV algorithms on the image.

Thank you.

2016-02-19 03:39:42 -0500 received badge  Notable Question (source)
2016-02-18 23:32:22 -0500 received badge  Popular Question (source)
2016-02-18 21:06:16 -0500 commented answer Detecting hallways using LaserScan data

I was restricted to 300 characters. So I wrote as an answer please reply to that. Thanks.

2016-02-18 21:04:18 -0500 answered a question Detecting hallways using LaserScan data

Thanks for the quick reply. Yes, what you said seems valid. However, I have a question, How do I apply hough's transform to laser data? for the equation r = x cos theta + y sin theta, I can get r value (range in laser message), theta (theta increments from the laser message). I am still left with two unknowns x and y.

I used hough's transforms on Images before as follows: I iterate over every pixel and for every edge pixel, I calculate theta using gradient, solve for r in r = x cos theta + y sin theta vote for r , theta in a accumulator. The (r, theta) that gets maximum votes are my hough parameters.

So, when I have two unknowns (x, y ) how can solve for the equation.

Edit: I found the answer. The laser messages are already in polar form. so, you have r and theta from it. Using r, theta find x = r * cos theta and y = r * sin theta. round of both x and y. Using opencv create an empty image (white image) - the image size depends on the accuracy/resolution you need, for every calculated x, y manipulate pixel at x,y to black pixel. By doing so, you will get a white image with black dots (walls/obstacles detected by the laser). Now, use the built in Hough transform from OpenCV and find the lines. In order to detect the hallway, select two strong lines whose slopes are equal.