Robotics StackExchange | Archived questions

navfn ros priority blocks

As code shows below, i do not understand the const 'INVSQRT2' and the variable 'curT',what do they play roles in code,how can i understand them

define INVSQRT2 0.707106781

  float le = INVSQRT2*(float)costarr[n-1];
  float re = INVSQRT2*(float)costarr[n+1];
  float ue = INVSQRT2*(float)costarr[n-nx];
  float de = INVSQRT2*(float)costarr[n+nx];


  if (pot < curT)   // low-cost buffer block
  {
      if (l > pot+le) {
              push_next(n-1);
      }
      if (r > pot+re)
      {
              push_next(n+1);
      }
      if (u > pot+ue)
      {

              push_next(n-nx);
      }
      if (d > pot+de)
      {
              push_next(n+nx);
      }
  }
  else
  {
      if (l > pot+le) {

              push_over(n-1);
      }
      if (r > pot+re)
      {
              push_over(n+1);
      }
      if (u > pot+ue)
      {

              push_over(n-nx);
      }
      if (d > pot+de)
      {

              push_over(n+nx);
      }
  }

Asked by sheldonyang on 2017-03-03 01:24:34 UTC

Comments

This is not really a question. Also, you are lacking a lot of context. What is this code, where is it from, what should it do and most importantly: Where do curT etc come from? This only appears once in this code. How do you think we should be able to get this?

Asked by mgruhler on 2017-03-03 02:06:56 UTC

INVSQRT2, however, is "invert squareroot of 2", so 1/sqrt(2).

Asked by mgruhler on 2017-03-03 02:07:29 UTC

the code is in the navfn package.(ros-indigo/navigation/navfn/src/navfn.cpp). link: http://www.ros.org/doc/diamondback/api/navfn/html/navfn_8cpp_source.html#l00473">

Asked by sheldonyang on 2017-03-07 02:38:32 UTC

I know INVSQRT2=1/sqrt(2),but I do not know why costarr should multiply it

Asked by sheldonyang on 2017-03-07 02:43:52 UTC

alright, this sounds more like a question. Cannot help with that, though. Maybe check the details of Djikstra alogrithm? Note, you linked to the diamondback source. This is quite old. better always use the link to the Code Api on the ROS wiki...

Asked by mgruhler on 2017-03-07 04:19:01 UTC

Alright,whatever,thanks

Asked by sheldonyang on 2017-03-07 04:25:28 UTC

Answers