navfn ros priority blocks

asked 2017-03-03 00:24:34 -0500

sheldonyang gravatar image

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);
      }
  }
edit retag flag offensive close merge delete

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?

mgruhler gravatar image mgruhler  ( 2017-03-03 01:06:56 -0500 )edit

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

mgruhler gravatar image mgruhler  ( 2017-03-03 01:07:29 -0500 )edit

the code is in the navfn package.(ros-indigo/navigation/navfn/src/navfn.cpp). link: http://www.ros.org/doc/diamondback/ap... >

sheldonyang gravatar image sheldonyang  ( 2017-03-07 01:38:32 -0500 )edit

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

sheldonyang gravatar image sheldonyang  ( 2017-03-07 01:43:52 -0500 )edit

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...

mgruhler gravatar image mgruhler  ( 2017-03-07 03:19:01 -0500 )edit

Alright,whatever,thanks

sheldonyang gravatar image sheldonyang  ( 2017-03-07 03:25:28 -0500 )edit