Robotics StackExchange | Archived questions

I'm struggled with running multiple hokuyo(laser) scanner for several weeks. plz help :(

Hello, all As i am a newbie of ROS i'm struggling with hokuyo_node package with running two hokuyo( UTM-LX30) device. first i actually tried the

<node name="Laser1" pkg="hokuyo_node" type="hokuyo_node">
    <param name="port" type="string" value ="/dev/ttyACM0"/>
    <param name="calibrate_time" type="bool" value="false"/>
    <param name="frame_id" type="string" value="/hokuyo"/>
    <param name="min_ang" type="double" value ="-1.57"/>
    <param name="max_ang" type="double" value ="1.57"/>
    <remap from="scan" to="scan1"/> 
    <param name="intensity" type="bool" value="true"/>

</node>
<node name="Laser2" pkg="hokuyo_node" type="hokuyo_node">
    <param name="port" type="string" value ="/dev/ttyACM1"/>
    <param name="calibrate_time" type="bool" value="false"/>
    <param name="frame_id" type="string" value="/hokuyo"/>
    <param name="min_ang" type="double" value ="-1.57"/>
    <param name="max_ang" type="double" value ="1.57"/>
    <param name="intensity" type="bool" value="true"/>
    <param name="time_offset" type="double" value="0.7"/>
    <remap from="scan" to="scan2"/> 
</node>

but this makes the second hokuyo didn't work at all. so i seperated the node in hokuyo1.launch, hokuyo2.launch files. when i run these files, only former(1st) hokuyo runs correctly, the later one runs for only couple of sequences(no more than 1sec) and stops. When i stop the node and rerun, It says error "timeout reached".

I tried several ways to solve this annoying problem.

  1. publishing. I though it might have been a problem of publishing in a same "scan". I tried to make 2 seperate scan pub ("scan1", "scan2") not to make a overlap in "scan".

scan_pub_1(node_handle_.advertise<sensor_msgs::LaserScan>("scan1", 100),
        diagnostic_,
        diagnostic_updater::FrequencyStatusParam(&desired_freq_, &desired_freq_, 0.05),
        diagnostic_updater::TimeStampStatusParam()),


scan_pub_2(node_handle_.advertise<sensor_msgs::LaserScan>("scan2", 100),
        diagnostic_,
        diagnostic_updater::FrequencyStatusParam(&desired_freq_, &desired_freq_, 0.05),
        diagnostic_updater::TimeStampStatusParam()),
    hokuyo_diagnostic_task_("Hokuyo Diagnostics", boost::bind(&HokuyoNode::connectionStatus, this, _1))
  {
    desired_freq_ = 0;
    driver_.useScan_ = boost::bind(&HokuyoNode::publishScan, this, _1);
    driver_.setPostOpenHook(boost::bind(&HokuyoNode::postOpenHook, this));

But it didn't work.

"2" . Poll. It might be the poll problem, that


int
hokuyo::Laser::laserReadline(char *buf, int len, int timeout)
{
  int current=0;

  struct pollfd ufd[1];
  int retval;
  ufd[0].fd = laser_fd_;
  ufd[0].events = POLLIN;

  if (timeout == 0)
    timeout = -1; // For compatibility with former behavior, 0 means no timeout. For poll, negative means no timeout.

  while (true)
  {
    if (read_buf_start == read_buf_end) // Need to read?
    {
      if ((retval = poll(ufd, 1, timeout)) < 0)
        HOKUYO_EXCEPT(hokuyo::Exception, "poll failed   --  error = %d: %s", errno, strerror(errno));

      if (retval == 0)
        HOKUYO_EXCEPT(hokuyo::TimeoutException, "timeout reached");

      if (ufd[0].revents & POLLERR)
        HOKUYO_EXCEPT(hokuyo::Exception, "error on socket, possibly unplugged");

      int bytes = read(laser_fd_, read_buf, sizeof(read_buf));
      if (bytes == -1 && errno != EAGAIN && errno != EWOULDBLOCK)
        HOKUYO_EXCEPT(hokuyo::Exception, "read failed");
      read_buf_start = 0;
      read_buf_end = bytes;
    }

    while (read_buf_end != read_buf_start)
    {
      if (current == len - 1)
      {
        buf[current] = 0;
        HOKUYO_EXCEPT(hokuyo::Exception, "buffer filled without end of line being found");
      }

      buf[current] = read_buf[read_buf_start++];
      if (buf[current++] == '\n')
      {
        buf[current] = 0;
        return current;
      }
    }

I'm not sure what to manage in this code.

Can someone help?? I'm kind of desperate because I got a business trip next week :(

Asked by Teo4012 on 2017-11-15 23:02:26 UTC

Comments

Your launch file looks ok. It looks like your laser is connected over USB, so you may want to look at the kernel logs to see if the problem is at a lower level.

Asked by ahendrix on 2017-11-16 01:16:52 UTC

Thanks for the reply ahendrix, Im not sure how can i deal with log files I can't see any "hokuyo.log"

Asked by Teo4012 on 2017-11-16 02:12:18 UTC

Did you mean by rostopic echo rosout? If that's so, hokuyo1 and hokuyo2 shows same logs on the command

Asked by Teo4012 on 2017-11-16 02:22:49 UTC

I'm suggesting you look at the linux kernel logs; either run the dmesg command or look in /var/log/syslog

Asked by ahendrix on 2017-11-16 02:25:13 UTC

Answers