Browse Source

add op_global_planner for autowware. change tool_trace2vectormap.

yuchuli 3 years ago
parent
commit
27e655caa2
40 changed files with 6811 additions and 2 deletions
  1. 319 0
      src/ros/catkin/src/autoware_can_msgs/CHANGELOG.rst
  2. 26 0
      src/ros/catkin/src/autoware_can_msgs/CMakeLists.txt
  3. 5 0
      src/ros/catkin/src/autoware_can_msgs/msg/CANData.msg
  4. 53 0
      src/ros/catkin/src/autoware_can_msgs/msg/CANInfo.msg
  5. 7 0
      src/ros/catkin/src/autoware_can_msgs/msg/CANPacket.msg
  6. 16 0
      src/ros/catkin/src/autoware_can_msgs/package.xml
  7. 1 1
      src/ros/catkin/src/map_file/launch/vector_map_loader.launch
  8. 120 0
      src/ros/catkin/src/op_global_planner/CHANGELOG.rst
  9. 54 0
      src/ros/catkin/src/op_global_planner/CMakeLists.txt
  10. 47 0
      src/ros/catkin/src/op_global_planner/README.md
  11. 202 0
      src/ros/catkin/src/op_global_planner/include/op_global_planner_core.h
  12. 28 0
      src/ros/catkin/src/op_global_planner/launch/op_global_planner.launch
  13. 35 0
      src/ros/catkin/src/op_global_planner/nodes/op_global_planner.cpp
  14. 617 0
      src/ros/catkin/src/op_global_planner/nodes/op_global_planner_core.cpp
  15. 27 0
      src/ros/catkin/src/op_global_planner/package.xml
  16. 2 0
      src/ros/catkin/src/op_planner/src/MappingHelpers.cpp
  17. 3 0
      src/ros/catkin/src/op_planner/src/PlannerH.cpp
  18. 230 0
      src/ros/catkin/src/op_ros_helpers/CHANGELOG.rst
  19. 64 0
      src/ros/catkin/src/op_ros_helpers/CMakeLists.txt
  20. 94 0
      src/ros/catkin/src/op_ros_helpers/include/op_ros_helpers/PolygonGenerator.h
  21. 288 0
      src/ros/catkin/src/op_ros_helpers/include/op_ros_helpers/op_ROSHelpers.h
  22. 26 0
      src/ros/catkin/src/op_ros_helpers/package.xml
  23. 112 0
      src/ros/catkin/src/op_ros_helpers/src/PolygonGenerator.cpp
  24. 1851 0
      src/ros/catkin/src/op_ros_helpers/src/op_ROSHelpers.cpp
  25. 4 0
      src/ros/catkin/src/op_simu/.gitignore
  26. 258 0
      src/ros/catkin/src/op_simu/CHANGELOG.rst
  27. 79 0
      src/ros/catkin/src/op_simu/CMakeLists.txt
  28. 32 0
      src/ros/catkin/src/op_simu/Makefile
  29. BIN
      src/ros/catkin/src/op_simu/docs/GPS meaningfulness.ods
  30. 18 0
      src/ros/catkin/src/op_simu/docs/Readme.txt
  31. 509 0
      src/ros/catkin/src/op_simu/include/op_simu/SimpleTracker.h
  32. 72 0
      src/ros/catkin/src/op_simu/include/op_simu/SimulatedTrajectoryFollower.h
  33. 111 0
      src/ros/catkin/src/op_simu/include/op_simu/TrajectoryFollower.h
  34. 15 0
      src/ros/catkin/src/op_simu/main.cpp
  35. 22 0
      src/ros/catkin/src/op_simu/package.xml
  36. 616 0
      src/ros/catkin/src/op_simu/src/SimpleTracker.cpp
  37. 177 0
      src/ros/catkin/src/op_simu/src/SimulatedTrajectoryFollower.cpp
  38. 623 0
      src/ros/catkin/src/op_simu/src/TrajectoryFollower.cpp
  39. 34 1
      src/tool/tool_trace2vectormap/trace2vectormap.cpp
  40. 14 0
      src/tool/tool_trace2vectormap/trace2vectormap.h

+ 319 - 0
src/ros/catkin/src/autoware_can_msgs/CHANGELOG.rst

@@ -0,0 +1,319 @@
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Changelog for package autoware_can_msgs
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1.13.0 (2019-12-03)
+-------------------
+* Update package.xml files to Format 2.
+* Contributors: Joshua Whitley
+
+1.12.0 (2019-07-12)
+-------------------
+
+1.11.0 (2019-03-21)
+-------------------
+* Fix license notice in corresponding package.xml
+* JSK messages not needed for autoware_can_msgs. (`#1840 <https://github.com/CPFL/Autoware/issues/1840>`_)
+* Contributors: Esteve Fernandez, amc-nu
+
+1.10.0 (2019-01-17)
+-------------------
+
+1.9.1 (2018-11-06)
+------------------
+
+1.9.0 (2018-10-31)
+------------------
+* Moved CAN mesages to autoware_can_msgs
+* Contributors: Esteve Fernandez
+
+1.7.0 (2018-05-18)
+------------------
+* update Version from 1.6.3 to 1.7.0 in package.xml and CHANGELOG.rst
+* [Fix] rename packages (`#1269 <https://github.com/CPFL/Autoware/issues/1269>`_)
+  * rename lidar_tracker
+  * Modify pf_lidar_track's cmake file
+  * Refactor code
+  * Rename from euclidean_lidar_tracker to lidar_euclidean_track
+  * Rename from kf_contour_track to lidar_kf_contour_track
+  * Rename from kf_lidar_track to lidar_kf_track, but need some modification in euclidean cluster(Cluster.h)
+  * Rename from pf_lidar_tarck to lidar_pf_track
+  * Rename range_fusion
+  * Rename obj_reproj
+  * Rename euclidean_cluster to lidar_euclidean_cluster_detect
+  * Rename svm_lidar_detect to lidar_svm_detect
+  * Rename kf_lidar_track to lidar_kf_track
+  * Change version 1.6.3 to 1.7.0 in pacakge.xml
+  * Modify CMake so that extrenal header would be loaded
+  * Remove obj_reproj from cv_tracker
+  * Add interface.yaml
+  * Rename road_wizard to trafficlight_recognizer
+  * create common directory
+  * Add lidar_imm_ukf_pda_track
+  * create vision_detector and moved cv
+  * Modify interface.yaml and package.xml
+  * remove dpm_ocv
+  * moved directory
+  * Delete unnecessary launch file
+  * Delete rcnn related file and code
+  * separated dummy_track from cv_tracker
+  * separated klt_track from cv_tracker
+  * Fix a cmake
+  * Remove unnecessary dependency of lidar_euclidean_cluster_detect package
+  * Rename image_segmenter to vision_segment_enet_detect
+  * Remove unnecessary dependency of lidar_svm_detect package
+  * separated kf_track and fix a some compiling issue
+  * move viewers
+  * merge ndt_localizer and icp_localizer, and rename to lidar_localizer
+  * Remove unnecessary dependency of lidar_euclidean_track
+  * moved image lib
+  * add launch
+  * lib move under lidar_tracker
+  * Rename dpm_ttic to vision_dpm_ttic_detect
+  * rename yolo3detector to vision_yolo3_detect
+  * Modify cmake and package.xml in vision_dpm_ttic_detect
+  * moved sourcefiles into nodes dir
+  * moved sourcefiles into nodes dir
+  * Move cv_tracker/data folder and delete cv_tracker/model folder
+  * fix a package file and cmake
+  * Rename yolo2 -> vision_yolo2_detect
+  * fix a package file and cmake
+  * Fix package name of launch file
+  * Rename ssd to vision_ssd_detect
+  * fixed cmake and package for decerese dependencies
+  * remove top packages dir for detection
+  * fixed cmake for cuda
+  * Rename lane_detector to vision_lane_detect
+  * Modify package.xml in lidar-related packages
+  * Remove unnecessary dependencies in lidar_detector and lidar_tracker
+  * Modify computing.yaml for dpm_ttic
+  * Modify dpm_ttic launch file
+  * Remove/Add dependencies to trafficlight_recognizer
+  * Update data folder in dpm_ttic
+  * Modified CMake and package file in dpm_ttic.
+  * Remove src dir in imm_ukf_pda_track
+  * removed unnecessary comments
+  * rename lidar_tracker
+  * Modify pf_lidar_track's cmake file
+  * Refactor code
+  * Rename from euclidean_lidar_tracker to lidar_euclidean_track
+  * Rename from kf_contour_track to lidar_kf_contour_track
+  * Rename from kf_lidar_track to lidar_kf_track, but need some modification in euclidean cluster(Cluster.h)
+  * Rename from pf_lidar_tarck to lidar_pf_track
+  * Rename range_fusion
+  * Rename obj_reproj
+  * Rename road_wizard to trafficlight_recognizer
+  * Rename euclidean_cluster to lidar_euclidean_cluster_detect
+  * Rename svm_lidar_detect to lidar_svm_detect
+  * Rename kf_lidar_track to lidar_kf_track
+  * Change version 1.6.3 to 1.7.0 in pacakge.xml
+  * Modify CMake so that extrenal header would be loaded
+  * Remove obj_reproj from cv_tracker
+  * Add interface.yaml
+  * create common directory
+  * Add lidar_imm_ukf_pda_track
+  * create vision_detector and moved cv
+  * Modify interface.yaml and package.xml
+  * remove dpm_ocv
+  * moved directory
+  * Delete unnecessary launch file
+  * Delete rcnn related file and code
+  * separated dummy_track from cv_tracker
+  * separated klt_track from cv_tracker
+  * Fix a cmake
+  * Remove unnecessary dependency of lidar_euclidean_cluster_detect package
+  * Rename image_segmenter to vision_segment_enet_detect
+  * Remove unnecessary dependency of lidar_svm_detect package
+  * separated kf_track and fix a some compiling issue
+  * move viewers
+  * merge ndt_localizer and icp_localizer, and rename to lidar_localizer
+  * Remove unnecessary dependency of lidar_euclidean_track
+  * moved image lib
+  * add launch
+  * lib move under lidar_tracker
+  * Rename dpm_ttic to vision_dpm_ttic_detect
+  * rename yolo3detector to vision_yolo3_detect
+  * Modify cmake and package.xml in vision_dpm_ttic_detect
+  * moved sourcefiles into nodes dir
+  * moved sourcefiles into nodes dir
+  * Move cv_tracker/data folder and delete cv_tracker/model folder
+  * fix a package file and cmake
+  * Rename yolo2 -> vision_yolo2_detect
+  * fix a package file and cmake
+  * Fix package name of launch file
+  * Rename ssd to vision_ssd_detect
+  * fixed cmake and package for decerese dependencies
+  * remove top packages dir for detection
+  * fixed cmake for cuda
+  * Rename lane_detector to vision_lane_detect
+  * Modify package.xml in lidar-related packages
+  * Remove unnecessary dependencies in lidar_detector and lidar_tracker
+  * Modify computing.yaml for dpm_ttic
+  * Modify dpm_ttic launch file
+  * Remove/Add dependencies to trafficlight_recognizer
+  * Update data folder in dpm_ttic
+  * Modified CMake and package file in dpm_ttic.
+  * Remove src dir in imm_ukf_pda_track
+  * Fix bug for not starting run time manager
+  * Remove invalid dependency
+* Return disable_decision_maker to rosparam
+* Rename class and functions filter->replan
+* Fix message
+* Fix config message path
+* change can_translator
+  - Support to vehicle_status(can intermediate layer)
+  - Separate the can translator and the odometry.
+  - Support to output vehicle autonomous mode
+* add vehicle_status msg
+* Add end point offset option
+* Fix/cmake cleanup (`#1156 <https://github.com/CPFL/Autoware/issues/1156>`_)
+  * Initial Cleanup
+  * fixed also for indigo
+  * kf cjeck
+  * Fix road wizard
+  * Added travis ci
+  * Trigger CI
+  * Fixes to cv_tracker and lidar_tracker cmake
+  * Fix kitti player dependencies
+  * Removed unnecessary dependencies
+  * messages fixing for can
+  * Update build script travis
+  * Travis Path
+  * Travis Paths fix
+  * Travis test
+  * Eigen checks
+  * removed unnecessary dependencies
+  * Eigen Detection
+  * Job number reduced
+  * Eigen3 more fixes
+  * More Eigen3
+  * Even more Eigen
+  * find package cmake modules included
+  * More fixes to cmake modules
+  * Removed non ros dependency
+  * Enable industrial_ci for indidog and kinetic
+  * Wrong install command
+  * fix rviz_plugin install
+  * FastVirtualScan fix
+  * Fix Qt5 Fastvirtualscan
+  * Fixed qt5 system dependencies for rosdep
+  * NDT TKU Fix catkin not pacakged
+  * Fixes from industrial_ci
+* add ctrl_cmd/cmd/linear_acceletion
+* Correspond to new version of waypoint_csv(for decision_maker)
+* fix runtime_manager layout and description
+* Add config_callback for online waypoint tuning
+* Separate configration for speed planning against obstacle/stopline (Note: no logics changed)
+* parametrize detection area
+* add ratio for stopline target
+* Add a transition to stopstate to re-start only manually
+* add new param for decision_maker
+* Contributors: Abraham Monrroy, Akihito Ohsato, Dejan Pangercic, Kosuke Murakami, Yamato ANDO, Yuma, Yuma Nihei, Yusuke FUJII
+
+1.6.3 (2018-03-06)
+------------------
+
+1.6.2 (2018-02-27)
+------------------
+* Update CHANGELOG
+* Contributors: Yusuke FUJII
+
+1.6.1 (2018-01-20)
+------------------
+* update CHANGELOG
+* Contributors: Yusuke FUJII
+
+1.6.0 (2017-12-11)
+------------------
+* Prepare release for 1.6.0
+* Added support to publish result of multiple traffic signals according to the lane
+  VectorMapServer Support to publish signals on current lane if current_pose and final_waypoints available
+* Initial modifications to feat_proj, tlr, context and vector_map loader, server and client to support different types of traffic signals
+* - Add new Node for object polygon representation and tracking (kf_contour_tracker)
+  - Add launch file and tune tracking parameters
+  - Test with Moriyama rosbag
+* Fixed:
+  - callback
+  - laneshift
+  Added:
+  - publisher for laneid
+  - new lanechange flag
+  - new param for decisionMaker
+* add to insert shift lane
+* Support to lanechange similar to state_machine(old) package
+* Changed path state recognition to the way based on /lane_waypoints_array
+* Fix build error, add msg definition
+* Rename and merge msgs
+* add path velocity smoothing
+* add msg of waypointstate for decision_maker
+* Feature/fusion_filter - fusion multiple lidar (`#842 <https://github.com/cpfl/autoware/issues/842>`_)
+  * Add fusion_filter to merge multiple lidar pointclouds
+  * Refactor fusion_filter
+  * Apply clang-format and rebase develop
+  * Add fusion_filter launch and runtime_manager config
+  * Fix names, fusion_filter -> points_concat_filter
+  * Fix build error in ros-indigo
+  * Fix some default message/frame names
+  * Refactor code and apply clang-format
+  * Add configrations for runtime_manager
+  * Fix CMake
+* refactor code
+* refactor code
+* refactor msg and add blinker to msg
+* Add ground_filter config for runtime_manager (`#828 <https://github.com/cpfl/autoware/issues/828>`_)
+* Ray Ground Filter Initial Commit
+* add approximate_ndt_mapping (`#811 <https://github.com/cpfl/autoware/issues/811>`_)
+* add new msg and rename msg
+* add mqtt sender
+* Contributors: AMC, Akihito Ohsato, Yamato ANDO, Yuki Iida, Yuki Kitsukawa, Yusuke FUJII, hatem-darweesh
+
+1.5.1 (2017-09-25)
+------------------
+* Release/1.5.1 (`#816 <https://github.com/cpfl/autoware/issues/816>`_)
+  * fix a build error by gcc version
+  * fix build error for older indigo version
+  * update changelog for v1.5.1
+  * 1.5.1
+* Contributors: Yusuke FUJII
+
+1.5.0 (2017-09-21)
+------------------
+* Update changelog
+* update decision maker config
+* Add to support dynamical parameter for decision_maker
+* Add decision_maker config
+* add config parameter
+* autoware_can_msgs does not depend on jsk_rviz_plugin, cmake and package.xml were not correct
+* Contributors: Dejan Pangercic, Yusuke FUJII
+
+1.4.0 (2017-08-04)
+------------------
+* version number must equal current release number so we can start releasing in the future
+* added changelogs
+* Contributors: Dejan Pangercic
+
+1.3.1 (2017-07-16)
+------------------
+
+1.3.0 (2017-07-14)
+------------------
+* convert to autoware_can_msgs
+* Contributors: YamatoAndo
+
+1.2.0 (2017-06-07)
+------------------
+
+1.1.2 (2017-02-27 23:10)
+------------------------
+
+1.1.1 (2017-02-27 22:25)
+------------------------
+
+1.1.0 (2017-02-24)
+------------------
+
+1.0.1 (2017-01-14)
+------------------
+
+1.0.0 (2016-12-22)
+------------------

+ 26 - 0
src/ros/catkin/src/autoware_can_msgs/CMakeLists.txt

@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 2.8.3)
+project(autoware_can_msgs)
+
+find_package(catkin REQUIRED COMPONENTS
+  message_generation
+  std_msgs
+)
+
+add_message_files(
+  DIRECTORY msg
+  FILES
+    CANData.msg
+    CANInfo.msg
+    CANPacket.msg
+)
+
+generate_messages(
+  DEPENDENCIES
+    std_msgs
+)
+
+catkin_package(
+  CATKIN_DEPENDS
+    message_runtime
+    std_msgs
+)

+ 5 - 0
src/ros/catkin/src/autoware_can_msgs/msg/CANData.msg

@@ -0,0 +1,5 @@
+Header header
+uint32 count
+uint32 id
+uint32 time
+uint16 flag

+ 53 - 0
src/ros/catkin/src/autoware_can_msgs/msg/CANInfo.msg

@@ -0,0 +1,53 @@
+Header header
+string tm
+int32 devmode
+int32 drvcontmode
+int32 drvoverridemode
+int32 drvservo
+int32 drivepedal
+int32 targetpedalstr
+int32 inputpedalstr
+float64 targetveloc
+float64 speed
+int32 driveshift
+int32 targetshift
+int32 inputshift
+int32 strmode
+int32 strcontmode
+int32 stroverridemode
+int32 strservo
+int32 targettorque
+int32 torque
+float64 angle
+float64 targetangle
+int32 bbrakepress
+int32 brakepedal
+int32 brtargetpedalstr
+int32 brinputpedalstr
+float64 battery
+int32 voltage
+float64 anp
+int32 battmaxtemparature
+int32 battmintemparature
+float64 maxchgcurrent
+float64 maxdischgcurrent
+float64 sideacc
+float64 accellfromp
+float64 anglefromp
+float64 brakepedalfromp
+float64 speedfr
+float64 speedfl
+float64 speedrr
+float64 speedrl
+float64 velocfromp2
+int32 drvmode
+int32 devpedalstrfromp
+int32 rpm
+float64 velocflfromp
+int32 ev_mode
+int32 temp
+int32 shiftfrmprius
+int32 light
+int32 gaslevel
+int32 door
+int32 cluise

+ 7 - 0
src/ros/catkin/src/autoware_can_msgs/msg/CANPacket.msg

@@ -0,0 +1,7 @@
+Header header
+uint32 count
+uint32 id
+uint8  len
+uint8[8]  dat
+uint16 flag
+uint32 time

+ 16 - 0
src/ros/catkin/src/autoware_can_msgs/package.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<package format="2">
+  <name>autoware_can_msgs</name>
+  <version>1.13.0</version>
+  <description>The autoware_can_msgs package</description>
+  <maintainer email="yusuke.fujii@tier4.jp">Yusuke Fujii</maintainer>
+  <license>Apache 2</license>
+
+  <buildtool_depend>catkin</buildtool_depend>
+
+  <build_depend>message_generation</build_depend>
+
+  <depend>std_msgs</depend>
+
+  <exec_depend>message_runtime</exec_depend>
+</package>

+ 1 - 1
src/ros/catkin/src/map_file/launch/vector_map_loader.launch

@@ -2,7 +2,7 @@
 <launch>
   <node pkg="map_file" type="vector_map_loader" name="vector_map_loader" output="screen">
     <param name="load_mode" value="directory" />
-    <param name="map_dir" value="$(env HOME)/map/lanevector" />
+    <param name="map_dir" value="$(env HOME)/map/tracevector/" />
     <param name="host_name" value="133.6.148.90" />
     <param name="port" value="80" />
     <param name="user" value="" />

+ 120 - 0
src/ros/catkin/src/op_global_planner/CHANGELOG.rst

@@ -0,0 +1,120 @@
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Changelog for package op_global_planner
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1.11.0 (2019-03-21)
+-------------------
+* [fix] Install commands for all the packages (`#1861 <https://github.com/CPFL/Autoware/issues/1861>`_)
+  * Initial fixes to detection, sensing, semantics and utils
+  * fixing wrong filename on install command
+  * Fixes to install commands
+  * Hokuyo fix name
+  * Fix obj db
+  * Obj db include fixes
+  * End of final cleaning sweep
+  * Incorrect command order in runtime manager
+  * Param tempfile not required by runtime_manager
+  * * Fixes to runtime manager install commands
+  * Remove devel directory from catkin, if any
+  * Updated launch files for robosense
+  * Updated robosense
+  * Fix/add missing install (`#1977 <https://github.com/CPFL/Autoware/issues/1977>`_)
+  * Added launch install to lidar_kf_contour_track
+  * Added install to op_global_planner
+  * Added install to way_planner
+  * Added install to op_local_planner
+  * Added install to op_simulation_package
+  * Added install to op_utilities
+  * Added install to sync
+  * * Improved installation script for pointgrey packages
+  * Fixed nodelet error for gmsl cameras
+  * USe install space in catkin as well
+  * add install to catkin
+  * Fix install directives (`#1990 <https://github.com/CPFL/Autoware/issues/1990>`_)
+  * Fixed installation path
+  * Fixed params installation path
+  * Fixed cfg installation path
+  * Delete cache on colcon_release
+* Fix license notice in corresponding package.xml
+* Contributors: Abraham Monrroy Cano, amc-nu
+
+1.10.0 (2019-01-17)
+-------------------
+* Switch to Apache 2 license (develop branch) (`#1741 <https://github.com/CPFL/Autoware/issues/1741>`_)
+  * Switch to Apache 2
+  * Replace BSD-3 license header with Apache 2 and reassign copyright to the
+  Autoware Foundation.
+  * Update license on Python files
+  * Update copyright years
+  * Add #ifndef/define _POINTS_IMAGE_H\_
+  * Updated license comment
+* Use colcon as the build tool (`#1704 <https://github.com/CPFL/Autoware/issues/1704>`_)
+  * Switch to colcon as the build tool instead of catkin
+  * Added cmake-target
+  * Added note about the second colcon call
+  * Added warning about catkin* scripts being deprecated
+  * Fix COLCON_OPTS
+  * Added install targets
+  * Update Docker image tags
+  * Message packages fixes
+  * Fix missing dependency
+* Fix Ros/ROS naming convention
+* Contributors: Esteve Fernandez
+
+1.9.1 (2018-11-06)
+------------------
+
+1.9.0 (2018-10-31)
+------------------
+* Fix missing dependencies
+* Moved CAN mesages to autoware_can_msgs
+* [fix] PascalCase messages (`#1408 <https://github.com/CPFL/Autoware/issues/1408>`_)
+  * Switch message files to pascal case
+  * Switch message names to pascal case in Runtime Manager
+  * Switch message names to pascal case in *.yaml
+  * Rename brake_cmd and steer_cmd to BrakeCmd and SteerCmd in main.yaml
+* Feature/beyond pixel tracker (`#1473 <https://github.com/CPFL/Autoware/issues/1473>`_)
+  * Add beyond_pixel node
+  * Update prototype of beyond pixel (`#1430 <https://github.com/CPFL/Autoware/issues/1430>`_)
+  * Add parser of DetectedObjectArray for beyond tracker(`#1430 <https://github.com/CPFL/Autoware/issues/1430>`_)
+  * * Adaptations to the original code
+  * Added README
+  * Added Runtime Manager entry
+  * Added Video link
+  * Added install commands for cmake
+  * * Add ID only to tracked objects
+  * Display valid IDs on the 3D labels
+  * Display only objects with image coords
+  * * Added Minimum dimensions
+  * Register angle from the vision tracker if available
+  * Keep message publishing rate continuous
+  * Revert platform_automation_msgs (`#1498 <https://github.com/CPFL/Autoware/issues/1498>`_)
+  * Code cleanup
+  * Fixed a crash when the dimensions are outside of the image
+  * Fix annoying catkin_make causing to run twice the Cmake generation
+* Contributors: Abraham Monrroy, Esteve Fernandez
+
+1.8.0 (2018-08-31)
+------------------
+* Support old behavior of insert static object for obstacle avoidance testing
+  Only one simulated car available in the runtime manager
+  update for copywrite note
+  insert autoware_build_flags to new nodes
+* Add README files for OpenPlanner packages
+* Test Simulated Vehicles
+  Fix Simulated Vehicle Initialization
+  Test Following
+  Test Obstacle Avoidance
+  Add Visualization information to rviz config file open_planner.rviz
+* Modify Map loading for OpenPlanner, now it reads from Autoware vector map messages, old behavior still works but from launch file only.
+  Delete way_planner, dp_planner from UI, but they still accessible from roslaunch.
+* Fix Vector Map parser problem, tested with three different maps
+  Fix Global Planning function for the new map modification
+  Add OpenPlanner Simulator for perception, traffic lights, cars
+  Add OpenPlanner new version to replace wp_planner and dp_planner
+  Remove unnecessary files from OpenPlanner libraries
+  Test Global and Local planning
+  Test Tracking node (kf_contour_track)
+  Test Simulation Nodes
+  Test Utility Nodes
+* Contributors: Hatem Darweesh, hatem-darweesh

+ 54 - 0
src/ros/catkin/src/op_global_planner/CMakeLists.txt

@@ -0,0 +1,54 @@
+cmake_minimum_required(VERSION 2.8.3)
+project(op_global_planner)
+
+find_package(autoware_build_flags REQUIRED)
+
+find_package(
+  catkin REQUIRED COMPONENTS
+    autoware_can_msgs
+    geometry_msgs
+    jsk_recognition_msgs
+    libwaypoint_follower
+    op_planner
+    op_ros_helpers
+    op_simu
+    op_utility
+    pcl_conversions
+    pcl_ros
+    roscpp
+    std_msgs
+    tf
+    vector_map_msgs
+)
+
+catkin_package(
+  INCLUDE_DIRS include
+  LIBRARIES op_global_planner
+)
+
+include_directories(
+  include
+  ${catkin_INCLUDE_DIRS}
+)
+
+add_executable(
+  op_global_planner
+  nodes/op_global_planner.cpp
+  nodes/op_global_planner_core.cpp
+)
+
+target_link_libraries(op_global_planner ${catkin_LIBRARIES})
+
+add_dependencies(op_global_planner ${catkin_EXPORTED_TARGETS})
+
+install(
+  TARGETS op_global_planner
+  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
+)
+        
+install(
+  DIRECTORY launch/
+  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
+)

+ 47 - 0
src/ros/catkin/src/op_global_planner/README.md

@@ -0,0 +1,47 @@
+# OpenPlanner - Global Planner 
+
+## op_global_planner 
+
+This node generate global path from start point to target point(s) on a map. Planning cost is distance only. the algorithm could be extended to handle other costs such as turning right and left busy lanes in the dynamic map. it supports autoware vector map, and special designed .kml maps.
+
+### Outputs
+Global path from start to goal, if multiple goals are set, replanning is automatic when the vehicle reaches the end one goal.
+
+
+### Options
+Lane change is avilable (parralel lanes are detected automatically) 
+Start/Goal(s) are set from Rviz, and saved to .csv files, if rviz param is disables, start/goal(s) will be loaded from .csv file at.
+
+### Requirements
+
+1. vector map
+
+### How to launch
+
+* From a sourced terminal:
+
+`roslaunch op_global_planner op_global_planner.launch`
+
+* From Runtime Manager:
+
+Computing Tab -> Mission Planning -> OpenPlanner - Global Planner  -> op_global_planner
+
+### Subscriptions/Publications
+
+
+```
+Publications: 
+ * /lane_waypoints_array [autoware_msgs::LaneArray]
+ * /global_waypoints_rviz [visualization_msgs::MarkerArray]
+ * /op_destinations_rviz [visualization_msgs::MarkerArray]
+ * /vector_map_center_lines_rviz [visualization_msgs::MarkerArray]
+
+Subscriptions: 
+ * /initialpose [geometry_msgs::PoseWithCovarianceStamped]
+ * /move_base_simple/goal [geometry_msgs::PoseStamped]
+ * /current_pose [geometry_msgs::PoseStamped]
+ * /current_velocity [geometry_msgs::TwistStamped]
+ * /vector_map_info/* 
+```
+
+![Demo Movie](https://youtu.be/BS5nLtBsXPE)

+ 202 - 0
src/ros/catkin/src/op_global_planner/include/op_global_planner_core.h

@@ -0,0 +1,202 @@
+/*
+ * Copyright 2018-2019 Autoware Foundation. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OP_GLOBAL_PLANNER
+#define OP_GLOBAL_PLANNER
+
+#include <ros/ros.h>
+
+#include "vector_map_msgs/PointArray.h"
+#include "vector_map_msgs/LaneArray.h"
+#include "vector_map_msgs/NodeArray.h"
+#include "vector_map_msgs/StopLineArray.h"
+#include "vector_map_msgs/DTLaneArray.h"
+#include "vector_map_msgs/LineArray.h"
+#include "vector_map_msgs/AreaArray.h"
+#include "vector_map_msgs/SignalArray.h"
+#include "vector_map_msgs/StopLine.h"
+#include "vector_map_msgs/VectorArray.h"
+
+#include <geometry_msgs/Vector3Stamped.h>
+#include <geometry_msgs/PoseWithCovarianceStamped.h>
+#include <geometry_msgs/PoseStamped.h>
+#include <nav_msgs/Odometry.h>
+#include <nav_msgs/OccupancyGrid.h>
+
+#include <tf/transform_broadcaster.h>
+#include <tf/transform_listener.h>
+#include <tf/tf.h>
+
+#include <std_msgs/Int8.h>
+#include "libwaypoint_follower/libwaypoint_follower.h"
+#include "autoware_can_msgs/CANInfo.h"
+#include <visualization_msgs/MarkerArray.h>
+
+#include "op_planner/PlannerCommonDef.h"
+#include "op_planner/MappingHelpers.h"
+#include "op_planner/PlannerH.h"
+
+namespace GlobalPlanningNS
+{
+
+#define MAX_GLOBAL_PLAN_DISTANCE 100000
+#define _ENABLE_VISUALIZE_PLAN
+#define REPLANNING_DISTANCE 30
+#define REPLANNING_TIME 5
+#define ARRIVE_DISTANCE 5
+#define CLEAR_COSTS_TIME 15 // seconds
+
+class WayPlannerParams
+{
+public:
+  std::string KmlMapPath;
+  bool bEnableSmoothing;
+  bool bEnableLaneChange;
+  bool bEnableHMI;
+  bool bEnableRvizInput;
+  bool bEnableReplanning;
+  double pathDensity;
+  PlannerHNS::MAP_SOURCE_TYPE  mapSource;
+  bool bEnableDynamicMapUpdate;
+
+
+  WayPlannerParams()
+  {
+      bEnableDynamicMapUpdate = false;
+    bEnableReplanning = false;
+    bEnableHMI = false;
+    bEnableSmoothing = false;
+    bEnableLaneChange = false;
+    bEnableRvizInput = true;
+    pathDensity = 0.5;
+    mapSource = PlannerHNS::MAP_KML_FILE;
+  }
+};
+
+
+class GlobalPlanner
+{
+
+public:
+  int m_iCurrentGoalIndex;
+protected:
+
+  WayPlannerParams m_params;
+  PlannerHNS::WayPoint m_CurrentPose;
+  std::vector<PlannerHNS::WayPoint> m_GoalsPos;
+  geometry_msgs::Pose m_OriginPos;
+  PlannerHNS::VehicleState m_VehicleState;
+  std::vector<int> m_GridMapIntType;
+  std::vector<std::pair<std::vector<PlannerHNS::WayPoint*> , timespec> > m_ModifiedMapItemsTimes;
+  timespec m_ReplnningTimer;
+
+  int m_GlobalPathID;
+
+  bool m_bFirstStart;
+
+  ros::NodeHandle nh;
+
+  ros::Publisher pub_MapRviz;
+  ros::Publisher pub_Paths;
+  ros::Publisher pub_PathsRviz;
+  ros::Publisher pub_TrafficInfo;
+  //ros::Publisher pub_TrafficInfoRviz;
+  //ros::Publisher pub_StartPointRviz;
+  //ros::Publisher pub_GoalPointRviz;
+  //ros::Publisher pub_NodesListRviz;
+  ros::Publisher pub_GoalsListRviz;
+
+  ros::Subscriber sub_robot_odom;
+  ros::Subscriber sub_start_pose;
+  ros::Subscriber sub_goal_pose;
+  ros::Subscriber sub_current_pose;
+  ros::Subscriber sub_current_velocity;
+  ros::Subscriber sub_can_info;
+  ros::Subscriber sub_road_status_occupancy;
+
+public:
+  GlobalPlanner();
+  ~GlobalPlanner();
+  void MainLoop();
+
+private:
+  PlannerHNS::WayPoint* m_pCurrGoal;
+
+  void GetTransformFromTF(const std::string parent_frame, const std::string child_frame, tf::StampedTransform &transform);
+
+  // Callback function for subscriber.
+  void callbackGetGoalPose(const geometry_msgs::PoseStampedConstPtr &msg);
+  void callbackGetStartPose(const geometry_msgs::PoseWithCovarianceStampedConstPtr &input);
+  void callbackGetCurrentPose(const geometry_msgs::PoseStampedConstPtr& msg);
+  void callbackGetVehicleStatus(const geometry_msgs::TwistStampedConstPtr& msg);
+  void callbackGetCANInfo(const autoware_can_msgs::CANInfoConstPtr &msg);
+  void callbackGetRobotOdom(const nav_msgs::OdometryConstPtr& msg);
+  void callbackGetRoadStatusOccupancyGrid(const nav_msgs::OccupancyGridConstPtr& msg);
+
+  protected:
+    PlannerHNS::RoadNetwork m_Map;
+    bool  m_bKmlMap;
+    PlannerHNS::PlannerH m_PlannerH;
+    std::vector<std::vector<PlannerHNS::WayPoint> > m_GeneratedTotalPaths;
+
+    bool GenerateGlobalPlan(PlannerHNS::WayPoint& startPoint, PlannerHNS::WayPoint& goalPoint, std::vector<std::vector<PlannerHNS::WayPoint> >& generatedTotalPaths);
+    void VisualizeAndSend(const std::vector<std::vector<PlannerHNS::WayPoint> > generatedTotalPaths);
+    void VisualizeDestinations(std::vector<PlannerHNS::WayPoint>& destinations, const int& iSelected);
+    void SaveSimulationData();
+    int LoadSimulationData();
+    void ClearOldCostFromMap();
+
+
+    //Mapping Section
+
+    UtilityHNS::MapRaw m_MapRaw;
+
+  ros::Subscriber sub_lanes;
+  ros::Subscriber sub_points;
+  ros::Subscriber sub_dt_lanes;
+  ros::Subscriber sub_intersect;
+  ros::Subscriber sup_area;
+  ros::Subscriber sub_lines;
+  ros::Subscriber sub_stop_line;
+  ros::Subscriber sub_signals;
+  ros::Subscriber sub_vectors;
+  ros::Subscriber sub_curbs;
+  ros::Subscriber sub_edges;
+  ros::Subscriber sub_way_areas;
+  ros::Subscriber sub_cross_walk;
+  ros::Subscriber sub_nodes;
+
+
+  void callbackGetVMLanes(const vector_map_msgs::LaneArray& msg);
+  void callbackGetVMPoints(const vector_map_msgs::PointArray& msg);
+  void callbackGetVMdtLanes(const vector_map_msgs::DTLaneArray& msg);
+  void callbackGetVMIntersections(const vector_map_msgs::CrossRoadArray& msg);
+  void callbackGetVMAreas(const vector_map_msgs::AreaArray& msg);
+  void callbackGetVMLines(const vector_map_msgs::LineArray& msg);
+  void callbackGetVMStopLines(const vector_map_msgs::StopLineArray& msg);
+  void callbackGetVMSignal(const vector_map_msgs::SignalArray& msg);
+  void callbackGetVMVectors(const vector_map_msgs::VectorArray& msg);
+  void callbackGetVMCurbs(const vector_map_msgs::CurbArray& msg);
+  void callbackGetVMRoadEdges(const vector_map_msgs::RoadEdgeArray& msg);
+  void callbackGetVMWayAreas(const vector_map_msgs::WayAreaArray& msg);
+  void callbackGetVMCrossWalks(const vector_map_msgs::CrossWalkArray& msg);
+  void callbackGetVMNodes(const vector_map_msgs::NodeArray& msg);
+
+};
+
+}
+
+#endif

+ 28 - 0
src/ros/catkin/src/op_global_planner/launch/op_global_planner.launch

@@ -0,0 +1,28 @@
+<!-- -->
+<launch>
+  <arg name="pathDensity"           default="0.75" /> <!-- distance between each two waypoints-->
+  <arg name="enableSmoothing"         default="true" /> <!-- 1 or 0 -->
+  <arg name="enableLaneChange"         default="false" /> <!-- 1 or 0 -->
+  <arg name="enableRvizInput"         default="true" /> <!-- 1 or 0 -->
+  <arg name="enableReplan"            default="true" /> <!-- 1 or 0 -->  
+  <arg name="velocitySource"          default="1" /> <!-- read velocities from (0- Odometry, 1- autoware current_velocities, 2- car_info) "" -->
+  <arg name="mapSource"             default="0" /> <!-- Autoware=0, Vector Map Folder=1, kml file=2 -->
+  <arg name="mapFileName"           default="" /> <!-- incase of kml map source -->
+  <arg name="enableDynamicMapUpdate"       default="false" />  
+  
+<node pkg="op_global_planner" type="op_global_planner" name="op_global_planner" output="screen">
+    
+    <param name="pathDensity"         value="$(arg pathDensity)" />
+    <param name="enableSmoothing"       value="$(arg enableSmoothing)" />
+    <param name="enableLaneChange"       value="$(arg enableLaneChange)" />
+    <param name="enableRvizInput"       value="$(arg enableRvizInput)" />
+    <param name="enableReplan"         value="$(arg enableReplan)" />        
+    <param name="velocitySource"       value="$(arg velocitySource)" />
+    <param name="mapSource"         value="$(arg mapSource)" />
+    <param name="mapFileName"         value="$(arg mapFileName)" />
+    
+    <param name="enableDynamicMapUpdate"   value="$(arg enableDynamicMapUpdate)" />
+          
+  </node> 
+  
+</launch>

+ 35 - 0
src/ros/catkin/src/op_global_planner/nodes/op_global_planner.cpp

@@ -0,0 +1,35 @@
+/*
+ * Copyright 2018-2019 Autoware Foundation. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @brief global Planner represents the Global planning Module, to generate global plan (reference path) the nodes takes start position, goal position and return sequence of waypoints.
+ * @brief Once the node starts (depending on the mapping option) it will load the vector map (road network) and send it to be visualized by RViz. topic name "/vector_map_center_lines_rviz"
+ * @param Start_Position in simulation environment like rviz, this node require the user to select start position using "2D Pose Estimate" button and select starting position from the global path, //
+ * if localization node is working and ndt_pose or curr_pose messages are published the node will use localization as starting position instead of "2D Pose Estimate"
+ * @param Goal_Position destination to generate global plan to. if "replan" option selection used can choose multiple goal positions. goal positions are selected from Rviz using "2D Nav Goal" button.
+ * @return global , reference path as list of waypoints. data type is "autoware_msgs::LaneArray" , and the topic name is "lane_waypoints_array"
+ */
+
+#include <ros/ros.h>
+#include "op_global_planner_core.h"
+
+int main(int argc, char **argv)
+{
+  ros::init(argc, argv, "op_global_planner");
+  GlobalPlanningNS::GlobalPlanner global_planner;
+  global_planner.MainLoop();
+  return 0;
+}

+ 617 - 0
src/ros/catkin/src/op_global_planner/nodes/op_global_planner_core.cpp

@@ -0,0 +1,617 @@
+/*
+ * Copyright 2018-2019 Autoware Foundation. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "op_global_planner_core.h"
+#include "op_ros_helpers/op_ROSHelpers.h"
+
+namespace GlobalPlanningNS
+{
+
+GlobalPlanner::GlobalPlanner()
+{
+  m_pCurrGoal = 0;
+  m_iCurrentGoalIndex = 0;
+  m_bKmlMap = false;
+  m_bFirstStart = false;
+  m_GlobalPathID = 1;
+  UtilityHNS::UtilityH::GetTickCount(m_ReplnningTimer);
+
+  nh.getParam("/op_global_planner/pathDensity" , m_params.pathDensity);
+  nh.getParam("/op_global_planner/enableSmoothing" , m_params.bEnableSmoothing);
+  nh.getParam("/op_global_planner/enableLaneChange" , m_params.bEnableLaneChange);
+  nh.getParam("/op_global_planner/enableRvizInput" , m_params.bEnableRvizInput);
+  nh.getParam("/op_global_planner/enableReplan" , m_params.bEnableReplanning);
+  nh.getParam("/op_global_planner/enableDynamicMapUpdate" , m_params.bEnableDynamicMapUpdate);
+  nh.getParam("/op_global_planner/mapFileName" , m_params.KmlMapPath);
+
+  int iSource = 0;
+  nh.getParam("/op_global_planner/mapSource", iSource);
+  if(iSource == 0)
+    m_params.mapSource = PlannerHNS::MAP_AUTOWARE;
+  else if (iSource == 1)
+    m_params.mapSource = PlannerHNS::MAP_FOLDER;
+  else if(iSource == 2)
+    m_params.mapSource = PlannerHNS::MAP_KML_FILE;
+
+/*
+  tf::StampedTransform transform;
+  PlannerHNS::ROSHelpers::GetTransformFromTF("map", "world", transform);
+  m_OriginPos.position.x  =  transform.getOrigin().x();
+  m_OriginPos.position.y  = transform.getOrigin().y();
+  m_OriginPos.position.z  = transform.getOrigin().z();
+  */
+
+    m_OriginPos.position.x  =  0;
+  m_OriginPos.position.y  = 0;
+  m_OriginPos.position.z  = 0;
+
+  pub_Paths = nh.advertise<autoware_msgs::LaneArray>("lane_waypoints_array", 1, true);
+  pub_PathsRviz = nh.advertise<visualization_msgs::MarkerArray>("global_waypoints_rviz", 1, true);
+  pub_MapRviz  = nh.advertise<visualization_msgs::MarkerArray>("vector_map_center_lines_rviz", 1, true);
+  pub_GoalsListRviz = nh.advertise<visualization_msgs::MarkerArray>("op_destinations_rviz", 1, true);
+
+  if(m_params.bEnableRvizInput)
+  {
+    std::cout<<" rviz input "<<std::endl;
+    sub_start_pose = nh.subscribe("/initialpose", 1, &GlobalPlanner::callbackGetStartPose, this);
+    sub_goal_pose = nh.subscribe("/move_base_simple/goal", 1, &GlobalPlanner::callbackGetGoalPose, this);
+  }
+  else
+  {
+    LoadSimulationData();
+  }
+
+  sub_current_pose = nh.subscribe("/current_pose", 10, &GlobalPlanner::callbackGetCurrentPose, this);
+
+  int bVelSource = 1;
+  nh.getParam("/op_global_planner/velocitySource", bVelSource);
+  if(bVelSource == 0)
+    sub_robot_odom = nh.subscribe("/odom", 10, &GlobalPlanner::callbackGetRobotOdom, this);
+  else if(bVelSource == 1)
+    sub_current_velocity = nh.subscribe("/current_velocity", 10, &GlobalPlanner::callbackGetVehicleStatus, this);
+  else if(bVelSource == 2)
+    sub_can_info = nh.subscribe("/can_info", 10, &GlobalPlanner::callbackGetCANInfo, this);
+
+  if(m_params.bEnableDynamicMapUpdate)
+    sub_road_status_occupancy = nh.subscribe<>("/occupancy_road_status", 1, &GlobalPlanner::callbackGetRoadStatusOccupancyGrid, this);
+
+  //Mapping Section
+  sub_lanes = nh.subscribe("/vector_map_info/lane", 1, &GlobalPlanner::callbackGetVMLanes,  this);
+  sub_points = nh.subscribe("/vector_map_info/point", 1, &GlobalPlanner::callbackGetVMPoints,  this);
+  sub_dt_lanes = nh.subscribe("/vector_map_info/dtlane", 1, &GlobalPlanner::callbackGetVMdtLanes,  this);
+  sub_intersect = nh.subscribe("/vector_map_info/cross_road", 1, &GlobalPlanner::callbackGetVMIntersections,  this);
+  sup_area = nh.subscribe("/vector_map_info/area", 1, &GlobalPlanner::callbackGetVMAreas,  this);
+  sub_lines = nh.subscribe("/vector_map_info/line", 1, &GlobalPlanner::callbackGetVMLines,  this);
+  sub_stop_line = nh.subscribe("/vector_map_info/stop_line", 1, &GlobalPlanner::callbackGetVMStopLines,  this);
+  sub_signals = nh.subscribe("/vector_map_info/signal", 1, &GlobalPlanner::callbackGetVMSignal,  this);
+  sub_vectors = nh.subscribe("/vector_map_info/vector", 1, &GlobalPlanner::callbackGetVMVectors,  this);
+  sub_curbs = nh.subscribe("/vector_map_info/curb", 1, &GlobalPlanner::callbackGetVMCurbs,  this);
+  sub_edges = nh.subscribe("/vector_map_info/road_edge", 1, &GlobalPlanner::callbackGetVMRoadEdges,  this);
+  sub_way_areas = nh.subscribe("/vector_map_info/way_area", 1, &GlobalPlanner::callbackGetVMWayAreas,  this);
+  sub_cross_walk = nh.subscribe("/vector_map_info/cross_walk", 1, &GlobalPlanner::callbackGetVMCrossWalks,  this);
+  sub_nodes = nh.subscribe("/vector_map_info/node", 1, &GlobalPlanner::callbackGetVMNodes,  this);
+
+}
+
+GlobalPlanner::~GlobalPlanner()
+{
+  if(m_params.bEnableRvizInput)
+    SaveSimulationData();
+}
+
+void GlobalPlanner::callbackGetRoadStatusOccupancyGrid(const nav_msgs::OccupancyGridConstPtr& msg)
+{
+//  std::cout << "Occupancy Grid Origin (" << msg->info.origin.position.x << ", " << msg->info.origin.position.x << ") , " << msg->header.frame_id << ", Res: " << msg->info.resolution <<  std::endl;
+
+  m_GridMapIntType.clear();
+
+  //std::cout << "Found Map Data: Zero " <<  std::endl;
+  for(unsigned int i=0; i < msg->data.size(); i++)
+  {
+    if((int8_t)msg->data.at(i) == 0)
+      m_GridMapIntType.push_back(0);
+    else if((int8_t)msg->data.at(i) == 50)
+      m_GridMapIntType.push_back(75);
+    else if((int8_t)msg->data.at(i) == 100)
+      m_GridMapIntType.push_back(255);
+    else
+      m_GridMapIntType.push_back(128);
+
+      //std::cout << msg->data.at(i) << ",";
+  }
+  //std::cout << std::endl << "--------------------------------------------------------" << std::endl;
+
+  //std::cout << "Found Map Data: Zero : " << m_GridMapIntType.size() <<  std::endl;
+  PlannerHNS::WayPoint center(msg->info.origin.position.x, msg->info.origin.position.y, msg->info.origin.position.z, tf::getYaw(msg->info.origin.orientation));
+  PlannerHNS::OccupancyToGridMap grid(msg->info.width,msg->info.height, msg->info.resolution, center);
+  std::vector<PlannerHNS::WayPoint*> modified_nodes;
+  timespec t;
+  UtilityHNS::UtilityH::GetTickCount(t);
+  PlannerHNS::MappingHelpers::UpdateMapWithOccupancyGrid(grid, m_GridMapIntType, m_Map, modified_nodes);
+  m_ModifiedMapItemsTimes.push_back(std::make_pair(modified_nodes, t));
+
+  visualization_msgs::MarkerArray map_marker_array;
+  PlannerHNS::ROSHelpers::ConvertFromRoadNetworkToAutowareVisualizeMapFormat(m_Map, map_marker_array);
+
+//  visualization_msgs::Marker mkr = PlannerHNS::ROSHelpers::CreateGenMarker(center.pos.x, center.pos.y, center.pos.z, 0, 0,0,1,0.5, 1000, "TestCenter", visualization_msgs::Marker::SPHERE);
+//
+//  map_marker_array.markers.push_back(mkr);
+
+  pub_MapRviz.publish(map_marker_array);
+}
+
+void GlobalPlanner::ClearOldCostFromMap()
+{
+  for(int i=0; i < (int)m_ModifiedMapItemsTimes.size(); i++)
+  {
+    if(UtilityHNS::UtilityH::GetTimeDiffNow(m_ModifiedMapItemsTimes.at(i).second) > CLEAR_COSTS_TIME)
+    {
+      for(unsigned int j= 0 ; j < m_ModifiedMapItemsTimes.at(i).first.size(); j++)
+      {
+        for(unsigned int i_action=0; i_action < m_ModifiedMapItemsTimes.at(i).first.at(j)->actionCost.size(); i_action++)
+        {
+          if(m_ModifiedMapItemsTimes.at(i).first.at(j)->actionCost.at(i_action).first == PlannerHNS::FORWARD_ACTION)
+          {
+            m_ModifiedMapItemsTimes.at(i).first.at(j)->actionCost.at(i_action).second = 0;
+          }
+        }
+      }
+
+      m_ModifiedMapItemsTimes.erase(m_ModifiedMapItemsTimes.begin()+i);
+      i--;
+    }
+  }
+}
+
+void GlobalPlanner::callbackGetGoalPose(const geometry_msgs::PoseStampedConstPtr &msg)
+{
+  PlannerHNS::WayPoint wp = PlannerHNS::WayPoint(msg->pose.position.x+m_OriginPos.position.x, msg->pose.position.y+m_OriginPos.position.y, msg->pose.position.z+m_OriginPos.position.z, tf::getYaw(msg->pose.orientation));
+  m_GoalsPos.push_back(wp);
+  std::cout<<" Received Goal Pose"<<std::endl;
+  ROS_INFO("Received Goal Pose");
+}
+
+void GlobalPlanner::callbackGetStartPose(const geometry_msgs::PoseWithCovarianceStampedConstPtr &msg)
+{
+  m_CurrentPose = PlannerHNS::WayPoint(msg->pose.pose.position.x+m_OriginPos.position.x, msg->pose.pose.position.y+m_OriginPos.position.y, msg->pose.pose.position.z+m_OriginPos.position.z, tf::getYaw(msg->pose.pose.orientation));
+  ROS_INFO("Received Start pose");
+}
+
+void GlobalPlanner::callbackGetCurrentPose(const geometry_msgs::PoseStampedConstPtr& msg)
+{
+  m_CurrentPose = PlannerHNS::WayPoint(msg->pose.position.x, msg->pose.position.y, msg->pose.position.z, tf::getYaw(msg->pose.orientation));
+}
+
+void GlobalPlanner::callbackGetRobotOdom(const nav_msgs::OdometryConstPtr& msg)
+{
+  m_VehicleState.speed = msg->twist.twist.linear.x;
+  m_CurrentPose.v = m_VehicleState.speed;
+  if(fabs(msg->twist.twist.linear.x) > 0.25)
+    m_VehicleState.steer += atan(2.7 * msg->twist.twist.angular.z/msg->twist.twist.linear.x);
+}
+
+void GlobalPlanner::callbackGetVehicleStatus(const geometry_msgs::TwistStampedConstPtr& msg)
+{
+  m_VehicleState.speed = msg->twist.linear.x;
+  m_CurrentPose.v = m_VehicleState.speed;
+  if(fabs(msg->twist.linear.x) > 0.25)
+    m_VehicleState.steer = atan(2.7 * msg->twist.angular.z/msg->twist.linear.x);
+  UtilityHNS::UtilityH::GetTickCount(m_VehicleState.tStamp);
+}
+
+void GlobalPlanner::callbackGetCANInfo(const autoware_can_msgs::CANInfoConstPtr &msg)
+{
+  m_VehicleState.speed = msg->speed/3.6;
+  m_CurrentPose.v = m_VehicleState.speed;
+  m_VehicleState.steer = msg->angle * 0.45 / 660;
+  UtilityHNS::UtilityH::GetTickCount(m_VehicleState.tStamp);
+}
+
+bool GlobalPlanner::GenerateGlobalPlan(PlannerHNS::WayPoint& startPoint, PlannerHNS::WayPoint& goalPoint, std::vector<std::vector<PlannerHNS::WayPoint> >& generatedTotalPaths)
+{
+  std::vector<int> predefinedLanesIds;
+  double ret = 0;
+
+  ret = m_PlannerH.PlanUsingDP(startPoint, goalPoint, MAX_GLOBAL_PLAN_DISTANCE, m_params.bEnableLaneChange, predefinedLanesIds, m_Map, generatedTotalPaths);
+
+  if(ret == 0)
+  {
+    std::cout << "Can't Generate Global Path for Start (" << startPoint.pos.ToString()
+                        << ") and Goal (" << goalPoint.pos.ToString() << ")" << std::endl;
+    return false;
+  }
+
+
+  if(generatedTotalPaths.size() > 0 && generatedTotalPaths.at(0).size()>0)
+  {
+    if(m_params.bEnableSmoothing)
+    {
+      for(unsigned int i=0; i < generatedTotalPaths.size(); i++)
+      {
+        PlannerHNS::PlanningHelpers::FixPathDensity(generatedTotalPaths.at(i), m_params.pathDensity);
+        PlannerHNS::PlanningHelpers::SmoothPath(generatedTotalPaths.at(i), 0.49, 0.35 , 0.01);
+      }
+    }
+
+    for(unsigned int i=0; i < generatedTotalPaths.size(); i++)
+    {
+      PlannerHNS::PlanningHelpers::CalcAngleAndCost(generatedTotalPaths.at(i));
+      if(m_GlobalPathID > 10000)
+        m_GlobalPathID = 1;
+
+      for(unsigned int j=0; j < generatedTotalPaths.at(i).size(); j++)
+        generatedTotalPaths.at(i).at(j).gid = m_GlobalPathID;
+
+      m_GlobalPathID++;
+
+      std::cout << "New DP Path -> " << generatedTotalPaths.at(i).size() << std::endl;
+    }
+    return true;
+  }
+  else
+  {
+    std::cout << "Can't Generate Global Path for Start (" << startPoint.pos.ToString() << ") and Goal (" << goalPoint.pos.ToString() << ")" << std::endl;
+  }
+  return false;
+}
+
+void GlobalPlanner::VisualizeAndSend(const std::vector<std::vector<PlannerHNS::WayPoint> > generatedTotalPaths)
+{
+  autoware_msgs::LaneArray lane_array;
+  visualization_msgs::MarkerArray pathsToVisualize;
+
+  for(unsigned int i=0; i < generatedTotalPaths.size(); i++)
+  {
+    autoware_msgs::Lane lane;
+    PlannerHNS::ROSHelpers::ConvertFromLocalLaneToAutowareLane(generatedTotalPaths.at(i), lane);
+    lane_array.lanes.push_back(lane);
+  }
+
+  std_msgs::ColorRGBA total_color;
+  total_color.r = 0;
+  total_color.g = 0.7;
+  total_color.b = 1.0;
+  total_color.a = 0.9;
+  PlannerHNS::ROSHelpers::createGlobalLaneArrayMarker(total_color, lane_array, pathsToVisualize);
+  PlannerHNS::ROSHelpers::createGlobalLaneArrayOrientationMarker(lane_array, pathsToVisualize);
+  PlannerHNS::ROSHelpers::createGlobalLaneArrayVelocityMarker(lane_array, pathsToVisualize);
+  pub_PathsRviz.publish(pathsToVisualize);
+  if((m_bFirstStart && m_params.bEnableHMI) || !m_params.bEnableHMI)
+    pub_Paths.publish(lane_array);
+
+  for(unsigned int i=0; i < generatedTotalPaths.size(); i++)
+  {
+    std::ostringstream str_out;
+    str_out << UtilityHNS::UtilityH::GetHomeDirectory();
+    str_out << UtilityHNS::DataRW::LoggingMainfolderName;
+    str_out << UtilityHNS::DataRW::GlobalPathLogFolderName;
+    str_out << "GlobalPath_";
+    str_out << i;
+    str_out << "_";
+    PlannerHNS::PlanningHelpers::WritePathToFile(str_out.str(), generatedTotalPaths.at(i));
+  }
+}
+
+void GlobalPlanner::VisualizeDestinations(std::vector<PlannerHNS::WayPoint>& destinations, const int& iSelected)
+{
+  visualization_msgs::MarkerArray goals_array;
+
+  for(unsigned int i=0; i< destinations.size(); i++)
+  {
+    visualization_msgs::Marker marker;
+    marker.header.frame_id = "map";
+    marker.header.stamp = ros::Time();
+    marker.ns = "HMI_Destinations";
+    marker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
+    marker.action = visualization_msgs::Marker::ADD;
+    marker.scale.x = 3.25;
+    marker.scale.y = 3.25;
+    marker.scale.z = 3.25;
+    marker.color.a = 0.9;
+    marker.id = i;
+    if(i == iSelected)
+    {
+      marker.color.r = 1;
+      marker.color.g = 0;
+      marker.color.b = 0;
+    }
+    else
+    {
+      marker.color.r = 0.2;
+      marker.color.g = 0.8;
+      marker.color.b = 0.2;
+    }
+    marker.pose.position.x = destinations.at(i).pos.x;
+    marker.pose.position.y = destinations.at(i).pos.y;
+    marker.pose.position.z = destinations.at(i).pos.z;
+    marker.pose.orientation = tf::createQuaternionMsgFromYaw(destinations.at(i).pos.a);
+
+    std::ostringstream str_out;
+    str_out << "G";
+    marker.text = str_out.str();
+
+    goals_array.markers.push_back(marker);
+  }
+  pub_GoalsListRviz.publish(goals_array);
+}
+
+void GlobalPlanner::SaveSimulationData()
+{
+  std::vector<std::string> simulationDataPoints;
+  std::ostringstream startStr;
+  startStr << m_CurrentPose.pos.x << "," << m_CurrentPose.pos.y << "," << m_CurrentPose.pos.z << "," << m_CurrentPose.pos.a << ","<< m_CurrentPose.cost << "," << 0 << ",";
+  simulationDataPoints.push_back(startStr.str());
+
+  for(unsigned int i=0; i < m_GoalsPos.size(); i++)
+  {
+    std::ostringstream goalStr;
+    goalStr << m_GoalsPos.at(i).pos.x << "," << m_GoalsPos.at(i).pos.y << "," << m_GoalsPos.at(i).pos.z << "," << m_GoalsPos.at(i).pos.a << "," << 0 << "," << 0 << ",destination_" << i+1 << ",";
+    simulationDataPoints.push_back(goalStr.str());
+  }
+
+  std::string header = "X,Y,Z,A,C,V,name,";
+
+  std::ostringstream fileName;
+  fileName << UtilityHNS::UtilityH::GetHomeDirectory()+UtilityHNS::DataRW::LoggingMainfolderName+UtilityHNS::DataRW::SimulationFolderName;
+  fileName << "EgoCar.csv";
+  std::ofstream f(fileName.str().c_str());
+
+  if(f.is_open())
+  {
+    if(header.size() > 0)
+      f << header << "\r\n";
+    for(unsigned int i = 0 ; i < simulationDataPoints.size(); i++)
+      f << simulationDataPoints.at(i) << "\r\n";
+  }
+
+  f.close();
+}
+
+int GlobalPlanner::LoadSimulationData()
+{
+  std::ostringstream fileName;
+  fileName << "EgoCar.csv";
+
+  std::string simuDataFileName = UtilityHNS::UtilityH::GetHomeDirectory()+UtilityHNS::DataRW::LoggingMainfolderName+UtilityHNS::DataRW::SimulationFolderName + fileName.str();
+  UtilityHNS::SimulationFileReader sfr(simuDataFileName);
+  UtilityHNS::SimulationFileReader::SimulationData data;
+
+  int nData = sfr.ReadAllData(data);
+  if(nData == 0)
+    return 0;
+
+  m_CurrentPose = PlannerHNS::WayPoint(data.startPoint.x, data.startPoint.y, data.startPoint.z, data.startPoint.a);
+  m_GoalsPos.push_back(PlannerHNS::WayPoint(data.goalPoint.x, data.goalPoint.y, data.goalPoint.z, data.goalPoint.a));
+
+  for(unsigned int i=0; i < data.simuCars.size(); i++)
+  {
+    m_GoalsPos.push_back(PlannerHNS::WayPoint(data.simuCars.at(i).x, data.simuCars.at(i).y, data.simuCars.at(i).z, data.simuCars.at(i).a));
+  }
+
+  return nData;
+}
+
+void GlobalPlanner::MainLoop()
+{
+  ros::Rate loop_rate(25);
+  timespec animation_timer;
+  UtilityHNS::UtilityH::GetTickCount(animation_timer);
+
+  while (ros::ok())
+  {
+    ros::spinOnce();
+    bool bMakeNewPlan = false;
+
+    if(m_params.mapSource == PlannerHNS::MAP_KML_FILE && !m_bKmlMap)
+    {
+      m_bKmlMap = true;
+      PlannerHNS::MappingHelpers::LoadKML(m_params.KmlMapPath, m_Map);
+      visualization_msgs::MarkerArray map_marker_array;
+      PlannerHNS::ROSHelpers::ConvertFromRoadNetworkToAutowareVisualizeMapFormat(m_Map, map_marker_array);
+      pub_MapRviz.publish(map_marker_array);
+    }
+    else if (m_params.mapSource == PlannerHNS::MAP_FOLDER && !m_bKmlMap)
+    {
+      m_bKmlMap = true;
+      PlannerHNS::MappingHelpers::ConstructRoadNetworkFromDataFiles(m_params.KmlMapPath, m_Map, true);
+      visualization_msgs::MarkerArray map_marker_array;
+      PlannerHNS::ROSHelpers::ConvertFromRoadNetworkToAutowareVisualizeMapFormat(m_Map, map_marker_array);
+
+      pub_MapRviz.publish(map_marker_array);
+    }
+    else if (m_params.mapSource == PlannerHNS::MAP_AUTOWARE && !m_bKmlMap)
+    {
+      std::vector<UtilityHNS::AisanDataConnFileReader::DataConn> conn_data;;
+
+      if(m_MapRaw.GetVersion()==2)
+      {
+        std::cout << "Map Version 2" << endl;
+        m_bKmlMap = true;
+        PlannerHNS::MappingHelpers::ConstructRoadNetworkFromROSMessageV2(m_MapRaw.pLanes->m_data_list, m_MapRaw.pPoints->m_data_list,
+            m_MapRaw.pCenterLines->m_data_list, m_MapRaw.pIntersections->m_data_list,m_MapRaw.pAreas->m_data_list,
+            m_MapRaw.pLines->m_data_list, m_MapRaw.pStopLines->m_data_list,  m_MapRaw.pSignals->m_data_list,
+            m_MapRaw.pVectors->m_data_list, m_MapRaw.pCurbs->m_data_list, m_MapRaw.pRoadedges->m_data_list, m_MapRaw.pWayAreas->m_data_list,
+            m_MapRaw.pCrossWalks->m_data_list, m_MapRaw.pNodes->m_data_list, conn_data,
+            m_MapRaw.pLanes, m_MapRaw.pPoints, m_MapRaw.pNodes, m_MapRaw.pLines, PlannerHNS::GPSPoint(), m_Map, true, m_params.bEnableLaneChange, false);
+      }
+      else if(m_MapRaw.GetVersion()==1)
+      {
+        std::cout << "Map Version 1" << endl;
+        m_bKmlMap = true;
+        PlannerHNS::MappingHelpers::ConstructRoadNetworkFromROSMessage(m_MapRaw.pLanes->m_data_list, m_MapRaw.pPoints->m_data_list,
+            m_MapRaw.pCenterLines->m_data_list, m_MapRaw.pIntersections->m_data_list,m_MapRaw.pAreas->m_data_list,
+            m_MapRaw.pLines->m_data_list, m_MapRaw.pStopLines->m_data_list,  m_MapRaw.pSignals->m_data_list,
+            m_MapRaw.pVectors->m_data_list, m_MapRaw.pCurbs->m_data_list, m_MapRaw.pRoadedges->m_data_list, m_MapRaw.pWayAreas->m_data_list,
+            m_MapRaw.pCrossWalks->m_data_list, m_MapRaw.pNodes->m_data_list, conn_data,  PlannerHNS::GPSPoint(), m_Map, true, m_params.bEnableLaneChange, false);
+      }
+
+      if(m_bKmlMap)
+      {
+        visualization_msgs::MarkerArray map_marker_array;
+        PlannerHNS::ROSHelpers::ConvertFromRoadNetworkToAutowareVisualizeMapFormat(m_Map, map_marker_array);
+        pub_MapRviz.publish(map_marker_array);
+      }
+    }
+
+    ClearOldCostFromMap();
+
+//  std::cout<<" goal size : "<<m_GoalsPos.size() <<std::endl;
+    if(m_GoalsPos.size() > 0)
+    {
+      if(m_GeneratedTotalPaths.size() > 0 && m_GeneratedTotalPaths.at(0).size() > 3)
+      {
+        if(m_params.bEnableReplanning)
+        {
+          PlannerHNS::RelativeInfo info;
+          bool ret = PlannerHNS::PlanningHelpers::GetRelativeInfoRange(m_GeneratedTotalPaths, m_CurrentPose, 0.75, info);
+          if(ret == true && info.iGlobalPath >= 0 &&  info.iGlobalPath < m_GeneratedTotalPaths.size() && info.iFront > 0 && info.iFront < m_GeneratedTotalPaths.at(info.iGlobalPath).size())
+          {
+            double remaining_distance =    m_GeneratedTotalPaths.at(info.iGlobalPath).at(m_GeneratedTotalPaths.at(info.iGlobalPath).size()-1).cost - (m_GeneratedTotalPaths.at(info.iGlobalPath).at(info.iFront).cost + info.to_front_distance);
+            if(remaining_distance <= REPLANNING_DISTANCE)
+            {
+              bMakeNewPlan = true;
+              if(m_GoalsPos.size() > 0)
+                m_iCurrentGoalIndex = (m_iCurrentGoalIndex + 1) % m_GoalsPos.size();
+              std::cout << "Current Goal Index = " << m_iCurrentGoalIndex << std::endl << std::endl;
+            }
+          }
+        }
+      }
+      else
+        bMakeNewPlan = true;
+
+      if(bMakeNewPlan || (m_params.bEnableDynamicMapUpdate && UtilityHNS::UtilityH::GetTimeDiffNow(m_ReplnningTimer) > REPLANNING_TIME))
+      {
+        UtilityHNS::UtilityH::GetTickCount(m_ReplnningTimer);
+        PlannerHNS::WayPoint goalPoint = m_GoalsPos.at(m_iCurrentGoalIndex);
+        bool bNewPlan = GenerateGlobalPlan(m_CurrentPose, goalPoint, m_GeneratedTotalPaths);
+
+
+        if(bNewPlan)
+        {
+          bMakeNewPlan = false;
+          VisualizeAndSend(m_GeneratedTotalPaths);
+        }
+      }
+      VisualizeDestinations(m_GoalsPos, m_iCurrentGoalIndex);
+    }
+
+    loop_rate.sleep();
+  }
+}
+
+
+//Mapping Section
+
+void GlobalPlanner::callbackGetVMLanes(const vector_map_msgs::LaneArray& msg)
+{
+  std::cout << "Received Lanes" << msg.data.size() << endl;
+  if(m_MapRaw.pLanes == nullptr)
+    m_MapRaw.pLanes = new UtilityHNS::AisanLanesFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMPoints(const vector_map_msgs::PointArray& msg)
+{
+  std::cout << "Received Points" << msg.data.size() << endl;
+  if(m_MapRaw.pPoints  == nullptr)
+    m_MapRaw.pPoints = new UtilityHNS::AisanPointsFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMdtLanes(const vector_map_msgs::DTLaneArray& msg)
+{
+  std::cout << "Received dtLanes" << msg.data.size() << endl;
+  if(m_MapRaw.pCenterLines == nullptr)
+    m_MapRaw.pCenterLines = new UtilityHNS::AisanCenterLinesFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMIntersections(const vector_map_msgs::CrossRoadArray& msg)
+{
+  std::cout << "Received CrossRoads" << msg.data.size() << endl;
+  if(m_MapRaw.pIntersections == nullptr)
+    m_MapRaw.pIntersections = new UtilityHNS::AisanIntersectionFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMAreas(const vector_map_msgs::AreaArray& msg)
+{
+  std::cout << "Received Areas" << msg.data.size() << endl;
+  if(m_MapRaw.pAreas == nullptr)
+    m_MapRaw.pAreas = new UtilityHNS::AisanAreasFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMLines(const vector_map_msgs::LineArray& msg)
+{
+  std::cout << "Received Lines" << msg.data.size() << endl;
+  if(m_MapRaw.pLines == nullptr)
+    m_MapRaw.pLines = new UtilityHNS::AisanLinesFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMStopLines(const vector_map_msgs::StopLineArray& msg)
+{
+  std::cout << "Received StopLines" << msg.data.size() << endl;
+  if(m_MapRaw.pStopLines == nullptr)
+    m_MapRaw.pStopLines = new UtilityHNS::AisanStopLineFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMSignal(const vector_map_msgs::SignalArray& msg)
+{
+  std::cout << "Received Signals" << msg.data.size() << endl;
+  if(m_MapRaw.pSignals  == nullptr)
+    m_MapRaw.pSignals = new UtilityHNS::AisanSignalFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMVectors(const vector_map_msgs::VectorArray& msg)
+{
+  std::cout << "Received Vectors" << msg.data.size() << endl;
+  if(m_MapRaw.pVectors  == nullptr)
+    m_MapRaw.pVectors = new UtilityHNS::AisanVectorFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMCurbs(const vector_map_msgs::CurbArray& msg)
+{
+  std::cout << "Received Curbs" << msg.data.size() << endl;
+  if(m_MapRaw.pCurbs == nullptr)
+    m_MapRaw.pCurbs = new UtilityHNS::AisanCurbFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMRoadEdges(const vector_map_msgs::RoadEdgeArray& msg)
+{
+  std::cout << "Received Edges" << msg.data.size() << endl;
+  if(m_MapRaw.pRoadedges  == nullptr)
+    m_MapRaw.pRoadedges = new UtilityHNS::AisanRoadEdgeFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMWayAreas(const vector_map_msgs::WayAreaArray& msg)
+{
+  std::cout << "Received Wayareas" << msg.data.size() << endl;
+  if(m_MapRaw.pWayAreas  == nullptr)
+    m_MapRaw.pWayAreas = new UtilityHNS::AisanWayareaFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMCrossWalks(const vector_map_msgs::CrossWalkArray& msg)
+{
+  std::cout << "Received CrossWalks" << msg.data.size() << endl;
+  if(m_MapRaw.pCrossWalks == nullptr)
+    m_MapRaw.pCrossWalks = new UtilityHNS::AisanCrossWalkFileReader(msg);
+}
+
+void GlobalPlanner::callbackGetVMNodes(const vector_map_msgs::NodeArray& msg)
+{
+  std::cout << "Received Nodes" << msg.data.size() << endl;
+  if(m_MapRaw.pNodes == nullptr)
+    m_MapRaw.pNodes = new UtilityHNS::AisanNodesFileReader(msg);
+}
+
+}

+ 27 - 0
src/ros/catkin/src/op_global_planner/package.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<package format="2">
+  <name>op_global_planner</name>
+  <version>1.12.0</version>
+  <description>The OpenPlanner Global Planning package</description>
+  <maintainer email="yusuke.fujii@tier4.jp">Yusuke FUJII</maintainer>
+  <author email="hatem.darweesh@g.sp.m.is.nagoya-u.ac.jp">Hatem Darweesh</author>
+  <license>Apache 2</license>
+
+  <buildtool_depend>autoware_build_flags</buildtool_depend>
+  <buildtool_depend>catkin</buildtool_depend>
+  
+  <depend>autoware_can_msgs</depend>
+  <depend>geometry_msgs</depend>
+  <depend>message_generation</depend>
+  <depend>op_planner</depend>
+  <depend>op_ros_helpers</depend>
+  <depend>op_simu</depend>
+  <depend>op_utility</depend>
+  <depend>pcl_conversions</depend>
+  <depend>pcl_ros</depend>
+  <depend>roscpp</depend>
+  <depend>rospy</depend>
+  <depend>std_msgs</depend>
+  <depend>vector_map_msgs</depend>
+  <depend>libwaypoint_follower</depend>
+</package>

+ 2 - 0
src/ros/catkin/src/op_planner/src/MappingHelpers.cpp

@@ -996,6 +996,7 @@ Lane* MappingHelpers::GetClosestLaneFromMap(const WayPoint& pos, RoadNetwork& ma
   vector<pair<double, Lane*> > laneLinksList;
   double d = 0;
   double min_d = DBL_MAX;
+  //std::cout<<"road segmentt size: "<<map.roadSegments.size()<<std::endl;
   for(unsigned int j=0; j< map.roadSegments.size(); j ++)
   {
     for(unsigned int k=0; k< map.roadSegments.at(j).Lanes.size(); k ++)
@@ -1040,6 +1041,7 @@ Lane* MappingHelpers::GetClosestLaneFromMap(const WayPoint& pos, RoadNetwork& ma
     }
   }
 
+  //std::cout<<" min d : "<<min_d<<std::endl;;
   return closest_lane;
 }
 

+ 3 - 0
src/ros/catkin/src/op_planner/src/PlannerH.cpp

@@ -143,6 +143,7 @@ double PlannerH::PlanUsingDP(const WayPoint& start,
   PlannerHNS::WayPoint* pGoal = PlannerHNS::MappingHelpers::GetClosestWaypointFromMap(goalPos, map);
   bool bEnableGoalBranching = false;
 
+std::cout<<" Finding Near"<<std::endl;
   if(!pStart ||  !pGoal)
   {
     GPSPoint sp = start.pos;
@@ -151,6 +152,8 @@ double PlannerH::PlanUsingDP(const WayPoint& start,
     return 0;
   }
 
+  std::cout<<"Found Near."<<std::endl;
+
   if(!pStart->pLane || !pGoal->pLane)
   {
     cout << endl << "Error: PlannerH -> Null Lane, Start (" << pStart->pLane << ") and Goal (" << pGoal->pLane << ")" << endl;

+ 230 - 0
src/ros/catkin/src/op_ros_helpers/CHANGELOG.rst

@@ -0,0 +1,230 @@
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Changelog for package op_ros_helpers
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1.11.0 (2019-03-21)
+-------------------
+* Fix license notice in corresponding package.xml
+* Contributors: amc-nu
+
+1.10.0 (2019-01-17)
+-------------------
+* Fixes for catkin_make
+* Use colcon as the build tool (`#1704 <https://github.com/CPFL/Autoware/issues/1704>`_)
+  * Switch to colcon as the build tool instead of catkin
+  * Added cmake-target
+  * Added note about the second colcon call
+  * Added warning about catkin* scripts being deprecated
+  * Fix COLCON_OPTS
+  * Added install targets
+  * Update Docker image tags
+  * Message packages fixes
+  * Fix missing dependency
+* Fix Ros/ROS naming convention
+* Contributors: Esteve Fernandez, amc-nu
+
+1.9.1 (2018-11-06)
+------------------
+
+1.9.0 (2018-10-31)
+------------------
+* [fix] PascalCase messages (`#1408 <https://github.com/CPFL/Autoware/issues/1408>`_)
+  * Switch message files to pascal case
+  * Switch message names to pascal case in Runtime Manager
+  * Switch message names to pascal case in *.yaml
+  * Rename brake_cmd and steer_cmd to BrakeCmd and SteerCmd in main.yaml
+* Contributors: Esteve Fernandez
+
+1.8.0 (2018-08-31)
+------------------
+* [Fix] Moved C++11 flag to autoware_build_flags (`#1395 <https://github.com/CPFL/Autoware/pull/1395>`_)
+* [Feature] Makes sure that all binaries have their dependencies linked (`#1385 <https://github.com/CPFL/Autoware/pull/1385>`_)
+* Fix Vector Map parser problem, tested with three different maps
+  Fix Global Planning function for the new map modification
+  Add OpenPlanner Simulator for perception, traffic lights, cars
+  Add OpenPlanner new version to replace wp_planner and dp_planner
+  Remove unnecessary files from OpenPlanner libraries
+  Test Global and Local planning
+  Test Tracking node (kf_contour_track)
+  Test Simulation Nodes
+  Test Utility Nodes
+* Update op_utility files for csv files loading
+  Update MappingHelpers with latest modifications
+  Update PlanningHelpers with latest modifications
+  add op_common_param node, for setting OpenPlanner parameter for all related nodes such as lidar_kf_contour_track
+  Improve tracking by including size different in association function
+  Update way_planner, dp_planner for compatibility with new Mapping Modifications, Map format is backward compatible
+* Update OpenPlanner libraries (op_planner, op_utitity, op_ros_helpers)
+  Update ring ground filter with latest implementation
+  Update lidar_kf_contour_track with latest implementation
+  Add op_utilities nodes (op_bag_player, op_data_logger, op_pose2tf)
+  Modify autoware_msgs for OpenPlanner use (CloudCluster, DetectedObject, lane, waypoint)
+  Update UI computing.yaml for the new nodes and modifies parameters
+  Update UI sensing.yaml for updated ring_ground_filter params
+* Contributors: Esteve Fernandez, hatem-darweesh
+
+1.7.0 (2018-05-18)
+------------------
+* update Version from 1.6.3 to 1.7.0 in package.xml and CHANGELOG.rst
+* [fix] Fixes for all packages and dependencies (`#1240 <https://github.com/CPFL/Autoware/pull/1240>`_)
+  * Initial Cleanup
+  * fixed also for indigo
+  * kf cjeck
+  * Fix road wizard
+  * Added travis ci
+  * Trigger CI
+  * Fixes to cv_tracker and lidar_tracker cmake
+  * Fix kitti player dependencies
+  * Removed unnecessary dependencies
+  * messages fixing for can
+  * Update build script travis
+  * Travis Path
+  * Travis Paths fix
+  * Travis test
+  * Eigen checks
+  * removed unnecessary dependencies
+  * Eigen Detection
+  * Job number reduced
+  * Eigen3 more fixes
+  * More Eigen3
+  * Even more Eigen
+  * find package cmake modules included
+  * More fixes to cmake modules
+  * Removed non ros dependency
+  * Enable industrial_ci for indidog and kinetic
+  * Wrong install command
+  * fix rviz_plugin install
+  * FastVirtualScan fix
+  * Fix Qt5 Fastvirtualscan
+  * Fixed qt5 system dependencies for rosdep
+  * NDT TKU Fix catkin not pacakged
+  * More in detail dependencies fixes for more packages
+  * GLEW library for ORB
+  * Ignore OrbLocalizer
+  * Ignore Version checker
+  * Fix for driveworks interface
+  * driveworks not catkinpackagedd
+  * Missing catkin for driveworks
+  * libdpm opencv not catkin packaged
+  * catkin lib gnss  not included in obj_db
+  * Points2Polygon fix
+  * More missing dependencies
+  * image viewer not packaged
+  * Fixed SSH2 detection, added viewers for all distros
+  * Fix gnss localizer incorrect dependency config
+  * Fixes to multiple packages dependencies
+  * gnss plib and package
+  * More fixes to gnss
+  * gnss dependencies for gnss_loclaizer
+  * Missing gnss dependency for gnss on localizer
+  * More fixes for dependencies
+  Replaced gnss for autoware_gnss_library
+  * gnss more fixes
+  * fixes to more dependencies
+  * header dependency
+  * Debug message
+  * more debug messages changed back to gnss
+  * debud messages
+  * gnss test
+  * gnss install command
+  * Several fixes for OpenPlanner and its lbiraries
+  * Fixes to ROSInterface
+  * More fixes to robotsdk and rosinterface
+  * robotsdk calibration fix
+  * Fixes to rosinterface robotsdk libraries and its nodes
+  * Fixes to Qt5 missing dependencies in robotsdk
+  * glviewer missing dependencies
+  * Missing qt specific config cmake for robotsdk
+  * disable cv_tracker
+  * Fix to open planner un needed dependendecies
+  * Fixes for libraries indecision maker
+  * Fixes to libraries decision_maker installation
+  * Gazebo on Kinetic
+  * Added Missing library
+  * * Removed Gazebo and synchonization packages
+  * Renames vmap in lane_planner
+  * Added installation commands for missing pakcages
+  * Fixes to lane_planner
+  * Added NDT TKU Glut extra dependencies
+  * ndt localizer/lib fast pcl fixes
+  re enable cv_tracker
+  * Fix kf_lib
+  * Keep industrial_ci
+  * Fixes for dpm library
+  * Fusion lib fixed
+  * dpm and fusion header should match exported project name
+  * Fixes to dpm_ocv  ndt_localizer and pcl_omp
+  * no fast_pcl anymore
+  * fixes to libdpm and its package
+  * CI test
+  * test with native travis ci
+  * missing update for apt
+  * Fixes to pcl_omp installation and headers
+  * Final fixes for tests, modified README
+  * * Fixes to README
+  * Enable industrial_ci
+  * re enable native travis tests
+* Contributors: Abraham Monrroy, Kosuke Murakami
+
+1.6.3 (2018-03-06)
+------------------
+
+1.6.2 (2018-02-27)
+------------------
+* Update CHANGELOG
+* Contributors: Yusuke FUJII
+
+1.6.1 (2018-01-20)
+------------------
+* update CHANGELOG
+* Contributors: Yusuke FUJII
+
+1.6.0 (2017-12-11)
+------------------
+* Prepare release for 1.6.0
+* - Add new Node for object polygon representation and tracking (kf_contour_tracker)
+  - Add launch file and tune tracking parameters
+  - Test with Moriyama rosbag
+* - Update OpenPlanner libraries (plannerh, simuh, utilityh) with the latest modifications
+  - Fix inconsistency after library update, make sure old (way_planner, dp_planner) are working fine
+  - Create new package (op_local_planner)
+  - Create common launch file for local planning params
+  - Create new node (op_trajectory_generator)
+  - Create launch file for trajectory generation only
+  - Test generating trajectories (rollouts) in simulation with way_planner
+  - Test generating trajectories with real rosbag data with way_planner
+  - Test generating trajectories with real rosbag data and waypoints_loader
+* Contributors: Yamato ANDO, hatem-darweesh
+
+1.5.1 (2017-09-25)
+------------------
+
+1.5.0 (2017-09-21)
+------------------
+
+1.4.0 (2017-08-04)
+------------------
+
+1.3.1 (2017-07-16)
+------------------
+
+1.3.0 (2017-07-14)
+------------------
+
+1.2.0 (2017-06-07)
+------------------
+
+1.1.2 (2017-02-27 23:10)
+------------------------
+
+1.1.1 (2017-02-27 22:25)
+------------------------
+
+1.1.0 (2017-02-24)
+------------------
+
+1.0.1 (2017-01-14)
+------------------
+
+1.0.0 (2016-12-22)
+------------------

+ 64 - 0
src/ros/catkin/src/op_ros_helpers/CMakeLists.txt

@@ -0,0 +1,64 @@
+cmake_minimum_required(VERSION 2.8.3)
+
+project(op_ros_helpers)
+
+find_package(autoware_build_flags REQUIRED)
+
+find_package(catkin REQUIRED COMPONENTS
+  autoware_msgs
+  geometry_msgs
+  jsk_recognition_msgs
+  libwaypoint_follower
+  map_file
+  op_planner
+  op_simu
+  op_utility
+  pcl_conversions
+  pcl_ros
+  sensor_msgs
+  tf
+  vector_map_msgs
+)
+
+catkin_package(
+  INCLUDE_DIRS include
+  LIBRARIES ${PROJECT_NAME}
+  CATKIN_DEPENDS
+    autoware_msgs
+    geometry_msgs
+    libwaypoint_follower
+    vector_map_msgs
+)
+
+set(CMAKE_CXX_FLAGS "-O2 -g -Wall -Wno-unused-result ${CMAKE_CXX_FLAGS}")
+
+include_directories(
+  include
+  ${catkin_INCLUDE_DIRS}
+)
+
+set(ROS_HELPERS_SRC
+  src/PolygonGenerator.cpp
+  src/op_ROSHelpers.cpp
+)
+
+## Declare a cpp library
+add_library(${PROJECT_NAME}
+  ${ROS_HELPERS_SRC}
+)
+
+target_link_libraries(${PROJECT_NAME}
+  ${catkin_LIBRARIES}
+)
+
+install(DIRECTORY include/${PROJECT_NAME}/
+  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
+  FILES_MATCHING PATTERN "*.h"
+)
+
+
+install(TARGETS ${PROJECT_NAME}
+  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
+)

+ 94 - 0
src/ros/catkin/src/op_ros_helpers/include/op_ros_helpers/PolygonGenerator.h

@@ -0,0 +1,94 @@
+/// \file  PolygonGenerator.h
+/// \brief Generate convex hull from point cloud cluster of detected object
+/// \author Hatem Darweesh
+/// \date Nov 2, 2016
+
+#ifndef OP_POLYGONGENERATOR_H_
+#define OP_POLYGONGENERATOR_H_
+
+#include "op_planner/RoadNetwork.h"
+#include <sensor_msgs/PointCloud2.h>
+#include <visualization_msgs/Marker.h>
+#include <pcl_conversions/pcl_conversions.h>
+#include <pcl/io/io.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/point_types.h>
+
+namespace PlannerHNS
+{
+
+class QuarterView
+{
+public:
+  int id;
+  int min_ang;
+  int max_ang;
+  WayPoint max_from_center;
+  bool bFirst;
+
+  QuarterView(const int& min_a, const int& max_a, const int& index)
+  {
+    min_ang = min_a;
+    max_ang = max_a;
+    id = index;
+    bFirst = true;
+  }
+
+  void InitQuarterView(const int& min_a, const int& max_a, const int& index)
+  {
+    min_ang = min_a;
+    max_ang = max_a;
+    id = index;
+    bFirst = true;
+  }
+
+  void ResetQuarterView()
+  {
+    bFirst = true;
+  }
+
+  bool UpdateQuarterView(const WayPoint& v)
+  {
+    if(v.pos.a <= min_ang || v.pos.a > max_ang)
+      return false;
+
+    if(bFirst)
+    {
+      max_from_center = v;
+      bFirst = false;
+    }
+    else if(v.cost > max_from_center.cost)
+      max_from_center = v;
+
+    return true;
+  }
+
+  bool GetMaxPoint(WayPoint& maxPoint)
+  {
+    if(bFirst)
+      return false;
+    else
+      maxPoint = max_from_center;
+
+    return true;
+  }
+};
+
+class PolygonGenerator
+{
+
+public:
+
+  GPSPoint m_Centroid;
+  std::vector<QuarterView> m_Quarters;
+  std::vector<GPSPoint> m_Polygon;
+
+  PolygonGenerator(int nQuarters);
+  virtual ~PolygonGenerator();
+  std::vector<QuarterView> CreateQuarterViews(const int& nResolution);
+  std::vector<GPSPoint> EstimateClusterPolygon(const pcl::PointCloud<pcl::PointXYZ>& cluster, const GPSPoint& original_centroid, GPSPoint& new_centroid, const double& polygon_resolution = 1.0);
+};
+
+} /* namespace PlannerXNS */
+
+#endif /* OP_POLYGONGENERATOR_H_ */

+ 288 - 0
src/ros/catkin/src/op_ros_helpers/include/op_ros_helpers/op_ROSHelpers.h

@@ -0,0 +1,288 @@
+/// \file  ROSHelpers.h
+/// \brief Helper functions for rviz visualization
+/// \author Hatem Darweesh
+/// \date Jun 30, 2016
+
+#ifndef OP_ROSHELPERS_H_
+#define OP_ROSHELPERS_H_
+
+#include <ros/ros.h>
+#include "op_planner/RoadNetwork.h"
+#include "op_planner/PlannerCommonDef.h"
+#include "op_planner/LocalPlannerH.h"
+
+#include "vector_map_msgs/PointArray.h"
+#include "vector_map_msgs/LaneArray.h"
+#include "vector_map_msgs/NodeArray.h"
+#include "vector_map_msgs/StopLineArray.h"
+#include "vector_map_msgs/DTLaneArray.h"
+#include "vector_map_msgs/LineArray.h"
+#include "vector_map_msgs/AreaArray.h"
+#include "vector_map_msgs/SignalArray.h"
+#include "vector_map_msgs/StopLine.h"
+#include "vector_map_msgs/VectorArray.h"
+
+#include <geometry_msgs/Vector3Stamped.h>
+#include <geometry_msgs/PoseWithCovarianceStamped.h>
+#include <geometry_msgs/PoseStamped.h>
+
+#include <jsk_recognition_msgs/BoundingBox.h>
+#include <jsk_recognition_msgs/BoundingBoxArray.h>
+#include <pcl_conversions/pcl_conversions.h>
+#include <pcl/io/io.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/point_types.h>
+
+#include "autoware_msgs/CloudClusterArray.h"
+#include "autoware_msgs/DetectedObjectArray.h"
+
+#include "libwaypoint_follower/libwaypoint_follower.h"
+#include "autoware_msgs/LaneArray.h"
+
+#include <visualization_msgs/MarkerArray.h>
+
+#include <tf/transform_broadcaster.h>
+#include <tf/transform_listener.h>
+#include <tf/tf.h>
+
+namespace PlannerHNS
+{
+
+class AutowareRoadNetwork
+{
+public:
+  vector_map_msgs::PointArray   points;
+  vector_map_msgs::LaneArray     lanes;
+  vector_map_msgs::NodeArray     nodes;
+  vector_map_msgs::StopLineArray   stoplines;
+  vector_map_msgs::DTLaneArray   dtlanes; //center lines
+  bool bPoints;
+  bool bLanes;
+  bool bNodes;
+  bool bStopLines;
+  bool bDtLanes;
+
+  AutowareRoadNetwork()
+  {
+    bPoints   = false;
+    bLanes    = false;
+    bStopLines   = false;
+    bDtLanes    = false;
+    bNodes     = false;
+  }
+};
+
+enum AUTOWARE_STATE_TYPE {AW_INITIAL_STATE, AW_WAITING_STATE, AW_FORWARD_STATE, AW_STOPPING_STATE, AW_EMERGENCY_STATE,
+  AW_TRAFFIC_LIGHT_STOP_STATE, AW_STOP_SIGN_STOP_STATE, AW_FOLLOW_STATE, AW_LANE_CHANGE_STATE, AW_OBSTACLE_AVOIDANCE_STATE, AW_FINISH_STATE};
+enum AUTOWARE_LIGHT_INDICATOR {AW_INDICATOR_LEFT, AW_INDICATOR_RIGHT, AW_INDICATOR_BOTH , AW_INDICATOR_NONE};
+enum AUTOWARE_SHIFT_POS {AW_SHIFT_POS_PP = 0x60, AW_SHIFT_POS_RR = 0x40, AW_SHIFT_POS_NN = 0x20,
+  AW_SHIFT_POS_DD = 0x10, AW_SHIFT_POS_BB = 0xA0, AW_SHIFT_POS_SS = 0x0f, AW_SHIFT_POS_UU = 0xff };
+
+class AutowareBehaviorState
+{
+public:
+  AUTOWARE_STATE_TYPE state;
+  double maxVelocity;
+  double minVelocity;
+  double stopDistance;
+  double followVelocity;
+  double followDistance;
+  AUTOWARE_LIGHT_INDICATOR indicator;
+
+  AutowareBehaviorState()
+  {
+    state = AW_INITIAL_STATE;
+    maxVelocity = 0;
+    minVelocity = 0;
+    stopDistance = 0;
+    followVelocity = 0;
+    followDistance = 0;
+    indicator  = AW_INDICATOR_NONE;
+  }
+};
+
+class AutowareVehicleState
+{
+public:
+  double speed;
+  double steer;
+  AUTOWARE_SHIFT_POS shift;
+
+  AutowareVehicleState()
+  {
+    speed = 0;
+    steer = 0;
+    shift = AW_SHIFT_POS_NN;
+  }
+};
+
+class AutowarePlanningParams
+{
+public:
+  double   maxSpeed;
+  double   minSpeed;
+  double   planningDistance;
+  double   microPlanDistance;
+  double   carTipMargin;
+  double   rollInMargin;
+  double   rollInSpeedFactor;
+  double   pathDensity;
+  double   rollOutDensity;
+  int   rollOutNumber;
+  double   horizonDistance;
+  double   minFollowingDistance;
+  double   maxFollowingDistance;
+  double   minDistanceToAvoid;
+  double   speedProfileFactor;
+
+  bool   enableLaneChange;
+  bool   enableSwerving;
+  bool   enableFollowing;
+  bool   enableHeadingSmoothing;
+  bool   enableTrafficLightBehavior;
+
+  AutowarePlanningParams()
+  {
+    maxSpeed             = 3;
+    minSpeed             = 0;
+    planningDistance         = 10000;
+    microPlanDistance         = 35;
+    carTipMargin          = 8.0;
+    rollInMargin          = 20.0;
+    rollInSpeedFactor        = 0.25;
+    pathDensity            = 0.25;
+    rollOutDensity          = 0.5;
+    rollOutNumber          = 4;
+    horizonDistance          = 120;
+    minFollowingDistance      = 35;
+    maxFollowingDistance      = 40;
+    minDistanceToAvoid        = 15;
+    speedProfileFactor        = 1.0;
+
+    enableHeadingSmoothing      = false;
+    enableSwerving           = false;
+    enableFollowing          = false;
+    enableTrafficLightBehavior    = false;
+    enableLaneChange         = false;
+  }
+};
+
+class ROSHelpers
+{
+public:
+  ROSHelpers();
+  virtual ~ROSHelpers();
+
+  static void GetTransformFromTF(const std::string parent_frame, const std::string child_frame, tf::StampedTransform &transform);
+
+  static void ConvertFromAutowareCloudClusterObstaclesToPlannerH(const PlannerHNS::WayPoint& currState, const double& car_width,
+      const double& car_length, const autoware_msgs::CloudClusterArray& clusters,
+      std::vector<PlannerHNS::DetectedObject>& impObstacles, const double max_obj_size, const double& min_obj_size, const double& detection_radius,
+      const int& n_poly_quarters,const double& poly_resolution, int& nOriginalPoints, int& nContourPoints);
+
+  static visualization_msgs::Marker CreateGenMarker(const double& x, const double& y, const double& z,const double& a,
+      const double& r, const double& g, const double& b, const double& scale, const int& id, const std::string& ns, const int& type);
+
+  static void InitMatchingMarkers(const int& nMarkers, visualization_msgs::MarkerArray& connections);
+
+  static void ConvertMatchingMarkers(const std::vector<std::pair<PlannerHNS::WayPoint, PlannerHNS::WayPoint> >& match_list,
+      visualization_msgs::MarkerArray& tracked_traj_d, visualization_msgs::MarkerArray& tracked_traj, int start_id=0);
+
+  static void InitMarkers(const int& nMarkers,
+      visualization_msgs::MarkerArray& centers,
+      visualization_msgs::MarkerArray& dirs,
+      visualization_msgs::MarkerArray& text_info,
+      visualization_msgs::MarkerArray& polygons,
+      visualization_msgs::MarkerArray& trajectories);
+
+  static int ConvertTrackedObjectsMarkers(const PlannerHNS::WayPoint& currState, const std::vector<PlannerHNS::DetectedObject>& trackedObstacles,
+      visualization_msgs::MarkerArray& centers_d,
+      visualization_msgs::MarkerArray& dirs_d,
+      visualization_msgs::MarkerArray& text_info_d,
+      visualization_msgs::MarkerArray& polygons_d,
+      visualization_msgs::MarkerArray& tracked_traj_d,
+      visualization_msgs::MarkerArray& centers,
+      visualization_msgs::MarkerArray& dirs,
+      visualization_msgs::MarkerArray& text_info,
+      visualization_msgs::MarkerArray& polygons,
+      visualization_msgs::MarkerArray& tracked_traj);
+
+  static void CreateCircleMarker(const PlannerHNS::WayPoint& _center, const double& radius, const int& start_id, visualization_msgs::Marker& circle_points);
+
+  static void InitPredMarkers(const int& nMarkers, visualization_msgs::MarkerArray& paths);
+
+  static void InitCurbsMarkers(const int& nMarkers, visualization_msgs::MarkerArray& curbs);
+
+  static void ConvertPredictedTrqajectoryMarkers(std::vector<std::vector<PlannerHNS::WayPoint> >& paths,visualization_msgs::MarkerArray& path_markers, visualization_msgs::MarkerArray& path_markers_d);
+
+  static void ConvertCurbsMarkers(const std::vector<PlannerHNS::DetectedObject>& curbs, visualization_msgs::MarkerArray& curbs_markers, visualization_msgs::MarkerArray& curbs_markers_d);
+
+  static void TrajectoriesToMarkers(const std::vector<std::vector<std::vector<PlannerHNS::WayPoint> > >& paths, visualization_msgs::MarkerArray& markerArray);
+
+  static void TrajectoriesToColoredMarkers(const std::vector<std::vector<PlannerHNS::WayPoint> >& paths,const std::vector<PlannerHNS::TrajectoryCost>& traj_costs, const int& iClosest, visualization_msgs::MarkerArray& markerArray);
+
+  static void InitCollisionPointsMarkers(const int& nMarkers, visualization_msgs::MarkerArray& col_points);
+
+  static void ConvertCollisionPointsMarkers(const std::vector<PlannerHNS::WayPoint>& col_pointss, visualization_msgs::MarkerArray& collision_markers, visualization_msgs::MarkerArray& collision_markers_d);
+
+  static void InitPredParticlesMarkers(const int& nMarkers, visualization_msgs::MarkerArray& paths);
+
+  static void ConvertParticles(std::vector<PlannerHNS::WayPoint>& points, visualization_msgs::MarkerArray& part_mkrs, visualization_msgs::MarkerArray& part_markers_d);
+
+  static void ConvertFromPlannerHToAutowarePathFormat(const std::vector<PlannerHNS::WayPoint>& path, const int& iStart,
+        autoware_msgs::Lane & trajectory);
+
+  static void ConvertFromPlannerHRectangleToAutowareRviz(const std::vector<PlannerHNS::GPSPoint>& safety_rect,
+      visualization_msgs::Marker& marker);
+
+  static void ConvertFromPlannerHToAutowareVisualizePathFormat(const std::vector<PlannerHNS::WayPoint>& curr_path,
+      const std::vector<std::vector<std::vector<PlannerHNS::WayPoint> > >& paths, const PlannerHNS::LocalPlannerH& localPlanner,
+        visualization_msgs::MarkerArray& markerArray);
+
+  static void ConvertFromPlannerHToAutowareVisualizePathFormat(const std::vector<std::vector<PlannerHNS::WayPoint> >& globalPaths, visualization_msgs::MarkerArray& markerArray);
+
+  static void ConvertFromRoadNetworkToAutowareVisualizeMapFormat(const PlannerHNS::RoadNetwork& map,  visualization_msgs::MarkerArray& markerArray);
+
+  static void ConvertFromAutowareBoundingBoxObstaclesToPlannerH(const jsk_recognition_msgs::BoundingBoxArray& detectedObstacles,
+      std::vector<PlannerHNS::DetectedObject>& impObstacles);
+
+  static void ConvertFromPlannerObstaclesToAutoware(const PlannerHNS::WayPoint& currState, const std::vector<PlannerHNS::DetectedObject>& trackedObstacles,
+      visualization_msgs::MarkerArray& detectedPolygons);
+
+  static void ConvertFromLocalLaneToAutowareLane(const std::vector<PlannerHNS::WayPoint>& path, autoware_msgs::Lane& trajectory , const unsigned int& iStart = 0);
+
+  static void ConvertFromLocalLaneToAutowareLane(const std::vector<PlannerHNS::GPSPoint>& path, autoware_msgs::Lane& trajectory);
+
+  static void ConvertFromAutowareLaneToLocalLane(const autoware_msgs::Lane& trajectory, std::vector<PlannerHNS::WayPoint>& path);
+
+  static void createGlobalLaneArrayMarker(std_msgs::ColorRGBA color, const autoware_msgs::LaneArray &lane_waypoints_array, visualization_msgs::MarkerArray& markerArray);
+
+  static void createGlobalLaneArrayVelocityMarker(const autoware_msgs::LaneArray &lane_waypoints_array , visualization_msgs::MarkerArray& markerArray);
+
+  static void createGlobalLaneArrayOrientationMarker(const autoware_msgs::LaneArray &lane_waypoints_array , visualization_msgs::MarkerArray& markerArray);
+
+  static void GetTrafficLightForVisualization(std::vector<PlannerHNS::TrafficLight>& lights, visualization_msgs::MarkerArray& markerArray);
+
+  static void ConvertFromAutowareDetectedObjectToOpenPlannerDetectedObject(const autoware_msgs::DetectedObject& det_obj, PlannerHNS::DetectedObject& obj);
+
+  static void ConvertFromOpenPlannerDetectedObjectToAutowareDetectedObject(const PlannerHNS::DetectedObject& det_obj, const bool& bSimulationMode, autoware_msgs::DetectedObject& obj);
+
+  static PlannerHNS::SHIFT_POS ConvertShiftFromAutowareToPlannerH(const PlannerHNS::AUTOWARE_SHIFT_POS& shift);
+
+  static PlannerHNS::AUTOWARE_SHIFT_POS ConvertShiftFromPlannerHToAutoware(const PlannerHNS::SHIFT_POS& shift);
+
+  static PlannerHNS::AutowareBehaviorState ConvertBehaviorStateFromPlannerHToAutoware(const PlannerHNS::BehaviorState& beh);
+
+  static std::string GetBehaviorNameFromCode(const PlannerHNS::STATE_TYPE& behState);
+
+  static void VisualizeBehaviorState(const PlannerHNS::WayPoint& currState, const PlannerHNS::BehaviorState& beh, const bool& bGreenLight, const int& avoidDirection, visualization_msgs::Marker& behaviorMarker, std::string ns,double size_factor = 1);
+
+  static void UpdateRoadMap(const AutowareRoadNetwork& src_map, PlannerHNS::RoadNetwork& out_map);
+
+  static void GetIndicatorArrows(const PlannerHNS::WayPoint& center, const double& width,const double& length, const PlannerHNS::LIGHT_INDICATOR& indicator, const int& id,visualization_msgs::MarkerArray& markerArray);
+
+  static void TTC_PathRviz(const std::vector<PlannerHNS::WayPoint>& path, visualization_msgs::MarkerArray& markerArray);
+};
+
+}
+#endif /* ROSHELPERS_H_ */

+ 26 - 0
src/ros/catkin/src/op_ros_helpers/package.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<package format="2">
+  <name>op_ros_helpers</name>
+  <version>1.12.0</version>
+  <description>Helper functions for OpenPlanner visualization package</description>
+  <maintainer email="yusuke.fujii@tier4.jp">Yusuke FUJII</maintainer>
+  <author email="hatem.darweesh@g.sp.m.is.nagoya-u.ac.jp">Hatem Darweesh</author>
+  <license>Apache 2</license>
+
+  <buildtool_depend>autoware_build_flags</buildtool_depend>
+  <buildtool_depend>catkin</buildtool_depend>
+
+  <depend>autoware_msgs</depend>
+  <depend>geometry_msgs</depend>
+  <depend>jsk_recognition_msgs</depend>
+  <depend>map_file</depend>
+  <depend>op_planner</depend>
+  <depend>op_simu</depend>
+  <depend>op_utility</depend>
+  <depend>pcl_conversions</depend>
+  <depend>pcl_ros</depend>
+  <depend>sensor_msgs</depend>
+  <depend>tf</depend>
+  <depend>vector_map_msgs</depend>
+  <depend>libwaypoint_follower</depend>
+</package>

+ 112 - 0
src/ros/catkin/src/op_ros_helpers/src/PolygonGenerator.cpp

@@ -0,0 +1,112 @@
+/// \file  PolygonGenerator.cpp
+/// \brief Generate convex hull from point cloud cluster of detected object
+/// \author Hatem Darweesh
+/// \date Nov 2, 2016
+
+#include "op_ros_helpers/PolygonGenerator.h"
+#include "op_planner/PlanningHelpers.h"
+
+namespace PlannerHNS
+{
+
+PolygonGenerator::PolygonGenerator(int nQuarters)
+{
+  m_Quarters = CreateQuarterViews(nQuarters);
+}
+
+PolygonGenerator::~PolygonGenerator()
+{
+}
+
+std::vector<GPSPoint> PolygonGenerator::EstimateClusterPolygon(const pcl::PointCloud<pcl::PointXYZ>& cluster, const GPSPoint& original_centroid, GPSPoint& new_centroid, const double& polygon_resolution)
+{
+  for(unsigned int i=0; i < m_Quarters.size(); i++)
+      m_Quarters.at(i).ResetQuarterView();
+
+  WayPoint p;
+  for(unsigned int i=0; i< cluster.points.size(); i++)
+  {
+    p.pos.x = cluster.points.at(i).x;
+    p.pos.y = cluster.points.at(i).y;
+    p.pos.z = original_centroid.z;
+
+    GPSPoint v(p.pos.x - original_centroid.x , p.pos.y - original_centroid.y, 0, 0);
+    p.cost = pointNorm(v);
+    p.pos.a = UtilityHNS::UtilityH::FixNegativeAngle(atan2(v.y, v.x))*(180. / M_PI);
+
+    for(unsigned int j = 0 ; j < m_Quarters.size(); j++)
+    {
+      if(m_Quarters.at(j).UpdateQuarterView(p))
+        break;
+    }
+  }
+
+  m_Polygon.clear();
+  WayPoint wp;
+  for(unsigned int j = 0 ; j < m_Quarters.size(); j++)
+  {
+    if(m_Quarters.at(j).GetMaxPoint(wp))
+      m_Polygon.push_back(wp.pos);
+  }
+
+//  //Fix Resolution:
+  bool bChange = true;
+  while (bChange && m_Polygon.size()>1)
+  {
+    bChange = false;
+    GPSPoint p1 =  m_Polygon.at(m_Polygon.size()-1);
+    for(unsigned int i=0; i< m_Polygon.size(); i++)
+    {
+      GPSPoint p2 = m_Polygon.at(i);
+      double d = hypot(p2.y- p1.y, p2.x - p1.x);
+      if(d > polygon_resolution)
+      {
+        GPSPoint center_p = p1;
+        center_p.x = (p2.x + p1.x)/2.0;
+        center_p.y = (p2.y + p1.y)/2.0;
+        m_Polygon.insert(m_Polygon.begin()+i, center_p);
+        bChange = true;
+        break;
+      }
+
+      p1 = p2;
+    }
+  }
+  GPSPoint sum_p;
+  for(unsigned int i = 0 ; i< m_Polygon.size(); i++)
+  {
+    sum_p.x += m_Polygon.at(i).x;
+    sum_p.y += m_Polygon.at(i).y;
+  }
+
+  new_centroid = original_centroid;
+
+  if(m_Polygon.size() > 0)
+  {
+    new_centroid.x = sum_p.x / (double)m_Polygon.size();
+    new_centroid.y = sum_p.y / (double)m_Polygon.size();
+  }
+
+  return m_Polygon;
+
+}
+
+std::vector<QuarterView> PolygonGenerator::CreateQuarterViews(const int& nResolution)
+{
+  std::vector<QuarterView> quarters;
+  if(nResolution <= 0)
+    return quarters;
+
+  double range = 360.0 / nResolution;
+  double angle = 0;
+  for(int i = 0; i < nResolution; i++)
+  {
+    QuarterView q(angle, angle+range, i);
+    quarters.push_back(q);
+    angle+=range;
+  }
+
+  return quarters;
+}
+
+} /* namespace PlannerXNS */

+ 1851 - 0
src/ros/catkin/src/op_ros_helpers/src/op_ROSHelpers.cpp

@@ -0,0 +1,1851 @@
+/// \file  ROSHelpers.cpp
+/// \brief Helper functions for rviz visualization
+/// \author Hatem Darweesh
+/// \date Jun 30, 2016
+
+#include "op_ros_helpers/op_ROSHelpers.h"
+
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <math.h>
+#include "op_ros_helpers/PolygonGenerator.h"
+#include "op_planner/MappingHelpers.h"
+#include "op_planner/MatrixOperations.h"
+
+
+namespace PlannerHNS
+{
+
+ROSHelpers::ROSHelpers() {
+
+}
+
+ROSHelpers::~ROSHelpers() {
+}
+
+void ROSHelpers::GetTransformFromTF(const std::string parent_frame, const std::string child_frame, tf::StampedTransform &transform)
+{
+  static tf::TransformListener listener;
+
+  int nFailedCounter = 0;
+  while (1)
+  {
+    try
+    {
+      listener.lookupTransform(parent_frame, child_frame, ros::Time(0), transform);
+      break;
+    }
+    catch (tf::TransformException& ex)
+    {
+      if(nFailedCounter > 2)
+      {
+        ROS_ERROR("%s", ex.what());
+      }
+      ros::Duration(1.0).sleep();
+      nFailedCounter ++;
+    }
+  }
+}
+
+visualization_msgs::Marker ROSHelpers::CreateGenMarker(const double& x, const double& y, const double& z,const double& a,
+    const double& r, const double& g, const double& b, const double& scale, const int& id, const std::string& ns, const int& type)
+{
+  visualization_msgs::Marker mkr;
+  mkr.header.frame_id = "map";
+  mkr.header.stamp = ros::Time();
+  mkr.ns = ns;
+  mkr.type = type;
+  mkr.action = visualization_msgs::Marker::ADD;
+  mkr.scale.x = scale;
+  mkr.scale.y = scale;
+  mkr.scale.z = scale;
+  mkr.color.a = 0.8;
+  mkr.color.r = r;
+  mkr.color.g = g;
+  mkr.color.b = b;
+  mkr.pose.position.x = x;
+  mkr.pose.position.y = y;
+  mkr.pose.position.z = z;
+  mkr.pose.orientation = tf::createQuaternionMsgFromYaw(a);
+  mkr.id = id;
+  return mkr;
+}
+
+void ROSHelpers::InitMarkers(const int& nMarkers,
+    visualization_msgs::MarkerArray& centers,
+    visualization_msgs::MarkerArray& dirs,
+    visualization_msgs::MarkerArray& text_info,
+    visualization_msgs::MarkerArray& polygons,
+    visualization_msgs::MarkerArray& trajectories)
+{
+  centers.markers.clear();
+  dirs.markers.clear();
+  text_info.markers.clear();
+  polygons.markers.clear();
+  trajectories.markers.clear();
+
+  for(int i=0; i<nMarkers; i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(0,0,0,0,1,1,1,1,i,"CenterMarker", visualization_msgs::Marker::SPHERE);
+    centers.markers.push_back(mkr);
+  }
+
+  for(int i=nMarkers; i<nMarkers*2; i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(0,0,0,0,1,1,1,1,i,"Directions", visualization_msgs::Marker::ARROW);
+    dirs.markers.push_back(mkr);
+  }
+
+  for(int i=nMarkers*2; i<nMarkers*3; i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(0,0,0,0,1,1,1,1,i,"InfoText", visualization_msgs::Marker::TEXT_VIEW_FACING);
+    text_info.markers.push_back(mkr);
+  }
+
+  for(int i=nMarkers*3; i<nMarkers*4; i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(0,0,0,0,1,1,1,1,i,"detected_polygons", visualization_msgs::Marker::LINE_STRIP);
+    polygons.markers.push_back(mkr);
+  }
+
+  for(int i=nMarkers*4; i<nMarkers*5; i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(0,0,0,0,1,1,1,1,i,"tracked_trajectories", visualization_msgs::Marker::LINE_STRIP);
+    trajectories.markers.push_back(mkr);
+  }
+}
+
+void ROSHelpers::InitMatchingMarkers(const int& nMarkers, visualization_msgs::MarkerArray& connections)
+{
+  connections.markers.clear();
+  for(int i=0; i<nMarkers; i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(0,0,0,0,1,1,1,1,i,"matching_connections", visualization_msgs::Marker::LINE_STRIP);
+    connections.markers.push_back(mkr);
+  }
+}
+
+void ROSHelpers::ConvertMatchingMarkers(const std::vector<std::pair<PlannerHNS::WayPoint, PlannerHNS::WayPoint> >& match_list,
+    visualization_msgs::MarkerArray& tracked_traj_d, visualization_msgs::MarkerArray& tracked_traj, int start_id)
+{
+
+  tracked_traj = tracked_traj_d;
+
+  for(unsigned int i = 0; i < match_list.size(); i++)
+  {
+    visualization_msgs::Marker match_mkr = CreateGenMarker(0,0,0,0,1,0,0,0.2, start_id+i,"matching_connections", visualization_msgs::Marker::LINE_STRIP);
+    geometry_msgs::Point point;
+    point.x = match_list.at(i).first.pos.x;
+    point.y = match_list.at(i).first.pos.y;
+    point.z = match_list.at(i).first.pos.z;
+    match_mkr.points.push_back(point);
+
+    point.x = match_list.at(i).second.pos.x;
+    point.y = match_list.at(i).second.pos.y;
+    point.z = match_list.at(i).second.pos.z;
+    match_mkr.points.push_back(point);
+
+    if(i < tracked_traj.markers.size())
+      tracked_traj.markers.at(i) = match_mkr;
+    else
+      tracked_traj.markers.push_back(match_mkr);
+  }
+}
+
+int ROSHelpers::ConvertTrackedObjectsMarkers(const PlannerHNS::WayPoint& currState, const std::vector<PlannerHNS::DetectedObject>& trackedObstacles,
+    visualization_msgs::MarkerArray& centers_d,
+    visualization_msgs::MarkerArray& dirs_d,
+    visualization_msgs::MarkerArray& text_info_d,
+    visualization_msgs::MarkerArray& polygons_d,
+    visualization_msgs::MarkerArray& tracked_traj_d,
+    visualization_msgs::MarkerArray& centers,
+    visualization_msgs::MarkerArray& dirs,
+    visualization_msgs::MarkerArray& text_info,
+    visualization_msgs::MarkerArray& polygons,
+    visualization_msgs::MarkerArray& tracked_traj)
+{
+
+  int i_next_id = 0;
+  centers = centers_d;
+  dirs = dirs_d;
+  text_info = text_info_d;
+  polygons = polygons_d;
+  tracked_traj = tracked_traj_d;
+
+  for(unsigned int i =0; i < trackedObstacles.size(); i++)
+  {
+    int speed = (trackedObstacles.at(i).center.v*3.6);
+
+    //Update Stage
+    visualization_msgs::Marker center_mkr = CreateGenMarker(trackedObstacles.at(i).center.pos.x,trackedObstacles.at(i).center.pos.y,trackedObstacles.at(i).center.pos.z,
+        trackedObstacles.at(i).center.pos.a,1,0,0,0.5,i,"CenterMarker", visualization_msgs::Marker::SPHERE);
+    if(i < centers.markers.size())
+    {
+      center_mkr.id = centers.markers.at(i).id;
+      centers.markers.at(i) = center_mkr;
+    }
+    else
+      centers.markers.push_back(center_mkr);
+
+    //Directions
+    if(trackedObstacles.at(i).bDirection)
+    {
+      visualization_msgs::Marker dir_mkr = CreateGenMarker(trackedObstacles.at(i).center.pos.x,trackedObstacles.at(i).center.pos.y,trackedObstacles.at(i).center.pos.z+0.5,
+          trackedObstacles.at(i).center.pos.a,0,1,0,0.3,centers.markers.size()+i,"Directions", visualization_msgs::Marker::ARROW);
+      dir_mkr.scale.x = 0.4;
+      if(i < dirs.markers.size())
+      {
+        dir_mkr.id = dirs.markers.at(i).id;
+        dirs.markers.at(i) = dir_mkr;
+      }
+      else
+        dirs.markers.push_back(dir_mkr);
+    }
+
+
+    //Text
+    visualization_msgs::Marker text_mkr;
+//    if(speed > 3.0)
+//      text_mkr = CreateGenMarker(trackedObstacles.at(i).center.pos.x+0.5,trackedObstacles.at(i).center.pos.y+0.5,trackedObstacles.at(i).center.pos.z+1,
+//          trackedObstacles.at(i).center.pos.a,1,0,0,0.75,centers.markers.size()*2+i,"InfoText", visualization_msgs::Marker::TEXT_VIEW_FACING);
+//    else
+    text_mkr = CreateGenMarker(trackedObstacles.at(i).center.pos.x+0.5,trackedObstacles.at(i).center.pos.y+0.5,trackedObstacles.at(i).center.pos.z+1,
+              trackedObstacles.at(i).center.pos.a,1,1,1,1.2,centers.markers.size()*2+i,"InfoText", visualization_msgs::Marker::TEXT_VIEW_FACING);
+
+    std::ostringstream str_out;
+    //str_out << trackedObstacles.at(i).id << " ( " << speed << " )" << " (" << trackedObstacles.at(i).distance_to_center << ")";
+    str_out << trackedObstacles.at(i).id << " (" << speed << ")";
+    text_mkr.text = str_out.str();
+
+    if(i < text_info.markers.size())
+    {
+      text_mkr.id = text_info.markers.at(i).id;
+      text_info.markers.at(i) = text_mkr;
+    }
+    else
+      text_info.markers.push_back(text_mkr);
+
+
+    //Polygons
+    visualization_msgs::Marker poly_mkr = CreateGenMarker(0,0,0,0, 1,0.25,0.25,0.1,centers.markers.size()*3+i,"detected_polygons", visualization_msgs::Marker::LINE_STRIP);
+
+    for(unsigned int p = 0; p < trackedObstacles.at(i).contour.size(); p++)
+    {
+      geometry_msgs::Point point;
+      point.x = trackedObstacles.at(i).contour.at(p).x;
+      point.y = trackedObstacles.at(i).contour.at(p).y;
+      point.z = trackedObstacles.at(i).contour.at(p).z;
+      poly_mkr.points.push_back(point);
+    }
+
+    if(trackedObstacles.at(i).contour.size()>0)
+    {
+      geometry_msgs::Point point;
+      point.x = trackedObstacles.at(i).contour.at(0).x;
+      point.y = trackedObstacles.at(i).contour.at(0).y;
+      point.z = trackedObstacles.at(i).contour.at(0).z;
+      poly_mkr.points.push_back(point);
+    }
+
+    if(i < polygons.markers.size())
+    {
+      poly_mkr.id =  polygons.markers.at(i).id;
+      polygons.markers.at(i) = poly_mkr;
+    }
+    else
+      polygons.markers.push_back(poly_mkr);
+
+
+    //Trajectories
+    visualization_msgs::Marker traj_mkr = CreateGenMarker(0,0,0,0,1,1,0,0.1,centers.markers.size()*4+i,"tracked_trajectories", visualization_msgs::Marker::LINE_STRIP);
+
+    for(unsigned int p = 0; p < trackedObstacles.at(i).centers_list.size(); p++)
+    {
+      geometry_msgs::Point point;
+      point.x = trackedObstacles.at(i).centers_list.at(p).pos.x;
+      point.y = trackedObstacles.at(i).centers_list.at(p).pos.y;
+      point.z = trackedObstacles.at(i).centers_list.at(p).pos.z;
+      traj_mkr.points.push_back(point);
+    }
+
+
+    if(i < tracked_traj.markers.size())
+    {
+      traj_mkr.id = tracked_traj.markers.at(i).id ;
+      tracked_traj.markers.at(i) = traj_mkr;
+    }
+    else
+      tracked_traj.markers.push_back(traj_mkr);
+
+    i_next_id = traj_mkr.id;
+
+  }
+
+  return i_next_id +1;
+}
+
+void ROSHelpers::CreateCircleMarker(const PlannerHNS::WayPoint& _center, const double& radius, const int& start_id, visualization_msgs::Marker& circle_points)
+{
+  circle_points = CreateGenMarker(0,0,0,0,1,1,1,0.2,start_id,"Detection_Circles", visualization_msgs::Marker::LINE_STRIP);
+  for (float i = 0; i < M_PI*2.0+0.05; i+=0.05)
+  {
+    geometry_msgs::Point point;
+    point.x = _center.pos.x + (radius * cos(i));
+    point.y = _center.pos.y + (radius * sin(i));
+    point.z = _center.pos.z;
+    circle_points.points.push_back(point);
+  }
+}
+
+void ROSHelpers::InitPredMarkers(const int& nMarkers, visualization_msgs::MarkerArray& paths)
+{
+  paths.markers.clear();
+  for(int i=0; i<nMarkers; i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(0,0,0,0,1,1,1,1,i,"Predicted_Trajectories", visualization_msgs::Marker::LINE_STRIP);
+    paths.markers.push_back(mkr);
+  }
+}
+
+void ROSHelpers::InitCurbsMarkers(const int& nMarkers, visualization_msgs::MarkerArray& curbs)
+{
+  curbs.markers.clear();
+  for(int i=0; i<nMarkers; i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(0,0,0,0,1,1,1,1,i,"map_detected_curbs", visualization_msgs::Marker::SPHERE);
+    curbs.markers.push_back(mkr);
+  }
+}
+
+void ROSHelpers::ConvertPredictedTrqajectoryMarkers(std::vector<std::vector<PlannerHNS::WayPoint> >& paths,visualization_msgs::MarkerArray& path_markers, visualization_msgs::MarkerArray& path_markers_d)
+{
+
+  path_markers = path_markers_d;
+  for(unsigned int i = 0; i < paths.size(); i++)
+  {
+    double additional_z = 0;
+    double basic_color = 0.5;
+    double prop = 1.0;
+    bool bCurrent = false;
+//    if(paths.at(i).size()>0)
+//    {
+//
+//      prop = paths.at(i).at(0).collisionCost;
+//      if(prop < 0.5)
+//        continue;
+//
+//      if(prop > 0.5)
+//      {
+//        additional_z = prop;
+//        bCurrent = true;
+//      }
+//    }
+
+
+//    double r = 0, g = 0, b = 0;
+//    if(bCurrent == true)
+//    {
+//      r = basic_color+additional_z;
+//      g = basic_color+additional_z;
+//      b = basic_color+additional_z;
+//    }
+//    else if(i == 0)
+//    {
+//      r = basic_color+additional_z;
+//    }
+//    else if(i == 1)
+//    {
+//      g = basic_color+additional_z;
+//    }
+//    else if(i == 2)
+//    {
+//      b = basic_color+additional_z;
+//    }
+//    else if(i == 3)
+//    {
+//      r = basic_color+additional_z;
+//      b = basic_color+additional_z;
+//    }
+//    else
+//    {
+//      g = basic_color+additional_z;
+//      b = basic_color+additional_z;
+//    }
+//
+//    visualization_msgs::Marker path_mkr = CreateGenMarker(0,0,0,0,r,g,b,0.1,i,"Predicted_Trajectories", visualization_msgs::Marker::LINE_STRIP);
+
+    visualization_msgs::Marker path_mkr = CreateGenMarker(0,0,0,0,1.0*prop,0.1*prop,0.1*prop,0.1,i,"Predicted_Trajectories", visualization_msgs::Marker::LINE_STRIP);
+
+
+    for(unsigned int p = 0; p < paths.at(i).size(); p++)
+    {
+      geometry_msgs::Point point;
+      point.x = paths.at(i).at(p).pos.x;
+      point.y = paths.at(i).at(p).pos.y;
+      point.z = paths.at(i).at(p).pos.z + additional_z;
+      path_mkr.points.push_back(point);
+    }
+
+    if(i < path_markers.markers.size())
+      path_markers.markers.at(i) = path_mkr;
+    else
+      path_markers.markers.push_back(path_mkr);
+  }
+}
+
+void ROSHelpers::ConvertCurbsMarkers(const std::vector<PlannerHNS::DetectedObject>& curbs, visualization_msgs::MarkerArray& curbs_markers, visualization_msgs::MarkerArray& curbs_markers_d)
+{
+
+  curbs_markers = curbs_markers_d;
+  for(unsigned int i = 0; i < curbs.size(); i++)
+  {
+    if(curbs.at(i).contour.size() > 0)
+    {
+      visualization_msgs::Marker curb_mkr = CreateGenMarker(curbs.at(i).contour.at(0).x,curbs.at(i).contour.at(0).y,curbs.at(i).contour.at(0).z,0,1,0.54,0,0.2,i,"map_detected_curbs", visualization_msgs::Marker::SPHERE);
+
+      if(i < curbs_markers.markers.size())
+        curbs_markers.markers.at(i) = curb_mkr;
+      else
+        curbs_markers.markers.push_back(curb_mkr);
+    }
+  }
+}
+
+void ROSHelpers::InitCollisionPointsMarkers(const int& nMarkers, visualization_msgs::MarkerArray& col_points)
+{
+  col_points.markers.clear();
+  for(int i=0; i<nMarkers; i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(0,0,0,0,1,1,1,1,i,"collision_points_rviz", visualization_msgs::Marker::SPHERE);
+    col_points.markers.push_back(mkr);
+  }
+}
+
+void ROSHelpers::ConvertCollisionPointsMarkers(const std::vector<PlannerHNS::WayPoint>& col_points, visualization_msgs::MarkerArray& collision_markers, visualization_msgs::MarkerArray& collision_markers_d)
+{
+  collision_markers = collision_markers_d;
+  for(unsigned int i = 0; i < col_points.size(); i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(col_points.at(i).pos.x, col_points.at(i).pos.y, col_points.at(i).pos.z,0,1,0,0,0.5,i,"collision_points_rviz", visualization_msgs::Marker::SPHERE);
+
+    if(i < collision_markers.markers.size())
+      collision_markers.markers.at(i) = mkr;
+    else
+      collision_markers.markers.push_back(mkr);
+
+  }
+}
+
+void ROSHelpers::ConvertFromPlannerHToAutowarePathFormat(const std::vector<PlannerHNS::WayPoint>& path, const int& iStart,
+    autoware_msgs::Lane& trajectory)
+{
+  trajectory.waypoints.clear();
+  for(unsigned int i=iStart; i < path.size(); i++)
+  {
+    autoware_msgs::Waypoint wp;
+    wp.pose.pose.position.x = path.at(i).pos.x;
+    wp.pose.pose.position.y = path.at(i).pos.y;
+    wp.pose.pose.position.z = path.at(i).pos.z;
+    wp.pose.pose.orientation = tf::createQuaternionMsgFromYaw(UtilityHNS::UtilityH::SplitPositiveAngle(path.at(i).pos.a));
+    wp.twist.twist.linear.x = path.at(i).v;
+    if(path.at(i).bDir == FORWARD_DIR)
+      wp.dtlane.dir = 0;
+    else if(path.at(i).bDir == FORWARD_LEFT_DIR)
+      wp.dtlane.dir = 1;
+    else if(path.at(i).bDir == FORWARD_RIGHT_DIR)
+      wp.dtlane.dir = 2;
+    //PlannerHNS::GPSPoint p = path.at(i).pos;
+    //std::cout << p.ToString() << std::endl;
+    trajectory.waypoints.push_back(wp);
+  }
+}
+
+void ROSHelpers::ConvertFromRoadNetworkToAutowareVisualizeMapFormat(const PlannerHNS::RoadNetwork& map,  visualization_msgs::MarkerArray& markerArray)
+{
+  visualization_msgs::Marker lane_waypoint_marker;
+  lane_waypoint_marker.header.frame_id = "map";
+  lane_waypoint_marker.header.stamp = ros::Time();
+  lane_waypoint_marker.ns = "road_network_vector_map";
+  lane_waypoint_marker.type = visualization_msgs::Marker::LINE_STRIP;
+  lane_waypoint_marker.action = visualization_msgs::Marker::ADD;
+  lane_waypoint_marker.scale.x = 0.25;
+  std_msgs::ColorRGBA roll_color, total_color, curr_color;
+  roll_color.r = 1;
+  roll_color.g = 1;
+  roll_color.b = 1;
+  roll_color.a = 0.5;
+
+  lane_waypoint_marker.color = roll_color;
+  lane_waypoint_marker.frame_locked = false;
+
+  markerArray.markers.clear();
+
+  for(unsigned int i = 0; i< map.roadSegments.size(); i++)
+  {
+    for(unsigned int j = 0; j < map.roadSegments.at(i).Lanes.size(); j++)
+    {
+      lane_waypoint_marker.points.clear();
+
+      lane_waypoint_marker.id = map.roadSegments.at(i).Lanes.at(j).id;
+      for(unsigned int p = 0; p < map.roadSegments.at(i).Lanes.at(j).points.size(); p++)
+      {
+        geometry_msgs::Point point;
+
+
+
+          point.x = map.roadSegments.at(i).Lanes.at(j).points.at(p).pos.x;
+          point.y = map.roadSegments.at(i).Lanes.at(j).points.at(p).pos.y;
+          point.z = map.roadSegments.at(i).Lanes.at(j).points.at(p).pos.z;
+
+          lane_waypoint_marker.points.push_back(point);
+      }
+
+      markerArray.markers.push_back(lane_waypoint_marker);
+    }
+  }
+}
+
+void ROSHelpers::InitPredParticlesMarkers(const int& nMarkers, visualization_msgs::MarkerArray& paths)
+{
+  paths.markers.clear();
+  for(int i=0; i<nMarkers; i++)
+  {
+    visualization_msgs::Marker mkr = CreateGenMarker(0,0,0,0,1,1,1,0.05,i,"Particles", visualization_msgs::Marker::ARROW);
+    mkr.scale.x = 0.3;
+    paths.markers.push_back(mkr);
+  }
+}
+
+void ROSHelpers::ConvertParticles(std::vector<PlannerHNS::WayPoint>& points, visualization_msgs::MarkerArray& part_mkrs, visualization_msgs::MarkerArray& part_markers_d)
+{
+  part_mkrs = part_markers_d;
+  for(unsigned int i = 0; i < points.size(); i++)
+  {
+    visualization_msgs::Marker mkr;
+    if(points.at(i).bDir == PlannerHNS::STANDSTILL_DIR)
+      mkr = CreateGenMarker(points.at(i).pos.x, points.at(i).pos.y,points.at(i).pos.z,points.at(i).pos.a,1,0,0,0.05,i,"Particles", visualization_msgs::Marker::ARROW);
+    else if(points.at(i).bDir == PlannerHNS::FORWARD_DIR)
+      mkr = CreateGenMarker(points.at(i).pos.x, points.at(i).pos.y,points.at(i).pos.z,points.at(i).pos.a,1,1,1,0.05,i,"Particles", visualization_msgs::Marker::ARROW);
+    else if(points.at(i).bDir == PlannerHNS::FORWARD_RIGHT_DIR)
+      mkr = CreateGenMarker(points.at(i).pos.x, points.at(i).pos.y,points.at(i).pos.z,points.at(i).pos.a,0,1,0,0.05,i,"Particles", visualization_msgs::Marker::ARROW);
+    else if(points.at(i).bDir == PlannerHNS::FORWARD_LEFT_DIR)
+      mkr = CreateGenMarker(points.at(i).pos.x, points.at(i).pos.y,points.at(i).pos.z,points.at(i).pos.a,0,0,1,0.05,i,"Particles", visualization_msgs::Marker::ARROW);
+    else if(points.at(i).bDir == PlannerHNS::BACKWARD_DIR)
+      mkr = CreateGenMarker(points.at(i).pos.x, points.at(i).pos.y,points.at(i).pos.z,points.at(i).pos.a,1,0,1,0.05,i,"Particles", visualization_msgs::Marker::ARROW);
+    else
+      mkr = CreateGenMarker(points.at(i).pos.x, points.at(i).pos.y,points.at(i).pos.z,points.at(i).pos.a,1,1,0,0.05,i,"Particles", visualization_msgs::Marker::ARROW);
+
+    mkr.scale.x = 0.3;
+    if(i < part_mkrs.markers.size())
+      part_mkrs.markers.at(i) = mkr;
+    else
+      part_mkrs.markers.push_back(mkr);
+  }
+}
+
+void ROSHelpers::ConvertFromPlannerHRectangleToAutowareRviz(const std::vector<PlannerHNS::GPSPoint>& safety_rect,
+    visualization_msgs::Marker& marker)
+{
+  //if(safety_rect.size() != 4) return;
+
+  visualization_msgs::Marker lane_waypoint_marker;
+  lane_waypoint_marker.header.frame_id = "map";
+  lane_waypoint_marker.header.stamp = ros::Time();
+  lane_waypoint_marker.ns = "global_lane_array_marker";
+  lane_waypoint_marker.type = visualization_msgs::Marker::LINE_STRIP;
+  lane_waypoint_marker.action = visualization_msgs::Marker::ADD;
+  lane_waypoint_marker.scale.x = 0.2;
+  lane_waypoint_marker.scale.y = 0.2;
+  //lane_waypoint_marker.scale.z = 0.1;
+  lane_waypoint_marker.frame_locked = false;
+  lane_waypoint_marker.color.r = 0.0;
+  lane_waypoint_marker.color.g = 1.0;
+  lane_waypoint_marker.color.b = 0.0;
+  lane_waypoint_marker.color.a = 0.6;
+
+  for(unsigned int i = 0; i < safety_rect.size(); i++)
+  {
+    geometry_msgs::Point p;
+    p.x = safety_rect.at(i).x;
+    p.y = safety_rect.at(i).y;
+    p.z = safety_rect.at(i).z;
+
+    lane_waypoint_marker.points.push_back(p);
+  }
+  if(safety_rect.size() > 0)
+  {
+    geometry_msgs::Point p;
+    p.x = safety_rect.at(0).x;
+    p.y = safety_rect.at(0).y;
+    p.z = safety_rect.at(0).z;
+    lane_waypoint_marker.points.push_back(p);
+  }
+
+//  geometry_msgs::Point p1, p2,p3,p4;
+//  p1.x = safety_rect.at(0).x;
+//  p1.y = safety_rect.at(0).y;
+//  p1.z = safety_rect.at(0).z;
+//
+//  p2.x = safety_rect.at(1).x;
+//  p2.y = safety_rect.at(1).y;
+//  p2.z = safety_rect.at(1).z;
+//
+//  p3.x = safety_rect.at(2).x;
+//  p3.y = safety_rect.at(2).y;
+//  p3.z = safety_rect.at(2).z;
+//
+//  p4.x = safety_rect.at(3).x;
+//  p4.y = safety_rect.at(3).y;
+//  p4.z = safety_rect.at(3).z;
+//
+//  lane_waypoint_marker.points.push_back(p1);
+//  lane_waypoint_marker.points.push_back(p2);
+//  lane_waypoint_marker.points.push_back(p3);
+//  lane_waypoint_marker.points.push_back(p4);
+//  lane_waypoint_marker.points.push_back(p1);
+
+   marker = lane_waypoint_marker;
+
+}
+
+void ROSHelpers::TrajectoriesToMarkers(const std::vector<std::vector<std::vector<PlannerHNS::WayPoint> > >& paths, visualization_msgs::MarkerArray& markerArray)
+{
+  visualization_msgs::Marker lane_waypoint_marker;
+  lane_waypoint_marker.header.frame_id = "map";
+  lane_waypoint_marker.header.stamp = ros::Time();
+  lane_waypoint_marker.ns = "global_lane_array_marker";
+  lane_waypoint_marker.type = visualization_msgs::Marker::LINE_STRIP;
+  lane_waypoint_marker.action = visualization_msgs::Marker::ADD;
+  lane_waypoint_marker.scale.x = 0.1;
+  lane_waypoint_marker.scale.y = 0.1;
+  //lane_waypoint_marker.scale.z = 0.1;
+  lane_waypoint_marker.frame_locked = false;
+  std_msgs::ColorRGBA  total_color, curr_color;
+
+  int count = 0;
+  for (unsigned int il = 0; il < paths.size(); il++)
+  {
+    for (unsigned int i = 0; i < paths.at(il).size(); i++)
+    {
+      lane_waypoint_marker.points.clear();
+      lane_waypoint_marker.id = count;
+
+      for (unsigned int j=0; j < paths.at(il).at(i).size(); j++)
+      {
+        geometry_msgs::Point point;
+
+        point.x = paths.at(il).at(i).at(j).pos.x;
+        point.y = paths.at(il).at(i).at(j).pos.y;
+        point.z = paths.at(il).at(i).at(j).pos.z;
+
+        lane_waypoint_marker.points.push_back(point);
+      }
+
+      lane_waypoint_marker.color.a = 0.9;
+
+      lane_waypoint_marker.color.r = 0.0;
+      lane_waypoint_marker.color.g = 1.0;
+      lane_waypoint_marker.color.b = 0.0;
+
+      markerArray.markers.push_back(lane_waypoint_marker);
+      count++;
+    }
+  }
+}
+
+void ROSHelpers::TrajectoriesToColoredMarkers(const std::vector<std::vector<PlannerHNS::WayPoint> >& paths, const std::vector<PlannerHNS::TrajectoryCost>& traj_costs,const int& iClosest, visualization_msgs::MarkerArray& markerArray)
+{
+  visualization_msgs::Marker lane_waypoint_marker;
+  lane_waypoint_marker.header.frame_id = "map";
+  lane_waypoint_marker.header.stamp = ros::Time();
+  lane_waypoint_marker.ns = "local_lane_array_marker_colored";
+  lane_waypoint_marker.type = visualization_msgs::Marker::LINE_STRIP;
+  lane_waypoint_marker.action = visualization_msgs::Marker::ADD;
+  lane_waypoint_marker.scale.x = 0.1;
+  lane_waypoint_marker.scale.y = 0.1;
+  //lane_waypoint_marker.scale.z = 0.1;
+  lane_waypoint_marker.color.a = 0.9;
+  lane_waypoint_marker.color.r = 1.0;
+  lane_waypoint_marker.color.g = 1.0;
+  lane_waypoint_marker.color.b = 1.0;
+  lane_waypoint_marker.frame_locked = false;
+
+  int count = 0;
+  for (unsigned int i = 0; i < paths.size(); i++)
+  {
+    lane_waypoint_marker.points.clear();
+    lane_waypoint_marker.id = count;
+
+    for (unsigned int j=0; j < paths.at(i).size(); j++)
+    {
+      geometry_msgs::Point point;
+
+      point.x = paths.at(i).at(j).pos.x;
+      point.y = paths.at(i).at(j).pos.y;
+      point.z = paths.at(i).at(j).pos.z;
+
+      lane_waypoint_marker.points.push_back(point);
+    }
+
+    lane_waypoint_marker.color.b = 0;
+
+    if(traj_costs.size() == paths.size())
+    {
+      float norm_cost = traj_costs.at(i).cost * paths.size();
+      if(norm_cost <= 1.0)
+      {
+        lane_waypoint_marker.color.r = norm_cost;
+        lane_waypoint_marker.color.g = 1.0;
+      }
+      else if(norm_cost > 1.0)
+      {
+        lane_waypoint_marker.color.r = 1.0;
+        lane_waypoint_marker.color.g = 2.0 - norm_cost;
+      }
+    }
+    else
+    {
+      lane_waypoint_marker.color.r = 1.0;
+      lane_waypoint_marker.color.g = 0.0;
+    }
+
+    if(traj_costs.at(i).bBlocked)
+    {
+      lane_waypoint_marker.color.r = 1.0;
+      lane_waypoint_marker.color.g = 0.0;
+      lane_waypoint_marker.color.b = 0.0;
+    }
+
+    if(i == iClosest)
+    {
+      lane_waypoint_marker.color.r = 1.0;
+      lane_waypoint_marker.color.g = 0.0;
+      lane_waypoint_marker.color.b = 1.0;
+    }
+
+    markerArray.markers.push_back(lane_waypoint_marker);
+    count++;
+  }
+}
+
+void ROSHelpers::ConvertFromPlannerHToAutowareVisualizePathFormat(const std::vector<PlannerHNS::WayPoint>& curr_path,
+    const std::vector<std::vector<std::vector<PlannerHNS::WayPoint> > >& paths, const PlannerHNS::LocalPlannerH& localPlanner,
+      visualization_msgs::MarkerArray& markerArray)
+{
+  visualization_msgs::Marker lane_waypoint_marker;
+  lane_waypoint_marker.header.frame_id = "map";
+  lane_waypoint_marker.header.stamp = ros::Time();
+  lane_waypoint_marker.ns = "global_lane_array_marker";
+  lane_waypoint_marker.type = visualization_msgs::Marker::LINE_STRIP;
+  lane_waypoint_marker.action = visualization_msgs::Marker::ADD;
+  lane_waypoint_marker.scale.x = 0.1;
+  lane_waypoint_marker.scale.y = 0.1;
+  //lane_waypoint_marker.scale.z = 0.1;
+  lane_waypoint_marker.frame_locked = false;
+  std_msgs::ColorRGBA  total_color, curr_color;
+
+
+  int count = 0;
+  for (unsigned int il = 0; il < paths.size(); il++)
+  {
+    for (unsigned int i = 0; i < paths.at(il).size(); i++)
+    {
+      lane_waypoint_marker.points.clear();
+      lane_waypoint_marker.id = count;
+
+      for (unsigned int j=0; j < paths.at(il).at(i).size(); j++)
+      {
+        geometry_msgs::Point point;
+
+        point.x = paths.at(il).at(i).at(j).pos.x;
+        point.y = paths.at(il).at(i).at(j).pos.y;
+        point.z = paths.at(il).at(i).at(j).pos.z;
+
+        lane_waypoint_marker.points.push_back(point);
+      }
+
+      lane_waypoint_marker.color.a = 0.9;
+      if(localPlanner.m_TrajectoryCostsCalculatotor.m_TrajectoryCosts.size() == paths.size())
+      {
+        float norm_cost = localPlanner.m_TrajectoryCostsCalculatotor.m_TrajectoryCosts.at(i).cost * paths.size();
+        if(norm_cost <= 1.0)
+        {
+          lane_waypoint_marker.color.r = norm_cost;
+          lane_waypoint_marker.color.g = 1.0;
+        }
+        else if(norm_cost > 1.0)
+        {
+          lane_waypoint_marker.color.r = 1.0;
+          lane_waypoint_marker.color.g = 2.0 - norm_cost;
+        }
+      }
+      else
+      {
+        lane_waypoint_marker.color.r = 0.0;
+        lane_waypoint_marker.color.g = 1.0;
+      }
+
+      if((int)i == localPlanner.m_iSafeTrajectory && (int)il == localPlanner.m_iCurrentTotalPathId)
+      {
+        lane_waypoint_marker.color.r = 1.0;
+        lane_waypoint_marker.color.g = 0.0;
+        lane_waypoint_marker.color.b = 1.0;
+      }
+      else
+      {
+        lane_waypoint_marker.color.b = 0;
+      }
+
+      markerArray.markers.push_back(lane_waypoint_marker);
+      count++;
+    }
+  }
+}
+
+void ROSHelpers::ConvertFromPlannerHToAutowareVisualizePathFormat(const std::vector<std::vector<PlannerHNS::WayPoint> >& globalPaths, visualization_msgs::MarkerArray& markerArray)
+{
+  visualization_msgs::Marker lane_waypoint_marker;
+  lane_waypoint_marker.header.frame_id = "map";
+  lane_waypoint_marker.header.stamp = ros::Time();
+  lane_waypoint_marker.ns = "global_lane_array_marker";
+  lane_waypoint_marker.type = visualization_msgs::Marker::LINE_STRIP;
+  lane_waypoint_marker.action = visualization_msgs::Marker::ADD;
+
+
+  std_msgs::ColorRGBA roll_color, total_color, curr_color;
+  lane_waypoint_marker.points.clear();
+  lane_waypoint_marker.id = 1;
+  lane_waypoint_marker.scale.x = 0.1;
+  lane_waypoint_marker.scale.y = 0.1;
+  total_color.r = 1;
+  total_color.g = 0;
+  total_color.b = 0;
+  total_color.a = 0.5;
+  lane_waypoint_marker.color = total_color;
+  lane_waypoint_marker.frame_locked = false;
+
+  int count = 0;
+  for (unsigned int i = 0; i < globalPaths.size(); i++)
+  {
+    lane_waypoint_marker.points.clear();
+    lane_waypoint_marker.id = count;
+
+    for (unsigned int j=0; j < globalPaths.at(i).size(); j++)
+    {
+      geometry_msgs::Point point;
+
+      point.x = globalPaths.at(i).at(j).pos.x;
+      point.y = globalPaths.at(i).at(j).pos.y;
+      point.z = globalPaths.at(i).at(j).pos.z;
+
+      lane_waypoint_marker.points.push_back(point);
+    }
+
+    markerArray.markers.push_back(lane_waypoint_marker);
+    count++;
+  }
+}
+
+void ROSHelpers::ConvertFromPlannerObstaclesToAutoware(const PlannerHNS::WayPoint& currState, const std::vector<PlannerHNS::DetectedObject>& trackedObstacles,
+    visualization_msgs::MarkerArray& detectedPolygons)
+{
+  visualization_msgs::Marker lane_waypoint_marker;
+  lane_waypoint_marker.header.frame_id = "map";
+  lane_waypoint_marker.header.stamp = ros::Time();
+  lane_waypoint_marker.ns = "detected_polygons";
+  lane_waypoint_marker.type = visualization_msgs::Marker::LINE_STRIP;
+  lane_waypoint_marker.action = visualization_msgs::Marker::ADD;
+  lane_waypoint_marker.scale.x = .1;
+  lane_waypoint_marker.scale.y = .1;
+  //lane_waypoint_marker.scale.z = .05;
+  lane_waypoint_marker.color.a = 0.8;
+  lane_waypoint_marker.frame_locked = false;
+
+  visualization_msgs::Marker corner_marker;
+  corner_marker.header.frame_id = "map";
+  corner_marker.header.stamp = ros::Time();
+  corner_marker.ns = "Polygon_Corners";
+  corner_marker.type = visualization_msgs::Marker::SPHERE;
+  corner_marker.action = visualization_msgs::Marker::ADD;
+  corner_marker.scale.x = .1;
+  corner_marker.scale.y = .1;
+  corner_marker.scale.z = .1;
+  corner_marker.color.a = 0.8;
+  corner_marker.frame_locked = false;
+
+
+  visualization_msgs::Marker quarters_marker;
+  quarters_marker.header.frame_id = "map";
+  quarters_marker.header.stamp = ros::Time();
+  quarters_marker.ns = "Quarters_Lines";
+  quarters_marker.type = visualization_msgs::Marker::LINE_STRIP;
+  quarters_marker.action = visualization_msgs::Marker::ADD;
+  quarters_marker.scale.x = .03;
+  quarters_marker.scale.y = .03;
+  quarters_marker.scale.z = .03;
+  quarters_marker.color.a = 0.8;
+  quarters_marker.color.r = 0.6;
+  quarters_marker.color.g = 0.5;
+  quarters_marker.color.b = 0;
+  quarters_marker.frame_locked = false;
+
+  visualization_msgs::Marker direction_marker;
+  direction_marker.header.frame_id = "map";
+  direction_marker.header.stamp = ros::Time();
+  direction_marker.ns = "Object_Direction";
+  direction_marker.type = visualization_msgs::Marker::ARROW;
+  direction_marker.action = visualization_msgs::Marker::ADD;
+  direction_marker.scale.x = .9;
+  direction_marker.scale.y = .4;
+  direction_marker.scale.z = .4;
+  direction_marker.color.a = 0.8;
+  direction_marker.color.r = 0;
+  direction_marker.color.g = 1;
+  direction_marker.color.b = 0;
+  direction_marker.frame_locked = false;
+
+
+  visualization_msgs::Marker velocity_marker;
+  velocity_marker.header.frame_id = "map";
+  velocity_marker.header.stamp = ros::Time();
+  velocity_marker.ns = "detected_polygons_velocity";
+  velocity_marker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
+  //velocity_marker.action = visualization_msgs::Marker::ADD;
+  velocity_marker.scale.z = 0.9;
+  velocity_marker.scale.x = 0.9;
+  velocity_marker.scale.y = 0.9;
+  velocity_marker.color.a = 0.5;
+
+  velocity_marker.frame_locked = false;
+  detectedPolygons.markers.clear();
+
+  int pointID = 0;
+  int quartersIds = 0;
+  for(unsigned int i =0; i < trackedObstacles.size(); i++)
+  {
+    //double distance = hypot(currState.pos.y-trackedObstacles.at(i).center.pos.y, currState.pos.x-trackedObstacles.at(i).center.pos.x);
+
+    lane_waypoint_marker.color.g = 0;
+    lane_waypoint_marker.color.r = 0;
+    lane_waypoint_marker.color.b = 1;
+
+    velocity_marker.color.r = 1;//trackedObstacles.at(i).center.v/16.0;
+    velocity_marker.color.g = 1;// - trackedObstacles.at(i).center.v/16.0;
+    velocity_marker.color.b = 1;
+
+    lane_waypoint_marker.points.clear();
+    lane_waypoint_marker.id = i;
+    velocity_marker.id = i;
+
+    //std::cout << " Distance : " << distance << ", Of Object" << trackedObstacles.at(i).id << std::endl;
+
+    for(unsigned int p = 0; p < trackedObstacles.at(i).contour.size(); p++)
+    {
+
+      geometry_msgs::Point point;
+
+        point.x = trackedObstacles.at(i).contour.at(p).x;
+        point.y = trackedObstacles.at(i).contour.at(p).y;
+        point.z = trackedObstacles.at(i).contour.at(p).z;
+
+        lane_waypoint_marker.points.push_back(point);
+
+        corner_marker.pose.position = point;
+        corner_marker.color.r = 0.8;
+        corner_marker.color.g = 0;
+        corner_marker.color.b = 0.7;
+        corner_marker.color.a = 0.5;
+        corner_marker.id = pointID;
+        pointID++;
+
+        detectedPolygons.markers.push_back(corner_marker);
+    }
+
+    if(trackedObstacles.at(i).contour.size()>0)
+    {
+    geometry_msgs::Point point;
+
+      point.x = trackedObstacles.at(i).contour.at(0).x;
+      point.y = trackedObstacles.at(i).contour.at(0).y;
+      point.z = trackedObstacles.at(i).contour.at(0).z+1;
+
+      lane_waypoint_marker.points.push_back(point);
+
+    }
+
+
+    geometry_msgs::Point point;
+
+    point.x = trackedObstacles.at(i).center.pos.x;
+    point.y = trackedObstacles.at(i).center.pos.y;
+    point.z = trackedObstacles.at(i).center.pos.z+1;
+
+//    geometry_msgs::Point relative_p;
+    //relative_p.y = 0.5;
+//    velocity_marker.pose.position = calcAbsoluteCoordinate(relative_p, point);
+    velocity_marker.pose.position = point;
+      velocity_marker.pose.position.z += 0.5;
+
+      direction_marker.id = i;
+      direction_marker.pose.position = point;
+      direction_marker.pose.position.z += 0.5;
+      direction_marker.pose.orientation = tf::createQuaternionMsgFromYaw(UtilityHNS::UtilityH::SplitPositiveAngle(trackedObstacles.at(i).center.pos.a));
+
+
+    for(unsigned int iq = 0; iq < 8; iq++)
+    {
+      quarters_marker.points.clear();
+      quarters_marker.id = quartersIds;
+      quarters_marker.points.push_back(point);
+      geometry_msgs::Point point2 = point;
+      double a_q = UtilityHNS::UtilityH::SplitPositiveAngle(trackedObstacles.at(i).center.pos.a+(iq*M_PI_4));
+      point2.x += 2.0*cos(a_q);
+      point2.y += 1.5*sin(a_q);
+      quarters_marker.points.push_back(point2);
+
+      quartersIds++;
+      detectedPolygons.markers.push_back(quarters_marker);
+    }
+
+    int speed = (trackedObstacles.at(i).center.v*3.6);
+
+    // double to string
+    std::ostringstream str_out;
+  //  if(trackedObstacles.at(i).center.v > 0.75)
+    str_out << "(" << trackedObstacles.at(i).id << " , " << speed << ")";
+//    else
+//      str_out << trackedObstacles.at(i).id;
+    //std::string vel = str_out.str();
+    velocity_marker.text = str_out.str();//vel.erase(vel.find_first_of(".") + 2);
+    //if(speed > 0.5)
+
+    detectedPolygons.markers.push_back(velocity_marker);
+    detectedPolygons.markers.push_back(lane_waypoint_marker);
+    detectedPolygons.markers.push_back(direction_marker);
+
+  }
+}
+
+std::string ROSHelpers::GetBehaviorNameFromCode(const PlannerHNS::STATE_TYPE& behState)
+{
+  std::string str = "Unknown";
+  switch(behState)
+  {
+  case PlannerHNS::INITIAL_STATE:
+    str = "Init";
+    break;
+  case PlannerHNS::WAITING_STATE:
+    str = "Waiting";
+    break;
+  case PlannerHNS::FORWARD_STATE:
+    str = "Forward";
+    break;
+  case PlannerHNS::STOPPING_STATE:
+    str = "Stop";
+    break;
+  case PlannerHNS::FINISH_STATE:
+    str = "End";
+    break;
+  case PlannerHNS::FOLLOW_STATE:
+    str = "Follow";
+    break;
+  case PlannerHNS::OBSTACLE_AVOIDANCE_STATE:
+    str = "Swerving";
+    break;
+  case PlannerHNS::TRAFFIC_LIGHT_STOP_STATE:
+    str = "Light Stop";
+    break;
+  case PlannerHNS::TRAFFIC_LIGHT_WAIT_STATE:
+    str = "Light Wait";
+    break;
+  case PlannerHNS::STOP_SIGN_STOP_STATE:
+    str = "Sign Stop";
+    break;
+  case PlannerHNS::STOP_SIGN_WAIT_STATE:
+    str = "Sign Wait";
+    break;
+  default:
+    str = "Unknown";
+    break;
+  }
+
+  return str;
+}
+
+void ROSHelpers::VisualizeBehaviorState(const PlannerHNS::WayPoint& currState, const PlannerHNS::BehaviorState& beh, const bool& bGreenLight, const int& avoidDirection, visualization_msgs::Marker& behaviorMarker, std::string ns,double size_factor)
+{
+  behaviorMarker.header.frame_id = "map";
+  behaviorMarker.header.stamp = ros::Time();
+  behaviorMarker.ns = ns;
+  behaviorMarker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
+  behaviorMarker.scale.z = 1.0*size_factor;
+  behaviorMarker.scale.x = 1.0*size_factor;
+  behaviorMarker.scale.y = 1.0*size_factor;
+  behaviorMarker.color.a = 0.9;
+  behaviorMarker.frame_locked = false;
+  if(bGreenLight)
+  {
+    behaviorMarker.color.r = 0.1;//trackedObstacles.at(i).center.v/16.0;
+    behaviorMarker.color.g = 1;// - trackedObstacles.at(i).center.v/16.0;
+    behaviorMarker.color.b = 0.1;
+  }
+  else
+  {
+    behaviorMarker.color.r = 1;//trackedObstacles.at(i).center.v/16.0;
+    behaviorMarker.color.g = 0.1;// - trackedObstacles.at(i).center.v/16.0;
+    behaviorMarker.color.b = 0.1;
+  }
+
+  behaviorMarker.id = 0;
+
+  geometry_msgs::Point point;
+
+  point.x = currState.pos.x;
+  point.y = currState.pos.y;
+  point.z = currState.pos.z+3.0;
+
+  behaviorMarker.pose.position = point;
+
+  std::ostringstream str_out;
+
+  //str_out << "(" << (int)(beh.followDistance * 100) / 100 <<")";
+  str_out << "(" << (int)(beh.stopDistance * 100.0) / 100.0 <<")";
+
+  if(avoidDirection == -1)
+    str_out << "<< ";
+
+  str_out << GetBehaviorNameFromCode(beh.state);
+  if(avoidDirection == 1)
+    str_out << " >>";
+  behaviorMarker.text = str_out.str();
+}
+
+void ROSHelpers::ConvertFromAutowareBoundingBoxObstaclesToPlannerH(const jsk_recognition_msgs::BoundingBoxArray& detectedObstacles,
+    std::vector<PlannerHNS::DetectedObject>& obstacles_list)
+{
+  obstacles_list.clear();
+  for(unsigned int i =0; i < detectedObstacles.boxes.size(); i++)
+  {
+    PlannerHNS::DetectedObject obj;
+    obj.center = PlannerHNS::WayPoint(detectedObstacles.boxes.at(i).pose.position.x,
+        detectedObstacles.boxes.at(i).pose.position.y,
+        0,
+        0);
+    obj.w = detectedObstacles.boxes.at(i).dimensions.y;
+    obj.l = detectedObstacles.boxes.at(i).dimensions.x;
+    obj.h = detectedObstacles.boxes.at(i).dimensions.z;
+    //double objSize = obj.w*obj.l;
+    //double d = hypot(m_State.state.pos.y - obj.center.pos.y, m_State.state.pos.x - obj.center.pos.x);
+    //std::cout << ", Distance of  : " << d;
+    //if(d < 7)
+    {
+
+      double l2 = obj.l/2.0;
+      double w2 = obj.w/2.0;
+
+      obj.contour.push_back(PlannerHNS::GPSPoint(-w2, -l2, 0,0));
+      obj.contour.push_back(PlannerHNS::GPSPoint(w2, -l2, 0,0));
+      obj.contour.push_back(PlannerHNS::GPSPoint(w2, l2, 0,0));
+      obj.contour.push_back(PlannerHNS::GPSPoint(-w2, l2, 0,0));
+      obstacles_list.push_back(obj);
+    }
+  }
+}
+
+void ROSHelpers::ConvertFromAutowareCloudClusterObstaclesToPlannerH(const PlannerHNS::WayPoint& currState, const double& car_width,
+    const double& car_length, const autoware_msgs::CloudClusterArray& clusters, vector<PlannerHNS::DetectedObject>& obstacles_list,
+    const double max_obj_size, const double& min_obj_size, const double& detection_radius,
+    const int& n_poly_quarters,const double& poly_resolution, int& nOriginalPoints, int& nContourPoints)
+{
+  PlannerHNS::Mat3 rotationMat(-currState.pos.a);
+  PlannerHNS::Mat3 translationMat(-currState.pos.x, -currState.pos.y);
+
+  int nPoints = 0;
+  int nOrPoints = 0;
+  double object_size = 0;
+  PlannerHNS::GPSPoint relative_point;
+  PlannerHNS::GPSPoint avg_center;
+  PolygonGenerator polyGen(n_poly_quarters);
+  PlannerHNS::DetectedObject obj;
+
+  for(unsigned int i =0; i < clusters.clusters.size(); i++)
+  {
+    obj.id = clusters.clusters.at(i).id;
+    obj.label = clusters.clusters.at(i).label;
+
+    obj.center.pos.x = clusters.clusters.at(i).centroid_point.point.x;
+    obj.center.pos.y = clusters.clusters.at(i).centroid_point.point.y;
+    obj.center.pos.z = clusters.clusters.at(i).centroid_point.point.z;
+    obj.center.pos.a = 0;
+    obj.center.v = 0;
+    obj.actual_yaw = clusters.clusters.at(i).estimated_angle;
+
+    obj.w = clusters.clusters.at(i).dimensions.x;
+    obj.l = clusters.clusters.at(i).dimensions.y;
+    obj.h = clusters.clusters.at(i).dimensions.z;
+
+    pcl::PointCloud<pcl::PointXYZ> point_cloud;
+    pcl::fromROSMsg(clusters.clusters.at(i).cloud, point_cloud);
+
+
+    obj.contour = polyGen.EstimateClusterPolygon(point_cloud ,obj.center.pos,avg_center, poly_resolution);
+
+    obj.distance_to_center = hypot(obj.center.pos.y-currState.pos.y, obj.center.pos.x-currState.pos.x);
+
+    object_size = hypot(obj.w, obj.l);
+
+    if(obj.distance_to_center > detection_radius || object_size < min_obj_size || object_size > max_obj_size)
+      continue;
+
+    relative_point = translationMat*obj.center.pos;
+    relative_point = rotationMat*relative_point;
+
+    double distance_x = fabs(relative_point.x - car_length/3.0);
+    double distance_y = fabs(relative_point.y);
+
+    if(distance_x  <= car_length*0.5 && distance_y <= car_width*0.5) // don't detect yourself
+      continue;
+
+    //obj.center.pos = avg_center;
+    nOrPoints += point_cloud.points.size();
+    nPoints += obj.contour.size();
+    //std::cout << " Distance_X: " << distance_x << ", " << " Distance_Y: " << distance_y << ", " << " Size: " << object_size << std::endl;
+    obstacles_list.push_back(obj);
+  }
+
+  nOriginalPoints = nOrPoints;
+  nContourPoints =  nPoints;
+}
+
+PlannerHNS::SHIFT_POS ROSHelpers::ConvertShiftFromAutowareToPlannerH(const PlannerHNS::AUTOWARE_SHIFT_POS& shift)
+{
+  if(shift == PlannerHNS::AW_SHIFT_POS_DD)
+    return PlannerHNS::SHIFT_POS_DD;
+  else if(shift == PlannerHNS::AW_SHIFT_POS_RR)
+    return PlannerHNS::SHIFT_POS_RR;
+  else if(shift == PlannerHNS::AW_SHIFT_POS_NN)
+    return PlannerHNS::SHIFT_POS_NN;
+  else if(shift == PlannerHNS::AW_SHIFT_POS_PP)
+    return PlannerHNS::SHIFT_POS_PP;
+  else if(shift == PlannerHNS::AW_SHIFT_POS_BB)
+    return PlannerHNS::SHIFT_POS_BB;
+  else if(shift == PlannerHNS::AW_SHIFT_POS_SS)
+    return PlannerHNS::SHIFT_POS_SS;
+  else
+    return PlannerHNS::SHIFT_POS_UU;
+}
+
+PlannerHNS::AUTOWARE_SHIFT_POS ROSHelpers::ConvertShiftFromPlannerHToAutoware(const PlannerHNS::SHIFT_POS& shift)
+{
+  if(shift == PlannerHNS::SHIFT_POS_DD)
+    return PlannerHNS::AW_SHIFT_POS_DD;
+  else if(shift == PlannerHNS::SHIFT_POS_RR)
+    return PlannerHNS::AW_SHIFT_POS_RR;
+  else if(shift == PlannerHNS::SHIFT_POS_NN)
+    return PlannerHNS::AW_SHIFT_POS_NN;
+  else if(shift == PlannerHNS::SHIFT_POS_PP)
+    return PlannerHNS::AW_SHIFT_POS_PP;
+  else if(shift == PlannerHNS::SHIFT_POS_BB)
+    return PlannerHNS::AW_SHIFT_POS_BB;
+  else if(shift == PlannerHNS::SHIFT_POS_SS)
+    return PlannerHNS::AW_SHIFT_POS_SS;
+  else
+    return PlannerHNS::AW_SHIFT_POS_UU;
+}
+
+PlannerHNS::AutowareBehaviorState ROSHelpers::ConvertBehaviorStateFromPlannerHToAutoware(const PlannerHNS::BehaviorState& beh)
+{
+  PlannerHNS::AutowareBehaviorState arw_state;
+  arw_state.followDistance = beh.followDistance;
+  arw_state.followVelocity = beh.followVelocity;
+  arw_state.maxVelocity = beh.maxVelocity;
+  arw_state.minVelocity = beh.minVelocity;
+  arw_state.stopDistance = beh.stopDistance;
+
+  if(beh.indicator == PlannerHNS::LIGHT_INDICATOR::INDICATOR_LEFT)
+    arw_state.indicator = PlannerHNS::AW_INDICATOR_LEFT;
+  else if(beh.indicator == PlannerHNS::LIGHT_INDICATOR::INDICATOR_RIGHT)
+    arw_state.indicator = PlannerHNS::AW_INDICATOR_RIGHT;
+  else if(beh.indicator == PlannerHNS::LIGHT_INDICATOR::INDICATOR_BOTH)
+    arw_state.indicator = PlannerHNS::AW_INDICATOR_BOTH;
+  else if(beh.indicator == PlannerHNS::LIGHT_INDICATOR::INDICATOR_NONE)
+    arw_state.indicator = PlannerHNS::AW_INDICATOR_NONE;
+
+  if(beh.state == PlannerHNS::INITIAL_STATE)
+    arw_state.state = PlannerHNS::AW_INITIAL_STATE;
+  else if(beh.state == PlannerHNS::WAITING_STATE)
+    arw_state.state = PlannerHNS::AW_WAITING_STATE;
+  else if(beh.state == PlannerHNS::FORWARD_STATE)
+    arw_state.state = PlannerHNS::AW_FORWARD_STATE;
+  else if(beh.state == PlannerHNS::STOPPING_STATE)
+    arw_state.state = PlannerHNS::AW_STOPPING_STATE;
+  else if(beh.state == PlannerHNS::EMERGENCY_STATE)
+    arw_state.state = PlannerHNS::AW_EMERGENCY_STATE;
+  else if(beh.state == PlannerHNS::TRAFFIC_LIGHT_STOP_STATE)
+    arw_state.state = PlannerHNS::AW_TRAFFIC_LIGHT_STOP_STATE;
+  else if(beh.state == PlannerHNS::STOP_SIGN_STOP_STATE)
+    arw_state.state = PlannerHNS::AW_STOP_SIGN_STOP_STATE;
+  else if(beh.state == PlannerHNS::FOLLOW_STATE)
+    arw_state.state = PlannerHNS::AW_FOLLOW_STATE;
+  else if(beh.state == PlannerHNS::LANE_CHANGE_STATE)
+    arw_state.state = PlannerHNS::AW_LANE_CHANGE_STATE;
+  else if(beh.state == PlannerHNS::OBSTACLE_AVOIDANCE_STATE)
+    arw_state.state = PlannerHNS::AW_OBSTACLE_AVOIDANCE_STATE;
+  else if(beh.state == PlannerHNS::FINISH_STATE)
+    arw_state.state = PlannerHNS::AW_FINISH_STATE;
+
+
+  return arw_state;
+
+}
+
+void ROSHelpers::ConvertFromLocalLaneToAutowareLane(const std::vector<PlannerHNS::WayPoint>& path, autoware_msgs::Lane& trajectory , const unsigned int& iStart)
+{
+  trajectory.waypoints.clear();
+
+  for(unsigned int i = iStart; i < path.size(); i++)
+  {
+    autoware_msgs::Waypoint wp;
+    wp.pose.pose.position.x = path.at(i).pos.x;
+    wp.pose.pose.position.y = path.at(i).pos.y;
+    wp.pose.pose.position.z = path.at(i).pos.z;
+    wp.pose.pose.orientation = tf::createQuaternionMsgFromYaw(UtilityHNS::UtilityH::SplitPositiveAngle(path.at(i).pos.a));
+
+    wp.twist.twist.linear.x = path.at(i).v;
+    wp.lane_id = path.at(i).laneId;
+    wp.stop_line_id = path.at(i).stopLineID;
+    wp.left_lane_id = path.at(i).LeftPointId;
+    wp.right_lane_id = path.at(i).RightPointId;
+    wp.time_cost = path.at(i).timeCost;
+
+    wp.gid = path.at(i).gid;
+
+    //wp.cost = path.at(i).cost;
+    wp.cost = 0;
+
+    if(path.at(i).actionCost.size()>0)
+    {
+      wp.direction = path.at(i).actionCost.at(0).first;
+      wp.cost += path.at(i).actionCost.at(0).second;
+    }
+
+    trajectory.waypoints.push_back(wp);
+  }
+}
+
+void ROSHelpers::ConvertFromLocalLaneToAutowareLane(const std::vector<PlannerHNS::GPSPoint>& path, autoware_msgs::Lane& trajectory)
+{
+  trajectory.waypoints.clear();
+
+  for(unsigned int i=0; i < path.size(); i++)
+  {
+    autoware_msgs::Waypoint wp;
+    wp.pose.pose.position.x = path.at(i).x;
+    wp.pose.pose.position.y = path.at(i).y;
+    wp.pose.pose.position.z = path.at(i).z;
+    wp.pose.pose.orientation = tf::createQuaternionMsgFromYaw(UtilityHNS::UtilityH::SplitPositiveAngle(path.at(i).a));
+
+    trajectory.waypoints.push_back(wp);
+  }
+}
+
+void ROSHelpers::ConvertFromAutowareLaneToLocalLane(const autoware_msgs::Lane& trajectory, std::vector<PlannerHNS::WayPoint>& path)
+{
+  path.clear();
+
+  for(unsigned int i=0; i < trajectory.waypoints.size(); i++)
+  {
+    PlannerHNS::WayPoint wp;
+    wp.pos.x = trajectory.waypoints.at(i).pose.pose.position.x;
+    wp.pos.y = trajectory.waypoints.at(i).pose.pose.position.y;
+    wp.pos.z = trajectory.waypoints.at(i).pose.pose.position.z;
+    wp.pos.a = tf::getYaw(trajectory.waypoints.at(i).pose.pose.orientation);
+
+    wp.v = trajectory.waypoints.at(i).twist.twist.linear.x;
+
+    wp.gid = trajectory.waypoints.at(i).gid;
+    wp.laneId = trajectory.waypoints.at(i).lane_id;
+    wp.stopLineID = trajectory.waypoints.at(i).stop_line_id;
+    wp.LeftPointId = trajectory.waypoints.at(i).left_lane_id;
+    wp.RightPointId = trajectory.waypoints.at(i).right_lane_id;
+    wp.timeCost = trajectory.waypoints.at(i).time_cost;
+
+    if(trajectory.waypoints.at(i).direction == 0)
+      wp.bDir = PlannerHNS::FORWARD_DIR;
+    else if(trajectory.waypoints.at(i).direction == 1)
+      wp.bDir = PlannerHNS::FORWARD_LEFT_DIR;
+    else if(trajectory.waypoints.at(i).direction == 2)
+      wp.bDir = PlannerHNS::FORWARD_RIGHT_DIR;
+    else if(trajectory.waypoints.at(i).direction == 3)
+      wp.bDir = PlannerHNS::BACKWARD_DIR;
+    else if(trajectory.waypoints.at(i).direction == 4)
+      wp.bDir = PlannerHNS::BACKWARD_LEFT_DIR;
+    else if(trajectory.waypoints.at(i).direction == 5)
+      wp.bDir = PlannerHNS::BACKWARD_RIGHT_DIR;
+    else if(trajectory.waypoints.at(i).direction == 6)
+      wp.bDir = PlannerHNS::STANDSTILL_DIR;
+
+    wp.cost = trajectory.waypoints.at(i).cost;
+
+    path.push_back(wp);
+  }
+}
+
+void ROSHelpers::createGlobalLaneArrayMarker(std_msgs::ColorRGBA color,
+    const autoware_msgs::LaneArray &lane_waypoints_array, visualization_msgs::MarkerArray& markerArray)
+{
+  visualization_msgs::Marker lane_waypoint_marker;
+  lane_waypoint_marker.header.frame_id = "map";
+  lane_waypoint_marker.header.stamp = ros::Time();
+  lane_waypoint_marker.ns = "global_lane_array_marker";
+  lane_waypoint_marker.type = visualization_msgs::Marker::LINE_STRIP;
+  lane_waypoint_marker.action = visualization_msgs::Marker::ADD;
+  lane_waypoint_marker.scale.x = 0.75;
+  lane_waypoint_marker.scale.y = 0.75;
+  lane_waypoint_marker.color = color;
+  lane_waypoint_marker.frame_locked = false;
+
+  int count = 0;
+  for (unsigned int i=0; i<  lane_waypoints_array.lanes.size(); i++)
+  {
+    lane_waypoint_marker.points.clear();
+    lane_waypoint_marker.id = count;
+
+    for (unsigned int j=0; j < lane_waypoints_array.lanes.at(i).waypoints.size(); j++)
+    {
+      geometry_msgs::Point point;
+      point = lane_waypoints_array.lanes.at(i).waypoints.at(j).pose.pose.position;
+      lane_waypoint_marker.points.push_back(point);
+    }
+    markerArray.markers.push_back(lane_waypoint_marker);
+    count++;
+  }
+
+}
+
+void ROSHelpers::createGlobalLaneArrayVelocityMarker(const autoware_msgs::LaneArray &lane_waypoints_array
+    , visualization_msgs::MarkerArray& markerArray)
+{
+  visualization_msgs::MarkerArray tmp_marker_array;
+  // display by markers the velocity of each waypoint.
+  visualization_msgs::Marker velocity_marker;
+  velocity_marker.header.frame_id = "map";
+  velocity_marker.header.stamp = ros::Time();
+  velocity_marker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
+  velocity_marker.action = visualization_msgs::Marker::ADD;
+  //velocity_marker.scale.z = 0.4;
+  velocity_marker.color.a = 0.9;
+  velocity_marker.color.r = 1;
+  velocity_marker.color.g = 1;
+  velocity_marker.color.b = 1;
+  velocity_marker.frame_locked = false;
+
+  int count = 1;
+  for (unsigned int i=0; i<  lane_waypoints_array.lanes.size(); i++)
+  {
+
+    std::ostringstream str_count;
+    str_count << count;
+    velocity_marker.ns = "global_velocity_lane_" + str_count.str();
+    for (unsigned int j=0; j < lane_waypoints_array.lanes.at(i).waypoints.size(); j++)
+    {
+      //std::cout << _waypoints[i].GetX() << " " << _waypoints[i].GetY() << " " << _waypoints[i].GetZ() << " " << _waypoints[i].GetVelocity_kmh() << std::endl;
+      velocity_marker.id = j;
+      geometry_msgs::Point relative_p;
+      relative_p.y = 0.5;
+      velocity_marker.pose.position = calcAbsoluteCoordinate(relative_p, lane_waypoints_array.lanes.at(i).waypoints.at(j).pose.pose);
+      velocity_marker.pose.position.z += 0.2;
+
+      // double to string
+      std::ostringstream str_out;
+      str_out << lane_waypoints_array.lanes.at(i).waypoints.at(j).twist.twist.linear.x;
+      //std::string vel = str_out.str();
+      velocity_marker.text = str_out.str();//vel.erase(vel.find_first_of(".") + 2);
+
+      tmp_marker_array.markers.push_back(velocity_marker);
+    }
+    count++;
+  }
+
+  markerArray.markers.insert(markerArray.markers.end(), tmp_marker_array.markers.begin(),
+                                       tmp_marker_array.markers.end());
+}
+
+void ROSHelpers::createGlobalLaneArrayOrientationMarker(const autoware_msgs::LaneArray &lane_waypoints_array
+    , visualization_msgs::MarkerArray& markerArray)
+{
+  visualization_msgs::MarkerArray tmp_marker_array;
+  visualization_msgs::Marker lane_waypoint_marker;
+  lane_waypoint_marker.header.frame_id = "map";
+  lane_waypoint_marker.header.stamp = ros::Time();
+  lane_waypoint_marker.type = visualization_msgs::Marker::ARROW;
+  lane_waypoint_marker.action = visualization_msgs::Marker::ADD;
+  lane_waypoint_marker.scale.x = 0.6;
+  lane_waypoint_marker.scale.y = 0.2;
+  lane_waypoint_marker.scale.z = 0.1;
+  lane_waypoint_marker.color.r = 1.0;
+  lane_waypoint_marker.color.a = 1.0;
+  //lane_waypoint_marker.frame_locked = false;
+
+  lane_waypoint_marker.ns = "global_lane_waypoint_orientation_marker";
+
+  int count = 1;
+  for (unsigned int i=0; i<  lane_waypoints_array.lanes.size(); i++)
+  {
+//    std::ostringstream str_ns;
+//    str_ns << "global_lane_waypoint_orientation_marker_";
+//    str_ns << i;
+//   lane_waypoint_marker.ns = str_ns.str();
+
+    for (unsigned int j=0; j < lane_waypoints_array.lanes.at(i).waypoints.size(); j++)
+    {
+      lane_waypoint_marker.id = count;
+      lane_waypoint_marker.pose = lane_waypoints_array.lanes.at(i).waypoints.at(j).pose.pose;
+
+      if(lane_waypoints_array.lanes.at(i).waypoints.at(j).dtlane.dir == 1)
+      {
+        lane_waypoint_marker.color.r = 0.0;
+        lane_waypoint_marker.color.g = 1.0;
+        lane_waypoint_marker.color.b = 0.0;
+        tmp_marker_array.markers.push_back(lane_waypoint_marker);
+      }
+      else if(lane_waypoints_array.lanes.at(i).waypoints.at(j).dtlane.dir == 2)
+      {
+        lane_waypoint_marker.color.r = 0.0;
+      lane_waypoint_marker.color.g = 0.0;
+      lane_waypoint_marker.color.b = 1.0;
+      tmp_marker_array.markers.push_back(lane_waypoint_marker);
+      }
+      else
+      {
+
+        if(lane_waypoints_array.lanes.at(i).waypoints.at(j).cost >= 100)
+        {
+          lane_waypoint_marker.color.r = 1.0;
+        lane_waypoint_marker.color.g = 0.0;
+        lane_waypoint_marker.color.b = 0.0;
+        tmp_marker_array.markers.push_back(lane_waypoint_marker);
+        }
+        else
+        {
+        lane_waypoint_marker.color.r = 0.0;
+        lane_waypoint_marker.color.g = 0.8;
+        lane_waypoint_marker.color.b = 0.0;
+        tmp_marker_array.markers.push_back(lane_waypoint_marker);
+        }
+      }
+
+
+      count++;
+    }
+  }
+
+  markerArray.markers.insert(markerArray.markers.end(), tmp_marker_array.markers.begin(),
+                       tmp_marker_array.markers.end());
+}
+
+void ROSHelpers::GetTrafficLightForVisualization(std::vector<PlannerHNS::TrafficLight>& lights, visualization_msgs::MarkerArray& markerArray)
+{
+  markerArray.markers.clear();
+  for(unsigned int i=0; i<lights.size(); i++)
+  {
+    if(lights.at(i).lightState == RED_LIGHT)
+    {
+      visualization_msgs::Marker mkr = CreateGenMarker(lights.at(i).pos.x,lights.at(i).pos.y,lights.at(i).pos.z,0,1,0,0,3,i,"traffic_light_visualize", visualization_msgs::Marker::SPHERE);
+      markerArray.markers.push_back(mkr);
+    }
+    else if(lights.at(i).lightState == GREEN_LIGHT)
+    {
+      visualization_msgs::Marker mkr = CreateGenMarker(lights.at(i).pos.x,lights.at(i).pos.y,lights.at(i).pos.z,0,0,1,0,3,i,"traffic_light_visualize", visualization_msgs::Marker::SPHERE);
+      markerArray.markers.push_back(mkr);
+    }
+  }
+}
+
+void ROSHelpers::ConvertFromAutowareDetectedObjectToOpenPlannerDetectedObject(const autoware_msgs::DetectedObject& det_obj, PlannerHNS::DetectedObject& obj)
+{
+  obj.id = det_obj.id;
+  obj.label = det_obj.label;
+  obj.l = det_obj.dimensions.x;
+  obj.w = det_obj.dimensions.y;
+  obj.h = det_obj.dimensions.z;
+
+  obj.center.pos.x = det_obj.pose.position.x;
+  obj.center.pos.y = det_obj.pose.position.y;
+  obj.center.pos.z = det_obj.pose.position.z;
+  obj.center.pos.a = tf::getYaw(det_obj.pose.orientation);
+
+  obj.center.v = det_obj.velocity.linear.x;
+  obj.acceleration_raw = det_obj.velocity.linear.y;
+  obj.acceleration_desc = det_obj.velocity.linear.z;
+  obj.bVelocity = det_obj.velocity_reliable;
+  obj.bDirection = det_obj.pose_reliable;
+
+  if(det_obj.indicator_state == 0)
+    obj.indicator_state = PlannerHNS::INDICATOR_LEFT;
+  else if(det_obj.indicator_state == 1)
+    obj.indicator_state = PlannerHNS::INDICATOR_RIGHT;
+  else if(det_obj.indicator_state == 2)
+    obj.indicator_state = PlannerHNS::INDICATOR_BOTH;
+  else if(det_obj.indicator_state == 3)
+    obj.indicator_state = PlannerHNS::INDICATOR_NONE;
+
+  PlannerHNS::GPSPoint p;
+  obj.contour.clear();
+
+  for(unsigned int j=0; j < det_obj.convex_hull.polygon.points.size(); j++)
+  {
+
+    p.x = det_obj.convex_hull.polygon.points.at(j).x;
+    p.y = det_obj.convex_hull.polygon.points.at(j).y;
+    p.z = det_obj.convex_hull.polygon.points.at(j).z;
+    obj.contour.push_back(p);
+  }
+
+  obj.predTrajectories.clear();
+
+  for(unsigned int j = 0 ; j < det_obj.candidate_trajectories.lanes.size(); j++)
+  {
+    std::vector<PlannerHNS::WayPoint> _traj;
+    PlannerHNS::ROSHelpers::ConvertFromAutowareLaneToLocalLane(det_obj.candidate_trajectories.lanes.at(j), _traj);
+    for(unsigned int k=0; k < _traj.size(); k++)
+      _traj.at(k).collisionCost = det_obj.candidate_trajectories.lanes.at(j).cost;
+
+    obj.predTrajectories.push_back(_traj);
+  }
+}
+
+void ROSHelpers::ConvertFromOpenPlannerDetectedObjectToAutowareDetectedObject(const PlannerHNS::DetectedObject& det_obj, const bool& bSimulationMode, autoware_msgs::DetectedObject& obj)
+{
+  if(bSimulationMode)
+    obj.id = det_obj.originalID;
+  else
+    obj.id = det_obj.id;
+
+  obj.label = det_obj.label;
+  obj.indicator_state = det_obj.indicator_state;
+  obj.dimensions.x = det_obj.l;
+  obj.dimensions.y = det_obj.w;
+  obj.dimensions.z = det_obj.h;
+
+  obj.pose.position.x = det_obj.center.pos.x;
+  obj.pose.position.y = det_obj.center.pos.y;
+  obj.pose.position.z = det_obj.center.pos.z;
+  obj.pose.orientation = tf::createQuaternionMsgFromRollPitchYaw(0, 0, UtilityHNS::UtilityH::SplitPositiveAngle(det_obj.center.pos.a));
+
+  obj.velocity.linear.x = det_obj.center.v;
+  obj.velocity.linear.y = det_obj.acceleration_raw;
+  obj.velocity.linear.z = det_obj.acceleration_desc;
+  obj.velocity_reliable = det_obj.bVelocity;
+  obj.pose_reliable = det_obj.bDirection;
+
+  geometry_msgs::Point32 p;
+  obj.convex_hull.polygon.points.clear();
+
+  for(unsigned int j=0; j < det_obj.contour.size(); j++)
+  {
+    p.x = det_obj.contour.at(j).x;
+    p.y = det_obj.contour.at(j).y;
+    p.z = det_obj.contour.at(j).z;
+    obj.convex_hull.polygon.points.push_back(p);
+  }
+
+
+  obj.candidate_trajectories.lanes.clear();
+  for(unsigned int j = 0 ; j < det_obj.predTrajectories.size(); j++)
+  {
+    autoware_msgs::Lane pred_traj;
+    PlannerHNS::ROSHelpers::ConvertFromLocalLaneToAutowareLane(det_obj.predTrajectories.at(j), pred_traj);
+    if(det_obj.predTrajectories.at(j).size() > 0)
+    {
+      pred_traj.cost = det_obj.predTrajectories.at(j).at(0).collisionCost;
+    }
+    pred_traj.lane_index = 0;
+    obj.candidate_trajectories.lanes.push_back(pred_traj);
+  }
+}
+
+void ROSHelpers::UpdateRoadMap(const AutowareRoadNetwork& src_map, PlannerHNS::RoadNetwork& out_map)
+{
+  std::vector<UtilityHNS::AisanLanesFileReader::AisanLane> lanes;
+  for(unsigned int i=0; i < src_map.lanes.data.size();i++)
+  {
+    UtilityHNS::AisanLanesFileReader::AisanLane l;
+    l.BLID     =  src_map.lanes.data.at(i).blid;
+    l.BLID2   =  src_map.lanes.data.at(i).blid2;
+    l.BLID3   =  src_map.lanes.data.at(i).blid3;
+    l.BLID4   =  src_map.lanes.data.at(i).blid4;
+    l.BNID     =  src_map.lanes.data.at(i).bnid;
+    l.ClossID   =  src_map.lanes.data.at(i).clossid;
+    l.DID     =  src_map.lanes.data.at(i).did;
+    l.FLID     =  src_map.lanes.data.at(i).flid;
+    l.FLID2   =  src_map.lanes.data.at(i).flid2;
+    l.FLID3   =  src_map.lanes.data.at(i).flid3;
+    l.FLID4   =  src_map.lanes.data.at(i).flid4;
+    l.FNID     =  src_map.lanes.data.at(i).fnid;
+    l.JCT     =  src_map.lanes.data.at(i).jct;
+    l.LCnt     =  src_map.lanes.data.at(i).lcnt;
+    l.LnID     =  src_map.lanes.data.at(i).lnid;
+    l.Lno     =  src_map.lanes.data.at(i).lno;
+    l.Span     =  src_map.lanes.data.at(i).span;
+    l.RefVel  =  src_map.lanes.data.at(i).refvel;
+    l.LimitVel  =  src_map.lanes.data.at(i).limitvel;
+
+//    l.LaneChgFG =  src_map.lanes.at(i).;
+//    l.LaneType   =  src_map.lanes.at(i).blid;
+//    l.LimitVel   =  src_map.lanes.at(i).;
+//    l.LinkWAID   =  src_map.lanes.at(i).blid;
+//    l.RefVel   =  src_map.lanes.at(i).blid;
+//    l.RoadSecID =  src_map.lanes.at(i).;
+
+    lanes.push_back(l);
+  }
+
+  std::vector<UtilityHNS::AisanPointsFileReader::AisanPoints> points;
+
+  for(unsigned int i=0; i < src_map.points.data.size();i++)
+  {
+    UtilityHNS::AisanPointsFileReader::AisanPoints p;
+    double integ_part = src_map.points.data.at(i).l;
+    double deg = trunc(src_map.points.data.at(i).l);
+    double min = trunc((src_map.points.data.at(i).l - deg) * 100.0) / 60.0;
+    double sec = modf((src_map.points.data.at(i).l - deg) * 100.0, &integ_part)/36.0;
+    double L =  deg + min + sec;
+
+    deg = trunc(src_map.points.data.at(i).b);
+    min = trunc((src_map.points.data.at(i).b - deg) * 100.0) / 60.0;
+    sec = modf((src_map.points.data.at(i).b - deg) * 100.0, &integ_part)/36.0;
+    double B =  deg + min + sec;
+
+    p.B     = B;
+    p.Bx     = src_map.points.data.at(i).bx;
+    p.H     = src_map.points.data.at(i).h;
+    p.L     = L;
+    p.Ly     = src_map.points.data.at(i).ly;
+    p.MCODE1   = src_map.points.data.at(i).mcode1;
+    p.MCODE2   = src_map.points.data.at(i).mcode2;
+    p.MCODE3   = src_map.points.data.at(i).mcode3;
+    p.PID     = src_map.points.data.at(i).pid;
+    p.Ref     = src_map.points.data.at(i).ref;
+
+    points.push_back(p);
+  }
+
+
+  std::vector<UtilityHNS::AisanCenterLinesFileReader::AisanCenterLine> dts;
+  for(unsigned int i=0; i < src_map.dtlanes.data.size();i++)
+  {
+    UtilityHNS::AisanCenterLinesFileReader::AisanCenterLine dt;
+
+    dt.Apara   = src_map.dtlanes.data.at(i).apara;
+    dt.DID     = src_map.dtlanes.data.at(i).did;
+    dt.Dir     = src_map.dtlanes.data.at(i).dir;
+    dt.Dist   = src_map.dtlanes.data.at(i).dist;
+    dt.LW     = src_map.dtlanes.data.at(i).lw;
+    dt.PID     = src_map.dtlanes.data.at(i).pid;
+    dt.RW     = src_map.dtlanes.data.at(i).rw;
+    dt.cant   = src_map.dtlanes.data.at(i).cant;
+    dt.r     = src_map.dtlanes.data.at(i).r;
+    dt.slope   = src_map.dtlanes.data.at(i).slope;
+
+    dts.push_back(dt);
+  }
+
+  std::vector<UtilityHNS::AisanAreasFileReader::AisanArea> areas;
+  std::vector<UtilityHNS::AisanIntersectionFileReader::AisanIntersection> inters;
+  std::vector<UtilityHNS::AisanLinesFileReader::AisanLine> line_data;
+  std::vector<UtilityHNS::AisanStopLineFileReader::AisanStopLine> stop_line_data;
+  std::vector<UtilityHNS::AisanSignalFileReader::AisanSignal> signal_data;
+  std::vector<UtilityHNS::AisanVectorFileReader::AisanVector> vector_data;
+  std::vector<UtilityHNS::AisanCurbFileReader::AisanCurb> curb_data;
+  std::vector<UtilityHNS::AisanRoadEdgeFileReader::AisanRoadEdge> roadedge_data;
+  std::vector<UtilityHNS::AisanWayareaFileReader::AisanWayarea> way_area;
+  std::vector<UtilityHNS::AisanCrossWalkFileReader::AisanCrossWalk> crossing;
+  std::vector<UtilityHNS::AisanNodesFileReader::AisanNode > nodes_data;
+  std::vector<UtilityHNS::AisanDataConnFileReader::DataConn> conn_data;
+
+  PlannerHNS::GPSPoint origin;//(m_OriginPos.position.x, m_OriginPos.position.y, m_OriginPos.position.z, 0);
+  PlannerHNS::MappingHelpers::ConstructRoadNetworkFromROSMessage(lanes, points, dts, inters, areas, line_data, stop_line_data, signal_data, vector_data, curb_data, roadedge_data,way_area, crossing, nodes_data,  conn_data, origin, out_map);
+}
+
+void ROSHelpers::GetIndicatorArrows(const PlannerHNS::WayPoint& center, const double& width,const double& length, const PlannerHNS::LIGHT_INDICATOR& indicator, const int& id, visualization_msgs::MarkerArray& markerArray)
+{
+  double critical_lateral_distance =  width/2.0 + 0.2;
+  //double critical_long_front_distance =  carInfo.length/2.0 ;
+  PlannerHNS::GPSPoint top_right(critical_lateral_distance, length, center.pos.z, 0);
+  PlannerHNS::GPSPoint top_left(-critical_lateral_distance, length, center.pos.z, 0);
+
+  PlannerHNS::Mat3 invRotationMat(center.pos.a-M_PI_2);
+  PlannerHNS::Mat3 invTranslationMat(center.pos.x, center.pos.y);
+
+  top_right = invRotationMat*top_right;
+  top_right = invTranslationMat*top_right;
+  top_left = invRotationMat*top_left;
+  top_left = invTranslationMat*top_left;
+
+  top_right.a = center.pos.a - M_PI_2;
+  top_left.a = center.pos.a + M_PI_2;
+
+  std_msgs::ColorRGBA color_l, color_r;
+  color_l.r = 1; color_l.g = 1;color_l.b = 1;
+  color_r.r = 1; color_r.g = 1;color_r.b = 1;
+
+  if(indicator == PlannerHNS::INDICATOR_LEFT)
+  {
+    color_l.b = 0;
+  }
+  else if(indicator == PlannerHNS::INDICATOR_RIGHT )
+  {
+    color_r.b = 0;
+  }
+  else if(indicator == PlannerHNS::INDICATOR_BOTH)
+  {
+    color_l.b = 0;
+    color_r.b = 0;
+  }
+
+  visualization_msgs::Marker mkr_l = PlannerHNS::ROSHelpers::CreateGenMarker(top_left.x,top_left.y,top_left.z,top_left.a,color_l.r,color_l.g,color_l.b,1.0, id,"simu_car_indicator_left", visualization_msgs::Marker::ARROW);
+  mkr_l.scale.y = 0.4;
+  mkr_l.scale.z = 0.4;
+  visualization_msgs::Marker mkr_r = PlannerHNS::ROSHelpers::CreateGenMarker(top_right.x,top_right.y,top_right.z,top_right.a,color_r.r,color_r.g,color_r.b,1.0, id,"simu_car_indicator_right", visualization_msgs::Marker::ARROW);
+  mkr_r.scale.y = 0.4;
+  mkr_r.scale.z = 0.4;
+  markerArray.markers.push_back(mkr_l);
+  markerArray.markers.push_back(mkr_r);
+}
+
+void ROSHelpers::TTC_PathRviz(const std::vector<PlannerHNS::WayPoint>& path, visualization_msgs::MarkerArray& markerArray)
+{
+  visualization_msgs::Marker lane_waypoint_marker;
+  lane_waypoint_marker.header.frame_id = "map";
+  lane_waypoint_marker.header.stamp = ros::Time();
+  lane_waypoint_marker.ns = "ttc_path";
+  lane_waypoint_marker.type = visualization_msgs::Marker::LINE_STRIP;
+  lane_waypoint_marker.action = visualization_msgs::Marker::ADD;
+  lane_waypoint_marker.scale.x = 1;
+  lane_waypoint_marker.scale.y = 1;
+  lane_waypoint_marker.scale.z = 1;
+  lane_waypoint_marker.frame_locked = false;
+  std_msgs::ColorRGBA  total_color, curr_color;
+
+  lane_waypoint_marker.color.a = 0.9;
+  lane_waypoint_marker.color.r = 0.5;
+  lane_waypoint_marker.color.g = 1.0;
+  lane_waypoint_marker.color.b = 0.0;
+
+  lane_waypoint_marker.id = 1;
+  for (unsigned int i = 0; i < path.size(); i++)
+  {
+    geometry_msgs::Point point;
+    point.x = path.at(i).pos.x;
+    point.y = path.at(i).pos.y;
+    point.z = path.at(i).pos.z;
+
+    lane_waypoint_marker.points.push_back(point);
+
+    markerArray.markers.push_back(lane_waypoint_marker);
+  }
+}
+
+}

+ 4 - 0
src/ros/catkin/src/op_simu/.gitignore

@@ -0,0 +1,4 @@
+!Makefile
+libs
+*.o
+*.so

+ 258 - 0
src/ros/catkin/src/op_simu/CHANGELOG.rst

@@ -0,0 +1,258 @@
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Changelog for package op_simu
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1.11.0 (2019-03-21)
+-------------------
+* Fix license notice in corresponding package.xml
+* Contributors: amc-nu
+
+1.10.0 (2019-01-17)
+-------------------
+* Use colcon as the build tool (`#1704 <https://github.com/CPFL/Autoware/issues/1704>`_)
+  * Switch to colcon as the build tool instead of catkin
+  * Added cmake-target
+  * Added note about the second colcon call
+  * Added warning about catkin* scripts being deprecated
+  * Fix COLCON_OPTS
+  * Added install targets
+  * Update Docker image tags
+  * Message packages fixes
+  * Fix missing dependency
+* Contributors: Esteve Fernandez
+
+1.9.1 (2018-11-06)
+------------------
+
+1.9.0 (2018-10-31)
+------------------
+
+1.8.0 (2018-08-31)
+------------------
+* Fix Indigo build issues
+* [Fix] Moved C++11 flag to autoware_build_flags (`#1395 <https://github.com/CPFL/Autoware/pull/1395>`_)
+* [Feature] Makes sure that all binaries have their dependencies linked (`#1385 <https://github.com/CPFL/Autoware/pull/1385>`_)
+* Fix Vector Map parser problem, tested with three different maps
+  Fix Global Planning function for the new map modification
+  Add OpenPlanner Simulator for perception, traffic lights, cars
+  Add OpenPlanner new version to replace wp_planner and dp_planner
+  Remove unnecessary files from OpenPlanner libraries
+  Test Global and Local planning
+  Test Tracking node (kf_contour_track)
+  Test Simulation Nodes
+  Test Utility Nodes
+* Contributors: Esteve Fernandez, hatem-darweesh
+
+1.7.0 (2018-05-18)
+------------------
+* update Version from 1.6.3 to 1.7.0 in package.xml and CHANGELOG.rst
+* [fix] Fixes for all packages and dependencies (`#1240 <https://github.com/CPFL/Autoware/pull/1240>`_)
+  * Initial Cleanup
+  * fixed also for indigo
+  * kf cjeck
+  * Fix road wizard
+  * Added travis ci
+  * Trigger CI
+  * Fixes to cv_tracker and lidar_tracker cmake
+  * Fix kitti player dependencies
+  * Removed unnecessary dependencies
+  * messages fixing for can
+  * Update build script travis
+  * Travis Path
+  * Travis Paths fix
+  * Travis test
+  * Eigen checks
+  * removed unnecessary dependencies
+  * Eigen Detection
+  * Job number reduced
+  * Eigen3 more fixes
+  * More Eigen3
+  * Even more Eigen
+  * find package cmake modules included
+  * More fixes to cmake modules
+  * Removed non ros dependency
+  * Enable industrial_ci for indidog and kinetic
+  * Wrong install command
+  * fix rviz_plugin install
+  * FastVirtualScan fix
+  * Fix Qt5 Fastvirtualscan
+  * Fixed qt5 system dependencies for rosdep
+  * NDT TKU Fix catkin not pacakged
+  * More in detail dependencies fixes for more packages
+  * GLEW library for ORB
+  * Ignore OrbLocalizer
+  * Ignore Version checker
+  * Fix for driveworks interface
+  * driveworks not catkinpackagedd
+  * Missing catkin for driveworks
+  * libdpm opencv not catkin packaged
+  * catkin lib gnss  not included in obj_db
+  * Points2Polygon fix
+  * More missing dependencies
+  * image viewer not packaged
+  * Fixed SSH2 detection, added viewers for all distros
+  * Fix gnss localizer incorrect dependency config
+  * Fixes to multiple packages dependencies
+  * gnss plib and package
+  * More fixes to gnss
+  * gnss dependencies for gnss_loclaizer
+  * Missing gnss dependency for gnss on localizer
+  * More fixes for dependencies
+  Replaced gnss for autoware_gnss_library
+  * gnss more fixes
+  * fixes to more dependencies
+  * header dependency
+  * Debug message
+  * more debug messages changed back to gnss
+  * debud messages
+  * gnss test
+  * gnss install command
+  * Several fixes for OpenPlanner and its lbiraries
+  * Fixes to ROSInterface
+  * More fixes to robotsdk and rosinterface
+  * robotsdk calibration fix
+  * Fixes to rosinterface robotsdk libraries and its nodes
+  * Fixes to Qt5 missing dependencies in robotsdk
+  * glviewer missing dependencies
+  * Missing qt specific config cmake for robotsdk
+  * disable cv_tracker
+  * Fix to open planner un needed dependendecies
+  * Fixes for libraries indecision maker
+  * Fixes to libraries decision_maker installation
+  * Gazebo on Kinetic
+  * Added Missing library
+  * * Removed Gazebo and synchonization packages
+  * Renames vmap in lane_planner
+  * Added installation commands for missing pakcages
+  * Fixes to lane_planner
+  * Added NDT TKU Glut extra dependencies
+  * ndt localizer/lib fast pcl fixes
+  re enable cv_tracker
+  * Fix kf_lib
+  * Keep industrial_ci
+  * Fixes for dpm library
+  * Fusion lib fixed
+  * dpm and fusion header should match exported project name
+  * Fixes to dpm_ocv  ndt_localizer and pcl_omp
+  * no fast_pcl anymore
+  * fixes to libdpm and its package
+  * CI test
+  * test with native travis ci
+  * missing update for apt
+  * Fixes to pcl_omp installation and headers
+  * Final fixes for tests, modified README
+  * * Fixes to README
+  * Enable industrial_ci
+  * re enable native travis tests
+* Fix/cmake cleanup (`#1156 <https://github.com/CPFL/Autoware/pull/1156>`_)
+  * Initial Cleanup
+  * fixed also for indigo
+  * kf cjeck
+  * Fix road wizard
+  * Added travis ci
+  * Trigger CI
+  * Fixes to cv_tracker and lidar_tracker cmake
+  * Fix kitti player dependencies
+  * Removed unnecessary dependencies
+  * messages fixing for can
+  * Update build script travis
+  * Travis Path
+  * Travis Paths fix
+  * Travis test
+  * Eigen checks
+  * removed unnecessary dependencies
+  * Eigen Detection
+  * Job number reduced
+  * Eigen3 more fixes
+  * More Eigen3
+  * Even more Eigen
+  * find package cmake modules included
+  * More fixes to cmake modules
+  * Removed non ros dependency
+  * Enable industrial_ci for indidog and kinetic
+  * Wrong install command
+  * fix rviz_plugin install
+  * FastVirtualScan fix
+  * Fix Qt5 Fastvirtualscan
+  * Fixed qt5 system dependencies for rosdep
+  * NDT TKU Fix catkin not pacakged
+  * Fixes from industrial_ci
+* Contributors: Abraham Monrroy, Kosuke Murakami
+
+1.6.3 (2018-03-06)
+------------------
+
+1.6.2 (2018-02-27)
+------------------
+* Update CHANGELOG
+* Contributors: Yusuke FUJII
+
+1.6.1 (2018-01-20)
+------------------
+* update CHANGELOG
+* Contributors: Yusuke FUJII
+
+1.6.0 (2017-12-11)
+------------------
+* Prepare release for 1.6.0
+* - Test Tracking
+  - Add missing parameter to lunch file and runtime manager
+* - Add new Node for object polygon representation and tracking (kf_contour_tracker)
+  - Add launch file and tune tracking parameters
+  - Test with Moriyama rosbag
+* - Update OpenPlanner libraries (plannerh, simuh, utilityh) with the latest modifications
+  - Fix inconsistency after library update, make sure old (way_planner, dp_planner) are working fine
+  - Create new package (op_local_planner)
+  - Create common launch file for local planning params
+  - Create new node (op_trajectory_generator)
+  - Create launch file for trajectory generation only
+  - Test generating trajectories (rollouts) in simulation with way_planner
+  - Test generating trajectories with real rosbag data with way_planner
+  - Test generating trajectories with real rosbag data and waypoints_loader
+* Contributors: Yamato ANDO, hatem-darweesh
+
+1.5.1 (2017-09-25)
+------------------
+* Release/1.5.1 (`#816 <https://github.com/cpfl/autoware/issues/816>`_)
+  * fix a build error by gcc version
+  * fix build error for older indigo version
+  * update changelog for v1.5.1
+  * 1.5.1
+* Contributors: Yusuke FUJII
+
+1.5.0 (2017-09-21)
+------------------
+* Update changelog
+* Contributors: Yusuke FUJII
+
+1.4.0 (2017-08-04)
+------------------
+* version number must equal current release number so we can start releasing in the future
+* added changelogs
+* Contributors: Dejan Pangercic
+
+1.3.1 (2017-07-16)
+------------------
+
+1.3.0 (2017-07-14)
+------------------
+
+1.2.0 (2017-06-07)
+------------------
+* Change OpenPlanner stand alone libraries names.
+* Contributors: hatem-darweesh
+
+1.1.2 (2017-02-27 23:10)
+------------------------
+
+1.1.1 (2017-02-27 22:25)
+------------------------
+
+1.1.0 (2017-02-24)
+------------------
+
+1.0.1 (2017-01-14)
+------------------
+
+1.0.0 (2016-12-22)
+------------------

+ 79 - 0
src/ros/catkin/src/op_simu/CMakeLists.txt

@@ -0,0 +1,79 @@
+cmake_minimum_required(VERSION 2.8.3)
+project(op_simu)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+find_package(autoware_build_flags REQUIRED)
+find_package(catkin REQUIRED COMPONENTS
+  op_utility
+  op_planner
+)
+
+find_package(OpenCV REQUIRED)
+find_package(OpenGL REQUIRED)
+find_package(GLEW REQUIRED)
+find_package(GLUT REQUIRED)
+find_package(X11 REQUIRED)
+find_package(Threads REQUIRED)
+
+catkin_package(
+  INCLUDE_DIRS include
+  LIBRARIES ${PROJECT_NAME}
+  CATKIN_DEPENDS op_utility op_planner
+)
+
+include_directories(
+  include
+  ${catkin_INCLUDE_DIRS}
+  ${OpenCV_INCLUDE_DIRS}
+  ${OpenGL_INCLUDE_DIRS}
+  ${GLUT_INCLUDE_DIRS}
+  ${GLEW_INCLUDE_DIRS}
+)
+
+set(SIMUH_SRC        
+  src/SimpleTracker.cpp
+  src/SimulatedTrajectoryFollower.cpp
+  src/TrajectoryFollower.cpp        
+)
+
+## Declare a cpp library
+add_library(${PROJECT_NAME}
+  ${SIMUH_SRC}
+)
+
+target_link_libraries(${PROJECT_NAME}
+  ${catkin_LIBRARIES}
+  ${OpenCV_LIBRARIES}
+  ${OPENGL_LIBRARIES}
+  ${GLUT_LIBRARIES}
+  ${GLEW_LIBRARIES}
+  ${X11_LIBRARIES}
+  ${CMAKE_THREAD_LIBS_INIT}
+)
+add_executable(Simu
+  ${SIMUH_SRC}
+  main.cpp
+)
+
+target_link_libraries(Simu
+  ${catkin_LIBRARIES}
+  ${OpenCV_LIBS}
+  ${OPENGL_LIBRARIES}
+  ${GLUT_LIBRARIES}
+  ${GLUT_LIBRARY}
+  ${GLEW_LIBRARIES}
+  ${X11_LIBRARIES}
+  ${CMAKE_THREAD_LIBS_INIT}
+)
+
+install(DIRECTORY include/${PROJECT_NAME}/
+  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
+  FILES_MATCHING PATTERN "*.h"
+)
+
+install(TARGETS ${PROJECT_NAME} Simu
+  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
+)

+ 32 - 0
src/ros/catkin/src/op_simu/Makefile

@@ -0,0 +1,32 @@
+CC = g++
+DEBUG = -g
+CFLAGS = -Iinclude -I../op_utility/include -I../op_planner/include -Wall $(DEBUG) 
+LFLAGS = -Llibs -L../op_planner/libs -L../op_utility/libs -lGL -lGLU -lglut -lpthread -lutility -lplanner -lopencv_core -lopencv_video -lopencv_highgui -Wl,-rpath=.:../op_utility/libs -Wl,-rpath=.:../op_planner/libs
+SRC = $(wildcard src/*.cpp)
+INCLUDES = $(wildcard include/*.h)
+OBJ = $(SRC:.cpp=.o)
+EXE = libs/Simu
+LIB = libs/libsimu.so
+
+
+all: $(LIB) $(EXE) 
+
+pre-build:
+	-@echo 'Post build commands'
+	
+$(EXE): main.o $(OBJ) 
+	$(CC) -o $@ $< src/*.o $(LFLAGS) 
+	
+$(LIB): $(OBJ)
+	$(CC) -o $(LIB) src/*.o $(LFLAGS) -shared
+
+main.o: main.cpp
+	$(CC) -o $@ $< $(CFLAGS) -c -fPIC
+
+src/%.o: src/%.cpp
+	$(CC) -o $@ -c $< $(CFLAGS) -fPIC
+		
+.PHONY: clean
+
+clean:
+	rm -rf src/*.o *.o libs/Simu  libs/libsimu.so

BIN
src/ros/catkin/src/op_simu/docs/GPS meaningfulness.ods


+ 18 - 0
src/ros/catkin/src/op_simu/docs/Readme.txt

@@ -0,0 +1,18 @@
+Hard Coded Important information: 
+
+#Mapppig: 
+
+1- Path to vector map csv files: -> Simu-> PlannerTestDraw.cpp
+#define VectorMapPath "/home/hatem/workspace/Data/VectorMap/"
+
+2- Path to template kml file, for writing kml maps: Simu-> PlannerTestDraw.cpp
+#define kmlTemplateFile "/home/hatem/workspace/Data/templates/PlannerX_MapTemplate.kml"
+
+3- Origin point for Aisan Technology map. (cartisian origin) : PlannerH -> MappingHelpers.h -> GetTestToyotaOrigin()
+
+4- lane IDs for predefined path .. : Simu-> PlannerTestDraw.cpp
+#define PreDefinedPath  "11,333,1090,1704,147, 1791,801, 431, 1522, 372, 791, 1875, 1872,171,108,21,"
+
+
+#Graphics and UI: 
+1- use or not use GPU capabilities: Simu -> MainWindowWrapper.cpp -> bGPU (true , false)

+ 509 - 0
src/ros/catkin/src/op_simu/include/op_simu/SimpleTracker.h

@@ -0,0 +1,509 @@
+
+/// \file SimpleTracker.h
+/// \brief Kalman Filter based object tracker
+/// \author Hatem Darweesh
+/// \date Aug 11, 2016
+
+#ifndef SimpleTracker_H_
+#define SimpleTracker_H_
+
+#include "op_planner/RoadNetwork.h"
+#include "op_planner/PlanningHelpers.h"
+#include "opencv2/video/tracking.hpp"
+#include <vector>
+#include "op_utility/UtilityH.h"
+#include <math.h>
+#include <iostream>
+
+namespace SimulationNS
+{
+
+#define DEBUG_TRACKER 0
+#define NEVER_GORGET_TIME -1000
+
+enum TRACKING_TYPE {ASSOCIATE_ONLY = 0, SIMPLE_TRACKER = 1, CONTOUR_TRACKER = 2};
+
+struct Kalman1dState
+{
+    double MovCov; //double q; //moving noise covariance
+    double MeasureCov; //double r; //measurement noise covariance
+    double x; //value
+    double p; //estimation error covariance
+    double k; //kalman gain
+};
+
+class  kalmanFilter1D
+{
+public:
+
+  Kalman1dState result;
+
+    kalmanFilter1D()
+  {
+
+  }
+    kalmanFilter1D(double MovCov, double MeasureCov, double p, double intial_value)
+    {
+        result.MovCov = MovCov;
+        result.MeasureCov = MeasureCov;
+        result.p = p;
+        result.x = intial_value;
+    }
+
+    Kalman1dState Update(double measurement)
+    {
+      //prediction update
+    result.p = result.p + result.MovCov;
+
+    //measurement update
+    result.k = result.p / (result.p + result.MeasureCov);
+    result.x = result.x + result.k * (measurement - result.x);
+    result.p = (1 - result.k) * result.p;
+
+    return result;
+    }
+};
+
+class KFTrackV
+{
+private:
+  cv::KalmanFilter m_filter;
+  double prev_x, prev_y, prev_v, prev_a;
+  long m_id;
+  int nStates;
+  int nMeasure;
+  int MinAppearanceCount;
+
+public:
+  int m_bUpdated;
+  int region_id;
+  double forget_time;
+  int m_iLife;
+  PlannerHNS::DetectedObject obj; // Used for associate only , don't remove
+  //kalmanFilter1D errorSmoother;
+
+  long GetTrackID()
+  {
+    return m_id;
+  }
+
+  KFTrackV(double x, double y, double a, long id, double _dt, int _MinAppearanceCount = 1)
+  {
+//    errorSmoother.result.MovCov = 0.125;
+//    errorSmoother.result.MeasureCov = 0.1;
+//    errorSmoother.result.p = 1;
+//    errorSmoother.result.x = 0;
+    region_id = -1;
+    forget_time = NEVER_GORGET_TIME; // this is very bad , dangerous
+    m_iLife = 0;
+    prev_x = x;
+    prev_y = y;
+    prev_v = 0;
+    prev_a = a;
+    nStates = 4;
+    nMeasure = 2;
+
+    MinAppearanceCount = _MinAppearanceCount;
+
+    m_id = id;
+    m_bUpdated = true;
+
+    m_filter = cv::KalmanFilter(nStates,nMeasure);
+#if (CV_MAJOR_VERSION == 2)
+    m_filter.transitionMatrix = *(cv::Mat_<float>(nStates, nStates) << 1  ,0  ,_dt  ,0  ,
+        0  ,1  ,0  ,_dt  ,
+        0  ,0  ,1  ,0  ,
+        0  ,0  ,0  ,1  );
+#elif (CV_MAJOR_VERSION == 3)
+    m_filter.transitionMatrix = (cv::Mat_<float>(nStates, nStates) << 1  ,0  ,_dt  ,0  ,
+        0  ,1  ,0  ,_dt  ,
+        0  ,0  ,1  ,0  ,
+        0  ,0  ,0  ,1  );
+#endif    
+
+    m_filter.statePre.at<float>(0) = x;
+    m_filter.statePre.at<float>(1) = y;
+    m_filter.statePre.at<float>(2) = 0;
+    m_filter.statePre.at<float>(3) = 0;
+
+    m_filter.statePost = m_filter.statePre;
+
+    setIdentity(m_filter.measurementMatrix);
+
+    cv::setIdentity(m_filter.measurementNoiseCov, cv::Scalar::all(0.0001));
+    cv::setIdentity(m_filter.processNoiseCov, cv::Scalar::all(0.0001));
+    cv::setIdentity(m_filter.errorCovPost, cv::Scalar::all(0.075));
+
+    m_filter.predict();
+
+    //errorSmoother.Update(a);
+  }
+
+  void UpdateTracking(double _dt, const PlannerHNS::DetectedObject& oldObj, PlannerHNS::DetectedObject& predObj)
+  {
+
+#if (CV_MAJOR_VERSION == 2)
+    m_filter.transitionMatrix = *(cv::Mat_<float>(nStates, nStates) << 1  ,0  ,_dt  ,0  ,
+        0  ,1  ,0  ,_dt  ,
+        0  ,0  ,1  ,0  ,
+        0  ,0  ,0  ,1  );
+#elif (CV_MAJOR_VERSION == 3)
+    m_filter.transitionMatrix = (cv::Mat_<float>(nStates, nStates) << 1  ,0  ,_dt  ,0  ,
+        0  ,1  ,0  ,_dt  ,
+        0  ,0  ,1  ,0  ,
+        0  ,0  ,0  ,1  );
+#endif    
+
+    cv::Mat_<float> measurement(nMeasure,1);
+    cv::Mat_<float> prediction(nStates,1);
+
+    measurement(0) = oldObj.center.pos.x;
+    measurement(1) = oldObj.center.pos.y;
+
+    prediction = m_filter.correct(measurement);
+
+    predObj.center.pos.x = prediction.at<float>(0);
+    predObj.center.pos.y = prediction.at<float>(1);
+    double vx  = prediction.at<float>(2);
+    double vy  = prediction.at<float>(3);
+
+    double currA = 0;
+    double currV = 0;
+
+    if(m_iLife > 1)
+    {
+      currV = sqrt(vx*vx+vy*vy);
+
+      double diff_y = predObj.center.pos.y - prev_y;
+      double diff_x = predObj.center.pos.x - prev_x;
+      if(hypot(diff_y, diff_x) > 0.2)
+      {
+        currA = atan2(diff_y, diff_x);
+      }
+      else
+      {
+        currA = prev_a;
+      }
+    }
+
+
+    if(m_iLife > MinAppearanceCount)
+    {
+      predObj.center.pos.a = currA;
+      predObj.center.v = currV;
+      predObj.bVelocity = true;
+      predObj.acceleration = UtilityHNS::UtilityH::GetSign(predObj.center.v - prev_v);
+    }
+    else
+    {
+      predObj.bDirection = false;
+      predObj.bVelocity = false;
+    }
+
+    if(predObj.centers_list.size() > 30)
+          predObj.centers_list.erase(predObj.centers_list.begin()+0);
+
+    if(predObj.centers_list.size() > 1)
+    {
+      double diff_y = predObj.center.pos.y - predObj.centers_list.at(predObj.centers_list.size()-1).pos.y;
+      double diff_x = predObj.center.pos.x - predObj.centers_list.at(predObj.centers_list.size()-1).pos.x;
+      if(hypot(diff_y, diff_x) > 0.1)
+      {
+        predObj.centers_list.push_back(predObj.center);
+        PlannerHNS::PlanningHelpers::SmoothPath(predObj.centers_list, 0.3, 0.4, 0.1);
+        PlannerHNS::PlanningHelpers::CalcAngleAndCost(predObj.centers_list);
+      }
+    }
+    else
+      predObj.centers_list.push_back(predObj.center);
+
+    if(predObj.centers_list.size()>3)
+    {
+      predObj.bDirection = true;
+      predObj.center.pos.a = (predObj.centers_list.at(predObj.centers_list.size()-1).pos.a + predObj.centers_list.at(predObj.centers_list.size()-2).pos.a + predObj.centers_list.at(predObj.centers_list.size()-3).pos.a)/3.0;
+    }
+    else if(predObj.centers_list.size()>2)
+    {
+      predObj.center.pos.a = (predObj.centers_list.at(predObj.centers_list.size()-1).pos.a + predObj.centers_list.at(predObj.centers_list.size()-2).pos.a)/2.0;
+    }
+    else if(predObj.centers_list.size()>1)
+    {
+      predObj.center.pos.a = predObj.centers_list.at(predObj.centers_list.size()-1).pos.a;
+    }
+
+
+    m_filter.predict();
+    m_filter.statePre.copyTo(m_filter.statePost);
+    m_filter.errorCovPre.copyTo(m_filter.errorCovPost);
+
+    prev_a = currA;
+    prev_y = predObj.center.pos.y;
+    prev_x = predObj.center.pos.x;
+    prev_v = currV;
+    forget_time -= _dt;
+    m_iLife++;
+  }
+
+  void PredictTracking(double _dt, const PlannerHNS::DetectedObject& oldObj, PlannerHNS::DetectedObject& predObj)
+  {
+    if(m_iLife < MinAppearanceCount)
+    {
+      forget_time -= _dt;
+      return;
+    }
+
+#if (CV_MAJOR_VERSION == 2)
+    m_filter.transitionMatrix = *(cv::Mat_<float>(nStates, nStates) << 1  ,0  ,_dt  ,0  ,
+        0  ,1  ,0  ,_dt  ,
+        0  ,0  ,1  ,0  ,
+        0  ,0  ,0  ,1  );
+#elif (CV_MAJOR_VERSION == 3)
+    m_filter.transitionMatrix = (cv::Mat_<float>(nStates, nStates) << 1  ,0  ,_dt  ,0  ,
+        0  ,1  ,0  ,_dt  ,
+        0  ,0  ,1  ,0  ,
+        0  ,0  ,0  ,1  );
+#endif
+
+
+    cv::Mat_<float> prediction(nStates,1);
+
+    prediction = m_filter.predict();
+
+    predObj.center.pos.x = prediction.at<float>(0);
+    predObj.center.pos.y = prediction.at<float>(1);
+    double vx  = prediction.at<float>(2);
+    double vy  = prediction.at<float>(3);
+
+    double currA = 0;
+    double currV = 0;
+
+    if(m_iLife > 1)
+    {
+      currV = sqrt(vx*vx+vy*vy);
+
+      double diff_y = predObj.center.pos.y - prev_y;
+      double diff_x = predObj.center.pos.x - prev_x;
+      if(hypot(diff_y, diff_x) > 0.2)
+      {
+        prev_y = oldObj.center.pos.y;
+        prev_x = oldObj.center.pos.x;
+        currA = atan2(diff_y, diff_x);
+        prev_a = currA;
+      }
+      else
+      {
+        currA = prev_a;
+      }
+
+      for(unsigned int k=0; k < obj.contour.size(); k++)
+      {
+        obj.contour.at(k).x += diff_x;
+        obj.contour.at(k).y += diff_y;
+      }
+    }
+
+
+    if(m_iLife > MinAppearanceCount)
+    {
+      predObj.center.pos.a = currA;
+      predObj.center.v = currV;
+
+      predObj.bVelocity = true;
+      predObj.acceleration = UtilityHNS::UtilityH::GetSign(predObj.center.v - oldObj.center.v);
+    }
+    else
+    {
+      predObj.bDirection = false;
+      predObj.bVelocity = false;
+    }
+
+    if(predObj.centers_list.size() > 30)
+          predObj.centers_list.erase(predObj.centers_list.begin()+0);
+
+    if(predObj.centers_list.size() > 1)
+    {
+      double diff_y = predObj.center.pos.y - predObj.centers_list.at(predObj.centers_list.size()-1).pos.y;
+      double diff_x = predObj.center.pos.x - predObj.centers_list.at(predObj.centers_list.size()-1).pos.x;
+      if(hypot(diff_y, diff_x) > 0.1)
+      {
+        predObj.centers_list.push_back(predObj.center);
+        PlannerHNS::PlanningHelpers::SmoothPath(predObj.centers_list, 0.3, 0.4, 0.1);
+        PlannerHNS::PlanningHelpers::CalcAngleAndCost(predObj.centers_list);
+      }
+    }
+    else
+      predObj.centers_list.push_back(predObj.center);
+
+    if(predObj.centers_list.size()>3)
+    {
+      predObj.bDirection = true;
+      predObj.center.pos.a = (predObj.centers_list.at(predObj.centers_list.size()-1).pos.a + predObj.centers_list.at(predObj.centers_list.size()-2).pos.a + predObj.centers_list.at(predObj.centers_list.size()-3).pos.a)/3.0;
+    }
+    else if(predObj.centers_list.size()>2)
+    {
+      predObj.center.pos.a = (predObj.centers_list.at(predObj.centers_list.size()-1).pos.a + predObj.centers_list.at(predObj.centers_list.size()-2).pos.a)/2.0;
+    }
+    else if(predObj.centers_list.size()>1)
+    {
+      predObj.center.pos.a = predObj.centers_list.at(predObj.centers_list.size()-1).pos.a;
+    }
+
+
+    //m_filter.predict();
+    m_filter.statePre.copyTo(m_filter.statePost);
+    m_filter.errorCovPre.copyTo(m_filter.errorCovPost);
+
+    prev_v = currV;
+
+    forget_time -= _dt;
+    m_iLife++;
+  }
+
+  void UpdateAssociateOnly(double _dt, const PlannerHNS::DetectedObject& oldObj, PlannerHNS::DetectedObject& predObj)
+  {
+    if(predObj.centers_list.size() > 30)
+      predObj.centers_list.erase(predObj.centers_list.begin()+0);
+
+    if(predObj.centers_list.size() > 1)
+    {
+      double diff_y = predObj.center.pos.y - predObj.centers_list.at(predObj.centers_list.size()-1).pos.y;
+      double diff_x = predObj.center.pos.x - predObj.centers_list.at(predObj.centers_list.size()-1).pos.x;
+      if(hypot(diff_y, diff_x) > 0.1)
+      {
+        predObj.centers_list.push_back(predObj.center);
+        PlannerHNS::PlanningHelpers::SmoothPath(predObj.centers_list, 0.3, 0.4, 0.1);
+        PlannerHNS::PlanningHelpers::CalcAngleAndCost(predObj.centers_list);
+      }
+    }
+    else
+      predObj.centers_list.push_back(predObj.center);
+
+    if(predObj.centers_list.size()>3)
+    {
+      predObj.bDirection = true;
+      predObj.center.pos.a = (predObj.centers_list.at(predObj.centers_list.size()-1).pos.a + predObj.centers_list.at(predObj.centers_list.size()-2).pos.a + predObj.centers_list.at(predObj.centers_list.size()-3).pos.a)/3.0;
+    }
+    else if(predObj.centers_list.size()>2)
+    {
+      predObj.bDirection = true;
+      predObj.center.pos.a = (predObj.centers_list.at(predObj.centers_list.size()-1).pos.a + predObj.centers_list.at(predObj.centers_list.size()-2).pos.a)/2.0;
+    }
+    else if(predObj.centers_list.size()>1)
+    {
+      predObj.bDirection = false;
+      predObj.center.pos.a = predObj.centers_list.at(predObj.centers_list.size()-1).pos.a;
+    }
+    else
+      predObj.bDirection = false;
+
+  }
+
+  virtual ~KFTrackV(){}
+};
+
+class InterestCircle
+{
+public:
+  int id;
+  double radius;
+  double forget_time;
+  std::vector<KFTrackV*> pTrackers;
+
+  InterestCircle(int _id)
+  {
+    id = _id;
+    radius = 0;
+    forget_time = NEVER_GORGET_TIME; // never forget
+  }
+};
+
+class CostRecordSet
+{
+public:
+  int i_obj;
+  int i_track;
+  double cost;
+   double size_diff;
+   double width_diff;
+   double length_diff;
+   double height_diff;
+   double angle_diff;
+   double distance_diff;
+  CostRecordSet(int obj_index, int track_index, double _distance_diff, double _size_diff, double _width_diff, double _length_diff, double _height_diff, double _angle_diff)
+  {
+    i_obj = obj_index;
+    i_track = track_index;
+    size_diff = _size_diff;
+    angle_diff = _angle_diff;
+    distance_diff = _distance_diff;
+    width_diff = _width_diff;
+    length_diff = _length_diff;
+    height_diff = _height_diff;
+    cost = 0;
+  }
+
+  CostRecordSet()
+  {
+    i_obj = -1;
+    i_track = -1;
+    size_diff = 0;
+    angle_diff = 0;
+    distance_diff = 0;
+    width_diff = 0;
+    length_diff = 0;
+    height_diff = 0;
+    cost = 0;
+  }
+};
+
+class SimpleTracker
+{
+public:
+  std::vector<CostRecordSet> m_CostsLists;
+  std::vector<InterestCircle*> m_InterestRegions;
+  std::vector<KFTrackV*> m_Tracks;
+  std::vector<KFTrackV> m_TrackSimply;
+  timespec m_TrackTimer;
+  long iTracksNumber;
+  PlannerHNS::WayPoint m_PrevState;
+  PlannerHNS::WayPoint m_StateDiff;
+  std::vector<PlannerHNS::DetectedObject> m_PrevDetectedObjects;
+  std::vector<PlannerHNS::DetectedObject> m_DetectedObjects;
+
+  void DoOneStep(const PlannerHNS::WayPoint& currPose, const std::vector<PlannerHNS::DetectedObject>& obj_list, const TRACKING_TYPE& type = SIMPLE_TRACKER);
+
+  SimpleTracker();
+  virtual ~SimpleTracker();
+  void InitSimpleTracker();
+  void InitializeInterestRegions(std::vector<InterestCircle*>& regions);
+
+public:
+  double m_dt;
+  double m_MAX_ASSOCIATION_DISTANCE;
+  bool m_bUseCenterOnly;
+  double m_MaxKeepTime;
+  bool m_bFirstCall;
+  int m_nMinTrustAppearances;
+  double m_Horizon;
+  double m_CirclesResolution;
+  double m_MAX_ASSOCIATION_SIZE_DIFF;
+  double m_MAX_ASSOCIATION_ANGLE_DIFF;
+
+private:
+  std::vector<KFTrackV> newObjects;
+  void AssociateAndTrack();
+  void AssociateSimply();
+  void AssociateToRegions(KFTrackV& detectedObject);
+  void CleanOldTracks();
+  void AssociateOnly();
+  void MergeObjectAndTrack(KFTrackV& track, PlannerHNS::DetectedObject& obj);
+  int InsidePolygon(const std::vector<PlannerHNS::GPSPoint>& polygon,const PlannerHNS::GPSPoint& p);
+
+  void MatchClosest();
+  void MatchClosestCost();
+
+};
+
+}
+
+#endif /* SimpleTracker_H_ */

+ 72 - 0
src/ros/catkin/src/op_simu/include/op_simu/SimulatedTrajectoryFollower.h

@@ -0,0 +1,72 @@
+/*
+ * SimulatedTrajectoryFollower.h
+ *
+ *  Created on: Jun 18, 2016
+ *      Author: hatem
+ */
+
+#ifndef SimulatedTrajectoryFollower_H_
+#define SimulatedTrajectoryFollower_H_
+#include "op_planner/RoadNetwork.h"
+#include "op_utility/UtilityH.h"
+#include "op_planner/PlannerCommonDef.h"
+
+namespace SimulationNS
+{
+
+class SimulatedTrajectoryFollower
+{
+public:
+  SimulatedTrajectoryFollower();
+  virtual ~SimulatedTrajectoryFollower();
+
+  void PrepareNextWaypoint(const PlannerHNS::WayPoint& CurPos, const double& currVelocity, const double& currSteering);
+
+  void UpdateCurrentPath(const std::vector<PlannerHNS::WayPoint>& path);
+
+  int SteerControllerUpdate(const PlannerHNS::VehicleState& CurrStatus,
+      const PlannerHNS::BehaviorState& CurrBehavior, double& desiredSteerAngle);
+  int VeclocityControllerUpdate(const double& dt, const PlannerHNS::VehicleState& CurrStatus,
+      const PlannerHNS::BehaviorState& CurrBehavior, double& desiredVelocity);
+
+  void Init(const PlannerHNS::ControllerParams& params, const PlannerHNS::CAR_BASIC_INFO& vehicleInfo);
+
+  PlannerHNS::VehicleState DoOneStep(const double& dt, const PlannerHNS::BehaviorState& behavior,
+        const std::vector<PlannerHNS::WayPoint>& path, const PlannerHNS::WayPoint& currPose,
+        const PlannerHNS::VehicleState& vehicleState, const bool& bNewTrajectory);
+
+  //Testing Points
+  PlannerHNS::WayPoint   m_PerpendicularPoint;
+  PlannerHNS::WayPoint   m_FollowMePoint;
+  double           m_LateralError;
+  double           m_FollowingDistance;
+  PlannerHNS::WayPoint   m_CurrPos;
+  int           m_iCalculatedIndex;
+
+private:
+  PlannerHNS::ControllerParams       m_Params;
+  PlannerHNS::CAR_BASIC_INFO         m_VehicleInfo;
+  std::vector<PlannerHNS::WayPoint>   m_Path;
+  double            m_PrevDesiredSteer; // control output
+  double             m_FollowAcceleration;
+  int             m_iPrevWayPoint;
+  UtilityHNS::PIDController   m_pidSteer;
+  UtilityHNS::PIDController   m_pidVelocity;
+
+  bool FindNextWayPoint(const std::vector<PlannerHNS::WayPoint>& path, const PlannerHNS::WayPoint& state,
+      const double& velocity, PlannerHNS::WayPoint& pursuite_point, PlannerHNS::WayPoint& prep,
+      double& lateral_err, double& follow_distance);
+
+  int SteerControllerPart(const PlannerHNS::WayPoint& state, const PlannerHNS::WayPoint& way_point,
+      const double& lateral_error, double& steerd);
+
+  int CalculateVelocityDesired(const double& dt, const double& currVel,const PlannerHNS::STATE_TYPE& CurrBehavior,
+      double& desiredVel);
+
+
+
+};
+
+} /* namespace SimulationNS */
+
+#endif /* SimulatedTrajectoryFollower_H_ */

+ 111 - 0
src/ros/catkin/src/op_simu/include/op_simu/TrajectoryFollower.h

@@ -0,0 +1,111 @@
+
+/// \file TrajectoryFollower.h
+/// \brief PID based trajectory follower
+/// \author Hatem Darweesh
+/// \date Jun 18, 2016
+
+
+#ifndef TRAJECTORYFOLLOWER_H_
+#define TRAJECTORYFOLLOWER_H_
+#include "op_planner/RoadNetwork.h"
+#include "op_utility/UtilityH.h"
+#include "op_planner/PlannerCommonDef.h"
+
+
+#define MAX_ACCELERATION_2G 5 // meter /sec/sec
+namespace SimulationNS
+{
+
+class TrajectoryFollower
+{
+public:
+  TrajectoryFollower();
+  virtual ~TrajectoryFollower();
+
+  void PrepareNextWaypoint(const PlannerHNS::WayPoint& CurPos, const double& currVelocity, const double& currSteering);
+
+  void UpdateCurrentPath(const std::vector<PlannerHNS::WayPoint>& path);
+
+  int SteerControllerUpdate(const PlannerHNS::VehicleState& CurrStatus,
+      const PlannerHNS::BehaviorState& CurrBehavior, double& desiredSteerAngle);
+  int VeclocityControllerUpdate(const double& dt, const PlannerHNS::VehicleState& CurrStatus,
+      const PlannerHNS::BehaviorState& CurrBehavior, double& desiredVelocity, PlannerHNS::SHIFT_POS& desiredShift);
+
+  void Init(const PlannerHNS::ControllerParams& params, const PlannerHNS::CAR_BASIC_INFO& vehicleInfo, bool bEnableLogs = false, bool bCalibration = false);
+
+  PlannerHNS::VehicleState DoOneStep(const double& dt, const PlannerHNS::BehaviorState& behavior,
+        const std::vector<PlannerHNS::WayPoint>& path, const PlannerHNS::WayPoint& currPose,
+        const PlannerHNS::VehicleState& vehicleState, const bool& bNewTrajectory);
+
+  //Testing Points
+  PlannerHNS::WayPoint   m_ForwardSimulation;
+  PlannerHNS::WayPoint   m_PerpendicularPoint;
+  PlannerHNS::WayPoint   m_FollowMePoint;
+  double           m_LateralError;
+  double           m_FollowingDistance;
+  PlannerHNS::WayPoint   m_CurrPos;
+  int           m_iCalculatedIndex;
+  bool          m_bEndPath;
+  double           m_WayPointsDensity;
+
+
+private:
+  double             m_StartFollowDistance;
+  double             m_FollowAcc;
+  PlannerHNS::ControllerParams       m_Params;
+  PlannerHNS::CAR_BASIC_INFO         m_VehicleInfo;
+  std::vector<PlannerHNS::WayPoint>   m_Path;
+  PlannerHNS::WayPoint     m_DesPos;
+  double            m_PrevDesiredSteer; // control output
+  double             m_FollowAcceleration;
+  int             m_iPrevWayPoint;
+  UtilityHNS::PIDController   m_pidSteer;
+  UtilityHNS::LowpassFilter   m_lowpassSteer;
+
+  UtilityHNS::PIDController   m_pidVelocity;
+  UtilityHNS::LowpassFilter   m_lowpassVelocity;
+
+  bool            m_bEnableLog;
+  std::vector<std::string>    m_LogData;
+  std::vector<std::string>    m_LogSteerPIDData;
+  std::vector<std::string>    m_LogVelocityPIDData;
+
+  //Steering and Velocity Calibration Global Variables
+  bool            m_bCalibrationMode;
+  int              m_iNextTest;
+  std::vector<std::string>    m_SteerCalibrationData;
+  std::vector<std::string>    m_VelocityCalibrationData;
+  PlannerHNS::VehicleState   m_prevCurrState_steer;
+  PlannerHNS::VehicleState   m_prevDesiredState_steer;
+  PlannerHNS::VehicleState   m_prevCurrState_vel;
+  PlannerHNS::VehicleState   m_prevDesiredState_vel;
+  struct timespec       m_SteerDelayTimer;
+  struct timespec       m_VelocityDelayTimer;
+  std::vector<std::pair<double, double> > m_CalibrationRunList;
+
+
+  bool FindNextWayPoint(const std::vector<PlannerHNS::WayPoint>& path, const PlannerHNS::WayPoint& state,
+      const double& velocity, PlannerHNS::WayPoint& pursuite_point, PlannerHNS::WayPoint& prep,
+      double& lateral_err, double& follow_distance);
+
+  int SteerControllerPart(const PlannerHNS::WayPoint& state, const PlannerHNS::WayPoint& way_point,
+      const double& lateral_error, double& steerd);
+
+  void PredictMotion(double& x, double &y, double& heading, double steering, double velocity,
+      double wheelbase, double time_elapsed);
+
+  double GetPID_LinearChange(double minVal, double maxVal, double speedMax, double currSpeed);
+
+  void AdjustPID(const double& v, const double& maxV,  PlannerHNS::PID_CONST& steerPID);
+
+  int CalculateVelocityDesired(const double& dt, const double& currVel,const PlannerHNS::STATE_TYPE& CurrBehavior,
+      double& desiredVel);
+
+  void LogCalibrationData(const PlannerHNS::VehicleState& currState,const PlannerHNS::VehicleState& desiredState);
+  void InitCalibration();
+  void CalibrationStep(const double& dt, const PlannerHNS::VehicleState& CurrStatus, double& desiredSteer, double& desiredVelocity);
+};
+
+} /* namespace SimulationNS */
+
+#endif /* TRAJECTORYFOLLOWER_H_ */

+ 15 - 0
src/ros/catkin/src/op_simu/main.cpp

@@ -0,0 +1,15 @@
+/*
+ * main.cpp
+ *
+ *  Created on: May 31, 2016
+ *      Author: hatem
+ */
+
+#include <iostream>
+
+int main(int argc, char** argv)
+{
+
+}
+
+

+ 22 - 0
src/ros/catkin/src/op_simu/package.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<package format="2">
+  <name>op_simu</name>
+  <version>1.12.0</version>
+  <description>The libopenplanner_simu package</description>
+  <maintainer email="yusuke.fujii@tier4.jp">Yusuke FUJII</maintainer>
+  <author email="hatem.darweesh@g.sp.m.is.nagoya-u.ac.jp">Hatem Darweesh</author>
+  <license>Apache 2</license>
+
+  <buildtool_depend>autoware_build_flags</buildtool_depend>
+  <buildtool_depend>catkin</buildtool_depend>
+
+  <depend>glut</depend>
+  <depend>libglew-dev</depend>
+  <depend>libopencv-dev</depend>
+  <depend>libx11-dev</depend>
+  <depend>libxi-dev</depend>
+  <depend>libxmu-dev</depend>
+  <depend>op_planner</depend>
+  <depend>op_utility</depend>
+  <depend>opengl</depend>
+</package>

+ 616 - 0
src/ros/catkin/src/op_simu/src/SimpleTracker.cpp

@@ -0,0 +1,616 @@
+/// \file SimpleTracker.cpp
+/// \brief Kalman Filter based object tracker
+/// \author Hatem Darweesh
+/// \date Aug 11, 2016
+
+#include "op_simu/SimpleTracker.h"
+#include "op_planner/MatrixOperations.h"
+#include "op_utility/UtilityH.h"
+
+#include <iostream>
+#include <vector>
+#include <cstdio>
+
+#include <opencv2/core/core.hpp>
+#include <opencv2/highgui/highgui.hpp>
+#include <opencv2/video/tracking.hpp>
+
+namespace SimulationNS
+{
+
+using namespace PlannerHNS;
+
+SimpleTracker::SimpleTracker()
+{
+  iTracksNumber = 1;
+  m_dt = 0.1;
+  m_MAX_ASSOCIATION_DISTANCE = 2.0;
+  m_MAX_ASSOCIATION_SIZE_DIFF = 1.0;
+  m_MAX_ASSOCIATION_ANGLE_DIFF = 0.44;
+  m_MaxKeepTime = 2; // seconds
+  m_bUseCenterOnly = true;
+  m_bFirstCall = true;
+  m_nMinTrustAppearances = 5;
+  m_Horizon = 100.0;
+  m_CirclesResolution = 5.0;
+  UtilityHNS::UtilityH::GetTickCount(m_TrackTimer);
+}
+
+void SimpleTracker::InitSimpleTracker()
+{
+  UtilityHNS::UtilityH::GetTickCount(m_TrackTimer);
+  InitializeInterestRegions(m_InterestRegions);
+}
+
+SimpleTracker::~SimpleTracker()
+{
+  for(unsigned int i = 0; i < m_InterestRegions.size(); i++)
+  {
+    delete m_InterestRegions.at(i);
+  }
+  m_InterestRegions.clear();
+
+  for(unsigned int i = 0; i < m_Tracks.size(); i++)
+  {
+    delete m_Tracks.at(i);
+  }
+  m_Tracks.clear();
+
+}
+
+void SimpleTracker::InitializeInterestRegions(std::vector<InterestCircle*>& regions)
+{
+  //initialize interest regions
+  double next_raduis = m_CirclesResolution;
+  double next_foget_time = m_MaxKeepTime;
+  while(1)
+  {
+    InterestCircle* pCir = new InterestCircle(regions.size()+1);
+    if(regions.size() == 0)
+    {
+      pCir->radius = next_raduis;
+      pCir->forget_time = next_foget_time;
+      regions.push_back(pCir);
+      std::cout << "Region No: " << regions.size() << ", Radius: " << pCir->radius << ", F time: " << pCir->forget_time << std::endl;
+    }
+    else
+    {
+      pCir->radius = next_raduis;
+      pCir->forget_time = next_foget_time;
+      regions.push_back(pCir);
+
+      std::cout << "Region No: " << regions.size() << ", Radius: " << pCir->radius << ", F time: " << pCir->forget_time << std::endl;
+    }
+
+    if(next_raduis >= m_Horizon)
+      break;
+
+    next_raduis += next_raduis * 0.8;
+    if(next_raduis > m_Horizon)
+      next_raduis = m_Horizon;
+    next_foget_time -= next_foget_time * 0.25;
+    if(next_foget_time < 0.1)
+      next_foget_time = 0.1;
+  }
+}
+
+void SimpleTracker::DoOneStep(const WayPoint& currPose, const std::vector<DetectedObject>& obj_list, const TRACKING_TYPE& type)
+{
+  if(!m_bFirstCall)
+  {
+    m_dt = UtilityHNS::UtilityH::GetTimeDiffNow(m_TrackTimer);
+    m_StateDiff.pos.x = m_PrevState.pos.x - currPose.pos.x ;
+    m_StateDiff.pos.y = m_PrevState.pos.y - currPose.pos.y;
+    m_StateDiff.pos.a = UtilityHNS::UtilityH::AngleBetweenTwoAnglesPositive(currPose.pos.a, m_PrevState.pos.a) * UtilityHNS::UtilityH::GetSign(m_PrevState.pos.a - currPose.pos.a);
+    //std::cout << "(" << m_StateDiff.pos.x << ", " << m_StateDiff.pos.y << ", " << m_StateDiff.pos.a << std::endl;
+  }
+  else
+    m_bFirstCall = false;
+
+  UtilityHNS::UtilityH::GetTickCount(m_TrackTimer);
+
+  m_DetectedObjects = obj_list;
+
+  if(type == ASSOCIATE_ONLY)
+  {
+    AssociateOnly();
+  }
+  else if (type == SIMPLE_TRACKER)
+  {
+    AssociateSimply();
+  }
+  else
+  {
+    AssociateAndTrack();
+    CleanOldTracks();
+  }
+
+  m_PrevState = currPose;
+
+}
+
+void SimpleTracker::MatchClosest()
+{
+  newObjects.clear();
+
+  std::cout << std::endl << std::endl  << std::endl;
+  while(m_DetectedObjects.size() > 0)
+  {
+    double iCloseset_track = -1;
+    double iCloseset_obj = -1;
+    double dCloseset = 99999999;
+    bool bFoundMatch = false;
+
+    double size_diff = -1;
+    std::cout << std::endl;
+
+    m_CostsLists.clear();
+
+    for(unsigned int jj = 0; jj < m_DetectedObjects.size(); jj++)
+    {
+      double object_size = sqrt(m_DetectedObjects.at(jj).w*m_DetectedObjects.at(jj).w + m_DetectedObjects.at(jj).l*m_DetectedObjects.at(jj).l + m_DetectedObjects.at(jj).h*m_DetectedObjects.at(jj).h);
+
+      for(unsigned int i = 0; i < m_TrackSimply.size(); i++)
+      {
+        double d = hypot(m_DetectedObjects.at(jj).center.pos.y-m_TrackSimply.at(i).obj.center.pos.y, m_DetectedObjects.at(jj).center.pos.x-m_TrackSimply.at(i).obj.center.pos.x);
+        double old_size = sqrt(m_TrackSimply.at(i).obj.w*m_TrackSimply.at(i).obj.w + m_TrackSimply.at(i).obj.l*m_TrackSimply.at(i).obj.l + m_TrackSimply.at(i).obj.h*m_TrackSimply.at(i).obj.h);
+        double obj_diff = fabs(object_size - old_size);
+
+        bool bInsidePolygon = (InsidePolygon(m_TrackSimply.at(i).obj.contour, m_DetectedObjects.at(jj).center.pos) == 1 || InsidePolygon(m_DetectedObjects.at(jj).contour, m_TrackSimply.at(i).obj.center.pos) == 1);
+
+        if(obj_diff < m_MAX_ASSOCIATION_SIZE_DIFF &&  bInsidePolygon)
+         {
+           bFoundMatch = true;
+           iCloseset_track = i;
+           iCloseset_obj = jj;
+           size_diff = obj_diff;
+           std::cout << "Polygon Size Match" << std::endl;
+           break;
+         }
+
+        if(obj_diff < m_MAX_ASSOCIATION_SIZE_DIFF && d < dCloseset)
+        {
+          dCloseset = d;
+          iCloseset_track = i;
+          iCloseset_obj = jj;
+          size_diff = obj_diff;
+          size_diff = obj_diff;
+        }
+      }
+
+      if(bFoundMatch)
+        break;
+    }
+
+    if(iCloseset_obj != -1 && iCloseset_track != -1 && (dCloseset <= m_MAX_ASSOCIATION_DISTANCE || bFoundMatch == true))
+    {
+      std::cout << "MatchObj: " << m_TrackSimply.at(iCloseset_track).obj.id << ", MinD: " << dCloseset << ", SizeDiff: (" << size_diff <<  ")" << ", ObjI" << iCloseset_obj <<", TrackI: " << iCloseset_track << ", CMatch: " << bFoundMatch << std::endl;
+
+      m_DetectedObjects.at(iCloseset_obj).id = m_TrackSimply.at(iCloseset_track).obj.id;
+      MergeObjectAndTrack(m_TrackSimply.at(iCloseset_track), m_DetectedObjects.at(iCloseset_obj));
+      newObjects.push_back(m_TrackSimply.at(iCloseset_track));
+      m_TrackSimply.erase(m_TrackSimply.begin()+iCloseset_track);
+      m_DetectedObjects.erase(m_DetectedObjects.begin()+iCloseset_obj);
+    }
+    else
+    {
+      iTracksNumber = iTracksNumber + 1;
+      if(iCloseset_obj != -1)
+      {
+        m_DetectedObjects.at(iCloseset_obj).id = iTracksNumber;
+        KFTrackV track(m_DetectedObjects.at(iCloseset_obj).center.pos.x, m_DetectedObjects.at(iCloseset_obj).center.pos.y,m_DetectedObjects.at(iCloseset_obj).actual_yaw, m_DetectedObjects.at(iCloseset_obj).id, m_dt, m_nMinTrustAppearances);
+        track.obj = m_DetectedObjects.at(iCloseset_obj);
+        newObjects.push_back(track);
+        //std::cout << "NewObj: " << iTracksNumber  << ", MinD: " << dCloseset << ", MinS: " << min_size << ", ObjI:" << iCloseset_obj <<", TrackI: " << iCloseset_track << ", ContMatch: " << bFoundMatch << std::endl;
+        m_DetectedObjects.erase(m_DetectedObjects.begin()+iCloseset_obj);
+      }
+      else
+      {
+        m_DetectedObjects.at(0).id = iTracksNumber;
+        KFTrackV track(m_DetectedObjects.at(0).center.pos.x, m_DetectedObjects.at(0).center.pos.y,m_DetectedObjects.at(0).actual_yaw, m_DetectedObjects.at(0).id, m_dt, m_nMinTrustAppearances);
+        track.obj = m_DetectedObjects.at(0);
+        newObjects.push_back(track);
+        //std::cout << "NewObj: " << iTracksNumber  << ", MinD: " << dCloseset << ", MinS: " << min_size << ", ObjI:" << 0 <<", TrackI: " << iCloseset_track << ", ContMatch: " << bFoundMatch << std::endl;
+        m_DetectedObjects.erase(m_DetectedObjects.begin()+0);
+      }
+    }
+  }
+
+  m_TrackSimply = newObjects;
+}
+
+void SimpleTracker::MatchClosestCost()
+{
+  newObjects.clear();
+
+  //std::cout << std::endl << std::endl  << std::endl;
+  while(m_DetectedObjects.size() > 0)
+  {
+    //std::cout << std::endl;
+    double max_d = -1;
+    double min_d = 999999999;
+    double max_s = -1;
+    double min_s = 999999999;
+    double max_a = -1;
+    double min_a = 999999999;
+    double max_w = -1;
+    double min_w = 999999999;
+    double max_l = -1;
+    double min_l = 999999999;
+    double max_h = -1;
+    double min_h = 999999999;
+
+    m_CostsLists.clear();
+
+    for(unsigned int jj = 0; jj < m_DetectedObjects.size(); jj++)
+    {
+      double object_size = sqrt(m_DetectedObjects.at(jj).w*m_DetectedObjects.at(jj).w + m_DetectedObjects.at(jj).l*m_DetectedObjects.at(jj).l + m_DetectedObjects.at(jj).h*m_DetectedObjects.at(jj).h);
+
+      for(unsigned int i = 0; i < m_TrackSimply.size(); i++)
+      {
+        double d = hypot(m_DetectedObjects.at(jj).center.pos.y-m_TrackSimply.at(i).obj.center.pos.y, m_DetectedObjects.at(jj).center.pos.x-m_TrackSimply.at(i).obj.center.pos.x);
+        double old_size = sqrt(m_TrackSimply.at(i).obj.w*m_TrackSimply.at(i).obj.w + m_TrackSimply.at(i).obj.l*m_TrackSimply.at(i).obj.l + m_TrackSimply.at(i).obj.h*m_TrackSimply.at(i).obj.h);
+        double obj_diff = fabs(object_size - old_size);
+        double w_diff = fabs(m_TrackSimply.at(i).obj.w - m_DetectedObjects.at(jj).w);
+        double h_diff = fabs(m_TrackSimply.at(i).obj.h - m_DetectedObjects.at(jj).h);
+        double l_diff = fabs(m_TrackSimply.at(i).obj.l - m_DetectedObjects.at(jj).l);
+
+        bool bDirectionMatch = false;
+        bool bSimilarSize = false;
+        double a_diff = M_PI;
+        if(m_TrackSimply.at(i).obj.bDirection)
+        {
+          double diff_y = m_DetectedObjects.at(jj).center.pos.y - m_TrackSimply.at(i).obj.center.pos.y;
+          double diff_x = m_DetectedObjects.at(jj).center.pos.x - m_TrackSimply.at(i).obj.center.pos.x ;
+          if(hypot(diff_y, diff_x) > 0.2)
+          {
+            double a = UtilityHNS::UtilityH::FixNegativeAngle(atan2(diff_y, diff_x));
+            a_diff = UtilityHNS::UtilityH::AngleBetweenTwoAnglesPositive(a,m_TrackSimply.at(i).obj.center.pos.a);
+            if(a_diff < m_MAX_ASSOCIATION_ANGLE_DIFF)
+              bDirectionMatch = true;
+          }
+        }
+
+        if(w_diff < m_MAX_ASSOCIATION_SIZE_DIFF/3.0 && h_diff < m_MAX_ASSOCIATION_SIZE_DIFF/3.0 && l_diff < m_MAX_ASSOCIATION_SIZE_DIFF/3.0)
+          bSimilarSize = true;
+
+        if(d > max_d) max_d = d; if(d < min_d) min_d = d;
+        if(obj_diff > max_s) max_s = obj_diff; if(obj_diff < min_s) min_s = obj_diff;
+        if(w_diff > max_w) max_w = w_diff; if(w_diff < min_w) min_w = w_diff;
+        if(l_diff > max_l) max_l = l_diff; if(l_diff < min_l) min_l = l_diff;
+        if(h_diff > max_h) max_h = h_diff; if(h_diff < min_h) min_h = h_diff;
+        if(a_diff > max_a) max_a = a_diff; if(a_diff < min_a) min_a = a_diff;
+
+        m_CostsLists.push_back(CostRecordSet(jj, i, d, obj_diff, w_diff, l_diff, h_diff, a_diff));
+
+      //  std::cout << "Test: " << m_TrackSimply.at(i).obj.id << ", MinD: " << d << ", ObjS: " << obj_diff << ", Angle: " << a_diff << ", ObjI: " << jj << ", TrackI: " << i << std::endl;
+      }
+
+    }
+
+    // Normalize and find the minimum
+    std::vector<double> vs;
+
+    double d_v = max_d - min_d;
+    double w_v = max_w - min_w;
+    double l_v = max_l - min_l;
+    double h_v = max_h - min_h;
+    double a_v = max_a - min_a;
+    double s_v = max_s - min_s;
+
+    for(unsigned int ic = 0 ; ic < m_CostsLists.size() ; ic++)
+    {
+      int actual_count = 0;
+      if(d_v != 0)
+      {
+        m_CostsLists.at(ic).cost += m_CostsLists.at(ic).distance_diff/d_v;
+        actual_count++;
+      }
+
+      if(w_v != 0)
+      {
+        m_CostsLists.at(ic).cost += m_CostsLists.at(ic).width_diff/w_v;
+        actual_count++;
+      }
+
+      if(l_v != 0)
+      {
+        m_CostsLists.at(ic).cost += m_CostsLists.at(ic).length_diff/l_v;
+        actual_count++;
+      }
+
+      if(h_v != 0)
+      {
+        m_CostsLists.at(ic).cost += m_CostsLists.at(ic).height_diff/h_v;
+        actual_count++;
+      }
+
+      if(a_v != 0 && m_CostsLists.at(ic).angle_diff < M_PI_2)
+      {
+        m_CostsLists.at(ic).cost += m_CostsLists.at(ic).angle_diff/a_v;
+        actual_count++;
+      }
+      else
+        m_CostsLists.at(ic).angle_diff = 0;
+
+//      if(s_v != 0 )
+//      {
+//        m_CostsLists.at(ic).cost += m_CostsLists.at(ic).size_diff/s_v;
+//        actual_count++;
+//      }
+
+
+      if(actual_count > 0)
+        m_CostsLists.at(ic).cost = m_CostsLists.at(ic).cost / (double)actual_count;
+    //  std::cout << "Cost = " << m_CostsLists.at(ic).cost << std::endl;
+    }
+
+    CostRecordSet min_set;
+    min_set.cost = 99999999;
+
+    for(unsigned int ic = 0 ; ic < m_CostsLists.size() ; ic++)
+    {
+      if(m_CostsLists.at(ic).cost < min_set.cost)
+        min_set = m_CostsLists.at(ic);
+    }
+
+
+    if(min_set.i_obj != -1 && min_set.i_track != -1 &&  min_set.distance_diff <= m_MAX_ASSOCIATION_DISTANCE && min_set.size_diff < m_MAX_ASSOCIATION_SIZE_DIFF && min_set.angle_diff < m_MAX_ASSOCIATION_ANGLE_DIFF)
+    {
+    //  std::cout << "MatchObj: " << m_TrackSimply.at(min_set.i_track).obj.id << ", MinD: " << min_set.distance_diff << ", SizeDiff: (" << min_set.size_diff << ")" << ", AngDiff: " << min_set.angle_diff  << ", ObjI" << min_set.i_obj <<", TrackI: " << min_set.i_track << std::endl;
+
+      m_DetectedObjects.at(min_set.i_obj).id = m_TrackSimply.at(min_set.i_track).obj.id;
+      MergeObjectAndTrack(m_TrackSimply.at(min_set.i_track), m_DetectedObjects.at(min_set.i_obj));
+      newObjects.push_back(m_TrackSimply.at(min_set.i_track));
+      m_TrackSimply.erase(m_TrackSimply.begin()+min_set.i_track);
+      m_DetectedObjects.erase(m_DetectedObjects.begin()+min_set.i_obj);
+    }
+    else
+    {
+      iTracksNumber = iTracksNumber + 1;
+
+      if(min_set.i_obj != -1)
+      {
+        m_DetectedObjects.at(min_set.i_obj).id = iTracksNumber;
+        KFTrackV track(m_DetectedObjects.at(min_set.i_obj).center.pos.x, m_DetectedObjects.at(min_set.i_obj).center.pos.y,m_DetectedObjects.at(min_set.i_obj).actual_yaw, m_DetectedObjects.at(min_set.i_obj).id, m_dt, m_nMinTrustAppearances);
+        track.obj = m_DetectedObjects.at(min_set.i_obj);
+        newObjects.push_back(track);
+
+        //std::cout << "NewMatch: " << iTracksNumber << ", "<< ", MinD: " << min_set.distance_diff << ", SizeDiff: (" << min_set.size_diff << ")" << ", AngDiff: " << min_set.angle_diff << ", ObjI" << min_set.i_obj <<", TrackI: " << min_set.i_track << std::endl;
+        m_DetectedObjects.erase(m_DetectedObjects.begin()+min_set.i_obj);
+      }
+      else
+      {
+        m_DetectedObjects.at(0).id = iTracksNumber;
+        KFTrackV track(m_DetectedObjects.at(0).center.pos.x, m_DetectedObjects.at(0).center.pos.y,m_DetectedObjects.at(0).actual_yaw, m_DetectedObjects.at(0).id, m_dt, m_nMinTrustAppearances);
+        track.obj = m_DetectedObjects.at(0);
+        newObjects.push_back(track);
+        //std::cout << "NewObj: " << iTracksNumber << ", "<< ", MinD: " << min_set.distance_diff << ", SizeDiff: (" << min_set.size_diff << ")" << ", AngDiff: " << min_set.angle_diff << ", ObjI" << min_set.i_obj <<", TrackI: " << min_set.i_track << std::endl;
+        m_DetectedObjects.erase(m_DetectedObjects.begin()+0);
+      }
+    }
+  }
+
+  m_TrackSimply = newObjects;
+}
+
+void SimpleTracker::AssociateOnly()
+{
+  MatchClosestCost();
+
+  for(unsigned int i =0; i< m_TrackSimply.size(); i++)
+    m_TrackSimply.at(i).UpdateAssociateOnly(m_dt, m_TrackSimply.at(i).obj, m_TrackSimply.at(i).obj);
+
+  m_DetectedObjects.clear();
+  for(unsigned int i = 0; i< m_TrackSimply.size(); i++)
+    m_DetectedObjects.push_back(m_TrackSimply.at(i).obj);
+}
+
+void SimpleTracker::AssociateSimply()
+{
+  for(unsigned int i = 0; i < m_TrackSimply.size(); i++)
+    m_TrackSimply.at(i).m_bUpdated = false;
+
+  MatchClosestCost();
+
+  for(unsigned int i =0; i< m_TrackSimply.size(); i++)
+    m_TrackSimply.at(i).UpdateTracking(m_dt, m_TrackSimply.at(i).obj, m_TrackSimply.at(i).obj);
+
+  m_DetectedObjects.clear();
+  for(unsigned int i = 0; i< m_TrackSimply.size(); i++)
+    m_DetectedObjects.push_back(m_TrackSimply.at(i).obj);
+}
+
+void SimpleTracker::AssociateToRegions(KFTrackV& detectedObject)
+{
+  for(unsigned int i = 0; i < m_InterestRegions.size(); i++)
+  {
+    m_InterestRegions.at(i)->pTrackers.clear();
+    if(detectedObject.obj.distance_to_center <= m_InterestRegions.at(i)->radius)
+    {
+      detectedObject.region_id = m_InterestRegions.at(i)->id;
+      detectedObject.forget_time = m_InterestRegions.at(i)->forget_time;
+      return;
+    }
+  }
+
+  if(m_InterestRegions.size() > 0)
+  {
+    detectedObject.region_id = m_InterestRegions.at(m_InterestRegions.size()-1)->id;
+    detectedObject.forget_time = m_InterestRegions.at(m_InterestRegions.size()-1)->forget_time;
+  }
+}
+
+void SimpleTracker::AssociateAndTrack()
+{
+  for(unsigned int i = 0; i < m_TrackSimply.size(); i++)
+    m_TrackSimply.at(i).m_bUpdated = false;
+
+
+  std::cout << std::endl;
+  while(m_DetectedObjects.size() > 0)
+  {
+    double iCloseset_track = -1;
+    double iCloseset_obj = -1;
+    double dCloseset = 99999999;
+    bool bFoundMatch = false;
+    double min_size = -1;
+    std::cout << "DetObjSize: " <<  m_DetectedObjects.size() <<  ", TracksSize: " << m_TrackSimply.size() << std::endl;
+    for(unsigned int jj = 0; jj < m_DetectedObjects.size(); jj++)
+    {
+      double object_size = hypot(m_DetectedObjects.at(jj).w, m_DetectedObjects.at(jj).l);
+
+      for(unsigned int i = 0; i < m_TrackSimply.size(); i++)
+      {
+        double old_size = hypot(m_TrackSimply.at(i).obj.w, m_TrackSimply.at(i).obj.l);
+        double obj_diff = fabs(object_size - old_size);
+        double d = hypot(m_DetectedObjects.at(jj).center.pos.y-m_TrackSimply.at(i).obj.center.pos.y, m_DetectedObjects.at(jj).center.pos.x-m_TrackSimply.at(i).obj.center.pos.x);
+
+        std::cout << "Test: " << m_TrackSimply.at(i).obj.id << ", MinD: " << d << ", ObjS: " << object_size << ", ObjI: " << jj << ", TrackS: " << old_size << ", TrackI: " << i << std::endl;
+
+        if(obj_diff < m_MAX_ASSOCIATION_SIZE_DIFF && (InsidePolygon(m_TrackSimply.at(i).obj.contour, m_DetectedObjects.at(jj).center.pos) == 1 || InsidePolygon(m_DetectedObjects.at(jj).contour, m_TrackSimply.at(i).obj.center.pos) == 1) )
+         {
+           bFoundMatch = true;
+           iCloseset_track = i;
+           iCloseset_obj = jj;
+           break;
+         }
+
+        if(obj_diff < m_MAX_ASSOCIATION_SIZE_DIFF && d < dCloseset)
+        {
+          dCloseset = d;
+          iCloseset_track = i;
+          iCloseset_obj = jj;
+          min_size = obj_diff;
+        }
+      }
+
+      if(bFoundMatch)
+        break;
+    }
+
+    if(iCloseset_obj != -1 && iCloseset_track != -1 && (dCloseset <= m_MAX_ASSOCIATION_DISTANCE || bFoundMatch == true))
+    {
+      std::cout << "MatchObj: " << m_TrackSimply.at(iCloseset_track).obj.id << ", MinD: " << dCloseset << ", MinS: " << min_size << ", ObjI" << iCloseset_obj <<", TrackI: " << iCloseset_track << ", ContourMatch: " << bFoundMatch << std::endl;
+      m_DetectedObjects.at(iCloseset_obj).id = m_TrackSimply.at(iCloseset_track).obj.id;
+      MergeObjectAndTrack(m_TrackSimply.at(iCloseset_track), m_DetectedObjects.at(iCloseset_obj));
+      AssociateToRegions(m_TrackSimply.at(iCloseset_track));
+      m_DetectedObjects.erase(m_DetectedObjects.begin()+iCloseset_obj);
+    }
+    else
+    {
+      iTracksNumber = iTracksNumber + 1;
+      if(iCloseset_obj != -1)
+      {
+        m_DetectedObjects.at(iCloseset_obj).id = iTracksNumber;
+        KFTrackV track(m_DetectedObjects.at(iCloseset_obj).center.pos.x, m_DetectedObjects.at(iCloseset_obj).center.pos.y,m_DetectedObjects.at(iCloseset_obj).actual_yaw, m_DetectedObjects.at(iCloseset_obj).id, m_dt, m_nMinTrustAppearances);
+        track.obj = m_DetectedObjects.at(iCloseset_obj);
+        AssociateToRegions(track);
+        m_TrackSimply.push_back(track);
+        std::cout << "UnMachedObj: " << iTracksNumber  << ", MinD: " << dCloseset << ", MinS: " << min_size << ", ObjI:" << iCloseset_obj <<", TrackI: " << iCloseset_track << ", ContMatch: " << bFoundMatch << std::endl;
+        m_DetectedObjects.erase(m_DetectedObjects.begin()+iCloseset_obj);
+      }
+      else
+      {
+        m_DetectedObjects.at(0).id = iTracksNumber;
+        KFTrackV track(m_DetectedObjects.at(0).center.pos.x, m_DetectedObjects.at(0).center.pos.y,m_DetectedObjects.at(0).actual_yaw, m_DetectedObjects.at(0).id, m_dt, m_nMinTrustAppearances);
+        track.obj = m_DetectedObjects.at(0);
+        AssociateToRegions(track);
+        m_TrackSimply.push_back(track);
+        std::cout << "NewObj: " << iTracksNumber  << ", MinD: " << dCloseset << ", MinS: " << min_size << ", ObjI:" << 0 <<", TrackI: " << iCloseset_track << ", ContMatch: " << bFoundMatch << std::endl;
+        m_DetectedObjects.erase(m_DetectedObjects.begin()+0);
+      }
+    }
+  }
+
+  for(unsigned int i =0; i< m_TrackSimply.size(); i++)
+  {
+    //if(m_TrackSimply.at(i).m_bUpdated)
+      m_TrackSimply.at(i).UpdateTracking(m_dt, m_TrackSimply.at(i).obj, m_TrackSimply.at(i).obj);
+//    else
+//    {
+////      double dx = 0;
+////      double dy = 0;
+////
+////      if(m_TrackSimply.at(i).obj.bVelocity && m_TrackSimply.at(i).obj.center.v > 3)
+////      {
+////        dx = m_TrackSimply.at(i).obj.center.v * cos(m_TrackSimply.at(i).obj.center.pos.a) * m_dt;
+////        dy = m_TrackSimply.at(i).obj.center.v * sin(m_TrackSimply.at(i).obj.center.pos.a) * m_dt;
+////      }
+////
+////      m_TrackSimply.at(i).obj.center.pos.x += dx;
+////      m_TrackSimply.at(i).obj.center.pos.y += dy;
+////
+////      for(unsigned int k=0; k < m_TrackSimply.at(i).obj.contour.size(); k++)
+////      {
+////        m_TrackSimply.at(i).obj.contour.at(k).x += dx;
+////        m_TrackSimply.at(i).obj.contour.at(k).y += dy;
+////      }
+//
+//      m_TrackSimply.at(i).PredictTracking(m_dt, m_TrackSimply.at(i).obj, m_TrackSimply.at(i).obj);
+//    }
+  }
+}
+
+void SimpleTracker::CleanOldTracks()
+{
+  m_DetectedObjects.clear();
+  for(int i = 0; i< (int)m_TrackSimply.size(); i++)
+  {
+    if(m_TrackSimply.at(i).forget_time < 0 && m_TrackSimply.at(i).forget_time != NEVER_GORGET_TIME)
+    {
+      m_TrackSimply.erase(m_TrackSimply.begin()+i);
+      i--;
+    }
+    else if(m_TrackSimply.at(i).m_iLife > m_nMinTrustAppearances)
+    {
+      m_DetectedObjects.push_back(m_TrackSimply.at(i).obj);
+    }
+  }
+}
+
+void SimpleTracker::MergeObjectAndTrack(KFTrackV& track, PlannerHNS::DetectedObject& obj)
+{
+  obj.centers_list = track.obj.centers_list;
+  track.obj = obj;
+  track.m_bUpdated = true;
+}
+
+int SimpleTracker::InsidePolygon(const std::vector<GPSPoint>& polygon,const GPSPoint& p)
+{
+  int counter = 0;
+  int i;
+  double xinters;
+  GPSPoint p1,p2;
+  int N = polygon.size();
+  if(N <=0 ) return -1;
+
+  p1 = polygon.at(0);
+  for (i=1;i<=N;i++)
+  {
+    p2 = polygon.at(i % N);
+
+    if (p.y > MIN(p1.y,p2.y))
+    {
+      if (p.y <= MAX(p1.y,p2.y))
+      {
+        if (p.x <= MAX(p1.x,p2.x))
+        {
+          if (p1.y != p2.y)
+          {
+            xinters = (p.y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y)+p1.x;
+            if (p1.x == p2.x || p.x <= xinters)
+              counter++;
+          }
+        }
+      }
+    }
+    p1 = p2;
+  }
+
+  if (counter % 2 == 0)
+    return 0;
+  else
+    return 1;
+}
+}

+ 177 - 0
src/ros/catkin/src/op_simu/src/SimulatedTrajectoryFollower.cpp

@@ -0,0 +1,177 @@
+/*
+ * SimulatedTrajectoryFollower.cpp
+ *
+ *  Created on: Jun 18, 2016
+ *      Author: hatem
+ */
+
+#include "op_simu/SimulatedTrajectoryFollower.h"
+#include "op_planner/PlanningHelpers.h"
+#include <cmath>
+#include <stdlib.h>
+#include <iostream>
+
+using namespace PlannerHNS;
+using namespace UtilityHNS;
+using namespace std;
+
+
+namespace SimulationNS
+{
+
+SimulatedTrajectoryFollower::SimulatedTrajectoryFollower()
+{
+  m_FollowingDistance = 0;
+  m_LateralError     = 0;
+  m_PrevDesiredSteer  = 0;
+  m_FollowAcceleration= 0;
+  m_iPrevWayPoint   = -1;
+  m_iCalculatedIndex = 0;
+
+
+  //m_pidSteer.Init(0.35, 0.01, 0.01); // for 5 m/s
+  //m_pidSteer.Init(1.5, 0.00, 0.00); // for 3 m/s
+  //m_pidSteer.Init(0.9, 0.1, 0.2); //for lateral error
+
+}
+
+void SimulatedTrajectoryFollower::Init(const ControllerParams& params, const CAR_BASIC_INFO& vehicleInfo)
+{
+  m_Params = params;
+  m_VehicleInfo = vehicleInfo;
+  m_pidSteer.Init(params.Steering_Gain.kP, params.Steering_Gain.kI, params.Steering_Gain.kD); // for 3 m/s
+  m_pidSteer.Setlimit(vehicleInfo.max_steer_angle, -vehicleInfo.max_steer_angle);
+  m_pidVelocity.Init(params.Velocity_Gain.kP, params.Velocity_Gain.kI, params.Velocity_Gain.kD);
+}
+
+SimulatedTrajectoryFollower::~SimulatedTrajectoryFollower()
+{
+}
+
+
+void SimulatedTrajectoryFollower::PrepareNextWaypoint(const PlannerHNS::WayPoint& CurPos, const double& currVelocity, const double& currSteering)
+{
+  m_CurrPos = CurPos;
+  FindNextWayPoint(m_Path, m_CurrPos, currVelocity, m_FollowMePoint, m_PerpendicularPoint, m_LateralError, m_FollowingDistance);
+}
+
+void SimulatedTrajectoryFollower::UpdateCurrentPath(const std::vector<PlannerHNS::WayPoint>& path)
+{
+  m_Path = path;
+}
+
+bool SimulatedTrajectoryFollower::FindNextWayPoint(const std::vector<PlannerHNS::WayPoint>& path, const PlannerHNS::WayPoint& state,
+    const double& velocity, PlannerHNS::WayPoint& pursuite_point, PlannerHNS::WayPoint& prep,
+    double& lateral_err, double& follow_distance)
+{
+  if(path.size()==0) return false;
+
+  follow_distance = m_Params.minPursuiteDistance;
+
+//  int iWayPoint =  PlanningHelpers::GetClosestNextPointIndex(path, state);
+//  m_iCalculatedIndex = iWayPoint;
+////  if(m_iPrevWayPoint >=0  && m_iPrevWayPoint < path.size() && iWayPoint < m_iPrevWayPoint)
+////    iWayPoint = m_iPrevWayPoint;
+//
+//
+//  m_iPrevWayPoint = iWayPoint;
+
+  RelativeInfo info;
+  PlanningHelpers::GetRelativeInfo(path, state, info);
+  unsigned int point_index = 0;
+  pursuite_point = PlanningHelpers::GetFollowPointOnTrajectory(path, info, follow_distance, point_index);
+  prep = info.perp_point;
+  lateral_err = info.perp_distance;
+  m_iPrevWayPoint = info.iFront;
+
+  return true;
+}
+
+int SimulatedTrajectoryFollower::SteerControllerUpdate(const PlannerHNS::VehicleState& CurrStatus,
+    const PlannerHNS::BehaviorState& CurrBehavior, double& desiredSteerAngle)
+{
+  if(m_Path.size()==0) return -1;
+
+  //AdjustPID(CurrStatus.velocity, 18.0, m_Params.Gain);
+  int ret = SteerControllerPart(m_CurrPos, m_FollowMePoint, m_LateralError, desiredSteerAngle);
+  if(ret < 0)
+    desiredSteerAngle = m_PrevDesiredSteer;
+  else
+    m_PrevDesiredSteer = desiredSteerAngle;
+
+  return ret;
+}
+
+int SimulatedTrajectoryFollower::SteerControllerPart(const PlannerHNS::WayPoint& state, const PlannerHNS::WayPoint& way_point,
+    const double& lateral_error, double& steerd)
+{
+  double current_a = UtilityH::SplitPositiveAngle(state.pos.a);
+  double target_a = atan2(way_point.pos.y - state.pos.y, way_point.pos.x - state.pos.x);
+
+  double e =  UtilityH::SplitPositiveAngle(target_a - current_a);
+
+  if(e > M_PI_2 || e < -M_PI_2)
+    return -1;
+
+  steerd = m_pidSteer.getPID(e);
+
+  return 1;
+}
+
+int SimulatedTrajectoryFollower::VeclocityControllerUpdate(const double& dt, const PlannerHNS::VehicleState& CurrStatus,
+    const PlannerHNS::BehaviorState& CurrBehavior, double& desiredVelocity)
+{
+  //desiredVelocity = CurrBehavior.maxVelocity;
+  m_pidVelocity.Setlimit(CurrBehavior.maxVelocity, 0);
+  double e = CurrBehavior.maxVelocity - CurrStatus.speed;
+
+  desiredVelocity = m_pidVelocity.getPID(e);
+
+  if(desiredVelocity > CurrBehavior.maxVelocity)
+    desiredVelocity = CurrBehavior.maxVelocity;
+  else if (desiredVelocity < 0)
+    desiredVelocity = 0;
+  return 1;
+}
+
+
+PlannerHNS::VehicleState SimulatedTrajectoryFollower::DoOneStep(const double& dt, const PlannerHNS::BehaviorState& behavior,
+    const std::vector<PlannerHNS::WayPoint>& path, const PlannerHNS::WayPoint& currPose,
+    const PlannerHNS::VehicleState& vehicleState, const bool& bNewTrajectory)
+{
+  if(bNewTrajectory && path.size() > 0)
+  {
+    m_iPrevWayPoint = -1;
+    UpdateCurrentPath(path);
+  }
+
+  PlannerHNS::VehicleState currState;
+
+  if(behavior.state == PlannerHNS::FORWARD_STATE)
+  {
+    if(m_Path.size()>0)
+    {
+      PrepareNextWaypoint(currPose, vehicleState.speed, vehicleState.steer);
+      VeclocityControllerUpdate(dt, currState,behavior, currState.speed);
+      SteerControllerUpdate(currState, behavior, currState.steer);
+
+      //currState.speed = 5;
+      //cout << currState.speed << endl;
+      currState.shift = PlannerHNS::SHIFT_POS_DD;
+    }
+  }
+  else if(behavior.state == PlannerHNS::STOPPING_STATE)
+  {
+    currState.speed = 0;
+    currState.shift = PlannerHNS::SHIFT_POS_DD;
+  }
+  else
+  {
+    currState.speed = 0;
+    currState.shift = PlannerHNS::SHIFT_POS_NN;
+  }
+
+  return currState;
+}
+
+} /* namespace SimulationNS */

+ 623 - 0
src/ros/catkin/src/op_simu/src/TrajectoryFollower.cpp

@@ -0,0 +1,623 @@
+/// \file TrajectoryFollower.cpp
+/// \brief PID based trajectory follower
+/// \author Hatem Darweesh
+/// \date Jun 18, 2016
+
+#include "op_simu/TrajectoryFollower.h"
+#include "op_planner/PlanningHelpers.h"
+#include <cmath>
+#include <stdlib.h>
+#include <iostream>
+
+using namespace PlannerHNS;
+using namespace UtilityHNS;
+using namespace std;
+
+
+namespace SimulationNS
+{
+
+TrajectoryFollower::TrajectoryFollower()
+{
+  m_iNextTest = 0;
+  m_bCalibrationMode = false;
+  m_bEnableLog = false;
+  m_WayPointsDensity = 1;
+  m_bEndPath = false;
+  m_FollowingDistance = 0;
+  m_LateralError     = 0;
+  m_PrevDesiredSteer  = 0;
+  m_FollowAcceleration= 0;
+  m_iPrevWayPoint   = -1;
+  m_StartFollowDistance = 0;
+  m_FollowAcc = 0.5;
+  m_iCalculatedIndex = 0;
+  UtilityH::GetTickCount(m_SteerDelayTimer);
+  UtilityH::GetTickCount(m_VelocityDelayTimer);
+}
+
+void TrajectoryFollower::Init(const ControllerParams& params, const CAR_BASIC_INFO& vehicleInfo, bool bEnableLogs, bool bCalibration)
+{
+  m_bEnableLog = bEnableLogs;
+  m_bCalibrationMode = bCalibration;
+  if(m_bCalibrationMode)
+    InitCalibration();
+
+  m_Params = params;
+  m_VehicleInfo = vehicleInfo;
+
+  //m_pidSteer.Init(0.1, 0.005, 0.001); // for 5 m/s
+  //m_pidSteer.Init(0.07, 0.02, 0.01); // for 3 m/s
+  //m_pidSteer.Init(0.9, 0.1, 0.2); //for lateral error
+  //m_pidVelocity.Init(0.1, 0.005, 0.1);
+  m_lowpassSteer.Init(2, 100, 4);
+
+  m_pidSteer.Init(params.Steering_Gain.kP, params.Steering_Gain.kI, params.Steering_Gain.kD); // for 3 m/s
+  m_pidSteer.Setlimit(m_VehicleInfo.max_steer_angle, -m_VehicleInfo.max_steer_angle);
+  m_pidVelocity.Init(params.Velocity_Gain.kP, params.Velocity_Gain.kI, params.Velocity_Gain.kD);
+}
+
+TrajectoryFollower::~TrajectoryFollower()
+{
+  if(m_bEnableLog)
+  {
+    DataRW::WriteLogData(UtilityH::GetHomeDirectory()+DataRW::LoggingMainfolderName+DataRW::ControlLogFolderName, "ControlLog",
+        "time,X,Y,heading, Target, error,LateralError,SteerBeforLowPass,Steer,iIndex, pathSize",
+        m_LogData);
+
+    DataRW::WriteLogData(UtilityH::GetHomeDirectory()+DataRW::LoggingMainfolderName+DataRW::ControlLogFolderName, "SteeringCalibrationLog",
+        "time, reset, start A, end A, desired A, dt, vel", m_SteerCalibrationData);
+
+    DataRW::WriteLogData(UtilityH::GetHomeDirectory()+DataRW::LoggingMainfolderName+DataRW::ControlLogFolderName, "VelocityCalibrationLog",
+        "time, reset, start V, end V, desired V, dt, steering", m_VelocityCalibrationData);
+
+    DataRW::WriteLogData(UtilityH::GetHomeDirectory()+DataRW::LoggingMainfolderName+DataRW::ControlLogFolderName, "SteeringPIDLog",m_pidSteer.ToStringHeader(), m_LogSteerPIDData );
+    DataRW::WriteLogData(UtilityH::GetHomeDirectory()+DataRW::LoggingMainfolderName+DataRW::ControlLogFolderName, "VelocityPIDLog",m_pidVelocity.ToStringHeader(), m_LogVelocityPIDData );
+  }
+}
+
+void TrajectoryFollower::PrepareNextWaypoint(const PlannerHNS::WayPoint& CurPos, const double& currVelocity, const double& currSteering)
+{
+  WayPoint pred_point = CurPos;
+  m_ForwardSimulation = pred_point;
+
+  double nIterations = m_Params.SteeringDelay/0.01; //angle error
+  //double nIterations = 0.5/0.01; //lateral  error
+  for(unsigned int i=0; i< nIterations; i++)
+  {
+    PredictMotion(m_ForwardSimulation.pos.x, m_ForwardSimulation.pos.y, m_ForwardSimulation.pos.a, currSteering,currVelocity, m_VehicleInfo.wheel_base, 0.01);
+  }
+
+  m_CurrPos = m_ForwardSimulation;
+
+  bool ret = FindNextWayPoint(m_Path, pred_point, currVelocity, m_FollowMePoint, m_PerpendicularPoint, m_LateralError, m_FollowingDistance);
+  if(ret)
+  {
+    m_DesPos = m_FollowMePoint;
+  //  m_DesPos.a = m_pDesAngCir->CalcAngle(m_DesPos.a);
+  }
+}
+
+void TrajectoryFollower::UpdateCurrentPath(const std::vector<PlannerHNS::WayPoint>& path)
+{
+  //BehaviorsNS::MappingHelpers::ConvertFromWaypointsToVectorPath(path, m_Path);
+  if(path.size()>0)
+    m_WayPointsDensity = hypot(path.at(1).pos.y - path.at(0).pos.y, path.at(1).pos.x - path.at(0).pos.x);
+
+  m_Path = path;
+}
+
+bool TrajectoryFollower::FindNextWayPoint(const std::vector<PlannerHNS::WayPoint>& path, const PlannerHNS::WayPoint& state,
+    const double& velocity, PlannerHNS::WayPoint& pursuite_point, PlannerHNS::WayPoint& prep,
+    double& lateral_err, double& follow_distance)
+{
+  if(path.size()==0) return false;
+
+  follow_distance = fabs(velocity) * (m_Params.SteeringDelay+0.5);
+  if(follow_distance < m_Params.minPursuiteDistance)
+    follow_distance = m_Params.minPursuiteDistance;
+
+  RelativeInfo info;
+  PlanningHelpers::GetRelativeInfo(path, state, info);
+  unsigned int point_index = 0;
+  pursuite_point = PlanningHelpers::GetFollowPointOnTrajectory(path, info, follow_distance, point_index);
+  prep = info.perp_point;
+  lateral_err = info.perp_distance;
+  m_iPrevWayPoint = info.iFront;
+
+  double d_critical = (-velocity*velocity)/2.0*m_VehicleInfo.max_deceleration;
+  int nPointToEnd = path.size() - m_iPrevWayPoint;
+  double totalD = m_WayPointsDensity*nPointToEnd;
+
+  if(totalD <= 1 || totalD <= d_critical)
+  {
+    m_bEndPath = true;
+    //cout << "Critical Distance: " << d_critical << endl;
+  }
+  else
+    m_bEndPath = false;
+
+  return true;
+}
+
+int TrajectoryFollower::SteerControllerUpdate(const PlannerHNS::VehicleState& CurrStatus,
+    const PlannerHNS::BehaviorState& CurrBehavior, double& desiredSteerAngle)
+{
+  if(m_Path.size()==0) return -1;
+  int ret = -1;
+  //AdjustPID(CurrStatus.velocity, 18.0, m_Params.Gain);
+  if(CurrBehavior.state == FORWARD_STATE || CurrBehavior.state == TRAFFIC_LIGHT_STOP_STATE || CurrBehavior.state == STOP_SIGN_STOP_STATE || CurrBehavior.state  == FOLLOW_STATE)
+    ret = SteerControllerPart(m_CurrPos, m_DesPos, m_LateralError, desiredSteerAngle);
+
+  if(ret < 0)
+    desiredSteerAngle = m_PrevDesiredSteer;
+  else
+    m_PrevDesiredSteer = desiredSteerAngle;
+
+  return ret;
+}
+
+int TrajectoryFollower::SteerControllerPart(const PlannerHNS::WayPoint& state, const PlannerHNS::WayPoint& way_point,
+    const double& lateral_error, double& steerd)
+{
+  double current_a = UtilityH::SplitPositiveAngle(state.pos.a);
+  double target_a = atan2(way_point.pos.y - state.pos.y, way_point.pos.x - state.pos.x);
+
+  double e =  UtilityH::SplitPositiveAngle(target_a - current_a);
+
+//  if(e > M_PI_2 || e < -M_PI_2)
+//    return -1;
+
+
+  double before_lowpass = m_pidSteer.getPID(e);
+  //cout << m_pidSteer.ToString() << endl;
+
+  if(m_bEnableLog)
+    m_LogSteerPIDData.push_back(m_pidSteer.ToString());
+
+  //TODO use lateral error instead of angle error
+  //double future_lateral_error = PlanningHelpers::GetPerpDistanceToTrajectorySimple(m_Path, m_ForwardSimulation,0);
+
+
+  //steerd = m_pidSteer.getPID( future_lateral_error*-1, 0);
+
+//  if(m_LateralError < 0)
+//    steerd = m_pidSteer.getPID(current_a+sqrt(abs(m_LateralError)), target_a);
+//  else
+//    steerd = m_pidSteer.getPID(current_a-sqrt(m_LateralError), target_a);
+
+
+  //cout << "Error : " << e << ", Current A: " << current_a << ", Target A: " << target_a <<  " Steeting Angle = " << steerd*RAD2DEG << endl;
+//  if(abs(before_lowpass) < m_Params.MaxSteerAngle*0.5)
+//    steerd = m_lowpassSteer.getFilter(before_lowpass);
+//  else
+    steerd = before_lowpass;
+
+//  timespec t;
+//  UtilityH::GetTickCount(t);
+//  std::ostringstream dataLine;
+//  dataLine << UtilityH::GetLongTime(t) << "," << state.pos.x << "," << state.pos.y << "," <<  current_a << "," <<
+//      target_a << "," <<  e << "," <<m_LateralError << "," <<  before_lowpass << "," <<  steerd <<  "," <<
+//      m_iPrevWayPoint << "," << m_Path.size() << ",";
+//  m_LogData.push_back(dataLine.str());
+
+  return 1;
+}
+
+void TrajectoryFollower::PredictMotion(double& x, double &y, double& heading, double steering, double velocity, double wheelbase, double time_elapsed)
+{
+  x += velocity * time_elapsed *  cos(heading);
+  y += velocity * time_elapsed *  sin(heading);
+  heading = heading + ((velocity*time_elapsed*tan(steering))  / (wheelbase) );
+}
+
+int TrajectoryFollower::VeclocityControllerUpdate(const double& dt, const PlannerHNS::VehicleState& CurrStatus,
+    const PlannerHNS::BehaviorState& CurrBehavior, double& desiredVelocity, PlannerHNS::SHIFT_POS& desiredShift)
+{
+  double critical_long_front_distance =  2.0;
+
+  if(CurrBehavior.state == TRAFFIC_LIGHT_STOP_STATE || CurrBehavior.state == STOP_SIGN_STOP_STATE || m_bEndPath)
+  {
+    double deceleration_critical = m_VehicleInfo.max_deceleration;
+    if(CurrBehavior.stopDistance != 0)
+      deceleration_critical = (-CurrStatus.speed*CurrStatus.speed)/(2.0*CurrBehavior.stopDistance);
+
+    desiredVelocity = (deceleration_critical * dt) + CurrStatus.speed;
+
+    //desiredVelocity = m_PerpendicularPoint.v;
+  }
+  else if(CurrBehavior.state == FORWARD_STATE || CurrBehavior.state == OBSTACLE_AVOIDANCE_STATE )
+  {
+
+    double e = CurrBehavior.maxVelocity - CurrStatus.speed;
+
+    //Using PID for velocity
+    //m_pidVelocity.Setlimit(CurrBehavior.maxVelocity, 0);
+    //desiredVelocity = m_pidVelocity.getPID(e);
+
+    //Using constant acceleration for velocity
+    if(e >= 0)
+      desiredVelocity = (m_VehicleInfo.max_acceleration * dt) + CurrStatus.speed;
+    else
+      desiredVelocity = (m_VehicleInfo.max_deceleration * dt) + CurrStatus.speed;
+
+    if(desiredVelocity > CurrBehavior.maxVelocity)
+      desiredVelocity = CurrBehavior.maxVelocity;
+    else if(desiredVelocity<m_VehicleInfo.min_speed_forward)
+      desiredVelocity = m_VehicleInfo.min_speed_forward;
+
+    //std::cout << "Velocity from follower : dt=" << dt << ", e= " << e << ", acc_const=" << acc_const << ", desiredVelocity = "<<desiredVelocity<<  std::endl;
+
+    m_StartFollowDistance = 0;
+  }
+  else if(CurrBehavior.state == STOPPING_STATE || CurrBehavior.state == FINISH_STATE)
+  {
+    desiredVelocity = 0;
+  }
+  else if(CurrBehavior.state == FOLLOW_STATE)
+  {
+    double deceleration_critical = 0;
+    double inv_time = 2.0*((CurrBehavior.followDistance-critical_long_front_distance)-CurrStatus.speed);
+    if(inv_time == 0)
+      deceleration_critical = MAX_ACCELERATION_2G;
+    else
+      deceleration_critical = CurrStatus.speed*CurrStatus.speed/inv_time;
+
+    if(deceleration_critical > 0) deceleration_critical = -deceleration_critical;
+    if(deceleration_critical < -MAX_ACCELERATION_2G) deceleration_critical = -MAX_ACCELERATION_2G;
+
+    desiredVelocity = (deceleration_critical * dt) + CurrStatus.speed;
+
+    if(desiredVelocity > CurrBehavior.maxVelocity)
+      desiredVelocity = CurrBehavior.maxVelocity;
+
+    if((desiredVelocity < 0.1 && desiredVelocity > -0.1) || CurrBehavior.followDistance <= 0) //use only effective velocities
+      desiredVelocity = 0;
+
+    //cout << "Follow State:  acceleration = " << deceleration_critical << ", speed = " << CurrStatus.speed <<  ", Distance = " << CurrBehavior.followDistance<< endl;
+  }
+  else
+  {
+    desiredVelocity = 0;
+  }
+
+  if(desiredVelocity > m_VehicleInfo.max_speed_forward)
+    desiredVelocity = m_VehicleInfo.max_speed_forward;
+  else if (desiredVelocity < 0)
+    desiredVelocity = 0;
+
+  desiredShift = PlannerHNS::SHIFT_POS_DD;
+  if(m_bEnableLog)
+    m_LogVelocityPIDData.push_back(m_pidVelocity.ToString());
+  return 1;
+}
+
+PlannerHNS::VehicleState TrajectoryFollower::DoOneStep(const double& dt, const PlannerHNS::BehaviorState& behavior,
+    const std::vector<PlannerHNS::WayPoint>& path, const PlannerHNS::WayPoint& currPose,
+    const PlannerHNS::VehicleState& vehicleState, const bool& bNewTrajectory)
+{
+  if(bNewTrajectory && path.size() > 0)
+  {
+    UpdateCurrentPath(path);
+    m_iPrevWayPoint = -1;
+  }
+
+  PlannerHNS::VehicleState desiredState;
+
+  if(m_bCalibrationMode)
+  {
+    CalibrationStep(dt, vehicleState, desiredState.steer, desiredState.speed);
+    desiredState.shift = PlannerHNS::SHIFT_POS_DD;
+  }
+  else if(m_Path.size()>0 && behavior.state != INITIAL_STATE )
+  {
+    PrepareNextWaypoint(currPose, vehicleState.speed, vehicleState.steer);
+    VeclocityControllerUpdate(dt, vehicleState, behavior, desiredState.speed, desiredState.shift);
+    SteerControllerUpdate(vehicleState, behavior, desiredState.steer);
+  }
+  else
+  {
+    desiredState.steer = 0;
+    desiredState.speed = 0;
+    desiredState.shift = PlannerHNS::SHIFT_POS_DD;
+    //cout << ">>> Error, Very Dangerous, Following No Path !!." << endl;
+  }
+
+  if(m_bEnableLog)
+    LogCalibrationData(vehicleState, desiredState);
+
+  return desiredState;
+}
+
+void TrajectoryFollower::CalibrationStep(const double& dt, const PlannerHNS::VehicleState& CurrStatus, double& desiredSteer, double& desiredVelocity)
+{
+  if(m_iNextTest >= (int)m_CalibrationRunList.size()-1)
+  {
+    desiredSteer = 0;
+    desiredVelocity = 0;
+    return;
+  }
+
+  if(fabs(CurrStatus.speed - m_CalibrationRunList.at(m_iNextTest).first)*3.6 <= 1
+      && fabs(CurrStatus.steer - m_CalibrationRunList.at(m_iNextTest).second)*RAD2DEG <=0.5)
+    m_iNextTest++;
+
+  desiredVelocity = m_CalibrationRunList.at(m_iNextTest).first;
+  desiredSteer = m_CalibrationRunList.at(m_iNextTest).second;
+
+  cout << "i:" << m_iNextTest << ", desVel:" << desiredVelocity << ", CurVel:" << CurrStatus.speed
+      << ", desStr:" << desiredSteer << ", CurrStr:" << CurrStatus.steer << endl;
+
+//  double e = targetSpeed - CurrStatus.speed;
+//  if(e >= 0)
+//    desiredVelocity = (m_VehicleInfo.max_acceleration * dt) + CurrStatus.speed;
+//  else
+//    desiredVelocity = (m_VehicleInfo.max_deceleration * dt) + CurrStatus.speed;
+}
+
+void TrajectoryFollower::LogCalibrationData(const PlannerHNS::VehicleState& currState,const PlannerHNS::VehicleState& desiredState)
+{
+  int startAngle=0, finishAngle=0, originalTargetAngle=0, currVelocity = 0;
+  double t_FromStartToFinish_a = 0;
+  bool bAngleReset = false;
+  int startV=0, finishV=0, originalTargetV=0, currSteering = 0;
+  double t_FromStartToFinish_v = 0;
+  bool bVelocityReset = false;
+
+  //1- decide reset
+  if((int)(m_prevDesiredState_steer.steer*RAD2DEG) != (int)(desiredState.steer*RAD2DEG))
+    bAngleReset = true;
+
+  if((int)(m_prevDesiredState_vel.speed*3.6) != (int)(desiredState.speed*3.6))
+    bVelocityReset = true;
+
+  //2- calculate time and log
+  if(bAngleReset)
+  {
+    startAngle = m_prevCurrState_steer.steer*RAD2DEG;
+    finishAngle = currState.steer*RAD2DEG;
+    originalTargetAngle = m_prevDesiredState_steer.steer*RAD2DEG;
+    t_FromStartToFinish_a = UtilityH::GetTimeDiffNow(m_SteerDelayTimer);
+    currVelocity = currState.speed*3.6;
+    UtilityH::GetTickCount(m_SteerDelayTimer);
+
+    std::ostringstream dataLine;
+    dataLine << UtilityH::GetLongTime(m_SteerDelayTimer) << ","
+        << bAngleReset << ","
+        << startAngle << ","
+        << finishAngle << ","
+        << originalTargetAngle << ","
+        << t_FromStartToFinish_a << ","
+        << currVelocity << ",";
+
+    m_SteerCalibrationData.push_back(dataLine.str());
+
+    if(bAngleReset)
+    {
+      bAngleReset = false;
+      m_prevCurrState_steer = currState;
+      m_prevDesiredState_steer = desiredState;
+    }
+  }
+
+  if(bVelocityReset)
+  {
+    startV = m_prevCurrState_vel.speed*3.6;
+    finishV = currState.speed*3.6;
+    originalTargetV = m_prevDesiredState_vel.speed*3.6;
+    t_FromStartToFinish_v = UtilityH::GetTimeDiffNow(m_VelocityDelayTimer);
+    currSteering = currState.steer*RAD2DEG;
+    UtilityH::GetTickCount(m_VelocityDelayTimer);
+
+    std::ostringstream dataLine;
+    dataLine << UtilityH::GetLongTime(m_VelocityDelayTimer) << ","
+        << bVelocityReset << ","
+        << startV << ","
+        << finishV << ","
+        << originalTargetV << ","
+        << t_FromStartToFinish_v << ","
+        << currSteering << ",";
+
+    m_VelocityCalibrationData.push_back(dataLine.str());
+
+    if(bVelocityReset)
+    {
+      bVelocityReset = false;
+      m_prevCurrState_vel = currState;
+      m_prevDesiredState_vel = desiredState;
+    }
+  }
+}
+
+void TrajectoryFollower::InitCalibration()
+{
+  m_CalibrationRunList.push_back(make_pair(0,0));
+  m_CalibrationRunList.push_back(make_pair(0,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(0,0.0));
+  m_CalibrationRunList.push_back(make_pair(0,-m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(0,m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(0,0.0));
+  m_CalibrationRunList.push_back(make_pair(0,-m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(0,m_VehicleInfo.max_steer_angle/1.5));
+  m_CalibrationRunList.push_back(make_pair(0,0.0));
+  m_CalibrationRunList.push_back(make_pair(0,-m_VehicleInfo.max_steer_angle/1.5));
+  m_CalibrationRunList.push_back(make_pair(0,m_VehicleInfo.max_steer_angle/1.0));
+  m_CalibrationRunList.push_back(make_pair(0,0.0));
+  m_CalibrationRunList.push_back(make_pair(0,-m_VehicleInfo.max_steer_angle/1.0));
+
+  m_CalibrationRunList.push_back(make_pair(1,0));
+  m_CalibrationRunList.push_back(make_pair(1,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(1,0.0));
+  m_CalibrationRunList.push_back(make_pair(1,-m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(1,m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(1,0.0));
+  m_CalibrationRunList.push_back(make_pair(1,-m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(1,m_VehicleInfo.max_steer_angle/1.5));
+  m_CalibrationRunList.push_back(make_pair(1,0.0));
+  m_CalibrationRunList.push_back(make_pair(1,-m_VehicleInfo.max_steer_angle/1.5));
+  m_CalibrationRunList.push_back(make_pair(1,m_VehicleInfo.max_steer_angle/1.0));
+  m_CalibrationRunList.push_back(make_pair(1,0.0));
+  m_CalibrationRunList.push_back(make_pair(1,-m_VehicleInfo.max_steer_angle/1.0));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(2,0));
+  m_CalibrationRunList.push_back(make_pair(2,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(2,0.0));
+  m_CalibrationRunList.push_back(make_pair(2,-m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(2,m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(2,0.0));
+  m_CalibrationRunList.push_back(make_pair(2,-m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(2,m_VehicleInfo.max_steer_angle/1.5));
+  m_CalibrationRunList.push_back(make_pair(2,0.0));
+  m_CalibrationRunList.push_back(make_pair(2,-m_VehicleInfo.max_steer_angle/1.5));
+  m_CalibrationRunList.push_back(make_pair(2,m_VehicleInfo.max_steer_angle/1.0));
+  m_CalibrationRunList.push_back(make_pair(2,0.0));
+  m_CalibrationRunList.push_back(make_pair(2,-m_VehicleInfo.max_steer_angle/1.0));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(3,0));
+  m_CalibrationRunList.push_back(make_pair(3,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(3,0.0));
+  m_CalibrationRunList.push_back(make_pair(3,-m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(3,m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(3,0.0));
+  m_CalibrationRunList.push_back(make_pair(3,-m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(3,m_VehicleInfo.max_steer_angle/1.5));
+  m_CalibrationRunList.push_back(make_pair(3,0.0));
+  m_CalibrationRunList.push_back(make_pair(3,-m_VehicleInfo.max_steer_angle/1.5));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(4,0));
+  m_CalibrationRunList.push_back(make_pair(4,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(4,0.0));
+  m_CalibrationRunList.push_back(make_pair(4,-m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(4,m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(4,0.0));
+  m_CalibrationRunList.push_back(make_pair(4,-m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(4,m_VehicleInfo.max_steer_angle/1.5));
+  m_CalibrationRunList.push_back(make_pair(4,0.0));
+  m_CalibrationRunList.push_back(make_pair(4,-m_VehicleInfo.max_steer_angle/1.5));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(5,0));
+  m_CalibrationRunList.push_back(make_pair(5,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(5,0.0));
+  m_CalibrationRunList.push_back(make_pair(5,-m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(5,m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(5,0.0));
+  m_CalibrationRunList.push_back(make_pair(5,-m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(5,m_VehicleInfo.max_steer_angle/1.5));
+  m_CalibrationRunList.push_back(make_pair(5,0.0));
+  m_CalibrationRunList.push_back(make_pair(5,-m_VehicleInfo.max_steer_angle/1.5));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(6,0));
+  m_CalibrationRunList.push_back(make_pair(6,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(6,0.0));
+  m_CalibrationRunList.push_back(make_pair(6,-m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(6,m_VehicleInfo.max_steer_angle/3.0));
+  m_CalibrationRunList.push_back(make_pair(6,0.0));
+  m_CalibrationRunList.push_back(make_pair(6,-m_VehicleInfo.max_steer_angle/3.0));
+  m_CalibrationRunList.push_back(make_pair(6,m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(6,0.0));
+  m_CalibrationRunList.push_back(make_pair(6,-m_VehicleInfo.max_steer_angle/2.0));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(7,0));
+  m_CalibrationRunList.push_back(make_pair(7,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(7,0.0));
+  m_CalibrationRunList.push_back(make_pair(7,-m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(7,m_VehicleInfo.max_steer_angle/3.0));
+  m_CalibrationRunList.push_back(make_pair(7,0.0));
+  m_CalibrationRunList.push_back(make_pair(7,-m_VehicleInfo.max_steer_angle/3.0));
+  m_CalibrationRunList.push_back(make_pair(7,m_VehicleInfo.max_steer_angle/2.0));
+  m_CalibrationRunList.push_back(make_pair(7,0.0));
+  m_CalibrationRunList.push_back(make_pair(7,-m_VehicleInfo.max_steer_angle/2.0));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(8,0));
+  m_CalibrationRunList.push_back(make_pair(8,m_VehicleInfo.max_steer_angle/6.0));
+  m_CalibrationRunList.push_back(make_pair(8,0.0));
+  m_CalibrationRunList.push_back(make_pair(8,-m_VehicleInfo.max_steer_angle/6.0));
+  m_CalibrationRunList.push_back(make_pair(8,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(8,0.0));
+  m_CalibrationRunList.push_back(make_pair(8,-m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(8,m_VehicleInfo.max_steer_angle/3.0));
+  m_CalibrationRunList.push_back(make_pair(8,0.0));
+  m_CalibrationRunList.push_back(make_pair(8,-m_VehicleInfo.max_steer_angle/3.0));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(9,0));
+  m_CalibrationRunList.push_back(make_pair(9,m_VehicleInfo.max_steer_angle/6.0));
+  m_CalibrationRunList.push_back(make_pair(9,0.0));
+  m_CalibrationRunList.push_back(make_pair(9,-m_VehicleInfo.max_steer_angle/6.0));
+  m_CalibrationRunList.push_back(make_pair(9,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(9,0.0));
+  m_CalibrationRunList.push_back(make_pair(9,-m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(9,m_VehicleInfo.max_steer_angle/3.0));
+  m_CalibrationRunList.push_back(make_pair(9,0.0));
+  m_CalibrationRunList.push_back(make_pair(9,-m_VehicleInfo.max_steer_angle/3.0));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(10,0));
+  m_CalibrationRunList.push_back(make_pair(10,m_VehicleInfo.max_steer_angle/6.0));
+  m_CalibrationRunList.push_back(make_pair(10,0.0));
+  m_CalibrationRunList.push_back(make_pair(10,-m_VehicleInfo.max_steer_angle/6.0));
+  m_CalibrationRunList.push_back(make_pair(10,m_VehicleInfo.max_steer_angle/5.0));
+  m_CalibrationRunList.push_back(make_pair(10,0.0));
+  m_CalibrationRunList.push_back(make_pair(10,-m_VehicleInfo.max_steer_angle/5.0));
+  m_CalibrationRunList.push_back(make_pair(10,m_VehicleInfo.max_steer_angle/4.0));
+  m_CalibrationRunList.push_back(make_pair(10,0.0));
+  m_CalibrationRunList.push_back(make_pair(10,-m_VehicleInfo.max_steer_angle/4.0));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(11,0));
+  m_CalibrationRunList.push_back(make_pair(11,m_VehicleInfo.max_steer_angle/8.0));
+  m_CalibrationRunList.push_back(make_pair(11,0.0));
+  m_CalibrationRunList.push_back(make_pair(11,-m_VehicleInfo.max_steer_angle/8.0));
+  m_CalibrationRunList.push_back(make_pair(11,m_VehicleInfo.max_steer_angle/6.0));
+  m_CalibrationRunList.push_back(make_pair(11,0.0));
+  m_CalibrationRunList.push_back(make_pair(11,-m_VehicleInfo.max_steer_angle/6.0));
+  m_CalibrationRunList.push_back(make_pair(11,m_VehicleInfo.max_steer_angle/5.0));
+  m_CalibrationRunList.push_back(make_pair(11,0.0));
+  m_CalibrationRunList.push_back(make_pair(11,-m_VehicleInfo.max_steer_angle/5.0));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(13,0));
+  m_CalibrationRunList.push_back(make_pair(13,m_VehicleInfo.max_steer_angle/10.0));
+  m_CalibrationRunList.push_back(make_pair(13,0.0));
+  m_CalibrationRunList.push_back(make_pair(13,-m_VehicleInfo.max_steer_angle/10.0));
+  m_CalibrationRunList.push_back(make_pair(13,m_VehicleInfo.max_steer_angle/9.0));
+  m_CalibrationRunList.push_back(make_pair(13,0.0));
+  m_CalibrationRunList.push_back(make_pair(13,-m_VehicleInfo.max_steer_angle/9.0));
+  m_CalibrationRunList.push_back(make_pair(13,m_VehicleInfo.max_steer_angle/8.0));
+  m_CalibrationRunList.push_back(make_pair(13,0.0));
+  m_CalibrationRunList.push_back(make_pair(13,-m_VehicleInfo.max_steer_angle/8.0));
+
+  m_CalibrationRunList.push_back(make_pair(0,0));
+
+  m_CalibrationRunList.push_back(make_pair(15,0));
+  m_CalibrationRunList.push_back(make_pair(15,m_VehicleInfo.max_steer_angle/15.0));
+  m_CalibrationRunList.push_back(make_pair(15,0.0));
+  m_CalibrationRunList.push_back(make_pair(15,-m_VehicleInfo.max_steer_angle/15.0));
+  m_CalibrationRunList.push_back(make_pair(15,m_VehicleInfo.max_steer_angle/12.0));
+  m_CalibrationRunList.push_back(make_pair(15,0.0));
+  m_CalibrationRunList.push_back(make_pair(15,-m_VehicleInfo.max_steer_angle/12.0));
+  m_CalibrationRunList.push_back(make_pair(15,m_VehicleInfo.max_steer_angle/10.0));
+  m_CalibrationRunList.push_back(make_pair(15,0.0));
+  m_CalibrationRunList.push_back(make_pair(15,-m_VehicleInfo.max_steer_angle/10.0));
+  m_CalibrationRunList.push_back(make_pair(0,0));
+}
+
+} /* namespace SimulationNS */

+ 34 - 1
src/tool/tool_trace2vectormap/trace2vectormap.cpp

@@ -42,6 +42,7 @@ int trace2vectormap::convert()
     std::vector<iv::vectormap::lane> xvectorlane;
     std::vector<iv::vectormap::line> xvectorline;
     std::vector<iv::vectormap::whiteline> xvectorwhiteline;
+    std::vector<iv::vectormap::dtlane> xvectordtlane;
 
     for(i=0;i<nline;i++)
     {
@@ -91,6 +92,17 @@ int trace2vectormap::convert()
         xlane.blid = 0;
         xlane.flid = 0;
         xvectorlane.push_back(xlane);
+        iv::vectormap::dtlane xdtlane;
+        xdtlane.did = i;
+        xdtlane.Dist  = xparam.fSpan;
+        xdtlane.pid = xvectornode[i-1].pid;
+        xdtlane.Dir = 0;
+        xdtlane.Apara = 90000000000;
+        xdtlane.r = 0.0;
+        xdtlane.slope = 0;
+        xdtlane.LW = xparam.fDisLeft;
+        xdtlane.RW = xparam.fDisRight;
+        xvectordtlane.push_back(xdtlane);
     }
 
     int nlanesize = xvectorlane.size();
@@ -247,7 +259,7 @@ int trace2vectormap::convert()
     xFileLane.setFileName(strfolder + "/lane.csv");
     if(!xFileLane.open(QIODevice::ReadWrite))
     {
-        qDebug(" node file open fail.");
+        qDebug(" lane file open fail.");
         return -6;
     }
     snprintf(strline,1000,"LnID,DID,BLID,FLID,BNID,FNID,JCT,BLID2,BLID3,BLID4,FLID2,FLID3,FLID4,ClossID,Span,LCnt,Lno,LaneType,LimitVel,RefVel,RoadSecID,LaneChgFG\n");
@@ -266,5 +278,26 @@ int trace2vectormap::convert()
     }
     xFileLane.close();
 
+    QFile xFiledtLane;
+    xFiledtLane.setFileName(strfolder + "/dtlane.csv");
+    if(!xFiledtLane.open(QIODevice::ReadWrite))
+    {
+        qDebug(" dtlane file open fail.");
+        return -6;
+    }
+    snprintf(strline,1000,"DID,Dist,PID,Dir,Apara,r,slope,cant,LW,RW\n");
+    xFiledtLane.write(strline);
+
+    for(i=0;i<(int)xvectordtlane.size();i++)
+    {
+        snprintf(strline,1000,"%d,%f,%d,%f,%f,%f,%f,%f,%f,%f\n",
+                 xvectordtlane[i].did,xvectordtlane[i].Dist,xvectordtlane[i].pid,
+                 xvectordtlane[i].Dir,xvectordtlane[i].Apara,xvectordtlane[i].r,
+                 xvectordtlane[i].slope,xvectordtlane[i].cant,xvectordtlane[i].LW,
+                 xvectordtlane[i].RW);
+        xFiledtLane.write(strline);
+    }
+    xFiledtLane.close();
+
     return 0;
 }

+ 14 - 0
src/tool/tool_trace2vectormap/trace2vectormap.h

@@ -65,6 +65,20 @@ struct lane
     int lno;
 };
 
+struct dtlane
+{
+    int did;
+    double Dist;
+    int pid;
+    double Dir;
+    double Apara;
+    double r;
+    double slope;
+    double cant;
+    double LW;
+    double RW;
+};
+
 }