unit3_pp/scripts/unit3_gbfs_exercise_server.py
def make_plan(req):
  ''' 
  Callback function used by the service server to process
  requests from clients. It returns a msg of type PathPlanningPluginResponse
  ''' 
  # costmap as 1-D array representation
  costmap = req.costmap_ros
  # number of columns in the occupancy grid
  width = req.width
  # number of rows in the occupancy grid
  height = req.height
  start_index = req.start
  goal_index = req.goal
  # side of each grid map square in meters
  resolution = 0.2
  # origin of grid map (bottom left pixel) w.r.t. world coordinates (Rviz's origin)
  origin = [-7.4, -7.4, 0]

  viz = GridViz(costmap, resolution, origin, start_index, goal_index, width)

  # time statistics
  start_time = rospy.Time.now()

  # calculate the shortes path using Greedy Best-First Search
  path = greedy_bfs(start_index, goal_index, width, height, costmap, resolution, origin, viz)

  if not path:
    rospy.logwarn("No path returned by Greedy Best-First Search")
    path = []
  else:
    execution_time = rospy.Time.now() - start_time
    print("\n")
    rospy.loginfo('+++++++ Greedy BFS execution metrics +++++++')
    rospy.loginfo('Total execution time: %s seconds', str(execution_time.to_sec()))
    rospy.loginfo('++++++++++++++++++++++++++++++++++++++++++++')
    print("\n")
    rospy.loginfo('Greedy BFS: Path sent to navigation stack')

  resp = PathPlanningPluginResponse()
  resp.plan = path
  return resp
 
  Callback function used by the service server to process
  requests from clients. It returns a msg of type PathPlanningPluginResponse
  
Callback function used by the service server to process
requests from clients. It returns a msg of type PathPlanningPluginResponse
Callback function used by the service server to process requests from clients . It returns a msg of type PathPlanningPluginResponse
def make_plan(req):
  costmap = req.costmap_ros
  width = req.width
  height = req.height
  start_index = req.start
  goal_index = req.goal
  resolution = 0.2
  origin = [-7.4, -7.4, 0]
  viz = GridViz(costmap, resolution, origin, start_index, goal_index, width)
  start_time = rospy.Time.now()
  path = greedy_bfs(start_index, goal_index, width, height, costmap, resolution, origin, viz)
  if not path:
    rospy.logwarn("No path returned by Greedy Best-First Search")
    path = []
  else:
    execution_time = rospy.Time.now() - start_time
    print("\n")
    rospy.loginfo('+++++++ Greedy BFS execution metrics +++++++')
    rospy.loginfo('Total execution time: %s seconds', str(execution_time.to_sec()))
    rospy.loginfo('++++++++++++++++++++++++++++++++++++++++++++')
    print("\n")
    rospy.loginfo('Greedy BFS: Path sent to navigation stack')
  resp = PathPlanningPluginResponse()
  resp.plan = path
  return resp
def make_plan ( req ) : costmap = req . costmap_ros width = req . width height = req . height start_index = req . start goal_index = req . goal resolution = 0.2 origin = [ - 7.4 , - 7.4 , 0 ] viz = GridViz ( costmap , resolution , origin , start_index , goal_index , width ) start_time = rospy . Time . now ( ) path = greedy_bfs ( start_index , goal_index , width , height , costmap , resolution , origin , viz ) if not path : rospy . logwarn ( "No path returned by Greedy Best-First Search" ) path = [ ] else : execution_time = rospy . Time . now ( ) - start_time print ( "\n" ) rospy . loginfo ( '+++++++ Greedy BFS execution metrics +++++++' ) rospy . loginfo ( 'Total execution time: %s seconds' , str ( execution_time . to_sec ( ) ) ) rospy . loginfo ( '++++++++++++++++++++++++++++++++++++++++++++' ) print ( "\n" ) rospy . loginfo ( 'Greedy BFS: Path sent to navigation stack' ) resp = PathPlanningPluginResponse ( ) resp . plan = path return resp
Callback function used by the service server to process
requests from clients.
Callback function used by the service server to process requests from clients .
''' 
  Callback function used by the service server to process
  requests from clients. It returns a msg of type PathPlanningPluginResponse
  ''' # costmap as 1-D array representation # number of columns in the occupancy grid # number of rows in the occupancy grid # side of each grid map square in meters # origin of grid map (bottom left pixel) w.r.t. world coordinates (Rviz's origin) # time statistics # calculate the shortes path using Greedy Best-First Search
req