laser_scan position transformer
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?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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?
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.
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();
}
}
Asked: 2016-04-27 09:24:09 -0500
Seen: 1,367 times
Last updated: Apr 29 '16