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

laser_scan position transformer

asked 2016-04-27 09:24:09 -0500

Emilien gravatar image

hi, i create a laser_scan node which publish /scan topic, and i wnat to show it on rviz but i can't find position transformer and color transformer. please what can i do?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-04-27 10:40:05 -0500

spmaniato gravatar image

updated 2016-04-28 11:51:04 -0500

Update: If the measurements are outside the LaserScan message's reported min-max range, RViz won't visualize them.

In RViz, expand the Global Options dropdown menu (upper left) and set the Fixed Frame to your laser sensor's frame ID (the frame_id of your LaserScan messages).

This will allow you to visualize the laser scans without having to worry about the map -> laser transformation.

edit flag offensive delete link more

Comments

can you explain more please? i am beginner on ROS

Emilien gravatar image Emilien  ( 2016-04-27 11:10:42 -0500 )edit

Have you succeeded in launching RViz? rosrun rviz rviz

spmaniato gravatar image spmaniato  ( 2016-04-27 11:48:36 -0500 )edit

yes and run laser scan with topic /scan but on rviz i dont found position transformer of laser scan

Emilien gravatar image Emilien  ( 2016-04-27 13:03:25 -0500 )edit

I don't understand what you mean by "i dont found position transformer of laser scan". Is that an error message? If not, maybe post a screenshot? Also, what's your 'Fixed Frame' in RViz? (see my answer above for how to find that)

spmaniato gravatar image spmaniato  ( 2016-04-27 13:37:09 -0500 )edit

fixed frame is /odom and i add laser_scan and odometry but i don't have laser_scan result in rvis i hope that is clear

Emilien gravatar image Emilien  ( 2016-04-27 15:24:58 -0500 )edit

OK, cool. Now, in RViz, change the Fixed Frame from /odom to whatever your laser scanner's frame_id is. (That should let you visualize laser scans without any influence from the rest of the system.)

spmaniato gravatar image spmaniato  ( 2016-04-27 16:17:04 -0500 )edit

nothing also, this is a screenshot image description

Emilien gravatar image Emilien  ( 2016-04-27 16:48:31 -0500 )edit

Cool, thanks. One last sanity check: rostopic echo /scan Are messages being published? Do they look reasonable? (frame_id, ranges, range_min, range_max) For example, if the measurements are outside the min-max range, RViz won't visualize them.

spmaniato gravatar image spmaniato  ( 2016-04-27 17:33:57 -0500 )edit
0

answered 2016-04-29 03:00:11 -0500

Emilien gravatar image

updated 2016-04-29 04:25:16 -0500

this is my code, but i get just zeros i run just topic /scan, i get the real value when i run /range topic. have you any idea for this problem?

  #include <ros/ros.h>
    #include <tf/transform_broadcaster.h>
    #include <sensor_msgs/LaserScan.h>
    #include "sensor_msgs/Range.h"
    #include "std_msgs/String.h"


    double range;
    void rangeCallback(const sensor_msgs::Range::ConstPtr& range_msg)
    {   
        range = range_msg->range;
        ROS_INFO("I heard: [%f]", range);
    }

    int main(int argc, char** argv){
    ros::init(argc, argv, "range_listner");
    ros::init(argc, argv, "laser_scan_publisher");
    tf::TransformBroadcaster broadcaster;
    ros::NodeHandle n;
    ros::Subscriber sub = n.subscribe("/ultrasound", 1000, rangeCallback);
    ros::Publisher scan_pub = n.advertise<sensor_msgs::LaserScan>("scan",50);
    unsigned int num_readings = 20;
    double laser_frequency = 40;
    double ranges[num_readings];
    int count = 10;
    ros::Rate r(1.0);
    while(n.ok()){

        for(unsigned int i=0; i<num_readings; i++)
        {
            ranges[i] = range;
        }
        ros::Time scan_time = ros::Time::now();
        sensor_msgs::LaserScan scan;
        scan.header.stamp = scan_time;
        scan.header.frame_id = "base_link";
        scan.angle_min = -1.57;
        scan.angle_max = 1.57;  
        scan.angle_increment = 3.14 / num_readings;
        scan.time_increment = (1/laser_frequency)/(num_readings);
        scan.range_min = 0.0;
        scan.range_max = 100.0;
        scan.ranges.resize(num_readings);
        scan.intensities.resize(num_readings);
        for(unsigned int i=0; i<num_readings; i++)
        {
            scan.ranges[i] = ranges[i];
        }
        scan_pub.publish(scan);
        ++count;
        broadcaster.sendTransform(
                tf::StampedTransform(
                    tf::Transform(tf::Quaternion(0, 0, 0, 1), tf::Vector3(0.1, 0.0, 0.2)),
                    ros::Time::now(),"base_link", "base_laser"));
        r.sleep();
    }
    }
edit flag offensive delete link more

Comments

This is a new question, not an answer. Please make a new post, here on ROS Answers, explaining the what your setup is, what you're trying to accomplish, what the code is meant to do, and what the problem is.

spmaniato gravatar image spmaniato  ( 2016-04-29 07:50:05 -0500 )edit

ok i add this question link text

Emilien gravatar image Emilien  ( 2016-04-29 08:16:42 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-04-27 09:24:09 -0500

Seen: 1,367 times

Last updated: Apr 29 '16