├── .gitignore ├── CMakeLists.txt ├── Maps ├── airport_departure.pgm ├── airport_departure.yaml ├── airport_depature_goals.txt ├── airport_depature_obstacles.txt ├── indian_cross_12_16_12.png ├── indian_cross_12_16_12.yaml ├── indian_cross_13_14_13.png ├── indian_cross_13_14_13.yaml ├── indian_cross_14_12_14.png ├── indian_cross_14_12_14.yaml ├── indian_cross_15_10_15.png ├── indian_cross_15_10_15.yaml ├── indian_cross_16_8_16.png ├── indian_cross_16_8_16.yaml ├── indian_cross_17_6_17.png ├── indian_cross_17_6_17.yaml ├── indian_cross_18_4_18.png ├── indian_cross_18_4_18.yaml ├── indian_cross_goals_12_16_12.txt ├── indian_cross_goals_13_14_13.txt ├── indian_cross_goals_14_12_14.txt ├── indian_cross_goals_15_10_15.txt ├── indian_cross_goals_16_8_16.txt ├── indian_cross_goals_17_6_17.txt ├── indian_cross_goals_18_4_18.txt ├── indian_cross_goals_tri_10_10.txt ├── indian_cross_goals_tri_10_12.txt ├── indian_cross_goals_tri_12_12.txt ├── indian_cross_goals_tri_12_14.txt ├── indian_cross_goals_tri_14_14.txt ├── indian_cross_goals_tri_14_16.txt ├── indian_cross_obs_12_16_12.txt ├── indian_cross_obs_13_14_13.txt ├── indian_cross_obs_14_12_14.txt ├── indian_cross_obs_15_10_15.txt ├── indian_cross_obs_16_8_16.txt ├── indian_cross_obs_17_6_17.txt ├── indian_cross_obs_18_4_18.txt ├── indian_cross_obs_tri_10_10.txt ├── indian_cross_obs_tri_10_12.txt ├── indian_cross_obs_tri_12_12.txt ├── indian_cross_obs_tri_12_14.txt ├── indian_cross_obs_tri_14_14.txt ├── indian_cross_obs_tri_14_16.txt ├── indian_cross_tri_10_10.png ├── indian_cross_tri_10_10.yaml ├── indian_cross_tri_10_12.png ├── indian_cross_tri_10_12.yaml ├── indian_cross_tri_12_12.png ├── indian_cross_tri_12_12.yaml ├── indian_cross_tri_12_14.png ├── indian_cross_tri_12_14.yaml ├── indian_cross_tri_14_14.png ├── indian_cross_tri_14_14.yaml ├── indian_cross_tri_14_16.png └── indian_cross_tri_14_16.yaml ├── README.md ├── car_hyp_despot ├── CMakeLists.txt ├── cmake │ ├── DespotConfig.cmake.in │ └── FindTinyXML.cmake ├── package.xml └── src │ ├── HypDespot │ ├── CMakeLists.txt │ ├── cmake │ │ ├── DespotConfig.cmake.in │ │ └── FindTinyXML.cmake │ ├── doc │ │ ├── NsightRemoteDebug │ │ ├── Untitled Document~ │ │ ├── Usage.txt │ │ ├── cpp_model_doc │ │ │ └── Tutorial on Using DESPOT with cpp model.pdf │ │ ├── eclipse_guide.md │ │ ├── nips2013.txt │ │ ├── nsight_error_parsing │ │ ├── nsight_error_parsing~ │ │ ├── nsight_patch │ │ │ ├── README │ │ │ ├── README~ │ │ │ ├── cproject_cuda │ │ │ └── nsight-err-parse-patch.py │ │ ├── polymorphism │ │ ├── polymorphism~ │ │ └── pomdpx_model_doc │ │ │ └── DESPOT tutorial on using pomdpx model.pdf │ ├── include │ │ └── despot │ │ │ ├── GPUconfig.h │ │ │ ├── GPUcore │ │ │ ├── CudaInclude.h │ │ │ ├── GPUbuiltin_lower_bound.h │ │ │ ├── GPUbuiltin_policy.h │ │ │ ├── GPUbuiltin_upper_bound.h │ │ │ ├── GPUglobals.h │ │ │ ├── GPUhistory.h │ │ │ ├── disabled_util.h │ │ │ ├── msg_queue.h │ │ │ ├── shared_node.h │ │ │ ├── shared_solver.h │ │ │ └── thread_globals.h │ │ │ ├── GPUinterface │ │ │ ├── GPUdefault_policy.h │ │ │ ├── GPUfunction_interfaces.h │ │ │ ├── GPUlower_bound.h │ │ │ ├── GPUpolicy_graph.h │ │ │ ├── GPUpomdp.h │ │ │ └── GPUupper_bound.h │ │ │ ├── GPUrandom_streams.h │ │ │ ├── GPUutil │ │ │ ├── Dvc_memorypool.h │ │ │ ├── GPUCudaUtilities.h │ │ │ ├── GPUDataParallel.h │ │ │ ├── GPUFile.h │ │ │ ├── GPUHostReflection.h │ │ │ ├── GPUHostReflectionDevice.h │ │ │ ├── GPUIntTypes.h │ │ │ ├── GPUKnob.h │ │ │ ├── GPURedBlackTree.h │ │ │ ├── GPUThreadId.h │ │ │ ├── GPUalgorithm.h │ │ │ ├── GPUallocator_traits.h │ │ │ ├── GPUcoord.h │ │ │ ├── GPUcstdlib.h │ │ │ ├── GPUcstring.h │ │ │ ├── GPUdebug.h │ │ │ ├── GPUfunctional.h │ │ │ ├── GPUiterator.h │ │ │ ├── GPUlimits.h │ │ │ ├── GPUmap.h │ │ │ ├── GPUmemorypool.h │ │ │ ├── GPUrandom.h │ │ │ ├── GPUseeds.h │ │ │ ├── GPUsplit_buffer.h │ │ │ ├── GPUstring.h │ │ │ ├── GPUtype_traits.h │ │ │ ├── GPUutil.h │ │ │ ├── GPUutility.h │ │ │ └── GPUvector.h │ │ │ ├── config.h │ │ │ ├── core │ │ │ ├── builtin_lower_bounds.h │ │ │ ├── builtin_policy.h │ │ │ ├── builtin_policygraph.h │ │ │ ├── builtin_upper_bounds.h │ │ │ ├── globals.h │ │ │ ├── history.h │ │ │ ├── mdp.h │ │ │ ├── node.h │ │ │ ├── particle_belief.h │ │ │ ├── pomdp_world.h │ │ │ ├── prior.h │ │ │ └── solver.h │ │ │ ├── interface │ │ │ ├── belief.h │ │ │ ├── default_policy.h │ │ │ ├── lower_bound.h │ │ │ ├── policy_graph.h │ │ │ ├── pomdp.h │ │ │ ├── upper_bound.h │ │ │ └── world.h │ │ │ ├── ippc │ │ │ └── client.h │ │ │ ├── logger.h │ │ │ ├── planner.h │ │ │ ├── plannerbase.h │ │ │ ├── pomdpx │ │ │ ├── parser │ │ │ │ ├── function.h │ │ │ │ ├── parser.h │ │ │ │ └── variable.h │ │ │ └── pomdpx.h │ │ │ ├── random_streams.h │ │ │ ├── solver │ │ │ ├── Hyp_despot.h │ │ │ ├── aems.h │ │ │ ├── baseline_solver.h │ │ │ ├── despot.h │ │ │ ├── pomcp.h │ │ │ └── pomdplite.h │ │ │ └── util │ │ │ ├── coord.h │ │ │ ├── dirichlet.h │ │ │ ├── error_handler.h │ │ │ ├── exec_tracker.h │ │ │ ├── floor.h │ │ │ ├── gamma.h │ │ │ ├── grid.h │ │ │ ├── logging.h │ │ │ ├── memorypool.h │ │ │ ├── optionparser.h │ │ │ ├── random.h │ │ │ ├── seeds.h │ │ │ ├── timer.h │ │ │ ├── tinyxml │ │ │ ├── tinystr.h │ │ │ └── tinyxml.h │ │ │ └── util.h │ ├── license │ │ ├── APACHE LICENSE-2.0.txt │ │ ├── GPL-2.0.txt │ │ ├── License │ │ └── zlib.txt │ └── src │ │ ├── GPUcore │ │ ├── GPUbuiltin_lower_bound.cu │ │ ├── GPUbuiltin_policy.cu │ │ ├── GPUbuiltin_upper_bound.cu │ │ ├── GPUconfig.cu │ │ ├── GPUglobals.cu │ │ ├── GPUhistory.cu │ │ ├── GPUnode.cu │ │ ├── GPUpolicy_graph.cu │ │ ├── shared_node.cu │ │ └── thread_globals.cu │ │ ├── GPUinterface │ │ ├── GPUdefault_policy.cu │ │ ├── GPUfunction_interfaces.cu │ │ ├── GPUlower_bound.cu │ │ ├── GPUpomdp.cu │ │ └── GPUupper_bound.cu │ │ ├── GPUrandom_streams.cu │ │ ├── GPUutil │ │ ├── GPUcoord.cu │ │ ├── GPUmemorypool.cu │ │ ├── GPUrandom.cu │ │ ├── GPUseeds.cu │ │ └── GPUutil.cu │ │ ├── Parallel_planner.cu │ │ ├── core │ │ ├── builtin_lower_bounds.cpp │ │ ├── builtin_policy.cpp │ │ ├── builtin_policygraph.cpp │ │ ├── builtin_upper_bounds.cpp │ │ ├── globals.cpp │ │ ├── mdp.cpp │ │ ├── node.cpp │ │ ├── particle_belief.cpp │ │ ├── pomdp_world.cpp │ │ └── solver.cpp │ │ ├── evaluator.cpp │ │ ├── interface │ │ ├── belief.cpp │ │ ├── default_policy.cpp │ │ ├── lower_bound.cpp │ │ ├── policy_graph.cpp │ │ ├── pomdp.cpp │ │ ├── upper_bound.cpp │ │ └── world.cpp │ │ ├── ippc │ │ └── client.cpp │ │ ├── logger.cpp │ │ ├── planner.cpp │ │ ├── plannerbase.cpp │ │ ├── pomdpx │ │ ├── parser │ │ │ ├── function.cpp │ │ │ ├── parser.cpp │ │ │ └── variable.cpp │ │ └── pomdpx.cpp │ │ ├── random_streams.cpp │ │ ├── solver │ │ ├── Hyp_despot.cu │ │ ├── aems.cpp │ │ ├── baseline_solver.cpp │ │ ├── despot.cpp │ │ ├── pomcp.cpp │ │ └── pomdplite.cpp │ │ └── util │ │ ├── coord.cpp │ │ ├── dirichlet.cpp │ │ ├── error_handler.cpp │ │ ├── exec_tracker.cpp │ │ ├── floor.cpp │ │ ├── gamma.cpp │ │ ├── logging.cpp │ │ ├── random.cpp │ │ ├── seeds.cpp │ │ ├── tinyxml │ │ ├── tinystr.cpp │ │ ├── tinyxml.cpp │ │ ├── tinyxmlerror.cpp │ │ └── tinyxmlparser.cpp │ │ └── util.cpp │ ├── gamma │ ├── .editorconfig │ ├── .gitignore │ ├── .travis.yml │ ├── Agent.cpp │ ├── Agent.h │ ├── AgentParams.h │ ├── ConvexHull.cpp │ ├── ConvexHull.h │ ├── Definitions.h │ ├── GammaParams.cpp │ ├── GammaParams.h │ ├── KdTree.cpp │ ├── KdTree.h │ ├── Minkowski.h │ ├── Obstacle.cpp │ ├── Obstacle.h │ ├── RVO.h │ ├── RVOSimulator.cpp │ ├── RVOSimulator.h │ └── Vector2.h │ └── planner │ ├── CMakeLists.txt │ ├── cmake │ ├── DespotConfig.cmake.in │ └── FindTinyXML.cmake │ ├── collision.cpp │ ├── context_pomdp.cpp │ ├── context_pomdp.h │ ├── coord.h │ ├── crowd_belief.cpp │ ├── crowd_belief.h │ ├── default_prior.cpp │ ├── default_prior.h │ ├── param.cpp │ ├── param.h │ ├── path.cpp │ ├── path.h │ ├── simulator_base.h │ ├── state.h │ ├── utils.h │ ├── world_model.cpp │ └── world_model.h ├── crowd_pomdp_planner ├── CMakeLists.txt ├── is_despot_param.yaml ├── package.xml ├── params.yaml ├── planner.launch ├── planner_debug.launch └── src │ ├── context_pomdp_node.cpp │ ├── context_pomdp_node.h │ ├── controller.cpp │ ├── controller.h │ ├── local_frame.cpp │ ├── vel_publisher.cpp │ ├── world_simulator.cpp │ └── world_simulator.h ├── msg_builder ├── CMakeLists.txt ├── msg │ ├── ActionDistrib.msg │ ├── ActionReward.msg │ ├── AgentPathArray.msg │ ├── AgentPaths.msg │ ├── CrowdNetworkAgent.msg │ ├── CrowdNetworkAgentArray.msg │ ├── CrowdSidewalkAgent.msg │ ├── CrowdSidewalkAgentArray.msg │ ├── EulerAngles.msg │ ├── EulerAnglesWithConfidence.msg │ ├── Frame.msg │ ├── FrameTest.msg │ ├── Gesture.msg │ ├── Gestures.msg │ ├── InputImages.msg │ ├── Landmark.msg │ ├── LandmarksInfo.msg │ ├── LaneSeg.msg │ ├── Lanes.msg │ ├── NetworkRoutePoint.msg │ ├── Obstacles.msg │ ├── PersonModuleState.msg │ ├── Pointing.msg │ ├── PomdpCmd.msg │ ├── RectWithConfidence.msg │ ├── SidewalkRoutePoint.msg │ ├── SkeletonJoint.msg │ ├── StartGoal.msg │ ├── TrafficAgent.msg │ ├── TrafficAgentArray.msg │ ├── User.msg │ ├── UserInfo.msg │ ├── Wave.msg │ ├── car_info.msg │ ├── cluster.msg │ ├── clusters.msg │ ├── imitation_data.msg │ ├── ped_belief.msg │ ├── ped_info.msg │ ├── ped_local_frame.msg │ ├── ped_local_frame_vector.msg │ ├── pedestrian.msg │ ├── pedestrian_array.msg │ ├── peds_believes.msg │ ├── peds_car_hist.msg │ ├── peds_car_info.msg │ └── peds_info.msg ├── package.xml └── srv │ ├── TensorData.srv │ └── TensorDataHybrid.srv ├── scripts ├── check_optimal_params.py ├── clear_process.py ├── draw_vel_log.py ├── experiment_summit.sh ├── hyper_param_tuning_service.py ├── launch_docker.py ├── run_data_collection.py ├── server_pipline.py ├── statistics.py ├── summit_simulator.py ├── timeout.py ├── timeout_inner.py └── visualize_txt_data.py ├── setup ├── install_opencv4.sh ├── install_ros_melodic.sh ├── install_torch.sh ├── requirements_python2.txt ├── requirements_python3.txt └── setup.sh ├── summit_connector ├── CMakeLists.txt ├── launch │ ├── connector.launch │ ├── indian_cross_16_8_16.png │ └── map.yaml ├── package.xml └── src │ ├── crowd_processor.py │ ├── ego_vehicle.py │ ├── path_smoothing.py │ ├── plot_avg_speed.py │ ├── plot_jam_factor.py │ ├── purepursuit_controller.py │ ├── spectator.py │ ├── speed_controller.py │ ├── summit.py │ └── util.py └── videodev.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | *.pyc 4 | *.txt 5 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # toplevel CMakeLists.txt for a catkin workspace 2 | # catkin/cmake/toplevel.cmake 3 | 4 | cmake_minimum_required(VERSION 2.8.3) 5 | 6 | set(CATKIN_TOPLEVEL TRUE) 7 | 8 | # search for catkin within the workspace 9 | set(_cmd "catkin_find_pkg" "catkin" "${CMAKE_SOURCE_DIR}") 10 | execute_process(COMMAND ${_cmd} 11 | RESULT_VARIABLE _res 12 | OUTPUT_VARIABLE _out 13 | ERROR_VARIABLE _err 14 | OUTPUT_STRIP_TRAILING_WHITESPACE 15 | ERROR_STRIP_TRAILING_WHITESPACE 16 | ) 17 | if(NOT _res EQUAL 0 AND NOT _res EQUAL 2) 18 | # searching fot catkin resulted in an error 19 | string(REPLACE ";" " " _cmd_str "${_cmd}") 20 | message(FATAL_ERROR "Search for 'catkin' in workspace failed (${_cmd_str}): ${_err}") 21 | endif() 22 | 23 | # include catkin from workspace or via find_package() 24 | if(_res EQUAL 0) 25 | set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/${_out}/cmake") 26 | # include all.cmake without add_subdirectory to let it operate in same scope 27 | include(${catkin_EXTRAS_DIR}/all.cmake NO_POLICY_SCOPE) 28 | add_subdirectory("${_out}") 29 | 30 | else() 31 | # use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument 32 | # or CMAKE_PREFIX_PATH from the environment 33 | if(NOT DEFINED CMAKE_PREFIX_PATH) 34 | if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "") 35 | if(NOT WIN32) 36 | string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH}) 37 | else() 38 | set(CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH}) 39 | endif() 40 | endif() 41 | endif() 42 | 43 | # list of catkin workspaces 44 | set(catkin_search_path "") 45 | foreach(path ${CMAKE_PREFIX_PATH}) 46 | if(EXISTS "${path}/.catkin") 47 | list(FIND catkin_search_path ${path} _index) 48 | if(_index EQUAL -1) 49 | list(APPEND catkin_search_path ${path}) 50 | endif() 51 | endif() 52 | endforeach() 53 | 54 | # search for catkin in all workspaces 55 | set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE) 56 | find_package(catkin QUIET 57 | NO_POLICY_SCOPE 58 | PATHS ${catkin_search_path} 59 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) 60 | unset(CATKIN_TOPLEVEL_FIND_PACKAGE) 61 | 62 | if(NOT catkin_FOUND) 63 | message(FATAL_ERROR "find_package(catkin) failed. catkin was neither found in the workspace nor in the CMAKE_PREFIX_PATH. One reason may be that no ROS setup.sh was sourced before.") 64 | endif() 65 | set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};~/libtorch") 66 | find_package(Torch REQUIRED) 67 | endif() 68 | 69 | catkin_workspace() 70 | -------------------------------------------------------------------------------- /Maps/airport_departure.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/airport_departure.pgm -------------------------------------------------------------------------------- /Maps/airport_departure.yaml: -------------------------------------------------------------------------------- 1 | image: airport_departure.pgm 2 | resolution: 0.080000 3 | origin: [-224.54, -163.83500, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/airport_depature_goals.txt: -------------------------------------------------------------------------------- 1 | -197.80 -134.80 2 | -180.15 -137.54 3 | -169.33 -141.1 4 | -174.8 -148.53 5 | -201.55 -148.53 6 | -216.57 -145 7 | -1 -1 -------------------------------------------------------------------------------- /Maps/airport_depature_obstacles.txt: -------------------------------------------------------------------------------- 1 | -222.55 -137.84 -203.23 -138.35 -202.49 -127 -222.33 -127 2 | -194.3 -137.87 -181.8 -138 -181.5 -127 -194.3 -127 3 | -178.5 -137.66 -164.95 -137.66 -164.95 -127 -178.5 -127 4 | -166.65 -148.05 -164 -148.05 -164 -138 -166.65 -138 5 | -172.06 -156 -166 -156 -166 -148.25 -172.06 -148.25 6 | -197.13 -156 -181.14 -156 -181.14 -148.65 -197.13 -148.65 7 | -222.33 -156 -204.66 -156 -204.66 -148.28 -222.33 -148.28 8 | -214.4 -143.25 -213.5 -143.25 -213.5 -142.4 -214.4 -142.4 9 | -209.66 -144.35 -208.11 -144.35 -208.11 -142.8 -209.66 -142.8 10 | -198.58 -144.2 -197.2 -144.2 -197.2 -142.92 -198.58 -142.92 11 | -184.19 -143.88 -183.01 -143.87 -181.5 -141.9 -184.19 -142.53 12 | -176 -143.69 -174.43 -143.69 -174.43 -142 -176 -142 -------------------------------------------------------------------------------- /Maps/indian_cross_12_16_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_12_16_12.png -------------------------------------------------------------------------------- /Maps/indian_cross_12_16_12.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_12_16_12.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_13_14_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_13_14_13.png -------------------------------------------------------------------------------- /Maps/indian_cross_13_14_13.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_13_14_13.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_14_12_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_14_12_14.png -------------------------------------------------------------------------------- /Maps/indian_cross_14_12_14.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_14_12_14.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_15_10_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_15_10_15.png -------------------------------------------------------------------------------- /Maps/indian_cross_15_10_15.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_15_10_15.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_16_8_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_16_8_16.png -------------------------------------------------------------------------------- /Maps/indian_cross_16_8_16.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_16_8_16.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_17_6_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_17_6_17.png -------------------------------------------------------------------------------- /Maps/indian_cross_17_6_17.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_17_6_17.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_18_4_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_18_4_18.png -------------------------------------------------------------------------------- /Maps/indian_cross_18_4_18.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_18_4_18.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_goals_12_16_12.txt: -------------------------------------------------------------------------------- 1 | 7.5 20.0 2 | -7.5 20.0 3 | 7.5 -20.0 4 | -7.5 -20.0 5 | 20.0 7.5 6 | 20.0 -7.5 7 | -20.0 7.5 8 | -20.0 -7.5 9 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_13_14_13.txt: -------------------------------------------------------------------------------- 1 | 6.5 20.0 2 | -6.5 20.0 3 | 6.5 -20.0 4 | -6.5 -20.0 5 | 20.0 6.5 6 | 20.0 -6.5 7 | -20.0 6.5 8 | -20.0 -6.5 9 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_14_12_14.txt: -------------------------------------------------------------------------------- 1 | 5.5 20.0 2 | -5.5 20.0 3 | 5.5 -20.0 4 | -5.5 -20.0 5 | 20.0 5.5 6 | 20.0 -5.5 7 | -20.0 5.5 8 | -20.0 -5.5 9 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_15_10_15.txt: -------------------------------------------------------------------------------- 1 | 4.5 20.0 2 | -4.5 20.0 3 | 4.5 -20.0 4 | -4.5 -20.0 5 | 20.0 4.5 6 | 20.0 -4.5 7 | -20.0 4.5 8 | -20.0 -4.5 9 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_16_8_16.txt: -------------------------------------------------------------------------------- 1 | 5.5 20.0 2 | -5.5 20.0 3 | 5.5 -20.0 4 | -5.5 -20.0 5 | 20.0 5.5 6 | 20.0 -5.5 7 | -20.0 5.5 8 | -20.0 -5.5 9 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_17_6_17.txt: -------------------------------------------------------------------------------- 1 | 2.5 20.0 2 | -2.5 20.0 3 | 2.5 -20.0 4 | -2.5 -20.0 5 | 20.0 2.5 6 | 20.0 -2.5 7 | -20.0 2.5 8 | -20.0 -2.5 9 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_18_4_18.txt: -------------------------------------------------------------------------------- 1 | 1.5 20.0 2 | -1.5 20.0 3 | 1.5 -20.0 4 | -1.5 -20.0 5 | 20.0 1.5 6 | 20.0 -1.5 7 | -20.0 1.5 8 | -20.0 -1.5 9 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_tri_10_10.txt: -------------------------------------------------------------------------------- 1 | -4.5 20.0 2 | 4.5 20.0 3 | 20.0 4.5 4 | 20.0 -4.5 5 | -20.0 4.5 6 | -20.0 -4.5 7 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_tri_10_12.txt: -------------------------------------------------------------------------------- 1 | -12.5 20.0 2 | -1.5 20.0 3 | 20.0 4.5 4 | 20.0 -4.5 5 | -20.0 4.5 6 | -20.0 -4.5 7 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_tri_12_12.txt: -------------------------------------------------------------------------------- 1 | -5.5 20.0 2 | 5.5 20.0 3 | 20.0 5.5 4 | 20.0 -5.5 5 | -20.0 5.5 6 | -20.0 -5.5 7 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_tri_12_14.txt: -------------------------------------------------------------------------------- 1 | -13 20.0 2 | 0 20.0 3 | 20.0 5.5 4 | 20.0 -5.5 5 | -20.0 5.5 6 | -20.0 -5.5 7 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_tri_14_14.txt: -------------------------------------------------------------------------------- 1 | -6.5 20.0 2 | 6.5 20.0 3 | 20.0 6.5 4 | 20.0 -6.5 5 | -20.0 6.5 6 | -20.0 -6.5 7 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_goals_tri_14_16.txt: -------------------------------------------------------------------------------- 1 | -13.5 20.0 2 | 1.5 20.0 3 | 20.0 6.5 4 | 20.0 -6.5 5 | -20.0 6.5 6 | -20.0 -6.5 7 | -1 -1 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_12_16_12.txt: -------------------------------------------------------------------------------- 1 | -8 8 -8 40 -40 40 -40 8 2 | -8 -40 -8 -8 -40 -8 -40 -40 3 | 40 -40 40 -8 8 -8 8 -40 4 | 40 8 40 40 8 40 8 8 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_13_14_13.txt: -------------------------------------------------------------------------------- 1 | -7 7 -7 40 -40 40 -40 7 2 | -7 -40 -7 -7 -40 -7 -40 -40 3 | 40 -40 40 -7 7 -7 7 -40 4 | 40 7 40 40 7 40 7 7 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_14_12_14.txt: -------------------------------------------------------------------------------- 1 | -6 6 -6 40 -40 40 -40 6 2 | -6 -40 -6 -6 -40 -6 -40 -40 3 | 40 -40 40 -6 6 -6 6 -40 4 | 40 6 40 40 6 40 6 6 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_15_10_15.txt: -------------------------------------------------------------------------------- 1 | -5 5 -5 40 -40 40 -40 5 2 | -5 -40 -5 -5 -40 -5 -40 -40 3 | 40 -40 40 -5 5 -5 5 -40 4 | 40 5 40 40 5 40 5 5 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_16_8_16.txt: -------------------------------------------------------------------------------- 1 | -4 4 -4 40 -40 40 -40 4 2 | -4 -40 -4 -4 -40 -4 -40 -40 3 | 40 -40 40 -4 4 -4 4 -40 4 | 40 4 40 40 4 40 4 4 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_17_6_17.txt: -------------------------------------------------------------------------------- 1 | -3 3 -3 40 -40 40 -40 3 2 | -3 -40 -3 -3 -40 -3 -40 -40 3 | 40 -40 40 -3 3 -3 3 -40 4 | 40 3 40 40 3 40 3 3 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_18_4_18.txt: -------------------------------------------------------------------------------- 1 | -2 2 -2 40 -40 40 -40 2 2 | -2 -40 -2 -2 -40 -2 -40 -40 3 | 40 -40 40 -2 2 -2 2 -40 4 | 40 2 40 40 2 40 2 2 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_tri_10_10.txt: -------------------------------------------------------------------------------- 1 | -5 5 -5 40 -40 40 -40 5 2 | 40 5 40 40 5 40 5 5 3 | 40 -40 40 -5 -40 -5 -40 -40 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_tri_10_12.txt: -------------------------------------------------------------------------------- 1 | -6 5 -13 20 -40 20 -40 5 2 | 40 5 40 20 -1 20 6 5 3 | 40 -40 40 -5 -40 -5 -40 -40 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_tri_12_12.txt: -------------------------------------------------------------------------------- 1 | -6 6 -6 40 -40 40 -40 6 2 | 40 6 40 40 6 40 6 6 3 | 40 -40 40 -6 -40 -6 -40 -40 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_tri_12_14.txt: -------------------------------------------------------------------------------- 1 | -7 6 -13.5 20 -40 20 -40 6 2 | 40 6 40 20 0.5 20 7 6 3 | 40 -40 40 -6 -40 -6 -40 -40 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_tri_14_14.txt: -------------------------------------------------------------------------------- 1 | -7 7 -7 40 -40 40 -40 7 2 | 40 7 40 40 7 40 7 7 3 | 40 -40 40 -7 -40 -7 -40 -40 -------------------------------------------------------------------------------- /Maps/indian_cross_obs_tri_14_16.txt: -------------------------------------------------------------------------------- 1 | -8 7 -14 20 -40 20 -40 7 2 | 40 7 40 20 2 20 8 7 3 | 40 -40 40 -7 -40 -7 -40 -40 -------------------------------------------------------------------------------- /Maps/indian_cross_tri_10_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_tri_10_10.png -------------------------------------------------------------------------------- /Maps/indian_cross_tri_10_10.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_tri_10_10.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_tri_10_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_tri_10_12.png -------------------------------------------------------------------------------- /Maps/indian_cross_tri_10_12.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_tri_10_12.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_tri_12_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_tri_12_12.png -------------------------------------------------------------------------------- /Maps/indian_cross_tri_12_12.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_tri_12_12.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_tri_12_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_tri_12_14.png -------------------------------------------------------------------------------- /Maps/indian_cross_tri_12_14.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_tri_12_14.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_tri_14_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_tri_14_14.png -------------------------------------------------------------------------------- /Maps/indian_cross_tri_14_14.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_tri_14_14.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /Maps/indian_cross_tri_14_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/Maps/indian_cross_tri_14_16.png -------------------------------------------------------------------------------- /Maps/indian_cross_tri_14_16.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_tri_14_16.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /car_hyp_despot/cmake/DespotConfig.cmake.in: -------------------------------------------------------------------------------- 1 | set(DESPOT_VERSION x.y.z) 2 | 3 | @PACKAGE_INIT@ 4 | 5 | include("${CMAKE_CURRENT_LIST_DIR}/DespotTargets.cmake") 6 | 7 | set_and_check(DESPOT_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_PATH@") 8 | set(DESPOT_INCLUDE_DIRS ${DESPOT_INCLUDE_DIR}) 9 | set(DESPOT_LIBRARIES despot) 10 | -------------------------------------------------------------------------------- /car_hyp_despot/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | car_hyp_despot 4 | 0.0.0 5 | The crowd_pomdp_planner package 6 | 7 | 8 | 9 | 10 | yuanfu 11 | 12 | 13 | 14 | 15 | 16 | TODO 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | catkin 43 | roscpp 44 | msg_builder 45 | 46 | roscpp 47 | msg_builder 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/cmake/DespotConfig.cmake.in: -------------------------------------------------------------------------------- 1 | set(DESPOT_VERSION x.y.z) 2 | 3 | @PACKAGE_INIT@ 4 | 5 | include("${CMAKE_CURRENT_LIST_DIR}/DespotTargets.cmake") 6 | 7 | set_and_check(DESPOT_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_PATH@") 8 | set(DESPOT_INCLUDE_DIRS ${DESPOT_INCLUDE_DIR}) 9 | set(DESPOT_LIBRARIES despot) 10 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/NsightRemoteDebug: -------------------------------------------------------------------------------- 1 | Follow section 3.7 Debugging Remote CUDA Applications of this guide: 2 | 3 | http://docs.nvidia.com/cuda/nsight-eclipse-edition-getting-started-guide/#remote-debugging 4 | 5 | Notes: 6 | 7 | Host name: peacock@d1.comp.nus.edu.sg 8 | Username:panpan 9 | 10 | Toolkit path: /usr/local/cuda/bin/ 11 | Lib path:/usr/local/cuda-8.0/lib64 12 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/Untitled Document~: -------------------------------------------------------------------------------- 1 | To enable the CUDA error parsing in NVIDIA Nsight: 2 | 3 | follow the instructions in nsight_patch/README. 4 | 5 | Key file: nsight_patch/nsight-err-parse-patch.py 6 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/Usage.txt: -------------------------------------------------------------------------------- 1 | 2 | ================================================================================ 3 | COMMAND LINE OPTIONS 4 | ================================================================================ 5 | --help Print usage and exit. 6 | -q --problem Problem name. 7 | -m --model-params Path to model-parameters file, if any. 8 | -d --depth Maximum depth of search tree (default 90). 9 | -g --discount Discount factor (default 0.95). 10 | --size Size of a problem (problem specific). 11 | --number Number of elements of a problem (problem 12 | specific). 13 | -r --seed Random number seed (default is random). 14 | -t --timeout Search time per move, in seconds (default 15 | 1). 16 | -n --nparticles Number of particles (default 500). 17 | -p --prune Pruning constant (default no pruning). 18 | --xi Gap constant (default to 0.95). 19 | -s --simlen Number of steps to simulate. (default 90; 0 20 | = infinite). 21 | --simulator Use IPPC server or a POMDP model as the 22 | simulator. 23 | --max-policy-simlen Number of steps to simulate the default 24 | policy. (default 90). 25 | --default-action Type of default action to use. (default 26 | none). 27 | --runs Number of runs. (default 1). 28 | --lbtype Lower bound strategy, if applicable. 29 | -l --blbtype Base lower bound, if applicable. 30 | -u --ubtype Upper bound strategy, if applicable. 31 | --bubtype Base upper bound, if applicable. 32 | -b --belief Belief update strategy, if applicable. 33 | -v --verbosity Verbosity level. 34 | --silence Reduce default output to minimal. 35 | --noise Noise level for transition in POMDPX belief 36 | update. -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/cpp_model_doc/Tutorial on Using DESPOT with cpp model.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/car_hyp_despot/src/HypDespot/doc/cpp_model_doc/Tutorial on Using DESPOT with cpp model.pdf -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/eclipse_guide.md: -------------------------------------------------------------------------------- 1 | # Using Eclipse (IDE) 2 | 3 | To create an Eclipse project for DESPOT, run the following commands: 4 | 5 | ```bash 6 | $ cd 7 | $ mkdir despot-eclipse; cd despot-eclipse 8 | $ cmake -G "Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug ./ 9 | ``` 10 | 11 | Then import the project into Eclipse: 12 | 13 | 1. Use `Menu File > Import` 14 | 2. Select `General > Existing projects into workspace` 15 | 3. Choose the root directory to be `despot-eclipse`. Keep "Copy projects into workspace" unchecked. 16 | 4. Click "finish" and your Eclipse DESPOT project should be ready to use. 17 | 3. To compile the DESPOT library and examples, select `Menu Project > Build all in Eclipse`. After compiling, the binaries will be created under `despot-eclipse and despot-eclipse/examples`. 18 | 19 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/nips2013.txt: -------------------------------------------------------------------------------- 1 | The following commands can be used to obtain results in [1], assuming you are 2 | in the right subdirectory in the problems directory: 3 | 4 | ./adventurer --runs 2000 5 | 6 | ./adventurer -p 10 --runs 2000 7 | 8 | ./bridge --runs 2000 9 | 10 | ./tag --runs 2000 11 | 12 | ./lasertag --runs 2000 13 | 14 | ./rocksample --size 7 --number 8 --runs 2000 15 | 16 | ./rocksample --size 11 --number 11 --runs 2000 17 | 18 | ./rocksample --size 15 --number 15 --runs 2000 19 | 20 | ./pocman --runs 2000 21 | 22 | Note that doing 2000 runs can take a long time. It is better to do fewer runs 23 | using multiple commands, i.e., run in parallel. For example, we can use 20 24 | commands like the following to do 2000 runs: 25 | 26 | ./tag --runs 100 -r 27 | 28 | Use a random number for the seed used in each command. 29 | 30 | [1] Online POMDP Planning with Regularization. Nan Ye, Adihraj Somani, David Hsu and Wee Sun Lee. This extends our NIPS 2013 paper with an improved search algorithm, its analysis, and more empirical results. -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/nsight_error_parsing: -------------------------------------------------------------------------------- 1 | To enable the CUDA error parsing in NVIDIA Nsight: 2 | 3 | Follow the instructions in nsight_patch/README. 4 | Match the project file with nsight_patch/cproject_cuda 5 | 6 | Key files: 7 | nsight_patch/nsight-err-parse-patch.py 8 | nsight_patch/cproject_cuda 9 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/nsight_error_parsing~: -------------------------------------------------------------------------------- 1 | To enable the CUDA error parsing in NVIDIA Nsight: 2 | 3 | Follow the instructions in nsight_patch/README. 4 | Change the project file to nsight_patch/cproject_cuda 5 | 6 | Key files: 7 | nsight_patch/nsight-err-parse-patch.py 8 | nsight_patch/cproject_cuda 9 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/nsight_patch/README: -------------------------------------------------------------------------------- 1 | 2 | Python 3 script to fix error parsing in CMake generated Eclipse project files. 3 | 4 | Version 0.01 5 | 6 | 2014-12-08 Georg Altmann 7 | 8 | 9 | Usage: 10 | python3 nsight-err-parse-patch.py ~/GPU-despot-eclipse 11 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/nsight_patch/README~: -------------------------------------------------------------------------------- 1 | 2 | Python 3 script to fix error parsing in CMake generated Eclipse project files. 3 | 4 | Version 0.01 5 | 6 | 2014-12-08 Georg Altmann 7 | 8 | 9 | Usage: 10 | python3 nsight-err-parse-patch.py path-to-project-dir 11 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/polymorphism: -------------------------------------------------------------------------------- 1 | Implementing polymophisim for GPU despot: 2 | 3 | Objective: Let the GPUDESPOT.cu able to use the __device__ step function (and others) defined in a specific model (like Tiger) without having knowledge about the real model. 4 | 5 | Prerequisites: 6 | 1. Project's nvcc compilation mode is set as separate compilation (--relocatable-device-code=true) 7 | 8 | Procedure: 9 | 1. Declare the function as an extern __device__ function pointer in GPUDESPOT.h: 10 | something like: extern __device__ void(*step_)(double&); 11 | 2. Define the function in main.cu on the model side (in the file scope): 12 | __device__ void(*step_)(double&); 13 | 3. Write a kernel to pass the address of the real step function from the concrete model to the global function pointer func_: 14 | __global__ void PassStepFunc(DvcModel* dvc) 15 | { 16 | step_=&(dvc->step); 17 | } 18 | 4. Run the PassStepFunc kernel with only one thread. Pass the allocated device model to it as a parameter. 19 | DvcModel* Dvc; 20 | cudaMalloc((void**)&Dvc, sizeof(DvcModel)); 21 | PassStepFunc<<<1,1,1>>>(Dvc); 22 | 5. Now you should be able to use the global function pointer in GPUDESPOT.cu: 23 | __global__ void stepkernel(double* tmp) 24 | { 25 | int i=threadIdx.x;tmp[i]=i; 26 | (*step_)(tmp[i]); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/polymorphism~: -------------------------------------------------------------------------------- 1 | Implementing polymophisim for GPU despot: 2 | 3 | Objective: Let the GPUDESPOT.cu able to use the __device__ step function (and others) defined in a specific model (like Tiger) without having knowledge about the real model. 4 | 5 | Prerequisites: 6 | 1. Project's nvcc compilation mode is set as separate compilation (--relocatable-device-code=true) 7 | 8 | Procedure: 9 | 1. Declare the function as an extern __device__ function pointer in GPUDESPOT.h: 10 | something like: extern __device__ void(*step_)(double&); 11 | 2. Define the function in main.cu on the model side (in the file scope): 12 | __device__ void(*step_)(double&); 13 | 3. Write a kernel to pass the address of the real step function from the concrete model to the global function pointer func_: 14 | __global__ void PassStepFunc(DvcModel* dvc) 15 | { 16 | step_=&(dvc->step); 17 | } 18 | 4. Run the PassStepFunc kernel with only one thread. Pass the allocated device model to it as a parameter. 19 | DvcModel* Dvc; 20 | cudaMalloc((void**)&Dvc, sizeof(DvcModel)); 21 | Initkernel<<<1,1,1>>>(Dvc); 22 | 5. Now you should be able to use the global function pointer in GPUDESPOT.cu: 23 | __global__ void stepkernel(double* tmp) 24 | { 25 | int i=threadIdx.x;tmp[i]=i; 26 | (*step_)(tmp[i]); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/doc/pomdpx_model_doc/DESPOT tutorial on using pomdpx model.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/car_hyp_despot/src/HypDespot/doc/pomdpx_model_doc/DESPOT tutorial on using pomdpx model.pdf -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef GPUCONFIG_H 2 | #define GPUCONFIG_H 3 | 4 | #include 5 | #include 6 | #include 7 | namespace despot { 8 | 9 | struct Dvc_Config { 10 | public: 11 | int search_depth; 12 | double discount; 13 | unsigned int root_seed; 14 | double time_per_move; // CPU time available to construct the search tree 15 | int num_scenarios; 16 | double pruning_constant; 17 | double xi; // xi * gap(root) is the target uncertainty at the root. 18 | int sim_len; // Number of steps to run the simulation for. 19 | //std::string default_action; 20 | int max_policy_sim_len; // Maximum number of steps for simulating the default policy 21 | double noise; 22 | bool silence; 23 | bool useGPU; 24 | 25 | DEVICE Dvc_Config() : 26 | search_depth(90), 27 | discount(0.95), 28 | root_seed(42), 29 | time_per_move(1), 30 | num_scenarios(500), 31 | pruning_constant(0), 32 | xi(0.95), 33 | sim_len(90), 34 | //default_action(""), 35 | max_policy_sim_len(90), 36 | noise(0.1), 37 | silence(false), 38 | useGPU(false) 39 | { 40 | } 41 | 42 | static void CopyToGPU(const Config* src); 43 | static void Clear(); 44 | }; 45 | 46 | extern DEVICE Dvc_Config* Dvc_config; 47 | 48 | 49 | } // namespace despot 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUcore/CudaInclude.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CudaInclude.h 3 | * 4 | * Created on: 22 Mar, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef CUDAINCLUDE_H_ 9 | #define CUDAINCLUDE_H_ 10 | //Use this file to make sure the portability of the CUDA header files. 11 | //When CUDACC is not defined (in .cpp files), DEVICE and HOST will be ignored 12 | #include 13 | 14 | #pragma once 15 | #ifdef __CUDACC__ 16 | #define HOST __host__ 17 | #define DEVICE __device__ 18 | #define ALIGN(n) __align__(n) 19 | 20 | 21 | 22 | //#include 23 | //#define ThrustVector thrust::host_vector 24 | static void HandleError( cudaError_t err, 25 | const char *file, 26 | int line ) { 27 | if (err != cudaSuccess) { 28 | printf( "%s in %s at line %d\n", cudaGetErrorString( err ), 29 | file, line ); 30 | exit( EXIT_FAILURE ); 31 | } 32 | } 33 | #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ )) 34 | 35 | #include 36 | #include 37 | 38 | #else 39 | #define HOST 40 | #define DEVICE 41 | #if defined(__GNUC__) // GCC 42 | #define ALIGN(n) __attribute__((aligned(n))) 43 | #elif defined(_MSC_VER) // MSVC 44 | #define ALIGN(n) __declspec(align(n)) 45 | #else 46 | #error "CudaInclude.h: Please provide a definition for ALIGN macro for your host compiler!" 47 | #endif 48 | #endif 49 | 50 | 51 | #endif /* CUDAINCLUDE_H_ */ 52 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUcore/GPUbuiltin_lower_bound.h: -------------------------------------------------------------------------------- 1 | #ifndef GPUBUILIN__LOWER_BOUND_H 2 | #define GPUBUILIN__LOWER_BOUND_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | namespace despot { 10 | 11 | class Dvc_State; 12 | class Dvc_DSPOMDP; 13 | 14 | /* ============================================================================= 15 | * Dvc_TrivialParticleLowerBound class 16 | * =============================================================================*/ 17 | 18 | class Dvc_TrivialParticleLowerBound: public Dvc_ParticleLowerBound { 19 | public: 20 | /** 21 | * Returns a trival lower bound value calculated as 1/(1-gamma)*max_a{V_worstcase(s,a)}. 22 | * 23 | * @param scenarioID ID of the scenario in the particle 24 | * @param particles Particles in the scenarios. 25 | * @return (a, v), where v is the trival lower bound and a is the first action needed 26 | * to obtain the lower bound. 27 | */ 28 | DEVICE 29 | static Dvc_ValuedAction Value(int scenarioID, Dvc_State * particles); 30 | }; 31 | 32 | 33 | } // namespace despot 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUcore/GPUbuiltin_policy.h: -------------------------------------------------------------------------------- 1 | #ifndef GPUBUILTIN_POLICY_H 2 | #define GPUBUILTIN_POLICY_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | #include 21 | 22 | namespace despot { 23 | 24 | class Dvc_State; 25 | class Dvc_DSPOMDP; 26 | 27 | /* ============================================================================= 28 | * Dvc_BlindPolicy class 29 | * =============================================================================*/ 30 | 31 | 32 | class Dvc_BlindPolicy: public Dvc_DefaultPolicy { 33 | 34 | public: 35 | /** 36 | * [ Compulsory ] 37 | * Call a kernel function to initialize DvcBlindPolicy_action_ in device memory 38 | */ 39 | HOST virtual void SetDefaultAction() = 0; 40 | 41 | DEVICE static ACT_TYPE Action(int scenarioID, const Dvc_State* particles, 42 | Dvc_RandomStreams& streams, 43 | Dvc_History& history); 44 | }; 45 | 46 | 47 | extern DEVICE ACT_TYPE DvcBlindPolicy_action_; 48 | 49 | /* ============================================================================= 50 | * Dvc_RandomPolicy class 51 | * =============================================================================*/ 52 | 53 | class Dvc_RandomPolicy: public Dvc_DefaultPolicy { 54 | 55 | public: 56 | DEVICE static void Init(int num_actions, double* action_probs_ = NULL); 57 | DEVICE static ACT_TYPE Action(int scenarioID, const Dvc_State* particles, 58 | Dvc_RandomStreams& streams, 59 | Dvc_History& history); 60 | }; 61 | 62 | extern DEVICE double* DvcRandomPolicy_action_probs_; 63 | 64 | extern DEVICE int DvcRandomPolicy_num_actions_; 65 | 66 | } // namespace despot 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUcore/GPUbuiltin_upper_bound.h: -------------------------------------------------------------------------------- 1 | #ifndef GPUBUILTIN_UPPER_BOUND_H 2 | #define GPUBUILTIN_UPPER_BOUND_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | namespace despot { 13 | 14 | class Dvc_State; 15 | class Dvc_DSPOMDP; 16 | 17 | 18 | /* ============================================================================= 19 | * Dvc_TrivialParticleUpperBound class 20 | * =============================================================================*/ 21 | 22 | class Dvc_TrivialParticleUpperBound: public Dvc_ParticleUpperBound { 23 | protected: 24 | const Dvc_DSPOMDP* model_; 25 | public: 26 | 27 | /* 28 | * Returns an upper bound calculated as 1/(1-gamma)*v_max. 29 | */ 30 | 31 | DEVICE 32 | static float Value(const Dvc_State* state, int scenarioID, 33 | Dvc_History& history); 34 | }; 35 | 36 | 37 | } // namespace despot 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUcore/GPUglobals.h: -------------------------------------------------------------------------------- 1 | #ifndef GPUGLOBALS_H 2 | #define GPUGLOBALS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | namespace despot { 30 | 31 | typedef uint64_t OBS_TYPE; 32 | 33 | namespace Dvc_Globals { 34 | extern DEVICE const double Dvc_NEG_INFTY; 35 | extern DEVICE const double Dvc_POS_INFTY; 36 | extern DEVICE const double Dvc_INF; 37 | extern DEVICE const double Dvc_TINY; 38 | 39 | extern Dvc_Config* config; 40 | 41 | DEVICE inline bool Dvc_Fequals(double a, double b) { 42 | return std::fabs(a - b) < Dvc_TINY; 43 | } 44 | 45 | DEVICE inline double Dvc_Discount(Dvc_Config* config) { 46 | return config->discount; 47 | } 48 | 49 | DEVICE inline double Dvc_Discount(Dvc_Config* config,int d) { 50 | return std::pow(config->discount, d); 51 | } 52 | 53 | } // namespace 54 | 55 | } // namespace despot 56 | #define MC_DIM 128 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUcore/GPUhistory.h: -------------------------------------------------------------------------------- 1 | #ifndef GPUHISTORY_H 2 | #define GPUHISTORY_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace despot { 11 | 12 | /** 13 | * Action-observation history. 14 | */ 15 | class Dvc_History { 16 | public: 17 | 18 | HOST static void InitInGPU(int num_particles, Dvc_History* Dvc_history, int length,void* cuda_stream=NULL); 19 | 20 | HOST static void CopyToGPU(int num_particles,int* particleIDs, Dvc_History* Dvc_history, History* history); 21 | HOST static void Dvc_Add(Dvc_History* Dvc_history,ACT_TYPE action, OBS_TYPE obs, void* cudaStream=NULL); 22 | HOST static void Dvc_Trunc(Dvc_History* Dvc_history, int size, void* cudaStream=NULL); 23 | 24 | DEVICE void Add(ACT_TYPE action, OBS_TYPE obs) { 25 | 26 | if(actions_)actions_[currentSize_]=action; 27 | if(observations_)observations_[currentSize_]=obs; 28 | currentSize_++; 29 | } 30 | 31 | DEVICE void RemoveLast() { 32 | if(actions_)actions_[currentSize_-1]=-1; 33 | if(observations_)observations_[currentSize_-1]=-1; 34 | currentSize_--; 35 | } 36 | 37 | DEVICE ACT_TYPE Action(int t) const { 38 | return actions_[t]; 39 | } 40 | 41 | DEVICE OBS_TYPE Observation(int t) const { 42 | return observations_[t]; 43 | } 44 | 45 | DEVICE size_t Size() const { 46 | return currentSize_; 47 | } 48 | 49 | DEVICE void Truncate(int d) { 50 | currentSize_=d; 51 | } 52 | 53 | DEVICE ACT_TYPE LastAction() const { 54 | return actions_[currentSize_-1]; 55 | } 56 | 57 | DEVICE OBS_TYPE LastObservation() const { 58 | return observations_[currentSize_-1]; 59 | } 60 | 61 | void CreateMemoryPool(int mode=0) const; 62 | void DestroyMemoryPool(int mode=0) const; 63 | public: 64 | ACT_TYPE* actions_; 65 | OBS_TYPE* observations_; 66 | int currentSize_; 67 | }; 68 | 69 | } // namespace despot 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUcore/disabled_util.h: -------------------------------------------------------------------------------- 1 | #ifndef HASH_UTIL_H 2 | #define HASH_UTIL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | using namespace chrono; 14 | 15 | // NOTE: disabled C++11 feature 16 | // Functions for hashing data structs 17 | namespace std { 18 | template 19 | inline void hypdespot_hash_combine(size_t& seed, const T& v) { 20 | std::hash hasher; 21 | seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); 22 | } 23 | 24 | template 25 | struct hash> { 26 | inline size_t operator()(const pair& v) const { 27 | size_t seed = 0; 28 | ::hypdespot_hash_combine(seed, v.first); 29 | ::hypdespot_hash_combine(seed, v.second); 30 | return seed; 31 | } 32 | }; 33 | 34 | template 35 | struct hash> { 36 | inline size_t operator()(const vector& v) const { 37 | size_t seed = 0; 38 | for (const T& ele : v) { 39 | ::hypdespot_hash_combine(seed, ele); 40 | } 41 | return seed; 42 | } 43 | }; 44 | } 45 | 46 | // NOTE: disabled C++11 feature 47 | template 48 | void write(ostringstream& os, T t) { 49 | os << t; 50 | } 51 | 52 | template 53 | void write(ostringstream& os, T t, Args ... args) { 54 | os << t; 55 | write(os, args...); 56 | } 57 | 58 | template 59 | string concat(T t, Args ... args) { 60 | ostringstream os; 61 | write(os, t, args...); 62 | return os.str(); 63 | } 64 | 65 | template 66 | string concat(vector v) { 67 | ostringstream os; 68 | for (int i = 0; i < v.size(); i++) { 69 | os << v[i]; 70 | os << " "; 71 | } 72 | return os.str(); 73 | } 74 | 75 | #endif -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUcore/msg_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * msgQueue.h 3 | * 4 | * Created on: 19 Jul, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef MSGQUEUE_H_ 9 | #define MSGQUEUE_H_ 10 | 11 | 12 | #include "thread_globals.h" 13 | #include 14 | 15 | using namespace std; 16 | namespace despot { 17 | using namespace Globals; 18 | 19 | template< class T> 20 | class MsgQueque{ 21 | deque _queue; 22 | condition_variable _cond; 23 | mutex _mutex; 24 | public: 25 | 26 | MsgQueque() 27 | { 28 | cout<<"new message queue:"< lck(_mutex); 34 | Globals::Global_print_mutex(this_thread::get_id(),this, __FUNCTION__, 0); 35 | _queue.push_front(msg); 36 | Globals::Global_print_mutex(this_thread::get_id(),this, __FUNCTION__, 1); 37 | } 38 | _cond.notify_one(); 39 | } 40 | void WakeOneThread() 41 | { 42 | lock_guard lck(_mutex); 43 | _cond.notify_one(); 44 | } 45 | 46 | T* receive (bool is_expansion_thread, float timeout) 47 | { 48 | unique_lock lck(_mutex); 49 | T* msg=NULL; 50 | Globals::Global_print_mutex(this_thread::get_id(),this, __FUNCTION__, 0); 51 | _cond.wait(lck,[this, timeout]{ 52 | if (_queue.empty()) 53 | { 54 | Globals::Global_print_mutex(this_thread::get_id(),this, "receive::wait", 1); 55 | Globals::Global_print_queue(this_thread::get_id(),this, _queue.empty()); 56 | } 57 | return !_queue.empty()||(_queue.empty() && ThreadStatistics::STATISTICS.Active_thread_count==0)||Globals::Timeout(timeout); 58 | }); 59 | 60 | 61 | if(!_queue.empty()) 62 | { 63 | if(is_expansion_thread) 64 | Globals::AddActiveThread(); 65 | msg= move(_queue.back()); 66 | Globals::Global_print_mutex(this_thread::get_id(),msg, __FUNCTION__, 2); 67 | 68 | _queue.pop_back(); 69 | } 70 | else 71 | { 72 | ; 73 | } 74 | Globals::Global_print_mutex(this_thread::get_id(),msg, __FUNCTION__, 3); 75 | return msg; 76 | } 77 | bool empty() 78 | { 79 | unique_lock lck(_mutex); 80 | Globals::Global_print_mutex(this_thread::get_id(),this, __FUNCTION__, 0); 81 | Globals::Global_print_mutex(this_thread::get_id(),this, __FUNCTION__, 1); 82 | return _queue.empty(); 83 | } 84 | 85 | 86 | }; 87 | 88 | } 89 | #endif /* MSGQUEUE_H_ */ 90 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUcore/shared_solver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * shared_solver.h 3 | * 4 | * Created on: 20 Jul, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef SHARED_SOLVER_H_ 9 | #define SHARED_SOLVER_H_ 10 | 11 | #include 12 | namespace despot { 13 | 14 | /* ============================================================================= 15 | * SearchStatistics class (with mutex protection for multi-threading) 16 | * =============================================================================*/ 17 | 18 | struct Shared_SearchStatistics: public SearchStatistics { 19 | std::mutex _mutex; 20 | public: 21 | Shared_SearchStatistics():SearchStatistics(){;} 22 | 23 | Shared_SearchStatistics& operator=(const Shared_SearchStatistics& other) 24 | { 25 | initial_lb=other.initial_lb; 26 | initial_ub=other.initial_ub; 27 | final_lb=other.final_lb; 28 | final_ub=other.final_ub; 29 | time_search=other.time_search; 30 | time_path=other.time_path; 31 | time_backup=other.time_backup; 32 | time_node_expansion=other.time_node_expansion; 33 | num_policy_nodes=other.num_policy_nodes; 34 | num_tree_nodes=other.num_tree_nodes; 35 | num_expanded_nodes=other.num_expanded_nodes; 36 | num_tree_particles=other.num_tree_particles; 37 | num_particles_before_search=other.num_particles_before_search; 38 | num_particles_after_search=other.num_particles_after_search; 39 | num_trials=other.num_trials; 40 | longest_trial_length=other.longest_trial_length; 41 | return *this; 42 | } 43 | int Get_longest_trial_len() 44 | { 45 | std::lock_guard lck(_mutex); 46 | return longest_trial_length; 47 | } 48 | void Update_longest_trial_len(int l) 49 | { 50 | std::lock_guard lck(_mutex); 51 | longest_trial_length=max(longest_trial_length,l); 52 | } 53 | void Set_longest_trial_len(int l) 54 | { 55 | std::lock_guard lck(_mutex); 56 | longest_trial_length=l; 57 | } 58 | void Add_time_node_expansion(double value) 59 | { 60 | std::lock_guard lck(_mutex); 61 | time_node_expansion+=value; 62 | } 63 | void Inc_num_expanded_nodes() 64 | { 65 | std::lock_guard lck(_mutex); 66 | num_expanded_nodes++; 67 | } 68 | 69 | void Add_num_tree_particles(int num) 70 | { 71 | std::lock_guard lck(_mutex); 72 | num_tree_particles+=num; 73 | } 74 | void Add_time_path(float value) 75 | { 76 | std::lock_guard lck(_mutex); 77 | time_path+=value; 78 | } 79 | 80 | void Add_time_backup(float value) 81 | { 82 | std::lock_guard lck(_mutex); 83 | time_backup+=value; 84 | } 85 | }; 86 | 87 | } 88 | #endif /* SHARED_SOLVER_H_ */ 89 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUinterface/GPUdefault_policy.h: -------------------------------------------------------------------------------- 1 | #ifndef GPUPOLICY_H 2 | #define GPUPOLICY_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | namespace despot { 23 | 24 | class Dvc_State; 25 | class Dvc_DSPOMDP; 26 | 27 | 28 | 29 | /* ============================================================================= 30 | * Dvc_DefaultPolicy class 31 | * =============================================================================*/ 32 | 33 | class Dvc_DefaultPolicy: public Dvc_ScenarioLowerBound{ 34 | 35 | public: 36 | 37 | DEVICE static Dvc_ValuedAction Value( 38 | Dvc_State* particles, 39 | Dvc_RandomStreams& streams, 40 | Dvc_History& history, 41 | int dummy_startnode); 42 | 43 | /** 44 | * Returns default action to perform roll-out. 45 | * 46 | * The function in your custom policy class should be: 47 | * DEVICE static Dvc_ValuedAction Value(Dvc_State* particles, 48 | * Dvc_RandomStreams& streams, Dvc_History& history); 49 | */ 50 | 51 | }; 52 | 53 | DEVICE extern ACT_TYPE (*DvcDefaultPolicyAction_)(int,const Dvc_State* ,Dvc_RandomStreams&, Dvc_History&); 54 | 55 | } // namespace despot 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUinterface/GPUfunction_interfaces.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | using namespace std; 7 | 8 | namespace despot { 9 | 10 | /* ============================================================================= 11 | * GPU function interfaces to be called in HyP-DESPOT 12 | * =============================================================================*/ 13 | /** 14 | * [Optional] 15 | * Global interfaces for functions in the problem model class and bound classes 16 | * to be called by the HyP-DESPOT solver. 17 | * This is a hacking trick for achieving class poly-morphism in GPU codes which is not naived supported in CUDA. 18 | */ 19 | 20 | 21 | 22 | } // namespace despot 23 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUinterface/GPUpolicy_graph.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPUpolicy_graph.h 3 | * 4 | * Created on: 9 Sep, 2018 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef GPUPOLICY_GRAPH_H_ 9 | #define GPUPOLICY_GRAPH_H_ 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | namespace despot { 30 | 31 | class Dvc_State; 32 | class Dvc_StateIndexer; 33 | class Dvc_StatePolicy; 34 | class Dvc_DSPOMDP; 35 | class Dvc_MMAPInferencer; 36 | 37 | 38 | /* ============================================================================= 39 | * Dvc_PolicyGraph class 40 | * =============================================================================*/ 41 | 42 | class Dvc_PolicyGraph/*: public Dvc_ScenarioLowerBound */{ 43 | public: 44 | 45 | DEVICE static Dvc_ValuedAction Value( 46 | Dvc_State* particles, 47 | Dvc_RandomStreams& streams, 48 | Dvc_History& history, int start_node); 49 | 50 | DEVICE static int Edge(int action, OBS_TYPE obs); 51 | 52 | }; 53 | 54 | /*These values need to be passed from the CPU side*/ 55 | DEVICE extern int graph_size_; 56 | DEVICE extern int num_edges_per_node_; 57 | DEVICE extern int* action_nodes_; 58 | DEVICE extern int* obs_edges_;/*A flattened pointer*/ 59 | 60 | 61 | DEVICE extern int (*DvcChooseEdge_)( int, OBS_TYPE); 62 | 63 | } // namespace despot 64 | 65 | 66 | #endif /* GPUPOLICY_GRAPH_H_ */ 67 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUinterface/GPUupper_bound.h: -------------------------------------------------------------------------------- 1 | #ifndef GPUUPPER_BOUND_H 2 | #define GPUUPPER_BOUND_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | namespace despot { 13 | 14 | class Dvc_State; 15 | //class Dvc_History; 16 | 17 | class Dvc_DSPOMDP; 18 | struct Dvc_ValuedAction; 19 | 20 | /* ============================================================================= 21 | * Dvc_ScenarioUpperBound class 22 | * =============================================================================*/ 23 | /** 24 | * [Optional] 25 | * Interface for an algorithm computing a upper bound for the optimal total 26 | * discounted reward on a set of weighted scenarios. 27 | * The horizon is infinite. 28 | */ 29 | 30 | class Dvc_ScenarioUpperBound { 31 | public: 32 | 33 | /* 34 | * Returns an upper bound to the maximum total discounted reward over an 35 | * infinite horizon for the (unweighted) particle. 36 | * 37 | * The function in your custom upper bound class should be: 38 | * DEVICE static float Value(const Dvc_State* state, int scenarioID, 39 | * Dvc_History& history); 40 | */ 41 | 42 | }; 43 | 44 | DEVICE extern float (*DvcUpperBoundValue_)(const Dvc_State*, int, Dvc_History&); 45 | 46 | /* ============================================================================= 47 | * Dvc_ParticleUpperBound class 48 | * =============================================================================*/ 49 | /** 50 | * [Optional] 51 | * Interface for an algorithm computing a upper bound for optimal total 52 | * discounted reward on a set of weighted scenarios with 53 | * only the particles given. The horizon is inifnite. 54 | */ 55 | 56 | class Dvc_ParticleUpperBound : public Dvc_ScenarioUpperBound { 57 | public: 58 | 59 | }; 60 | 61 | 62 | } // namespace despot 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUrandom_streams.h: -------------------------------------------------------------------------------- 1 | #ifndef GPURANDOM_STREAMS_H 2 | #define GPURANDOM_STREAMS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace despot { 14 | 15 | /** 16 | * A Dvc_RandomStreams object represents multiple random number sequences, where each 17 | * entry is independently and identically drawn from [0, 1]. 18 | */ 19 | class Dvc_RandomStreams { 20 | public: 21 | int num_streams_; int length_; 22 | double** streams_; // streams_[i] is associated with i-th particle 23 | mutable int position_; 24 | 25 | bool externel_streams; 26 | public: 27 | /** 28 | * Constructs multiple random sequences of the same length. 29 | * 30 | * @param num_streams number of sequences 31 | * @param length sequence length 32 | */ 33 | DEVICE Dvc_RandomStreams(int num_streams, int length, double** stream); 34 | DEVICE Dvc_RandomStreams(int num_streams, int length, double** stream, int pos); 35 | DEVICE Dvc_RandomStreams() 36 | { 37 | num_streams_=0; length_=0; 38 | streams_=0; // streams_[i] is associated with i-th particle 39 | position_=0; 40 | externel_streams=false; 41 | } 42 | 43 | DEVICE ~Dvc_RandomStreams(); 44 | 45 | /** 46 | * Returns the number of sequences. 47 | */ 48 | DEVICE int NumStreams() const; 49 | 50 | /** 51 | * Returns the length of the sequences. 52 | */ 53 | DEVICE int Length() const; 54 | 55 | DEVICE void Advance() const; 56 | DEVICE void Back() const; 57 | 58 | DEVICE void position(int value) const; 59 | DEVICE int position() const; 60 | 61 | DEVICE bool Exhausted() const; 62 | 63 | DEVICE double Entry(int stream) const; 64 | DEVICE double Entry(int stream, int position) const; 65 | 66 | //DEVICE friend std::ostream& operator<<(std::ostream& os, const Dvc_RandomStreams& stream); 67 | 68 | HOST void assign(RandomStreams* host_stream); 69 | HOST void Alloc(int num_streams, int length); 70 | HOST static void CopyToGPU(Dvc_RandomStreams* Dvc, const RandomStreams* Hst, void* cudaStream=NULL); 71 | HOST static void ShareStreamsAmongThreads(Dvc_RandomStreams** streams); 72 | HOST static void Init(Dvc_RandomStreams* Dvc, int num_streams,int length, bool do_step2=false); 73 | HOST static void Clear(Dvc_RandomStreams* Dvc); 74 | }; 75 | 76 | } // namespace despot 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUDataParallel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPUDataParallel.h 3 | * 4 | * Created on: 28 Mar, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef GPUDATAPARALLEL_H_ 9 | #define GPUDATAPARALLEL_H_ 10 | /*! \file DataParallel.h 11 | \author Gregory Diamos 12 | \date Thursday September 22, 2011 13 | \brief The header file for the DataParallel primitive functions. 14 | */ 15 | 16 | #pragma once 17 | 18 | namespace util 19 | { 20 | 21 | class DataParallelConfig 22 | { 23 | public: 24 | unsigned int threads; 25 | unsigned int ctas; 26 | 27 | unsigned int sharedSize; 28 | }; 29 | 30 | template 31 | void transpose(Type* begin, Type* end, unsigned int stride, Type* out) 32 | { 33 | __shared__ Type buffer[config.sharedSize]; 34 | 35 | unsigned int size = end - begin; 36 | unsigned int rows = size / stride; 37 | 38 | unsigned int step = config.threads; 39 | unsigned int start = threadIdx.x; 40 | 41 | for(unsigned int i = start; i < size; i+=step) 42 | { 43 | offset = (i / stride) % stride; 44 | 45 | buffer[i + offset] = begin[i]; 46 | } 47 | 48 | __syncthreads(); 49 | 50 | for(unsigned int i = start; i < size; i+=step) 51 | { 52 | unsigned int row = i % stride; 53 | unsigned int column = i / stride; 54 | 55 | unsigned int index = (row * stride) + (row % stride) + column; 56 | 57 | out[i] = buffer[index]; 58 | } 59 | } 60 | 61 | } 62 | 63 | 64 | 65 | #endif /* GPUDATAPARALLEL_H_ */ 66 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUHostReflection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPUHostReflection.h 3 | * 4 | * Created on: 28 Mar, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef GPUHOSTREFLECTION_H_ 9 | #define GPUHOSTREFLECTION_H_ 10 | /* \file HostReflection.h 11 | \author Gregory Diamos 12 | \date Saturday July 16, 2011 13 | \brief The header file for the HostReflection set of functions. 14 | */ 15 | 16 | #pragma once 17 | 18 | // Standard Library Includes 19 | #include 20 | 21 | // Macro defines 22 | #define KERNEL_PAYLOAD_BYTES 32 23 | #define KERNEL_PAYLOAD_PARAMETERS 5 24 | 25 | namespace archaeopteryx 26 | { 27 | 28 | namespace util 29 | { 30 | 31 | class HostReflectionShared 32 | { 33 | public: 34 | typedef unsigned int HandlerId; 35 | 36 | static const size_t MaxMessageSize = 16384; 37 | 38 | enum MessageHandler 39 | { 40 | OpenFileMessageHandler = 0, 41 | OpenFileReplyHandler = 0, 42 | TeardownFileMessageHandler = 1, 43 | FileWriteMessageHandler = 2, 44 | FileReadMessageHandler = 3, 45 | FileReadReplyHandler = 3, 46 | KernelLaunchMessageHandler = 4, 47 | InvalidMessageHandler = -1 48 | }; 49 | 50 | enum MessageType 51 | { 52 | Synchronous, 53 | Asynchronous, 54 | Invalid, 55 | }; 56 | 57 | class Header 58 | { 59 | public: 60 | MessageType type; 61 | unsigned int threadId; 62 | unsigned int size; 63 | HandlerId handler; 64 | }; 65 | 66 | class SynchronousHeader : public Header 67 | { 68 | public: 69 | void* address; 70 | }; 71 | 72 | class PayloadData 73 | { 74 | public: 75 | char data[KERNEL_PAYLOAD_BYTES]; 76 | unsigned int indexes[KERNEL_PAYLOAD_PARAMETERS]; 77 | }; 78 | 79 | class Payload 80 | { 81 | public: 82 | PayloadData data; 83 | 84 | public: 85 | }; 86 | 87 | class QueueMetaData 88 | { 89 | public: 90 | char* hostBegin; 91 | char* deviceBegin; 92 | 93 | size_t size; 94 | size_t head; 95 | size_t tail; 96 | size_t mutex; 97 | }; 98 | 99 | }; 100 | 101 | } 102 | 103 | } 104 | 105 | 106 | #endif /* GPUHOSTREFLECTION_H_ */ 107 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUIntTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPUIntTypes.h 3 | * 4 | * Created on: 28 Mar, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef GPUINTTYPES_H_ 9 | #define GPUINTTYPES_H_ 10 | 11 | 12 | 13 | #pragma once 14 | 15 | #include 16 | 17 | 18 | #endif /* GPUINTTYPES_H_ */ 19 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUKnob.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPUKnob.h 3 | * 4 | * Created on: 28 Mar, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef GPUKNOB_H_ 9 | #define GPUKNOB_H_ 10 | /* \file Knob.h 11 | \author Gregory Diamos 12 | \date November 7, 2012 13 | \brief The header file for the Knob class 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | namespace archaeopteryx 22 | { 23 | 24 | namespace util 25 | { 26 | 27 | class Knob 28 | { 29 | public: 30 | __device__ Knob(const util::string& name, const util::string& value); 31 | 32 | public: 33 | __device__ const util::string& name() const; 34 | __device__ const util::string& value() const; 35 | 36 | private: 37 | util::string _name; 38 | util::string _value; 39 | 40 | }; 41 | 42 | class KnobDatabase 43 | { 44 | public: 45 | __device__ static void addKnob(Knob* base); 46 | __device__ static void removeKnob(const Knob& base); 47 | 48 | template 49 | __device__ static T getKnob(const util::string& name); 50 | 51 | __device__ static const Knob& getKnobBase(const util::string& name); 52 | 53 | public: 54 | __device__ static void create(); 55 | __device__ static void destroy(); 56 | 57 | }; 58 | 59 | template 60 | class TypeConverter 61 | { 62 | public: 63 | /*__device__ T operator()(const util::string& value) 64 | { 65 | T result; 66 | 67 | util::stringstream stream; 68 | 69 | stream << value; 70 | 71 | result >> value; 72 | return result; 73 | } 74 | */ 75 | }; 76 | 77 | template<> 78 | class TypeConverter 79 | { 80 | public: 81 | __device__ util::string operator()(const util::string& value) 82 | { 83 | return value; 84 | } 85 | 86 | }; 87 | 88 | template<> 89 | class TypeConverter 90 | { 91 | public: 92 | __device__ unsigned int operator()(const util::string& value) 93 | { 94 | return util::atoi(value.c_str()); 95 | } 96 | 97 | }; 98 | 99 | template<> 100 | class TypeConverter 101 | { 102 | public: 103 | __device__ size_t operator()(const util::string& value) 104 | { 105 | return util::atoi(value.c_str()); 106 | } 107 | 108 | }; 109 | 110 | template 111 | __device__ T KnobDatabase::getKnob(const util::string& name) 112 | { 113 | const Knob& knob = getKnobBase(name); 114 | 115 | TypeConverter converter; 116 | 117 | return converter(knob.value()); 118 | 119 | /* 120 | util::stringstream stream; 121 | 122 | stream << knob.value(); 123 | 124 | T result; 125 | 126 | stream >> result; 127 | 128 | return result; 129 | */ 130 | } 131 | 132 | } 133 | 134 | } 135 | 136 | 137 | 138 | #endif /* GPUKNOB_H_ */ 139 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUThreadId.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPUThreadId.h 3 | * 4 | * Created on: 28 Mar, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef GPUTHREADID_H_ 9 | #define GPUTHREADID_H_ 10 | 11 | #pragma once 12 | 13 | namespace archaeopteryx 14 | { 15 | 16 | namespace util 17 | { 18 | 19 | __device__ unsigned int threadId(); 20 | 21 | } 22 | 23 | } 24 | 25 | #endif /* GPUTHREADID_H_ */ 26 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUcstdlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPUcstdlib.h 3 | * 4 | * Created on: 28 Mar, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef GPUCSTDLIB_H_ 9 | #define GPUCSTDLIB_H_ 10 | 11 | #pragma once 12 | 13 | namespace archaeopteryx 14 | { 15 | 16 | namespace util 17 | { 18 | 19 | __device__ int atoi(const char*); 20 | 21 | } 22 | 23 | } 24 | 25 | 26 | 27 | #endif /* GPUCSTDLIB_H_ */ 28 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUcstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPUcstring.h 3 | * 4 | * Created on: 28 Mar, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef GPUCSTRING_H_ 9 | #define GPUCSTRING_H_ 10 | /*! \file cstring.h 11 | \date Tuesday June 28, 2011 12 | \author Gregory Diamos 13 | \brief The header file for device string functions. 14 | */ 15 | #include 16 | 17 | #pragma once 18 | 19 | namespace archaeopteryx 20 | { 21 | 22 | namespace util 23 | { 24 | 25 | /*! \brief Safe string copy 26 | 27 | \param destination The target string 28 | \param source The source string 29 | \param max The max number of characters to copy 30 | */ 31 | DEVICE void strlcpy(char* destination, const char* source, size_t max); 32 | 33 | /*! \brief string compare 34 | 35 | \param left The target string 36 | \param right The source string 37 | 38 | \return 0 if all bytes match, some random int otherwise 39 | */ 40 | DEVICE int strcmp(const char* left, const char* right); 41 | 42 | DEVICE int memcmp(const void* s1, const void* s2, size_t n); 43 | DEVICE size_t strlen(const char* s); 44 | DEVICE const void* memchr(const void* s, int c, size_t n); 45 | DEVICE void* memchr( void* s, int c, size_t n); 46 | DEVICE void* memmove(void* s1, const void* s2, size_t n); 47 | 48 | DEVICE void* memcpy(void* s1, const void* s2, size_t n); 49 | DEVICE void* memset(void* s, int c, size_t n); 50 | 51 | } 52 | 53 | } 54 | 55 | 56 | #endif /* GPUCSTRING_H_ */ 57 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUdebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPUdebug.h 3 | * 4 | * Created on: 28 Mar, 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef GPUDEBUG_H_ 9 | #define GPUDEBUG_H_ 10 | /*! \file debug.h 11 | \date Sunday July 24, 2011 12 | \author Gregory Diamos 13 | \brief The header file for archaeopteryx debug functions. 14 | */ 15 | 16 | #pragma once 17 | 18 | // Standard Library Includes 19 | #include 20 | #include 21 | 22 | #ifdef REPORT_BASE 23 | #undef REPORT_BASE 24 | #endif 25 | 26 | #define REPORT_BASE 0 27 | 28 | // Preprocessor macros 29 | #ifdef device_assert 30 | #undef device_assert 31 | #endif 32 | 33 | #define device_assert(x) util::_assert(x, #x, __FILE__, __LINE__) 34 | #define device_assert_m(x, y) device_report(y "\n"); device_assert(x) 35 | 36 | #ifndef NDEBUG 37 | #define report(y) \ 38 | if(REPORT_BASE > 0)\ 39 | { \ 40 | {\ 41 | std::cout << __FILE__ << ":" << __LINE__ \ 42 | << ": " << y << "\n";\ 43 | }\ 44 | \ 45 | } 46 | #else 47 | #define report(y) 48 | #endif 49 | 50 | #ifdef device_report 51 | #undef device_report 52 | #endif 53 | 54 | #define device_report(...) \ 55 | if(REPORT_BASE > 0)\ 56 | { \ 57 | printf(__VA_ARGS__);\ 58 | } 59 | 60 | #ifdef cta_report 61 | #undef cta_report 62 | #endif 63 | 64 | #define cta_report(...) \ 65 | if(threadIdx.x == 0)\ 66 | { \ 67 | device_report(__VA_ARGS__);\ 68 | } 69 | 70 | #ifdef kernel_report 71 | #undef kernel_report 72 | #endif 73 | 74 | #define kernel_report(...) \ 75 | if(blockIdx.x == 0)\ 76 | { \ 77 | cta_report(__VA_ARGS__);\ 78 | } 79 | 80 | namespace archaeopteryx 81 | { 82 | 83 | namespace util 84 | { 85 | 86 | __device__ void _assert(bool condition, const char* expression, 87 | const char* filename, int line); 88 | 89 | } 90 | 91 | } 92 | 93 | 94 | #endif /* GPUDEBUG_H_ */ 95 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUrandom.h: -------------------------------------------------------------------------------- 1 | #ifndef GPURANDOM_H 2 | #define GPURANDOM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace despot { 11 | 12 | 13 | /* ============================================================================= 14 | * Dvc_Random class 15 | * ============================================================================= 16 | * Generate independent random numbers in parallel GPU threads 17 | */ 18 | 19 | 20 | class Dvc_Random { 21 | public: 22 | 23 | static void init(int num_particles); 24 | static void clear(); 25 | 26 | DEVICE int NextInt(int n, int i); 27 | DEVICE int NextInt(int min, int max, int i); 28 | 29 | DEVICE double NextDouble(int i); 30 | DEVICE double NextDouble(double min, double max, int i); 31 | 32 | DEVICE double NextGaussian(double mean, double delta, int i); 33 | 34 | DEVICE int NextCategory(int num_catogories, const double* category_probs, int i); 35 | 36 | DEVICE static int GetCategory(int num_catogories, const double* category_probs, 37 | double rand_num); 38 | }; 39 | extern DEVICE Dvc_Random* Dvc_random; 40 | 41 | 42 | class Dvc_QuickRandom { 43 | public: 44 | 45 | static void InitRandGen(); 46 | static void DestroyRandGen(); 47 | 48 | static void DebugRandom(std::ostream& fout, char* msg); 49 | 50 | DEVICE static float RandGeneration(unsigned long long int *recorded_seed, float seed); 51 | 52 | DEVICE static float RandGeneration(unsigned long long int *recorded_seed, float seed, int num_pass); 53 | 54 | static unsigned long long int* seeds_; 55 | 56 | }; 57 | 58 | 59 | 60 | } // namespace despot 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUseeds.h: -------------------------------------------------------------------------------- 1 | #ifndef GPUSEEDS_H 2 | #define GPUSEEDS_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | namespace despot { 9 | 10 | 11 | } // namespace despot 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/GPUutil/GPUutil.h: -------------------------------------------------------------------------------- 1 | #ifndef GPUUTIL_H 2 | #define GPUUTIL_H 3 | 4 | #include 5 | 6 | namespace despot { 7 | 8 | 9 | DEVICE inline bool Dvc_CheckFlag(int flags, int bit) { 10 | return (flags & (1 << bit)) != 0; 11 | } 12 | DEVICE inline void Dvc_SetFlag(int& flags, int bit) { 13 | flags = (flags | (1 << bit)); 14 | } 15 | DEVICE inline void Dvc_UnsetFlag(int& flags, int bit) { 16 | flags = flags & ~(1 << bit); 17 | } 18 | 19 | 20 | 21 | } // namespace despot 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/core/builtin_lower_bounds.h: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_LOWER_BOUND_H 2 | #define BUILTIN_LOWER_BOUND_H 3 | 4 | #include 5 | 6 | namespace despot { 7 | 8 | /* ============================================================================= 9 | * POMCPScenarioLowerBound class 10 | * =============================================================================*/ 11 | 12 | class POMCPPrior; 13 | class POMCPScenarioLowerBound: public ScenarioLowerBound { 14 | private: 15 | double explore_constant_; 16 | POMCPPrior* prior_; 17 | 18 | protected: 19 | double Simulate(State* particle, RandomStreams& streams, VNode* vnode, 20 | History& history) const; 21 | double Rollout(State* particle, RandomStreams& streams, int depth, 22 | History& history) const; 23 | VNode* CreateVNode(const History& history, int depth) const; 24 | 25 | public: 26 | POMCPScenarioLowerBound(const DSPOMDP* model, POMCPPrior* prior, 27 | Belief* belief = NULL); 28 | 29 | ValuedAction Value(const std::vector& particles, RandomStreams& streams, 30 | History& history) const; 31 | }; 32 | 33 | /* ============================================================================= 34 | * TrivialParticleLowerBound class 35 | * =============================================================================*/ 36 | 37 | class TrivialParticleLowerBound: public ParticleLowerBound { 38 | public: 39 | TrivialParticleLowerBound(const DSPOMDP* model); 40 | 41 | public: 42 | virtual ValuedAction Value(const std::vector& particles) const; 43 | }; 44 | 45 | /* ============================================================================= 46 | * TrivialBeliefLowerBound class 47 | * =============================================================================*/ 48 | 49 | class TrivialBeliefLowerBound: public BeliefLowerBound { 50 | public: 51 | TrivialBeliefLowerBound(const DSPOMDP* model); 52 | 53 | virtual ValuedAction Value(const Belief* belief) const; 54 | }; 55 | 56 | } // namespace despot 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/core/builtin_policygraph.h: -------------------------------------------------------------------------------- 1 | /* 2 | * builtin_policygraph.h 3 | * 4 | * Created on: 9 Sep, 2018 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef BUILTIN_POLICYGRAPH_H_ 9 | #define BUILTIN_POLICYGRAPH_H_ 10 | 11 | #include 12 | 13 | namespace despot { 14 | 15 | /* ============================================================================= 16 | * RandomPolicyGraph class 17 | * =============================================================================*/ 18 | 19 | class RandomPolicyGraph: public PolicyGraph { 20 | private: 21 | std::vector action_probs_; 22 | 23 | public: 24 | RandomPolicyGraph(const DSPOMDP* model, ParticleLowerBound* ParticleLowerBound, 25 | Belief* belief = NULL); 26 | virtual ~RandomPolicyGraph(); 27 | virtual void ConstructGraph(int size, int branch); 28 | }; 29 | 30 | }// namespace despot 31 | 32 | 33 | 34 | 35 | #endif /* BUILTIN_POLICYGRAPH_H_ */ 36 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/core/builtin_upper_bounds.h: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_UPPER_BOUND_H 2 | #define BUILTIN_UPPER_BOUND_H 3 | 4 | #include 5 | 6 | namespace despot { 7 | 8 | /* ============================================================================= 9 | * TrivialParticleUpperBound class 10 | * =============================================================================*/ 11 | 12 | class TrivialParticleUpperBound: public ParticleUpperBound { 13 | protected: 14 | const DSPOMDP* model_; 15 | public: 16 | TrivialParticleUpperBound(const DSPOMDP* model); 17 | virtual ~TrivialParticleUpperBound(); 18 | 19 | double Value(const State& state) const; 20 | 21 | virtual double Value(const std::vector& particles, 22 | RandomStreams& streams, History& history) const; 23 | }; 24 | 25 | /* ============================================================================= 26 | * LookaheadUpperBound class 27 | * =============================================================================*/ 28 | 29 | class LookaheadUpperBound: public ScenarioUpperBound { 30 | protected: 31 | const DSPOMDP* model_; 32 | const StateIndexer& indexer_; 33 | std::vector > > bounds_; 34 | ParticleUpperBound* particle_upper_bound_; 35 | 36 | public: 37 | LookaheadUpperBound(const DSPOMDP* model, const StateIndexer& indexer, 38 | ParticleUpperBound* bound); 39 | 40 | virtual void Init(const RandomStreams& streams); 41 | 42 | double Value(const std::vector& particles, 43 | RandomStreams& streams, History& history) const; 44 | }; 45 | 46 | /* ============================================================================= 47 | * TrivialBeliefUpperBound class 48 | * =============================================================================*/ 49 | 50 | class TrivialBeliefUpperBound: public BeliefUpperBound { 51 | protected: 52 | const DSPOMDP* model_; 53 | public: 54 | TrivialBeliefUpperBound(const DSPOMDP* model); 55 | 56 | double Value(const Belief* belief) const; 57 | }; 58 | 59 | /* ============================================================================= 60 | * MDPUpperBound class 61 | * =============================================================================*/ 62 | 63 | class MDPUpperBound: public ParticleUpperBound, public BeliefUpperBound { 64 | protected: 65 | const MDP* model_; 66 | const StateIndexer& indexer_; 67 | std::vector policy_; 68 | 69 | public: 70 | MDPUpperBound(const MDP* model, const StateIndexer& indexer); 71 | 72 | // shut off "hides overloaded virtual function" warning 73 | using ParticleUpperBound::Value; 74 | double Value(const State& state) const; 75 | 76 | double Value(const Belief* belief) const; 77 | }; 78 | 79 | } // namespace despot 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/core/globals.h: -------------------------------------------------------------------------------- 1 | #ifndef GLOBALS_H 2 | #define GLOBALS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | namespace despot { 28 | 29 | typedef uint64_t OBS_TYPE; 30 | //typedef State* OBS_TYPE; 31 | typedef int ACT_TYPE; 32 | 33 | namespace Globals { 34 | extern const double NEG_INFTY; 35 | extern const double POS_INFTY; 36 | extern const double INF; 37 | extern const double TINY; 38 | 39 | extern Config config; 40 | extern ExecTracker tracker; 41 | 42 | inline bool Fequals(double a, double b) { 43 | return std::fabs(a - b) < TINY; 44 | } 45 | 46 | inline double Discount() { 47 | return config.discount; 48 | } 49 | 50 | inline double Discount(int d) { 51 | return std::pow(config.discount, d); 52 | } 53 | 54 | inline void Track(std::string addr, std::string loc) { 55 | tracker.Track(addr, loc); 56 | } 57 | 58 | inline void Untrack(std::string addr) { 59 | tracker.Untrack(addr); 60 | } 61 | 62 | inline void PrintLocs() { 63 | tracker.PrintLocs(); 64 | } 65 | } // namespace 66 | 67 | /*================ For Hyp-despot ===============*/ 68 | enum MEMORY_MODE { INIT, ALLOC_ROOT, ALLOC, RESET, DESTROY}; 69 | 70 | enum DRIVING_MODE {NO, JOINT_POMDP, ROLL_OUT}; 71 | 72 | enum OBS_PARAM 73 | { 74 | OBS_LONG64, 75 | OBS_INT_ARRAY, 76 | }; 77 | extern OBS_PARAM Obs_type; 78 | 79 | } // namespace despot 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/core/mdp.h: -------------------------------------------------------------------------------- 1 | #ifndef MDP_H 2 | #define MDP_H 3 | 4 | #include 5 | 6 | namespace despot { 7 | class ParticleBelief; 8 | 9 | /** 10 | * Interface for a discrete MDP. This class implements the following functions: 11 | *
    12 | *
  1. value iteration, 13 | *
  2. computation of alpha vectors and POMDP value for fixed-action policies. 14 | *
15 | */ 16 | class MDP { 17 | protected: 18 | std::vector policy_; 19 | 20 | std::vector > blind_alpha_; // For blind policy 21 | 22 | public: 23 | virtual ~MDP(); 24 | 25 | virtual int NumStates() const = 0; 26 | virtual int NumActions() const = 0; 27 | virtual const std::vector& TransitionProbability(int s, ACT_TYPE a) const = 0; 28 | virtual double Reward(int s, ACT_TYPE a) const = 0; 29 | 30 | virtual void ComputeOptimalPolicyUsingVI(); 31 | const std::vector& policy() const; 32 | 33 | virtual void ComputeBlindAlpha(); 34 | double ComputeActionValue(const ParticleBelief* belief, 35 | const StateIndexer& indexer, ACT_TYPE action) const; 36 | const std::vector >& blind_alpha() const; 37 | }; 38 | 39 | } // namespace despot 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/core/pomdp_world.h: -------------------------------------------------------------------------------- 1 | /* 2 | * POMDPWorld.h 3 | * 4 | * Created on: 20 Sep 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef POMDP_WORLD_H_ 9 | #define POMDP_WORLD_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace despot { 17 | 18 | class POMDPWorld: public World { 19 | protected: 20 | //POMDP model shared with despot solver 21 | DSPOMDP* model_; 22 | //Random number generator. 23 | Random random_; 24 | public: 25 | double step_reward_; 26 | 27 | public: 28 | POMDPWorld(DSPOMDP* model, unsigned seed); 29 | virtual ~POMDPWorld(); 30 | virtual inline void world_seed(unsigned seed) { 31 | random_ = Random(seed); 32 | } 33 | 34 | public: 35 | //establish connection to simulator or system 36 | bool Connect(); 37 | //Initialize or reset the simulation environment 38 | State* Initialize(); 39 | //To help construct initial belief to print debug informations in Logger 40 | State* GetCurrentState(); 41 | //send action, receive reward, obs, and terminal 42 | bool ExecuteAction(ACT_TYPE action, OBS_TYPE& obs); 43 | }; 44 | 45 | } /* namespace despot */ 46 | 47 | #endif /* POMDP_WORLD_H_ */ 48 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/core/solver.h: -------------------------------------------------------------------------------- 1 | #ifndef SOLVER_H 2 | #define SOLVER_H 3 | 4 | #include 5 | #include 6 | 7 | namespace despot { 8 | 9 | class DSPOMDP; 10 | class Belief; 11 | struct ValuedAction; 12 | 13 | /* ============================================================================= 14 | * SearchStatistics class 15 | * =============================================================================*/ 16 | 17 | struct SearchStatistics { 18 | double initial_lb, initial_ub, final_lb, final_ub; 19 | double time_search; 20 | double time_path; 21 | double time_backup; 22 | double time_node_expansion; 23 | int num_policy_nodes; 24 | int num_tree_nodes; 25 | int num_expanded_nodes; 26 | int num_tree_particles; 27 | int num_particles_before_search; 28 | int num_particles_after_search; 29 | int num_trials; 30 | int longest_trial_length; 31 | 32 | SearchStatistics(); 33 | 34 | friend std::ostream& operator<<(std::ostream& os, const SearchStatistics& statitics); 35 | }; 36 | 37 | /* ============================================================================= 38 | * Solver class 39 | * =============================================================================*/ 40 | 41 | class Solver { 42 | protected: 43 | const DSPOMDP* model_; 44 | Belief* belief_; 45 | History history_; 46 | 47 | public: 48 | Solver(const DSPOMDP* model, Belief* belief); 49 | virtual ~Solver(); 50 | 51 | /** 52 | * Find the optimal action for current belief, and optionally return the 53 | * found value for the action. Return the value Globals::NEG_INFTY if the 54 | * value is not to be used. 55 | */ 56 | virtual ValuedAction Search() = 0; 57 | 58 | /** 59 | * Update current belief, history, and any other internal states that is 60 | * needed for Search() to function correctly. 61 | */ 62 | virtual void BeliefUpdate(ACT_TYPE action, OBS_TYPE obs); 63 | 64 | /** 65 | * Set initial belief for planning. Make sure internal states associated with 66 | * initial belief are reset. In particular, history need to be cleaned, and 67 | * allocated memory from previous searches need to be cleaned if not. 68 | */ 69 | virtual void belief(Belief* b); 70 | Belief* belief(); 71 | }; 72 | 73 | } // namespace despot 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/interface/belief.h: -------------------------------------------------------------------------------- 1 | #ifndef BELIEF_H 2 | #define BELIEF_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace despot { 11 | 12 | class State; 13 | class StateIndexer; 14 | class DSPOMDP; 15 | 16 | /* ============================================================================= 17 | * Belief class 18 | * =============================================================================*/ 19 | /** 20 | * [Optional] 21 | * Design your custom belief by inheriting this class 22 | */ 23 | class Belief { 24 | public: 25 | const DSPOMDP* model_; 26 | History history_; 27 | 28 | public: 29 | Belief(const DSPOMDP* model); 30 | virtual ~Belief(); 31 | 32 | /** 33 | * Sample states from a belief. 34 | * Returns a set of sampled states. 35 | * 36 | * @param num Number of states to be sampled 37 | */ 38 | virtual std::vector Sample(int num) const = 0; 39 | 40 | /** 41 | * Update the belief. 42 | * 43 | * @param action The action taken in the last step 44 | * @param obs The observation received in the last step 45 | */ 46 | virtual void Update(ACT_TYPE action, OBS_TYPE obs) = 0; 47 | 48 | virtual std::string text() const; 49 | friend std::ostream& operator<<(std::ostream& os, const Belief& belief); 50 | 51 | /** 52 | * Returns a copy of this belief. 53 | */ 54 | virtual Belief* MakeCopy() const = 0; 55 | 56 | }; 57 | 58 | } // namespace despot 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/interface/default_policy.h: -------------------------------------------------------------------------------- 1 | #ifndef POLICY_H 2 | #define POLICY_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace despot { 19 | 20 | class State; 21 | class StateIndexer; 22 | class StatePolicy; 23 | class DSPOMDP; 24 | class MMAPInferencer; 25 | 26 | /* ============================================================================= 27 | * ValuedAction struct 28 | * =============================================================================*/ 29 | 30 | struct ValuedAction { 31 | ACT_TYPE action; 32 | double value; 33 | 34 | ValuedAction(); 35 | ValuedAction(ACT_TYPE _action, double _value); 36 | 37 | friend std::ostream& operator<<(std::ostream& os, const ValuedAction& va); 38 | }; 39 | 40 | /* ============================================================================= 41 | * DefaultPolicy class 42 | * =============================================================================*/ 43 | /** 44 | * [Optional] 45 | * Design your custom default policy by inheriting this class 46 | */ 47 | class DefaultPolicy: public ScenarioLowerBound { 48 | private: 49 | mutable int initial_depth_; 50 | ParticleLowerBound* particle_lower_bound_; 51 | 52 | ValuedAction RecursiveValue(const std::vector& particles, 53 | RandomStreams& streams, History& history) const; 54 | 55 | public: 56 | DefaultPolicy(const DSPOMDP* model, ParticleLowerBound* particle_lower_bound); 57 | virtual ~DefaultPolicy(); 58 | 59 | void Reset(); 60 | 61 | /** 62 | * Returns an action based on the weighted scenarios and the history 63 | * 64 | * @param particles States in the head of the scenarios 65 | * @param streams Random streams attached to the scenarios 66 | * @param history The current action-observation history 67 | */ 68 | virtual ACT_TYPE Action(const std::vector& particles, RandomStreams& streams, 69 | History& history) const = 0; 70 | 71 | ParticleLowerBound* particle_lower_bound() const; 72 | 73 | ValuedAction Value(const std::vector& particles, RandomStreams& streams, 74 | History& history) const; 75 | }; 76 | 77 | } // namespace despot 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/interface/policy_graph.h: -------------------------------------------------------------------------------- 1 | /* 2 | * policy_graph.h 3 | * 4 | * Created on: 9 Sep, 2018 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef POLICY_GRAPH_H_ 9 | #define POLICY_GRAPH_H_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace despot { 25 | 26 | /* ============================================================================= 27 | * PolicyGraph class 28 | * =============================================================================*/ 29 | 30 | 31 | class PolicyGraph: public ScenarioLowerBound { 32 | protected: 33 | 34 | mutable int initial_depth_; 35 | ParticleLowerBound* particle_lower_bound_; 36 | 37 | 38 | public: 39 | mutable int graph_size_; 40 | mutable int num_edges_per_node_; 41 | std::vector action_nodes_; 42 | mutable std::map > obs_edges_; 43 | 44 | mutable int current_node_; 45 | mutable int entry_node_; 46 | 47 | public: 48 | PolicyGraph(const DSPOMDP* model, ParticleLowerBound* particle_lower_bound, 49 | Belief* belief = NULL); 50 | virtual ~PolicyGraph(); 51 | 52 | void Reset(); 53 | 54 | ParticleLowerBound* particle_lower_bound() const; 55 | 56 | virtual void ConstructGraph(int size, int branch)=0; 57 | void ClearGraph(); 58 | 59 | void SetEntry(int node) 60 | {entry_node_=node;} 61 | 62 | virtual ValuedAction Value(const std::vector& particles, RandomStreams& streams, 63 | History& history) const; 64 | 65 | virtual void ExportGraph(std::ostream& fout); 66 | virtual void ImportGraph(std::ifstream& fin, int size, int branch); 67 | 68 | public: 69 | static bool Load_Graph; 70 | }; 71 | 72 | }// namespace despot 73 | 74 | 75 | 76 | #endif /* POLICY_GRAPH_H_ */ 77 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/interface/world.h: -------------------------------------------------------------------------------- 1 | /* 2 | * World.h 3 | * 4 | * Created on: 20 Sep 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef DESPOT_WORLD_H_ 9 | #define DESPOT_WORLD_H_ 10 | #include 11 | #include 12 | 13 | namespace despot { 14 | 15 | /* ============================================================================= 16 | * World class 17 | * =============================================================================*/ 18 | /** 19 | * [Essential] 20 | * Interface for communication with the real world. 21 | */ 22 | class World { 23 | protected: 24 | // True state of the (simulated) world 25 | State* state_; 26 | 27 | public: 28 | World(); 29 | virtual ~World(); 30 | 31 | public: 32 | /** 33 | * [Essential] 34 | * Establish connection to simulator or system 35 | */ 36 | virtual bool Connect()=0; 37 | 38 | /** 39 | * [Essential] 40 | * Initialize or reset the (simulation) environment, return the start state if applicable 41 | */ 42 | virtual State* Initialize()=0; 43 | 44 | /** 45 | * [Optional] 46 | * To help construct initial belief to print debug informations in Logger 47 | */ 48 | virtual State* GetCurrentState(); 49 | 50 | /** 51 | * [Essential] 52 | * send action, receive reward, obs, and terminal 53 | * @param action Action to be executed in the real-world system 54 | * @param obs Observation sent back from the real-world system 55 | */ 56 | virtual bool ExecuteAction(ACT_TYPE action, OBS_TYPE& obs) =0; 57 | }; 58 | 59 | } /* namespace despot */ 60 | 61 | #endif /* DESPOT_WORLD_H_ */ 62 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/ippc/client.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENT_H_ 2 | #define CLIENT_H_ 3 | 4 | #include // Needed for memset 5 | #include 6 | #include // Needed for the socket functions 7 | #include 8 | #include // Needed for the socket functions 9 | #include 10 | #include 11 | #include 12 | 13 | namespace despot { 14 | 15 | class Client { 16 | public: 17 | Client(void); 18 | ~Client(void); 19 | 20 | private: 21 | int socketfd; 22 | std::string HOSTNAME; 23 | std::string PORT; 24 | struct addrinfo host_info; // The struct that getaddrinfo() fills up with data.^M 25 | struct addrinfo *host_info_list; 26 | 27 | public: 28 | void setHostName(std::string hostname); 29 | void setPort(std::string port); 30 | 31 | void initializeSocket(); 32 | 33 | void connectToServer(); 34 | 35 | void closeConnection(); 36 | 37 | void sendMessage(std::string sendbuf); 38 | 39 | std::string recvMessage(); 40 | 41 | std::string recvMessageTwice(); 42 | 43 | std::string createSessionRequestMes(std::string problemName); 44 | 45 | int processSessionInitMes(std::string mes); 46 | 47 | std::string createRoundRequestMes(); 48 | 49 | void processRoundInitMes(std::string mes); 50 | 51 | std::map processTurnMes(std::string mes); 52 | 53 | //get step reward from turn message: added by wkg 54 | double getStepReward(std::string mes); 55 | 56 | std::string createActionMes(const std::string actionName, std::string actionValue); 57 | 58 | double processRoundEndMes(std::string mes); 59 | 60 | double processSessionEndMes(std::string mes); 61 | }; 62 | 63 | } // namespace despot 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/planner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Planner.h 3 | * 4 | * Created on: 5 Oct 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef INCLUDE_DESPOT_PLANNER_H_ 9 | #define INCLUDE_DESPOT_PLANNER_H_ 10 | 11 | #include 12 | 13 | namespace despot { 14 | 15 | class Planner: public PlannerBase { 16 | protected: 17 | int step_; 18 | int round_; 19 | public: 20 | Planner(string lower_bounds_str = "TRIVIAL", 21 | string base_lower_bounds_str = "TRIVIAL", string upper_bounds_str = 22 | "TRIVIAL", string base_upper_bounds_str = "TRIVIAL"); 23 | 24 | virtual ~Planner(); 25 | 26 | /** 27 | * Perform one search-execute-update step 28 | */ 29 | virtual bool RunStep(Solver* solver, World* world, Logger* logger); 30 | 31 | /** 32 | * Run POMDP planning till terminal reached or time out 33 | */ 34 | virtual int RunPlanning(int argc, char* argv[]); 35 | 36 | /** 37 | * Loop the search-execute-update process for a given number of steps 38 | * Overwrite this function to customize your planning pipeline 39 | */ 40 | virtual void PlanningLoop(Solver*& solver, World* world, Logger* logger); 41 | 42 | /** 43 | * Run and evaluate POMDP planning for a given number of rounds 44 | */ 45 | virtual int RunEvaluation(int argc, char* argv[]); 46 | 47 | /** 48 | * Evaluate the planner by repeating a test problem for multiple trials 49 | * Overwrite this function to customize your evaluation pipeline 50 | */ 51 | virtual void EvaluationLoop(DSPOMDP *model, World* world, Belief* belief, 52 | std::string belief_type, Solver *&solver, Logger *logger, 53 | option::Option *options, clock_t main_clock_start, int num_runs, 54 | int start_run); 55 | 56 | /* ======================================================================== 57 | * Functions for HyP-DESPOT 58 | * ========================================================================*/ 59 | void PrepareGPU(); 60 | void ClearGPU(); 61 | 62 | }; 63 | 64 | } /* namespace despot */ 65 | 66 | #endif /* INCLUDE_DESPOT_PLANNER_H_ */ 67 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/random_streams.h: -------------------------------------------------------------------------------- 1 | #ifndef RANDOM_STREAMS_H 2 | #define RANDOM_STREAMS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace despot { 10 | 11 | /** 12 | * A RandomStreams object represents multiple random number sequences, where each 13 | * entry is independently and identically drawn from [0, 1]. 14 | */ 15 | class RandomStreams { 16 | private: 17 | mutable int position_; 18 | 19 | public: 20 | std::vector > streams_; // streams_[i] is associated with i-th particle 21 | 22 | /** 23 | * Constructs multiple random sequences of the same length. 24 | * 25 | * @param num_streams number of sequences 26 | * @param length sequence length 27 | */ 28 | RandomStreams(int num_streams, int length); 29 | RandomStreams(){;} 30 | /** 31 | * Returns the number of sequences. 32 | */ 33 | int NumStreams() const; 34 | 35 | /** 36 | * Returns the length of the sequences. 37 | */ 38 | int Length() const; 39 | 40 | void Advance() const; 41 | void Back() const; 42 | 43 | void position(int value) const; 44 | int position() const; 45 | 46 | bool Exhausted() const; 47 | 48 | double Entry(int stream) const; 49 | double Entry(int stream, int position) const; 50 | 51 | friend std::ostream& operator<<(std::ostream& os, const RandomStreams& stream); 52 | void ImportStream(std::istream& in,int num_streams, int length); 53 | 54 | RandomStreams(const RandomStreams& src); 55 | }; 56 | 57 | } // namespace despot 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/solver/Hyp_despot.h: -------------------------------------------------------------------------------- 1 | #ifndef HYPDESPOT_H 2 | #define HYPDESPOT_H 3 | 4 | 5 | #include 6 | #include 7 | 8 | namespace despot { 9 | 10 | /** 11 | * HyP-DESPOT is a parallel extension of DESPOT using a hybrid parallelization model with bot CPUs and GPUs 12 | * The HyP-DESPOT solver is implemented by extending the DESPOT class 13 | */ 14 | 15 | } // namespace despot 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/solver/aems.h: -------------------------------------------------------------------------------- 1 | #ifndef AEMS_H 2 | #define AEMS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace despot { 11 | 12 | class AEMS: public Solver { 13 | private: 14 | VNode* root_; 15 | BeliefLowerBound* lower_bound_; 16 | BeliefUpperBound* upper_bound_; 17 | SearchStatistics statistics_; 18 | const BeliefMDP* model_; 19 | bool reuse_; 20 | 21 | public: 22 | AEMS(const DSPOMDP* model, BeliefLowerBound* lower_bound, 23 | BeliefUpperBound* upper_bound, Belief* belief = NULL); 24 | 25 | ValuedAction Search(); 26 | virtual void Update(int action, OBS_TYPE obs); 27 | virtual void belief(Belief* belief); 28 | 29 | private: 30 | static void InitLowerBound(VNode* vnode, BeliefLowerBound* lower_bound, 31 | History& history); 32 | static void InitUpperBound(VNode* vnode, BeliefUpperBound* upper_bound, 33 | History& history); 34 | 35 | static void Expand(QNode* qnode, BeliefLowerBound* lower_bound, 36 | BeliefUpperBound* upper_bound, const BeliefMDP* model, History& history); 37 | static void Expand(VNode* vnode, BeliefLowerBound* lower_bound, 38 | BeliefUpperBound* upper_bound, const BeliefMDP* model, History& history); 39 | static void Backup(VNode* vnode); 40 | static void Update(VNode* vnode); 41 | static void Update(QNode* qnode); 42 | static VNode* FindMaxApproxErrorLeaf(VNode* root); 43 | static void FindMaxApproxErrorLeaf(VNode* vnode, double likelihood, 44 | double& bestAE, VNode*& bestNode); 45 | static void FindMaxApproxErrorLeaf(QNode* qnode, double likelihood, 46 | double& bestAE, VNode*& bestNode); 47 | 48 | static ValuedAction OptimalAction(const VNode* vnode); 49 | static double Likelihood(QNode* qnode); 50 | static double AEMS2Likelihood(QNode* qnode); 51 | }; 52 | 53 | } // namespace despot 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/solver/baseline_solver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * baselinesolver.h 3 | * 4 | * Created on: 24 Oct 2017 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef SRC_SOLVER_BASELINESOLVER_H_ 9 | #define SRC_SOLVER_BASELINESOLVER_H_ 10 | 11 | #include 12 | #include 13 | 14 | namespace despot { 15 | 16 | /* ============================================================================= 17 | * ScenarioBaselineSolver class 18 | * =============================================================================*/ 19 | /** 20 | * Wrapper for using ScenarioLowerBound as base-line solvers. 21 | */ 22 | 23 | class ScenarioBaselineSolver: public Solver { 24 | protected: 25 | ScenarioLowerBound* lb_solver_; 26 | public: 27 | ScenarioBaselineSolver(ScenarioLowerBound* lowerbound, Belief* belief = NULL); 28 | virtual ~ScenarioBaselineSolver(); 29 | 30 | virtual ValuedAction Search(); 31 | }; 32 | 33 | /* ============================================================================= 34 | * BeliefBaselineSolver class 35 | * =============================================================================*/ 36 | /** 37 | * Wrapper for using BeliefLowerBound as base-line solvers. 38 | */ 39 | 40 | class BeliefBaselineSolver: public Solver { 41 | protected: 42 | BeliefLowerBound* lb_solver_; 43 | public: 44 | BeliefBaselineSolver(BeliefLowerBound* lowerbound, Belief* belief = NULL); 45 | virtual ~BeliefBaselineSolver(); 46 | 47 | virtual ValuedAction Search(); 48 | }; 49 | 50 | } /* namespace despot */ 51 | 52 | #endif /* SRC_SOLVER_BASELINESOLVER_H_ */ 53 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/coord.h: -------------------------------------------------------------------------------- 1 | #ifndef COORD_H 2 | #define COORD_H 3 | 4 | #include 5 | #include 6 | 7 | namespace despot { 8 | 9 | struct Coord { 10 | int x, y; 11 | 12 | Coord(); 13 | Coord(int _x, int _y); 14 | 15 | Coord operator*(int v) const; 16 | friend Coord& operator +=(Coord& left, const Coord& right); 17 | friend const Coord operator +(const Coord& first, const Coord& second); 18 | friend bool operator ==(const Coord& first, const Coord& second); 19 | friend bool operator !=(const Coord& first, const Coord& second); 20 | friend std::ostream& operator<<(std::ostream& os, const Coord& coord); 21 | 22 | static double EuclideanDistance(Coord c1, Coord c2); 23 | static int ManhattanDistance(Coord c1, Coord c2); 24 | static int DirectionalDistance(Coord c1, Coord c2, int direction); 25 | }; 26 | 27 | /*---------------------------------------------------------------------------*/ 28 | 29 | struct Compass { 30 | enum { 31 | NORTH, EAST, SOUTH, WEST, NORTHEAST, SOUTHEAST, SOUTHWEST, NORTHWEST 32 | }; 33 | 34 | static const Coord DIRECTIONS[]; 35 | static const std::string CompassString[]; 36 | static int Opposite(int dir); 37 | static bool Opposite(int dir1, int dir2); 38 | }; 39 | 40 | } // namespace despot 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/dirichlet.h: -------------------------------------------------------------------------------- 1 | #ifndef DIRICHLET_H 2 | #define DIRICHLET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace despot { 8 | 9 | class Dirichlet { 10 | private: 11 | std::vector alpha_; 12 | public: 13 | Dirichlet(std::vector alpha); 14 | 15 | std::vector alpha(); 16 | std::vector Next(); 17 | static std::vector Next(std::vector alpha); 18 | }; 19 | 20 | } // namespace despot 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/error_handler.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | void my_terminate(void); 11 | 12 | namespace { 13 | // invoke set_terminate as part of global constant initialization 14 | static const bool SET_TERMINATE = std::set_terminate(my_terminate); 15 | } 16 | 17 | extern struct sigaction sa; 18 | extern struct sigaction sigact; 19 | 20 | 21 | void segfault_sigaction(int sig, siginfo_t *info, void *c); 22 | 23 | void abort_sigaction(int sig_num, siginfo_t * info, void * ucontext); 24 | 25 | void set_error_handlers(); 26 | 27 | 28 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/exec_tracker.h: -------------------------------------------------------------------------------- 1 | #ifndef EXECTRACKER_H 2 | #define EXECTRACKER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace despot { 10 | 11 | class ExecTracker { 12 | private: 13 | std::map creation_loc_; 14 | public: 15 | ExecTracker(); 16 | 17 | void Track(std::string addr, std::string position); 18 | void Untrack(std::string addr); 19 | void Print(std::ostream& out = std::cout) const; 20 | void PrintLocs(std::ostream& out = std::cout) const; 21 | }; 22 | 23 | } // namespace despot 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/floor.h: -------------------------------------------------------------------------------- 1 | #ifndef FLOOR_H 2 | #define FLOOR_H 3 | 4 | #include 5 | #include 6 | 7 | namespace despot { 8 | 9 | class Floor { 10 | private: 11 | int num_rows_, num_cols_; 12 | int** floor_; 13 | std::vector cells_; 14 | std::vector > dist_; 15 | 16 | std::vector ComputeDistances(int source); 17 | 18 | public: 19 | static int INVALID; 20 | 21 | Floor(); 22 | Floor(int num_rows, int num_cols); 23 | 24 | void AddCell(Coord coord); 25 | Coord GetCell(int i) const; 26 | inline int GetIndex(const Coord& coord) const { 27 | return GetIndex(coord.x, coord.y); 28 | } 29 | inline int GetIndex(int x, int y) const { 30 | return 31 | (x >= 0 && x < num_cols_ && y >= 0 && y < num_rows_) ? 32 | floor_[y][x] : INVALID; 33 | } 34 | bool Inside(Coord coord) const; 35 | bool Inside(int x, int y) const; 36 | 37 | void ComputeDistances(); 38 | double Distance(int c1, int c2) const; 39 | 40 | std::vector ComputeShortestPath(int start, int end) const; 41 | 42 | int num_rows() const; 43 | int num_cols() const; 44 | int NumCells() const; 45 | }; 46 | 47 | } // namespace despot 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/gamma.h: -------------------------------------------------------------------------------- 1 | #ifndef GAMMA_H 2 | #define GAMMA_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace despot { 9 | 10 | class Gamma { 11 | private: 12 | double k_; 13 | double theta_; 14 | public: 15 | Gamma(double k, double theta); 16 | 17 | double Next(); 18 | 19 | static double Next(double k, double theta); 20 | }; 21 | 22 | } // namespace despot 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/logging.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGGING_H 2 | #define LOGGING_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace despot { 9 | 10 | class log_ostream: public std::ostream { 11 | private: 12 | class log_buf: public std::stringbuf { 13 | private: 14 | std::ostream& out_; 15 | std::string marker_; 16 | 17 | public: 18 | log_buf(std::ostream& out, std::string marker = ""); 19 | ~log_buf(); 20 | 21 | virtual std::streambuf* setbuf(char* s, std::streamsize n); 22 | virtual int sync(); 23 | }; 24 | 25 | log_buf buffer_; 26 | 27 | protected: 28 | 29 | public: 30 | log_ostream(std::ostream& out, std::string marker = ""); 31 | }; 32 | 33 | class logging { 34 | private: 35 | static int verbosity_; 36 | 37 | static std::vector streams_; 38 | static std::vector InitializeLogStreams(); 39 | static const std::string markers_[]; 40 | 41 | public: 42 | static const int NONE, ERROR, WARN, INFO, DEBUG, VERBOSE; 43 | 44 | public: 45 | static void level(int verbosity); 46 | static int level(); 47 | static log_ostream& stream(int level); 48 | static void stream(int level, std::ostream& out); 49 | }; 50 | 51 | } // namespace despot 52 | 53 | //#undef LOG 54 | 55 | #define LOG(lv) \ 56 | if (despot::logging::level() < despot::logging::ERROR || despot::logging::level() < lv) ; \ 57 | else despot::logging::stream(lv) 58 | 59 | #define loge LOG(despot::logging::ERROR) 60 | #define logw LOG(despot::logging::WARN) 61 | #define logi LOG(despot::logging::INFO) 62 | #define logd LOG(despot::logging::DEBUG) 63 | #define logv LOG(despot::logging::VERBOSE) 64 | 65 | #define default_out \ 66 | if (Globals::config.silence) ; \ 67 | else cout 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/memorypool.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORYPOOL_H 2 | #define MEMORYPOOL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace despot { 10 | 11 | class MemoryObject { 12 | public: 13 | void SetAllocated() { 14 | allocated_ = true; 15 | } 16 | void ClearAllocated() { 17 | allocated_ = false; 18 | } 19 | bool IsAllocated() const { 20 | return allocated_; 21 | } 22 | 23 | public: 24 | bool allocated_; 25 | }; 26 | 27 | template 28 | class MemoryPool { 29 | public: 30 | MemoryPool() : 31 | num_allocated_(0) { 32 | } 33 | 34 | ~MemoryPool() { 35 | DeleteAll(); 36 | } 37 | 38 | T* Construct() { 39 | T* obj = Allocate(); 40 | return new (obj) T; 41 | } 42 | 43 | void Destroy(T* obj) { 44 | obj.T::~T(); 45 | Free(obj); 46 | } 47 | 48 | T* Allocate() { 49 | Globals::lock_process(); 50 | 51 | if (freelist_.empty()) 52 | NewChunk(); 53 | T* obj = freelist_.back(); 54 | freelist_.pop_back(); 55 | 56 | 57 | assert(!obj->IsAllocated()); 58 | obj->SetAllocated(); 59 | num_allocated_++; 60 | 61 | Globals::unlock_process(); 62 | 63 | return obj; 64 | } 65 | 66 | void Free(T* obj) { 67 | Globals::lock_process(); 68 | 69 | assert(obj->IsAllocated()); 70 | obj->ClearAllocated(); 71 | freelist_.push_back(obj); 72 | num_allocated_--; 73 | 74 | Globals::unlock_process(); 75 | } 76 | 77 | void DeleteAll() { 78 | for (chunk_iterator_ i_chunk = chunks_.begin(); 79 | i_chunk != chunks_.end(); ++i_chunk) 80 | delete *i_chunk; 81 | chunks_.clear(); 82 | freelist_.clear(); 83 | num_allocated_ = 0; 84 | } 85 | 86 | int num_allocated() const { 87 | return num_allocated_; 88 | } 89 | 90 | private: 91 | struct Chunk { 92 | static const int Size = 256; 93 | T Objects[Size]; 94 | }; 95 | 96 | void NewChunk() { 97 | Chunk* chunk = new Chunk; 98 | chunks_.push_back(chunk); 99 | for (int i = Chunk::Size - 1; i >= 0; --i) { 100 | freelist_.push_back(&chunk->Objects[i]); 101 | chunk->Objects[i].ClearAllocated(); 102 | } 103 | } 104 | 105 | std::vector chunks_; 106 | std::vector freelist_; 107 | typedef typename std::vector::iterator chunk_iterator_; 108 | 109 | public: 110 | int num_allocated_; 111 | }; 112 | 113 | } // namespace despot 114 | 115 | #endif // MEMORYPOOL_H 116 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/random.h: -------------------------------------------------------------------------------- 1 | #ifndef RANDOM_H 2 | #define RANDOM_H 3 | 4 | #include 5 | 6 | namespace despot { 7 | 8 | class Random { 9 | private: 10 | unsigned seed_; 11 | 12 | public: 13 | static Random RANDOM; 14 | 15 | 16 | Random(double seed); 17 | Random(unsigned seed); 18 | 19 | unsigned seed(); 20 | void seed(unsigned); 21 | unsigned NextUnsigned(); 22 | int NextInt(int n); 23 | int NextInt(int min, int max); 24 | 25 | double NextDouble(); 26 | double NextDouble(double min, double max); 27 | 28 | double NextGaussian(); 29 | 30 | int NextCategory(const std::vector& category_probs); 31 | 32 | template 33 | T NextElement(const std::vector& vec) { 34 | return vec[NextInt(vec.size())]; 35 | } 36 | 37 | static int GetCategory(const std::vector& category_probs, 38 | double rand_num); 39 | }; 40 | 41 | class QuickRandom { 42 | public: 43 | 44 | static void InitRandGen(); 45 | static void DestroyRandGen(); 46 | 47 | static float RandGeneration(float seed); 48 | 49 | static void SetSeed(unsigned long long int v, int ThreadID); 50 | 51 | 52 | static unsigned long long int* seeds_; 53 | }; 54 | 55 | #define INIT_QUICKRANDSEED 123456 56 | } // namespace despot 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/seeds.h: -------------------------------------------------------------------------------- 1 | #ifndef SEEDS_H 2 | #define SEEDS_H 3 | 4 | #include 5 | #include 6 | 7 | namespace despot { 8 | 9 | class Seeds { 10 | private: 11 | static unsigned root_seed_; 12 | static Random seed_gen_; 13 | static int num_assigned_seeds_; 14 | 15 | public: 16 | static void root_seed(unsigned value); 17 | 18 | static unsigned Next(); 19 | 20 | static std::vector Next(int n); 21 | }; 22 | 23 | } // namespace despot 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/include/despot/util/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMER_H 2 | #define TIMER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* Compile with -lpthread*/ 10 | 11 | namespace despot { 12 | 13 | class Timer { 14 | private: 15 | pthread_t timer; 16 | int millis; 17 | bool done; 18 | 19 | void* timing(void* arg) { 20 | usleep(millis * 1000); 21 | done = true; 22 | } 23 | 24 | static void* helper(void* context) { 25 | return ((Timer*) context)->timing(NULL); 26 | } 27 | 28 | public: 29 | Timer(int millis) { 30 | this->millis = millis; 31 | done = true; 32 | } 33 | 34 | ~Timer() { 35 | //pthread_join(timer, NULL); 36 | } 37 | 38 | void start() { 39 | done = false; 40 | int status = pthread_create(&timer, NULL, &Timer::helper, this); 41 | assert(status == 0); 42 | } 43 | 44 | bool finished() { 45 | return done; 46 | } 47 | }; 48 | 49 | } // namespace despot 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/license/License: -------------------------------------------------------------------------------- 1 | LICENSE 2 | 3 | Files in src/util/tinyxml and include/util/tinyxml are from TinyXML 4 | (http://www.grinninglizard.com/tinyxml/) released under zlib License. All the 5 | other files are original. 6 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/license/zlib.txt: -------------------------------------------------------------------------------- 1 | This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. 2 | 3 | Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 4 | 5 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 6 | 7 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 8 | 9 | 3. This notice may not be removed or altered from any source distribution. 10 | 11 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUcore/GPUbuiltin_lower_bound.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace despot { 9 | 10 | /* ============================================================================= 11 | * TrivialParticleLowerBound class 12 | * =============================================================================*/ 13 | 14 | 15 | DEVICE Dvc_ValuedAction Dvc_TrivialParticleLowerBound::Value( 16 | int scenarioID, Dvc_State * particles) { 17 | Dvc_ValuedAction va = DvcModelGetBestAction_(); 18 | va.value *= 1.0 / (1 - Dvc_Globals::Dvc_Discount(Dvc_config)); 19 | return va; 20 | } 21 | 22 | __global__ void PassLbValueFunc(Dvc_TrivialParticleLowerBound* lowerbound) 23 | { 24 | DvcParticleLowerBound_Value_=&(lowerbound->Value); 25 | } 26 | 27 | } // namespace despot 28 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUcore/GPUbuiltin_upper_bound.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace despot { 8 | 9 | /* ============================================================================= 10 | * Dvc_TrivialParticleUpperBound class 11 | * =============================================================================*/ 12 | 13 | DEVICE float Dvc_TrivialParticleUpperBound::Value(const Dvc_State* state, int scenarioID, 14 | Dvc_History& history) { 15 | float max_reward = DvcModelGetMaxReward_(); 16 | return max_reward * 1.0 / (1 - Dvc_Globals::Dvc_Discount(Dvc_config)); 17 | } 18 | 19 | __global__ void PassUbValueFunc(Dvc_TrivialParticleUpperBound* upperbound) 20 | { 21 | DvcUpperBoundValue_=&(upperbound->Value); 22 | } 23 | 24 | } // namespace despot 25 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUcore/GPUconfig.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace despot{ 4 | __managed__ Dvc_Config* tmp; 5 | DEVICE Dvc_Config* Dvc_config=NULL; 6 | 7 | __global__ void copy(const Dvc_Config* src) 8 | { 9 | Dvc_config->search_depth = src->search_depth; 10 | Dvc_config->discount = src->discount; 11 | Dvc_config->root_seed = src->root_seed; 12 | Dvc_config->time_per_move = src->time_per_move; 13 | Dvc_config->num_scenarios = src->num_scenarios; 14 | Dvc_config->pruning_constant = src->pruning_constant; 15 | Dvc_config->xi = src->xi; 16 | Dvc_config->sim_len = src->sim_len; 17 | Dvc_config->max_policy_sim_len = src->max_policy_sim_len; 18 | Dvc_config->noise = src->noise; 19 | Dvc_config->silence = src->silence; 20 | Dvc_config->useGPU = src->useGPU; 21 | } 22 | 23 | __global__ void AllocGlobalConfig() { 24 | Dvc_config = new Dvc_Config; 25 | } 26 | 27 | void Dvc_Config::CopyToGPU(const Config* src) { 28 | cudaMallocManaged((void**)&tmp, sizeof(Dvc_Config)); 29 | tmp->search_depth = src->search_depth; 30 | tmp->discount = src->discount; 31 | tmp->root_seed = src->root_seed; 32 | tmp->time_per_move = src->time_per_move; 33 | tmp->num_scenarios = src->num_scenarios; 34 | tmp->pruning_constant = src->pruning_constant; 35 | tmp->xi = src->xi; 36 | tmp->sim_len = src->sim_len; 37 | tmp->max_policy_sim_len = src->max_policy_sim_len; 38 | tmp->noise = src->noise; 39 | tmp->silence = src->silence; 40 | tmp->useGPU = src->useGPU; 41 | 42 | AllocGlobalConfig<<<1, 1, 1>>>(); 43 | HANDLE_ERROR(cudaDeviceSynchronize()); 44 | 45 | copy<<<1,1>>>(tmp); 46 | HANDLE_ERROR(cudaDeviceSynchronize()); 47 | 48 | cudaFree(tmp); 49 | } 50 | 51 | __global__ void clearConfig() { 52 | if (Dvc_config != NULL) { 53 | delete Dvc_config; 54 | Dvc_config = NULL; 55 | } 56 | } 57 | 58 | void Dvc_Config::Clear() { 59 | clearConfig<<<1, 1, 1>>>(); 60 | HANDLE_ERROR(cudaDeviceSynchronize()); 61 | } 62 | 63 | 64 | }//namespace despot 65 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUcore/GPUglobals.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | namespace despot { 6 | namespace Dvc_Globals { 7 | 8 | Dvc_Config* config; 9 | const double Dvc_INF = 1e8; 10 | const double Dvc_TINY = 1e-8; 11 | const double Dvc_POS_INFTY = DBL_MAX; 12 | const double Dvc_NEG_INFTY = -Dvc_POS_INFTY; 13 | 14 | } // namespace Dvc_Globals 15 | } // namespace despot 16 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUinterface/GPUdefault_policy.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace despot { 8 | 9 | //DvcDefaultPolicyAction_ = NULL; 10 | DEVICE ACT_TYPE (*DvcDefaultPolicyAction_)(int,const Dvc_State* ,Dvc_RandomStreams&, Dvc_History&)=NULL; 11 | 12 | 13 | 14 | 15 | } // namespace despot 16 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUinterface/GPUfunction_interfaces.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace despot { 8 | 9 | 10 | 11 | } // namespace despot 12 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUinterface/GPUlower_bound.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | namespace despot { 7 | /* 8 | DvcLowerBoundValue_ = NULL; 9 | DvcParticleLowerBound_Value_ = NULL;*/ 10 | 11 | DEVICE Dvc_ValuedAction (*DvcLowerBoundValue_)( Dvc_State *, Dvc_RandomStreams&, Dvc_History&, int) = NULL; 12 | DEVICE Dvc_ValuedAction (*DvcParticleLowerBound_Value_) (int, Dvc_State *)=NULL; 13 | 14 | /* ============================================================================= 15 | * Dvc_ValuedAction class 16 | * =============================================================================*/ 17 | 18 | DEVICE Dvc_ValuedAction::Dvc_ValuedAction() 19 | { 20 | action=-1; 21 | value=0; 22 | } 23 | 24 | DEVICE Dvc_ValuedAction::Dvc_ValuedAction(ACT_TYPE _action, float _value) 25 | { 26 | action=_action; 27 | value=_value ; 28 | } 29 | 30 | } // namespace despot 31 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUinterface/GPUpomdp.cu: -------------------------------------------------------------------------------- 1 | using namespace std; 2 | 3 | #include 4 | namespace despot { 5 | 6 | 7 | // Model-related GPU functions 8 | 9 | DEVICE bool (*DvcModelStep_)(Dvc_State&, float, ACT_TYPE, float&, OBS_TYPE&)=NULL; 10 | DEVICE bool (*DvcModelStepIntObs_)(Dvc_State&, float, ACT_TYPE, float&, int*)=NULL; 11 | DEVICE Dvc_ValuedAction (*DvcModelGetBestAction_)()=NULL; 12 | DEVICE int (*DvcModelNumActions_)() = NULL; 13 | DEVICE float (*DvcModelGetMaxReward_)()=NULL; 14 | 15 | 16 | 17 | // Memory management-related functions 18 | DEVICE void (*DvcModelCopyNoAlloc_)(Dvc_State*, const Dvc_State*, int pos, 19 | bool offset_des)=NULL; 20 | DEVICE void (*DvcModelCopyToShared_)(Dvc_State*, const Dvc_State*, int pos, 21 | bool offset_des)=NULL; 22 | DEVICE Dvc_State* (*DvcModelGet_)(Dvc_State* , int )=NULL; 23 | 24 | 25 | // Lowerbound-related GPU functions 26 | 27 | 28 | 29 | // Upperbound-related GPU functions 30 | 31 | /*Unused function pointers*/ 32 | //DEVICE Dvc_State* (*DvcModelAlloc_)(int num)=NULL; 33 | //DEVICE Dvc_State* (*DvcModelCopy_)(const Dvc_State*, int pos)=NULL; 34 | //DEVICE void (*DvcModelFree_)(Dvc_State*)=NULL; 35 | 36 | 37 | 38 | /*DvcModelStep_ = NULL; 39 | DvcModelStepIntObs_ = NULL; 40 | 41 | DvcModelGetBestAction_ = NULL; 42 | DvcModelGetMaxReward_ = NULL; 43 | Dvc_DSPOMDP::DvcModelNumAction_ = NULL; 44 | 45 | DvcModelCopyNoAlloc_ = NULL; 46 | DvcModelCopyToShared_ = NULL; 47 | DvcModelGet_ = NULL;*/ 48 | 49 | 50 | } // namespace despot 51 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUinterface/GPUupper_bound.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | namespace despot { 7 | 8 | //DvcUpperBoundValue_ = NULL; 9 | DEVICE float (*DvcUpperBoundValue_)(const Dvc_State*, int, Dvc_History&) = NULL; 10 | 11 | 12 | } // namespace despot 13 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUutil/GPUmemorypool.cu: -------------------------------------------------------------------------------- 1 | #include "despot/GPUutil/GPUmemorypool.h" 2 | 3 | 4 | namespace despot { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUutil/GPUseeds.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | namespace despot { 6 | 7 | } // namespace despot 8 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/GPUutil/GPUutil.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/core/builtin_lower_bounds.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace despot { 9 | 10 | /* ============================================================================= 11 | * POMCPScenarioLowerBound class 12 | * =============================================================================*/ 13 | 14 | POMCPScenarioLowerBound::POMCPScenarioLowerBound(const DSPOMDP* model, 15 | POMCPPrior* prior, 16 | Belief* belief) : 17 | ScenarioLowerBound(model/*, belief*/), 18 | prior_(prior) { 19 | explore_constant_ = model_->GetMaxReward() 20 | - model_->GetBestAction().value; 21 | } 22 | 23 | ValuedAction POMCPScenarioLowerBound::Value(const vector& particles, 24 | RandomStreams& streams, History& history) const { 25 | prior_->history(history); 26 | VNode* root = POMCP::CreateVNode(0, particles[0], prior_, model_); 27 | // Note that particles are assumed to be of equal weight 28 | for (int i = 0; i < particles.size(); i++) { 29 | State* particle = particles[i]; 30 | State* copy = model_->Copy(particle); 31 | POMCP::Simulate(copy, streams, root, model_, prior_); 32 | model_->Free(copy); 33 | } 34 | 35 | ValuedAction va = POMCP::OptimalAction(root); 36 | va.value *= State::Weight(particles); 37 | delete root; 38 | return va; 39 | } 40 | 41 | /* ============================================================================= 42 | * TrivialParticleLowerBound class 43 | * =============================================================================*/ 44 | 45 | TrivialParticleLowerBound::TrivialParticleLowerBound(const DSPOMDP* model) : 46 | ParticleLowerBound(model) { 47 | } 48 | 49 | ValuedAction TrivialParticleLowerBound::Value( 50 | const vector& particles) const { 51 | ValuedAction va = model_->GetBestAction(); 52 | va.value *= State::Weight(particles) / (1 - Globals::Discount()); 53 | return va; 54 | } 55 | 56 | /* ============================================================================= 57 | * TrivialBeliefLowerBound class 58 | * =============================================================================*/ 59 | 60 | TrivialBeliefLowerBound::TrivialBeliefLowerBound(const DSPOMDP* model) : 61 | BeliefLowerBound(model) { 62 | } 63 | 64 | ValuedAction TrivialBeliefLowerBound::Value(const Belief* belief) const { 65 | ValuedAction va = model_->GetBestAction(); 66 | va.value *= 1.0 / (1 - Globals::Discount()); 67 | return va; 68 | } 69 | 70 | } // namespace despot 71 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/core/builtin_policygraph.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * builtin_policygraph.cpp 3 | * 4 | * Created on: 9 Sep, 2018 5 | * Author: panpan 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | 16 | namespace despot { 17 | /* ============================================================================= 18 | * PolicyGraph class 19 | * =============================================================================*/ 20 | bool Load_Graph=false; 21 | 22 | RandomPolicyGraph::RandomPolicyGraph(const DSPOMDP* model, ParticleLowerBound* bound, 23 | Belief* belief) : 24 | PolicyGraph(model, bound, belief) { 25 | } 26 | RandomPolicyGraph::~RandomPolicyGraph() 27 | { 28 | ClearGraph(); 29 | } 30 | void RandomPolicyGraph::ConstructGraph(int size, int branch) 31 | { 32 | if(FIX_SCENARIO==1 || Load_Graph==true) 33 | { 34 | ifstream fin;fin.open("Graph.txt", ios::in); 35 | 36 | if(!fin.is_open()) 37 | { 38 | throw; 39 | exit(-1); 40 | } 41 | ImportGraph(fin,size,branch); 42 | fin.close(); 43 | } 44 | else 45 | { 46 | graph_size_=size; 47 | num_edges_per_node_=branch; 48 | action_nodes_.resize(size); 49 | 50 | //Set random actions for nodes 51 | for (int i = 0; i < graph_size_; i++) 52 | { 53 | action_nodes_[i]=Random::RANDOM.NextInt(model_->NumActions()); 54 | } 55 | //Link to random nodes for edges 56 | for (int i = 0; i < num_edges_per_node_; i++) 57 | { 58 | for (int j = 0; j < graph_size_; j++) 59 | { 60 | int rand_next_node=Random::RANDOM.NextInt(graph_size_); 61 | obs_edges_[(OBS_TYPE)i].push_back(rand_next_node); 62 | } 63 | } 64 | current_node_=0; 65 | } 66 | 67 | if(FIX_SCENARIO==2 && !Load_Graph) 68 | { 69 | ofstream fout;fout.open("Graph.txt", ios::trunc); 70 | ExportGraph(fout); 71 | fout.close(); 72 | } 73 | 74 | } 75 | 76 | } // namespace despot 77 | 78 | 79 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/core/globals.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | namespace despot { 6 | namespace Globals { 7 | 8 | Config config; 9 | ExecTracker tracker; 10 | const double INF = 1e8; 11 | const double TINY = 1e-8; 12 | const double POS_INFTY = std::numeric_limits::is_iec559 ? 13 | numeric_limits::infinity() : 14 | numeric_limits::max(); 15 | const double NEG_INFTY = -POS_INFTY; 16 | 17 | } // namespace Globals 18 | } // namespace despot 19 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/core/pomdp_world.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * POMDPWorld.cpp 3 | * 4 | * Created on: 20 Sep 2017 5 | * Author: panpan 6 | */ 7 | 8 | #include 9 | 10 | namespace despot { 11 | 12 | POMDPWorld::POMDPWorld(DSPOMDP* model, unsigned seed) : 13 | model_(model), 14 | random_(Random(seed)) { 15 | } 16 | 17 | POMDPWorld::~POMDPWorld() { 18 | } 19 | 20 | bool POMDPWorld::Connect() { 21 | return true; 22 | } 23 | 24 | State* POMDPWorld::Initialize() { 25 | 26 | if(FIX_SCENARIO==1) 27 | { 28 | std::ifstream fin;fin.open("StartState.txt", std::ios::in); 29 | state_ = model_->ImportState(fin); 30 | fin.close(); 31 | } 32 | else 33 | { 34 | state_ = model_->CreateStartState(); 35 | } 36 | 37 | 38 | if(FIX_SCENARIO==2) 39 | { 40 | std::ofstream fout;fout.open("StartState.txt", std::ios::trunc); 41 | model_->ExportState(*state_,fout); 42 | fout.close(); 43 | } 44 | 45 | return state_; 46 | } 47 | 48 | despot::State* POMDPWorld::GetCurrentState() { 49 | return state_; 50 | } 51 | 52 | bool POMDPWorld::ExecuteAction(ACT_TYPE action, OBS_TYPE& obs) { 53 | bool terminal = model_->Step(*state_, random_.NextDouble(), action, 54 | step_reward_, obs); 55 | return terminal; 56 | } 57 | 58 | } /* namespace despot */ 59 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/interface/belief.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | namespace despot { 7 | 8 | /* ============================================================================= 9 | * ParticleBelief class 10 | * =============================================================================*/ 11 | 12 | Belief::Belief(const DSPOMDP* model) : 13 | model_(model) { 14 | } 15 | 16 | Belief::~Belief() { 17 | } 18 | 19 | string Belief::text() const { 20 | return "AbstractBelief"; 21 | } 22 | 23 | ostream& operator<<(ostream& os, const Belief& belief) { 24 | os << (&belief)->text(); 25 | return os; 26 | } 27 | 28 | } // namespace despot 29 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/interface/lower_bound.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace despot { 9 | 10 | /* ============================================================================= 11 | * ValuedAction class 12 | * =============================================================================*/ 13 | 14 | ValuedAction::ValuedAction() : 15 | action(-1), 16 | value(0) { 17 | } 18 | 19 | ValuedAction::ValuedAction(ACT_TYPE _action, double _value) : 20 | action(_action), 21 | value(_value) { 22 | } 23 | 24 | ostream& operator<<(ostream& os, const ValuedAction& va) { 25 | os << "(" << va.action << ", " << va.value << ")"; 26 | return os; 27 | } 28 | 29 | /* ============================================================================= 30 | * ScenarioLowerBound class 31 | * =============================================================================*/ 32 | 33 | ScenarioLowerBound::ScenarioLowerBound(const DSPOMDP* model) : 34 | model_(model){ 35 | } 36 | 37 | void ScenarioLowerBound::Init(const RandomStreams& streams) { 38 | } 39 | 40 | void ScenarioLowerBound::Reset() { 41 | } 42 | 43 | void ScenarioLowerBound::Learn(VNode* tree) { 44 | } 45 | 46 | /* ============================================================================= 47 | * ParticleLowerBound class 48 | * =============================================================================*/ 49 | 50 | ParticleLowerBound::ParticleLowerBound(const DSPOMDP* model) : 51 | ScenarioLowerBound(model) { 52 | } 53 | 54 | ValuedAction ParticleLowerBound::Value(const vector& particles, 55 | RandomStreams& streams, History& history) const { 56 | return Value(particles); 57 | } 58 | 59 | /* ============================================================================= 60 | * BeliefLowerBound class 61 | * =============================================================================*/ 62 | 63 | BeliefLowerBound::BeliefLowerBound(const DSPOMDP* model) : 64 | model_(model) { 65 | } 66 | 67 | void BeliefLowerBound::Learn(VNode* tree) { 68 | } 69 | 70 | } // namespace despot 71 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/interface/upper_bound.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace despot { 8 | 9 | /* ============================================================================= 10 | * ScenarioUpperBound 11 | * =============================================================================*/ 12 | 13 | ScenarioUpperBound::ScenarioUpperBound() { 14 | } 15 | 16 | ScenarioUpperBound::~ScenarioUpperBound() { 17 | } 18 | 19 | void ScenarioUpperBound::Init(const RandomStreams& streams) { 20 | } 21 | 22 | /* ============================================================================= 23 | * ParticleUpperBound 24 | * =============================================================================*/ 25 | 26 | ParticleUpperBound::ParticleUpperBound() { 27 | } 28 | 29 | ParticleUpperBound::~ParticleUpperBound() { 30 | } 31 | 32 | double ParticleUpperBound::Value(const vector& particles, 33 | RandomStreams& streams, History& history) const { 34 | double value = 0; 35 | for (int i = 0; i < particles.size(); i++) { 36 | State* particle = particles[i]; 37 | value += particle->weight * Value(*particle); 38 | } 39 | return value; 40 | } 41 | 42 | /* ============================================================================= 43 | * BeliefUpperBound 44 | * =============================================================================*/ 45 | 46 | BeliefUpperBound::BeliefUpperBound() { 47 | } 48 | 49 | BeliefUpperBound::~BeliefUpperBound() { 50 | } 51 | 52 | } // namespace despot 53 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/interface/world.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * World.cpp 3 | * 4 | * Created on: 20 Sep 2017 5 | * Author: panpan 6 | */ 7 | 8 | #include 9 | 10 | namespace despot { 11 | 12 | World::World() { 13 | state_ = NULL; 14 | } 15 | 16 | World::~World() { 17 | } 18 | 19 | State* World::GetCurrentState(){ 20 | return NULL; 21 | } 22 | 23 | } /* namespace despot */ 24 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/solver/baseline_solver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * baselinesolver.cpp 3 | * 4 | * Created on: 24 Oct 2017 5 | * Author: panpan 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using std::vector; 16 | 17 | namespace despot { 18 | 19 | ScenarioBaselineSolver::ScenarioBaselineSolver(ScenarioLowerBound* lowerbound, Belief* belief): 20 | Solver(lowerbound->model(),belief){ 21 | lb_solver_=lowerbound; 22 | } 23 | 24 | ScenarioBaselineSolver::~ScenarioBaselineSolver() { 25 | } 26 | 27 | ValuedAction ScenarioBaselineSolver::Search() { 28 | RandomStreams streams(Globals::config.num_scenarios, 29 | Globals::config.search_depth); 30 | vector particles = belief_->Sample(Globals::config.num_scenarios); 31 | 32 | ValuedAction va = lb_solver_->Value(particles, streams, history_); 33 | 34 | for (int i = 0; i < particles.size(); i++) 35 | model_->Free(particles[i]); 36 | 37 | return va; 38 | } 39 | 40 | 41 | 42 | BeliefBaselineSolver::BeliefBaselineSolver(BeliefLowerBound* lowerbound, Belief* belief): 43 | Solver(lowerbound->model(), belief){ 44 | lb_solver_=lowerbound; 45 | } 46 | 47 | BeliefBaselineSolver::~BeliefBaselineSolver() { 48 | } 49 | 50 | ValuedAction BeliefBaselineSolver::Search() { 51 | return lb_solver_->Value(belief_); 52 | } 53 | 54 | } /* namespace despot */ 55 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/util/coord.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace despot { 9 | 10 | Coord::Coord() : 11 | x(0), 12 | y(0) { 13 | } 14 | Coord::Coord(int _x, int _y) : 15 | x(_x), 16 | y(_y) { 17 | } 18 | 19 | Coord Coord::operator*(int v) const { 20 | return Coord(this->x * v, this->y * v); 21 | } 22 | 23 | Coord& operator+=(Coord& left, const Coord& right) { 24 | left.x += right.x; 25 | left.y += right.y; 26 | return left; 27 | } 28 | 29 | const Coord operator+(const Coord& first, const Coord& second) { 30 | return Coord(first.x + second.x, first.y + second.y); 31 | } 32 | 33 | bool operator==(const Coord& first, const Coord& second) { 34 | return first.x == second.x && first.y == second.y; 35 | } 36 | 37 | bool operator!=(const Coord& first, const Coord& second) { 38 | return first.x != second.x || first.y != second.y; 39 | } 40 | 41 | ostream& operator<<(ostream& os, const Coord& coord) { 42 | os << "(" << coord.x << ", " << coord.y << ")"; 43 | return os; 44 | } 45 | 46 | /*---------------------------------------------------------------------------*/ 47 | const Coord Compass::DIRECTIONS[] = { Coord(0, 1), Coord(1, 0), Coord(0, -1), 48 | Coord(-1, 0), Coord(1, 1), Coord(1, -1), Coord(-1, -1), Coord(-1, 1) }; 49 | 50 | const string Compass::CompassString[] = { "North", "East", "South", "West", 51 | "NE", "SE", "SW", "NW" }; 52 | 53 | double Coord::EuclideanDistance(Coord c1, Coord c2) { 54 | return sqrt((c1.x - c2.x) * (c1.x - c2.x) + (c1.y - c2.y) * (c1.y - c2.y)); 55 | } 56 | 57 | int Coord::ManhattanDistance(Coord c1, Coord c2) { 58 | return abs(c1.x - c2.x) + abs(c1.y - c2.y); 59 | } 60 | 61 | int Coord::DirectionalDistance(Coord lhs, Coord rhs, int direction) { 62 | switch (direction) { 63 | case Compass::NORTH: 64 | return rhs.y - lhs.y; 65 | case Compass::EAST: 66 | return rhs.x - lhs.x; 67 | case Compass::SOUTH: 68 | return lhs.y - rhs.y; 69 | case Compass::WEST: 70 | return lhs.x - rhs.x; 71 | default: 72 | assert(false); 73 | return -1; 74 | } 75 | } 76 | 77 | int Compass::Opposite(int dir) { 78 | return (dir + 2) % 4; 79 | } 80 | 81 | bool Compass::Opposite(int dir1, int dir2) { 82 | return DIRECTIONS[dir1] + DIRECTIONS[dir2] == Coord(0, 0); 83 | } 84 | 85 | } // namespace despot 86 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/util/dirichlet.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | namespace despot { 6 | 7 | Dirichlet::Dirichlet(vector alpha) { 8 | alpha_ = alpha; 9 | } 10 | 11 | vector Dirichlet::alpha() { 12 | return alpha_; 13 | } 14 | 15 | vector Dirichlet::Next() { 16 | return Next(alpha_); 17 | } 18 | 19 | vector Dirichlet::Next(vector alpha) { 20 | int dim = alpha.size(); 21 | vector x(dim, 0); 22 | double sum = 0; 23 | for (int i = 0; i < dim; i++) { 24 | x[i] = Gamma::Next(alpha[i], 1); 25 | sum = sum + x[i]; 26 | } 27 | for (int i = 0; i < dim; i++) 28 | x[i] = x[i] / sum; 29 | return x; 30 | } 31 | 32 | } // namespace despot 33 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/util/exec_tracker.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | namespace despot { 6 | 7 | ExecTracker::ExecTracker() { 8 | } 9 | 10 | void ExecTracker::Track(string addr, string position) { 11 | creation_loc_[addr] = position; 12 | } 13 | 14 | void ExecTracker::Untrack(string addr) { 15 | creation_loc_.erase(addr); 16 | } 17 | 18 | void ExecTracker::Print(ostream& out) const { 19 | for (map::const_iterator it = creation_loc_.begin(); 20 | it != creation_loc_.end(); it++) { 21 | out << "(" << it->first << ", " << it->second << ")" << endl; 22 | } 23 | } 24 | 25 | void ExecTracker::PrintLocs(ostream& out) const { 26 | map locs; 27 | for (map::const_iterator it = creation_loc_.begin(); 28 | it != creation_loc_.end(); it++) { 29 | locs[it->second]++; 30 | } 31 | out << "Locs:"; 32 | for (map::iterator loc = locs.begin(); loc != locs.end(); loc++) 33 | out << " (" << loc->first << ", " << loc->second << ")"; 34 | out << endl; 35 | } 36 | 37 | } // namespace despot 38 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/util/gamma.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace despot { 4 | 5 | Gamma::Gamma(double k, double theta) { 6 | k_ = k; 7 | theta_ = theta; 8 | } 9 | 10 | double Gamma::Next() { 11 | return Next(k_, theta_); 12 | } 13 | 14 | double Gamma::Next(double k, double theta) { 15 | if (k < 1) { 16 | double c = 1 / k; 17 | double d = (1 - k) * pow(k, k / (1 - k)); 18 | double z, e, x; 19 | while (true) { //Weibull's algorithm 20 | double u = Random::RANDOM.NextDouble(); 21 | double v = Random::RANDOM.NextDouble(); 22 | z = -log(u); 23 | e = -log(v); 24 | x = pow(z, c); 25 | if (z + e >= d + x) 26 | return x * theta; 27 | } 28 | } else { // Cheng's algorithm 29 | double b = k - log(4); 30 | double c = k + sqrt(2 * k - 1); 31 | double d = sqrt(2 * k - 1); 32 | double e = 1 + log(4.5); 33 | double x, y, z, r; 34 | while (true) { 35 | double u = Random::RANDOM.NextDouble(); 36 | double v = Random::RANDOM.NextDouble(); 37 | y = log(v / (1 - v)) / d; 38 | x = k * exp(y); 39 | z = u * v * v; 40 | r = b + c * y - x; 41 | if (r >= 4.5 * z - e || r >= log(z)) 42 | return x * theta; 43 | } 44 | } 45 | } 46 | 47 | } // namespace despot 48 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/util/logging.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // #include 3 | 4 | using namespace std; 5 | 6 | namespace despot { 7 | 8 | const string logging::markers_[] = { "NONE", "ERROR", "WARN", "INFO", "DEBUG", 9 | "VERBOSE" }; 10 | const int logging::NONE = 0; 11 | const int logging::ERROR = 1; 12 | const int logging::WARN = 2; 13 | const int logging::INFO = 3; 14 | const int logging::DEBUG = 4; 15 | const int logging::VERBOSE = 5; 16 | 17 | log_ostream::log_ostream(ostream& out, string marker) : 18 | ostream(&buffer_), 19 | buffer_(out, marker) { 20 | } 21 | 22 | log_ostream::log_buf::log_buf(ostream& out, string marker) : 23 | out_(out), 24 | marker_(marker) { 25 | } 26 | 27 | log_ostream::log_buf::~log_buf() { 28 | // pubsync(); 29 | } 30 | 31 | streambuf* log_ostream::log_buf::setbuf(char* s, streamsize n) { 32 | return this; 33 | } 34 | 35 | int log_ostream::log_buf::sync() { 36 | //NOTE: disabled c++11 feature 37 | // out_ << marker_ << "-" << this_thread::get_id() << ": " << str(); 38 | out_ << marker_ << ": " << str(); 39 | str(""); 40 | return !out_; 41 | } 42 | 43 | int logging::verbosity_ = ERROR; 44 | 45 | void logging::level(int verbosity) { 46 | verbosity_ = verbosity; 47 | } 48 | 49 | int logging::level() { 50 | return verbosity_; 51 | } 52 | 53 | log_ostream& logging::stream(int level) { 54 | return *(streams_[level]); 55 | } 56 | 57 | void logging::stream(int level, ostream& out) { 58 | if (level >= ERROR && level <= VERBOSE) { 59 | streams_[level] = new log_ostream(out, markers_[level]); 60 | } 61 | } 62 | 63 | vector logging::InitializeLogStreams() { 64 | vector streams(6); 65 | 66 | streams[NONE] = NULL; 67 | streams[ERROR] = new log_ostream(cerr, markers_[ERROR]); 68 | streams[WARN] = new log_ostream(cerr, markers_[WARN]); 69 | streams[INFO] = new log_ostream(cerr, markers_[INFO]); 70 | streams[DEBUG] = new log_ostream(cerr, markers_[DEBUG]); 71 | streams[VERBOSE] = new log_ostream(cerr, markers_[VERBOSE]); 72 | 73 | return streams; 74 | } 75 | 76 | vector logging::streams_ = logging::InitializeLogStreams(); 77 | 78 | } // namespace despot 79 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/util/seeds.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | namespace despot { 6 | 7 | int Seeds::num_assigned_seeds_ = 0; 8 | unsigned Seeds::root_seed_ = 0; 9 | Random Seeds::seed_gen_ = Random((unsigned) 0); 10 | 11 | void Seeds::root_seed(unsigned value) { 12 | root_seed_ = value; 13 | seed_gen_ = Random(root_seed_); 14 | } 15 | 16 | unsigned Seeds::Next() { 17 | // return root_seed_ ^ (num_assigned_seeds_++); 18 | return seed_gen_.NextUnsigned(); 19 | } 20 | 21 | vector Seeds::Next(int n) { 22 | vector seeds; 23 | for (int i = 0; i < n; i++) 24 | seeds.push_back(Next()); 25 | return seeds; 26 | } 27 | 28 | } // namespace despot 29 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/util/tinyxml/tinyxmlerror.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | www.sourceforge.net/projects/tinyxml 3 | Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any 7 | damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any 10 | purpose, including commercial applications, and to alter it and 11 | redistribute it freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must 14 | not claim that you wrote the original software. If you use this 15 | software in a product, an acknowledgment in the product documentation 16 | would be appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and 19 | must not be misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source 22 | distribution. 23 | */ 24 | 25 | #include 26 | 27 | namespace despot { 28 | namespace util { 29 | namespace tinyxml { 30 | 31 | // The goal of the seperate error file is to make the first 32 | // step towards localization. tinyxml (currently) only supports 33 | // english error messages, but the could now be translated. 34 | // 35 | // It also cleans up the code a bit. 36 | // 37 | 38 | const char * TiXmlBase::errorString[TIXML_ERROR_STRING_COUNT] = 39 | { "No error", "Error", "Failed to open file", "Memory allocation failed.", 40 | "Error parsing Element.", "Failed to read Element name", 41 | "Error reading Element value.", "Error reading Attributes.", 42 | "Error: empty tag.", "Error reading end tag.", "Error parsing Unknown.", 43 | "Error parsing Comment.", "Error parsing Declaration.", 44 | "Error document empty.", 45 | "Error null (0) or unexpected EOF found in input stream.", 46 | "Error parsing CDATA.", 47 | "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", }; 48 | 49 | } // namespace tinyxml 50 | } // namespace util 51 | } // namespace despot 52 | -------------------------------------------------------------------------------- /car_hyp_despot/src/HypDespot/src/util/util.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | namespace despot { 6 | 7 | string repeat(string str, int n) { 8 | ostringstream oss; 9 | for (int i = 0; i < n; i++) 10 | oss << str; 11 | return oss.str(); 12 | } 13 | 14 | double erf(double x) { 15 | // constants 16 | double a1 = 0.254829592; 17 | double a2 = -0.284496736; 18 | double a3 = 1.421413741; 19 | double a4 = -1.453152027; 20 | double a5 = 1.061405429; 21 | double p = 0.3275911; 22 | // Save the sign of x 23 | int sign = 1; 24 | if (x < 0) 25 | sign = -1; 26 | x = fabs(x); 27 | // A&S formula 7.1.26 28 | double t = 1.0 / (1.0 + p * x); 29 | double y = 1.0 30 | - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * exp(-x * x); 31 | 32 | return sign * y; 33 | } 34 | 35 | // CDF of the normal distribution 36 | double gausscdf(double x, double mean, double sigma) { 37 | return 0.5 * (1 + erf((x - mean) / (sqrt(2) * sigma))); 38 | } 39 | 40 | vector Tokenize(string line, char delim) { 41 | // Tokenizes a string on a delim and strips whitespace from the tokens 42 | vector tokens; 43 | stringstream ss(line); 44 | string item; 45 | while (getline(ss, item, delim)) { 46 | while (isspace(item[0])) 47 | item.erase(item.begin()); 48 | while (isspace(item[item.length()-1])) 49 | item.erase(item.end() - 1); 50 | tokens.push_back(item); 51 | } 52 | return tokens; 53 | } 54 | 55 | vector Tokenize(const string& str, const string& delimiters) { 56 | vector tokens; 57 | string::size_type last_pos = str.find_first_not_of(delimiters, 0); 58 | string::size_type pos = str.find_first_of(delimiters, last_pos); 59 | 60 | while (string::npos != pos || string::npos != last_pos) { 61 | tokens.push_back(str.substr(last_pos, pos - last_pos)); 62 | 63 | last_pos = str.find_first_not_of(delimiters, pos); 64 | pos = str.find_first_of(delimiters, last_pos); 65 | } 66 | return tokens; 67 | } 68 | 69 | std::string GetCurrentWorkingDir(void) { 70 | char buff[FILENAME_MAX]; 71 | GetCurrentDir( buff, FILENAME_MAX ); 72 | std::string current_working_dir(buff); 73 | return current_working_dir; 74 | } 75 | 76 | } // namespace despot 77 | 78 | -------------------------------------------------------------------------------- /car_hyp_despot/src/gamma/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | indent_size = 4 6 | indent_style = tab 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | 13 | [*.yml] 14 | indent_size = 2 15 | indent_style = space 16 | -------------------------------------------------------------------------------- /car_hyp_despot/src/gamma/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | -------------------------------------------------------------------------------- /car_hyp_despot/src/gamma/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | sudo: false 3 | language: cpp 4 | compiler: 5 | - clang 6 | - gcc 7 | os: 8 | - linux 9 | - osx 10 | script: 11 | - mkdir _build 12 | - cd _build 13 | - cmake -DCMAKE_CXX_FLAGS="-DRVO_OUTPUT_TIME_AND_POSITIONS=0 -DRVO_SEED_RANDOM_NUMBER_GENERATOR=0" .. 14 | - ctest --extra-verbose --dashboard Experimental . 15 | -------------------------------------------------------------------------------- /car_hyp_despot/src/gamma/ConvexHull.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Yuanfu Luo 3 | */ 4 | 5 | #include 6 | #include "Definitions.h" 7 | #include "RVOSimulator.h" 8 | 9 | namespace RVO { 10 | 11 | // Returns a new list of points representing the convex hull of 12 | // the given set of points. The convex hull excludes collinear points. 13 | // This algorithm runs in O(n log n) time. 14 | std::vector makeConvexHull(const std::vector &points); 15 | 16 | 17 | // Returns the convex hull, assuming that each points[i] <= points[i + 1]. Runs in O(n) time. 18 | std::vector makeConvexHullPresorted(const std::vector &points); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /car_hyp_despot/src/gamma/GammaParams.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Yuanfu Luo 3 | */ 4 | 5 | #include "GammaParams.h" 6 | 7 | namespace GammaParams{ 8 | bool use_polygon = true; 9 | bool consider_kinematics = true; 10 | bool use_dynamic_resp = true; 11 | bool use_dynamic_att = true; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /car_hyp_despot/src/gamma/GammaParams.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Yuanfu Luo 3 | */ 4 | 5 | #ifndef GAMMA_PARAMS_H_ 6 | #define GAMMA_PARAMS_H_ 7 | 8 | namespace GammaParams{ 9 | extern bool use_polygon; 10 | extern bool consider_kinematics; 11 | extern bool use_dynamic_resp; 12 | extern bool use_dynamic_att; 13 | 14 | const float GAMMA_PI = 3.14159f; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /car_hyp_despot/src/gamma/Minkowski.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Yuanfu Luo 3 | */ 4 | 5 | #ifndef RVO_MINKOWSKI_H_ 6 | #define RVO_MINKOWSKI_H_ 7 | 8 | #include "ConvexHull.h" 9 | 10 | namespace RVO { 11 | class Minkowski { 12 | public: 13 | static std::vector Sum(std::vector a_points, std::vector b_points) { 14 | std::vector sum; // = new std::vector(); 15 | for(size_t i=0; i results = makeConvexHull(sum); 24 | std::reverse(results.begin(), results.end()); // return the points in counter-clockwise order 25 | return results; 26 | } 27 | 28 | static std::vector Diff(std::vector a_points, std::vector b_points) { 29 | std::vector diff;// = new std::vector(); 30 | for(size_t i=0; i results = makeConvexHull(diff); 39 | std::reverse(results.begin(), results.end()); // return the points in counter-clockwise order 40 | return results; 41 | } 42 | }; 43 | } 44 | 45 | #endif /* RVO_MINKOWSKI_H_ */ 46 | -------------------------------------------------------------------------------- /car_hyp_despot/src/gamma/Obstacle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Obstacle.cpp 3 | * RVO2 Library 4 | * 5 | * Copyright 2008 University of North Carolina at Chapel Hill 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * Please send all bug reports to . 20 | * 21 | * The authors may be contacted via: 22 | * 23 | * Jur van den Berg, Stephen J. Guy, Jamie Snape, Ming C. Lin, Dinesh Manocha 24 | * Dept. of Computer Science 25 | * 201 S. Columbia St. 26 | * Frederick P. Brooks, Jr. Computer Science Bldg. 27 | * Chapel Hill, N.C. 27599-3175 28 | * United States of America 29 | * 30 | * 31 | * 32 | * modified by Yuanfu Luo 33 | */ 34 | 35 | #include "Obstacle.h" 36 | #include "RVOSimulator.h" 37 | 38 | namespace RVO { 39 | Obstacle::Obstacle() : isConvex_(false), nextObstacle_(NULL), prevObstacle_(NULL), id_(0) { } 40 | } 41 | -------------------------------------------------------------------------------- /car_hyp_despot/src/gamma/Obstacle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Obstacle.h 3 | * RVO2 Library 4 | * 5 | * Copyright 2008 University of North Carolina at Chapel Hill 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * Please send all bug reports to . 20 | * 21 | * The authors may be contacted via: 22 | * 23 | * Jur van den Berg, Stephen J. Guy, Jamie Snape, Ming C. Lin, Dinesh Manocha 24 | * Dept. of Computer Science 25 | * 201 S. Columbia St. 26 | * Frederick P. Brooks, Jr. Computer Science Bldg. 27 | * Chapel Hill, N.C. 27599-3175 28 | * United States of America 29 | * 30 | * 31 | * 32 | * modified by Yuanfu Luo 33 | */ 34 | 35 | #ifndef RVO_OBSTACLE_H_ 36 | #define RVO_OBSTACLE_H_ 37 | 38 | /** 39 | * \file Obstacle.h 40 | * \brief Contains the Obstacle class. 41 | */ 42 | 43 | #include "Definitions.h" 44 | 45 | namespace RVO { 46 | /** 47 | * \brief Defines static obstacles in the simulation. 48 | */ 49 | class Obstacle { 50 | private: 51 | /** 52 | * \brief Constructs a static obstacle instance. 53 | */ 54 | Obstacle(); 55 | 56 | bool isConvex_; 57 | Obstacle *nextObstacle_; 58 | Vector2 point_; 59 | Obstacle *prevObstacle_; 60 | Vector2 unitDir_; 61 | 62 | size_t id_; 63 | 64 | friend class Agent; 65 | friend class KdTree; 66 | friend class RVOSimulator; 67 | }; 68 | } 69 | 70 | #endif /* RVO_OBSTACLE_H_ */ 71 | -------------------------------------------------------------------------------- /car_hyp_despot/src/planner/cmake/DespotConfig.cmake.in: -------------------------------------------------------------------------------- 1 | set(DESPOT_VERSION x.y.z) 2 | 3 | @PACKAGE_INIT@ 4 | 5 | include("${CMAKE_CURRENT_LIST_DIR}/DespotTargets.cmake") 6 | 7 | set_and_check(DESPOT_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_PATH@") 8 | set(DESPOT_INCLUDE_DIRS ${DESPOT_INCLUDE_DIR}) 9 | set(DESPOT_LIBRARIES despot) 10 | -------------------------------------------------------------------------------- /car_hyp_despot/src/planner/default_prior.h: -------------------------------------------------------------------------------- 1 | /* 2 | * neural_prior.h 3 | * 4 | * Created on: Dec 11, 2018 5 | * Author: panpan 6 | */ 7 | 8 | #ifndef DEFAULT_PRIOR_H_ 9 | #define DEFAULT_PRIOR_H_ 10 | 11 | #include "despot/interface/pomdp.h" 12 | #include "despot/core/globals.h" 13 | #include "despot/util/coord.h" 14 | #include 15 | #include "world_model.h" 16 | 17 | class DefaultPrior: public SolverPrior { 18 | public: 19 | DefaultPrior(const DSPOMDP* model, WorldModel& world); 20 | 21 | std::vector ComputeLegalActions(const State* state, const DSPOMDP* model); 22 | void DebugHistory(string msg); 23 | void RecordCurHistory(); 24 | void CompareHistoryWithRecorded(); 25 | 26 | public: 27 | WorldModel& world_model; 28 | VariableActionStateHistory as_history_in_search_recorded; 29 | }; 30 | 31 | 32 | #endif /* DEFAULT_PRIOR_H_ */ 33 | -------------------------------------------------------------------------------- /car_hyp_despot/src/planner/param.cpp: -------------------------------------------------------------------------------- 1 | #include"param.h" 2 | 3 | namespace ModelParams { 4 | double GOAL_TRAVELLED = 20.0; 5 | double CRASH_PENALTY = -1000; 6 | double REWARD_FACTOR_VEL = 0.5; 7 | double REWARD_BASE_CRASH_VEL = 0.5; 8 | double BELIEF_SMOOTHING = 0.05; 9 | double NOISE_ROBVEL = 0.01; 10 | double NOISE_GOAL_ANGLE = 3.14 * 0.1; //use 0 for debugging 11 | double NOISE_PED_VEL = 0.3; //use 0 for debugging 12 | double NOISE_PED_POS = 0.2; 13 | double COLLISION_DISTANCE = 1.5; 14 | double IN_FRONT_ANGLE_DEG = 60; 15 | int DRIVING_PLACE = 0; 16 | 17 | double VEL_MAX = 8.0; 18 | double LASER_RANGE = 50.0; 19 | 20 | double CAR_WIDTH = 2.0; 21 | double CAR_LENGTH = 2.68; 22 | double CAR_WHEEL_DIST = 2.68; 23 | double CAR_FRONT = 1.34; 24 | double CAR_REAR = 1.34; 25 | double MAX_STEER_ANGLE = 35 / 180.0 * M_PI; 26 | 27 | std::string ROS_NS = ""; 28 | std::string LASER_FRAME = "/laser_frame"; 29 | bool ROS_BRIDG = false; 30 | 31 | void PrintParams() { 32 | printf("ModelParams:\n"); 33 | printf("=> GOAL_TRAVELLED=%f\n", GOAL_TRAVELLED); 34 | printf("=> CRASH_PENALTY=%f\n", CRASH_PENALTY); 35 | printf("=> REWARD_FACTOR_VEL=%f\n", REWARD_FACTOR_VEL); 36 | printf("=> REWARD_BASE_CRASH_VEL=%f\n", REWARD_BASE_CRASH_VEL); 37 | printf("=> BELIEF_SMOOTHING=%f\n", BELIEF_SMOOTHING); 38 | printf("=> NOISE_ROBVEL=%f\n", NOISE_ROBVEL); 39 | printf("=> NOISE_GOAL_ANGLE=%f\n", NOISE_GOAL_ANGLE); 40 | printf("=> NOISE_PED_VEL=%f\n", NOISE_PED_VEL); 41 | printf("=> NOISE_PED_POS=%f\n", NOISE_PED_POS); 42 | printf("=> COLLISION_DISTANCE=%f\n", COLLISION_DISTANCE); 43 | printf("=> IN_FRONT_ANGLE_DEG=%f\n", IN_FRONT_ANGLE_DEG); 44 | printf("=> DRIVING_PLACE=%d\n", DRIVING_PLACE); 45 | printf("=> VEL_MAX=%f\n", VEL_MAX); 46 | printf("=> LASER_RANGE=%f\n", LASER_RANGE); 47 | 48 | printf("=> ROS_NS=%s\n", ROS_NS.c_str()); 49 | printf("=> LASER_FRAME=%s\n", LASER_FRAME.c_str()); 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /car_hyp_despot/src/planner/param.h: -------------------------------------------------------------------------------- 1 | #ifndef MODELPARAMS_H 2 | #define MODELPARAMS_H 3 | #include 4 | #include 5 | 6 | namespace ModelParams { 7 | const int N_PED_WORLD = 200; 8 | const int N_PED_IN = 20; 9 | 10 | extern double GOAL_TRAVELLED; 11 | extern double VEL_MAX; 12 | extern double NOISE_GOAL_ANGLE; 13 | extern double NOISE_PED_VEL; 14 | extern double CRASH_PENALTY; 15 | extern double REWARD_FACTOR_VEL; 16 | extern double REWARD_BASE_CRASH_VEL; 17 | extern double BELIEF_SMOOTHING; 18 | extern double NOISE_ROBVEL; 19 | extern double COLLISION_DISTANCE; 20 | extern double IN_FRONT_ANGLE_DEG; 21 | extern double LASER_RANGE; 22 | extern int DRIVING_PLACE; 23 | extern double NOISE_PED_POS; 24 | const double PATH_STEP = 0.05; 25 | const double GOAL_TOLERANCE = 2; 26 | const double OBS_LINE_STEP = 0.5; // only check end points 27 | 28 | extern double CAR_WIDTH; 29 | extern double CAR_LENGTH; 30 | extern double CAR_WHEEL_DIST; 31 | extern double CAR_FRONT; // car pos may not be measured at rear wheel 32 | extern double CAR_REAR; // car pos may not be measured at rear wheel 33 | extern double MAX_STEER_ANGLE; 34 | 35 | const double POS_RLN = 0.4; // position resolution 36 | const double VEL_RLN = 0.3; // velocity resolution 37 | 38 | const double CONTROL_FREQ = 3; 39 | const double ACC_SPEED = 3.0; 40 | const double NUM_ACC = 1; 41 | 42 | const double NUM_STEER_ANGLE = 7; 43 | const double ANGLE_RLN = MAX_STEER_ANGLE / NUM_STEER_ANGLE; // velocity resolution 44 | 45 | const double GOAL_REWARD = 0.0; 46 | const double TIME_REWARD = 0.1; 47 | 48 | extern std::string ROS_NS; 49 | extern std::string LASER_FRAME; 50 | extern bool ROS_BRIDG; 51 | 52 | inline void InitParams(bool in_simulation) { 53 | if (in_simulation) { 54 | ROS_NS = ""; 55 | LASER_FRAME = "/laser_frame"; 56 | } else { 57 | ROS_NS = ""; 58 | LASER_FRAME = "/laser_frame"; 59 | } 60 | } 61 | 62 | const bool CPUDoPrint = false; 63 | 64 | void PrintParams(); 65 | }; 66 | 67 | //#define CAR_SIDE_MARGIN 0.0f 68 | //#define CAR_FRONT_MARGIN 0.0f 69 | 70 | #define CAR_SIDE_MARGIN 0.8f 71 | #define CAR_FRONT_MARGIN 3.0f 72 | #define PED_SIZE 0.25f 73 | #define CAR_EXPAND_SIZE 0.0f 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /car_hyp_despot/src/planner/path.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include"coord.h" 4 | #include"param.h" 5 | 6 | struct Path : std::vector { 7 | int Nearest(const COORD pos) const; 8 | double MinDist(COORD pos); 9 | int Forward(double i, double len) const; 10 | double GetYaw(int i) const; 11 | Path Interpolate(double max_len = 10000.0) const; 12 | void CutJoin(const Path& p); 13 | 14 | double GetLength(int start=0); 15 | double GetCurDir(int pos_along = 0); 16 | COORD GetCrossDir(int, bool); 17 | 18 | void Text(); 19 | 20 | void CopyTo(Path& des){ 21 | des.assign(begin(),end()); 22 | } 23 | }; 24 | 25 | double CapAngle(double x); 26 | -------------------------------------------------------------------------------- /car_hyp_despot/src/planner/simulator_base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class WorldBeliefTracker; 8 | class WorldModel; 9 | class WorldStateTracker; 10 | 11 | using namespace despot; 12 | 13 | class SimulatorBase { 14 | protected: 15 | double time_scale_; 16 | double cmd_speed_; 17 | double cmd_steer_; 18 | 19 | ACT_TYPE buffered_action_; 20 | 21 | public: 22 | ros::NodeHandle& nh; 23 | 24 | double real_speed; 25 | 26 | static WorldModel world_model; 27 | static bool agents_data_ready; 28 | static bool agents_path_data_ready; 29 | 30 | public: 31 | SimulatorBase(ros::NodeHandle&_nh): 32 | nh(_nh), time_scale_(1.0), buffered_action_(0), 33 | cmd_speed_(0), real_speed(0), cmd_steer_(0) {} 34 | }; 35 | 36 | 37 | static int action_map[3]={2,0,1}; 38 | -------------------------------------------------------------------------------- /car_hyp_despot/src/planner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef DEBUG_UTIL_H 2 | #define DEBUG_UTIL_H 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace std; 18 | using namespace chrono; 19 | 20 | template< typename... Args > 21 | std::string string_sprintf( const char* format, Args... args ) { 22 | int length = std::snprintf( nullptr, 0, format, args... ); 23 | assert( length >= 0 ); 24 | 25 | char* buf = new char[length + 1]; 26 | std::snprintf( buf, length + 1, format, args... ); 27 | std::string str( buf ); 28 | delete[] buf; 29 | 30 | return str; 31 | } 32 | 33 | #define ERR(msg) { std::string str = msg; \ 34 | fprintf(stderr,"ERROR: %s, in %s, at file %s_line_%d \n", str.c_str(), __FUNCTION__, __FILE__, __LINE__); \ 35 | raise(SIGABRT); } 36 | 37 | #define DEBUG(msg) { std::string str = msg; \ 38 | fprintf(stderr, "MSG: %s, in %s, at file %s_line_%d \n", str.c_str(), __FUNCTION__, __FILE__, __LINE__); } 39 | 40 | 41 | namespace std { 42 | template 43 | inline void hypdespot_hash_combine(size_t& seed, const T& v) { 44 | std::hash hasher; 45 | seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); 46 | } 47 | 48 | template 49 | struct hash> { 50 | inline size_t operator()(const pair& v) const { 51 | size_t seed = 0; 52 | ::hypdespot_hash_combine(seed, v.first); 53 | ::hypdespot_hash_combine(seed, v.second); 54 | return seed; 55 | } 56 | }; 57 | 58 | template 59 | struct hash> { 60 | inline size_t operator()(const vector& v) const { 61 | size_t seed = 0; 62 | for (const T& ele : v) { 63 | ::hypdespot_hash_combine(seed, ele); 64 | } 65 | return seed; 66 | } 67 | }; 68 | } 69 | 70 | // NOTE: disabled C++11 feature 71 | template 72 | void write(ostringstream& os, T t) { 73 | os << t; 74 | } 75 | 76 | template 77 | void write(ostringstream& os, T t, Args ... args) { 78 | os << t; 79 | write(os, args...); 80 | } 81 | 82 | template 83 | string concat(T t, Args ... args) { 84 | ostringstream os; 85 | write(os, t, args...); 86 | return os.str(); 87 | } 88 | 89 | template 90 | string concat(vector v) { 91 | ostringstream os; 92 | for (int i = 0; i < v.size(); i++) { 93 | os << v[i]; 94 | os << " "; 95 | } 96 | return os.str(); 97 | } 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /crowd_pomdp_planner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | 3 | set(CUDA_SDK_ROOT_DIR "/usr/local/cuda/samples") 4 | 5 | project(crowd_pomdp_planner CXX CUDA) 6 | 7 | if(NOT DEFINED CMAKE_CXX_STANDARD) 8 | set(CMAKE_CXX_STANDARD 14) 9 | set(CMAKE_CXX_STANDARD_REQUIRED True) 10 | endif() 11 | 12 | if(NOT DEFINED CMAKE_CUDA_STANDARD) 13 | set(CMAKE_CUDA_STANDARD 14) 14 | set(CMAKE_CUDA_STANDARD_REQUIRED True) 15 | endif() 16 | 17 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -mfpmath=sse") 18 | # set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch=sm_30") 19 | set(CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH} "${PROJECT_SOURCE_DIR}/cmake") 20 | 21 | add_definitions(-std=c++0x -O3) 22 | 23 | find_package(catkin REQUIRED COMPONENTS 24 | geometry_msgs 25 | roscpp 26 | std_msgs 27 | sensor_msgs 28 | nav_msgs 29 | msg_builder 30 | tf 31 | ) 32 | 33 | catkin_package( 34 | CATKIN_DEPENDS geometry_msgs msg_builder car_hyp_despot roscpp 35 | # DEPENDS CUDA 36 | ) 37 | 38 | include_directories( 39 | include 40 | ${catkin_INCLUDE_DIRS} 41 | ../car_hyp_despot/src/gamma/ 42 | ../car_hyp_despot/src/planner/ 43 | ../car_hyp_despot/src/HypDespot/include/ 44 | ../car_hyp_despot/src/HypDespot/include/despot 45 | ../crowd_pomdp_planner/src/ 46 | ) 47 | 48 | add_library(car_hyp_despot STATIC IMPORTED) 49 | set_target_properties(car_hyp_despot PROPERTIES 50 | IMPORTED_LOCATION ${CATKIN_DEVEL_PREFIX}/lib/libcar_hyp_despot.a 51 | ) 52 | set_target_properties(car_hyp_despot PROPERTIES 53 | IMPORTED_LINK_INTERFACE_LANGUAGES "CUDA" 54 | ) 55 | 56 | add_executable(ped_pomdp src/context_pomdp_node.cpp src/controller.cpp src/world_simulator.cpp) 57 | add_executable(local_frame src/local_frame.cpp) 58 | add_executable(vel_publisher src/vel_publisher.cpp) 59 | 60 | set_target_properties( ped_pomdp 61 | PROPERTIES CUDA_SEPARABLE_COMPILATION ON) 62 | set_target_properties( ped_pomdp 63 | PROPERTIES POSITION_INDEPENDENT_CODE ON) 64 | 65 | target_link_libraries(ped_pomdp 66 | car_hyp_despot 67 | ${catkin_LIBRARIES} 68 | ) 69 | 70 | target_link_libraries(local_frame 71 | car_hyp_despot 72 | ${catkin_LIBRARIES} 73 | ) 74 | 75 | target_link_libraries(vel_publisher 76 | car_hyp_despot 77 | ${catkin_LIBRARIES} 78 | ) 79 | -------------------------------------------------------------------------------- /crowd_pomdp_planner/is_despot_param.yaml: -------------------------------------------------------------------------------- 1 | ### for scooter 2 | # goalx: -175.5 3 | # goaly: -146.68 4 | 5 | # goalx: 18.0 6 | # goaly: 0.0 7 | 8 | fixed_path: false 9 | pruning_constant: 0 #100000000 10 | #pruning_constant: 1000000000 11 | #pathplan_ahead: 3.0 12 | pathplan_ahead: 1.5 13 | 14 | 15 | crash_penalty: -3000.0 16 | #reward_factor_vel: 0.5 17 | reward_factor_vel: 4 18 | reward_base_crash_vel: 0.5 19 | belief_smoothing: 0.05 20 | noise_robvel: 0.05 21 | noise_goal_angle_deg: 5 22 | max_vel: 6.0 23 | #collision_distance: 1.5 24 | collision_distance: 0.5 25 | infront_angle_deg: 70 26 | #places the car drives at (used for selecting goals of peds). 0: utown_small_fill. 1: inside smart office (my_create) 27 | driving_place: 0 28 | -------------------------------------------------------------------------------- /crowd_pomdp_planner/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | crowd_pomdp_planner 4 | 0.0.0 5 | The crowd_pomdp_planner package 6 | 7 | 8 | 9 | 10 | yuanfu 11 | 12 | 13 | 14 | 15 | 16 | TODO 17 | 18 | catkin 19 | nav_msgs 20 | rosconsole 21 | roscpp 22 | rospy 23 | sensor_msgs 24 | tf 25 | laser_geometry 26 | pnc_msgs 27 | geometry_msgs 28 | rosgraph_msgs 29 | visualization_msgs 30 | 31 | car_hyp_despot 32 | msg_builder 33 | 34 | nav_msgs 35 | rosconsole 36 | roscpp 37 | rospy 38 | sensor_msgs 39 | tf 40 | laser_geometry 41 | geometry_msgs 42 | rosgraph_msgs 43 | pnc_msgs 44 | visualization_msgs 45 | 46 | car_hyp_despot 47 | msg_builder 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /crowd_pomdp_planner/params.yaml: -------------------------------------------------------------------------------- 1 | # GOAL: after CREATE door 2 | goalx: -170.5 3 | goaly: -146.68 4 | 5 | # GOAL: some place inside SMART office 6 | #goalx: 6.54 7 | #goaly: 10.3 8 | 9 | # GOAL: cheers 10 | #goalx: 4.0 11 | #goaly: 9.0 12 | 13 | fixed_path: false 14 | pruning_constant: 0 15 | #pruning_constant: 1000000000 16 | #pathplan_ahead: 3.0 17 | pathplan_ahead: 1.5 18 | 19 | 20 | crash_penalty: -1000.0 21 | reward_factor_vel: 0.5 22 | reward_base_crash_vel: 0.5 23 | belief_smoothing: 0.05 24 | noise_robvel: 0.1 25 | noise_goal_angle_deg: 45 26 | max_vel: 1.5 27 | #collision_distance: 1.5 28 | collision_distance: 0.4 29 | infront_angle_deg: 70 30 | #places the car drives at (used for selecting goals of peds). 0: utown_small_fill. 1: inside smart office (my_create) 31 | driving_place: 0 32 | 33 | 34 | -------------------------------------------------------------------------------- /crowd_pomdp_planner/planner.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /crowd_pomdp_planner/planner_debug.launch: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /crowd_pomdp_planner/src/context_pomdp_node.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ContextPomdpNode.cpp 3 | * 4 | */ 5 | 6 | #include "context_pomdp_node.h" 7 | 8 | ContextPomdpNode::ContextPomdpNode(int argc, char** argv) { 9 | ROS_INFO("Starting Crowd-POMDP ..."); 10 | 11 | cerr << "DEBUG: Setting up subscription..." << endl; 12 | ros::NodeHandle nh; 13 | ros::NodeHandle n("~"); 14 | 15 | pathPublished = false; 16 | bool simulation; 17 | n.param("simulation", simulation, false); 18 | ModelParams::InitParams(simulation); 19 | cout << "simulation = " << simulation << endl; 20 | cout << "rosns = " << ModelParams::ROS_NS << endl; 21 | 22 | bool fixed_path; 23 | n.param("fixed_path", fixed_path, false); 24 | n.param("crash_penalty", ModelParams::CRASH_PENALTY, -1000.0); 25 | n.param("reward_base_crash_vel", ModelParams::REWARD_BASE_CRASH_VEL, 0.8); 26 | n.param("reward_factor_vel", ModelParams::REWARD_FACTOR_VEL, 1.0); 27 | n.param("belief_smoothing", ModelParams::BELIEF_SMOOTHING, 0.05); 28 | n.param("noise_robvel", ModelParams::NOISE_ROBVEL, 0.2); 29 | n.param("collision_distance", ModelParams::COLLISION_DISTANCE, 1.0); 30 | n.param("infront_angle_deg", ModelParams::IN_FRONT_ANGLE_DEG, 90.0); 31 | n.param("driving_place", ModelParams::DRIVING_PLACE, 0); 32 | 33 | std::cout << "before obstacle" << std::endl; 34 | std::cout << "before obstacle" << std::endl; 35 | 36 | double noise_goal_angle_deg; 37 | n.param("noise_goal_angle_deg", noise_goal_angle_deg, 45.0); 38 | ModelParams::NOISE_GOAL_ANGLE = noise_goal_angle_deg / 180.0 * M_PI; 39 | 40 | n.param("max_vel", ModelParams::VEL_MAX, 2.0); 41 | n.param("drive_mode", Controller::b_drive_mode, 0); 42 | n.param("gpu_id", Controller::gpu_id, 0); 43 | n.param("summit_port", Controller::summit_port, 0); 44 | n.param("time_scale", Controller::time_scale, 1.0); 45 | n.param("map_location", Controller::map_location, ""); 46 | 47 | cerr << "DEBUG: Params list: " << endl; 48 | cerr << "-drive_mode " << Controller::b_drive_mode << endl; 49 | cerr << "-time_scale " << Controller::time_scale << endl; 50 | cerr << "-summit_port " << Controller::summit_port << endl; 51 | cerr << "-map_location " << Controller::map_location << endl; 52 | 53 | controller = new Controller(nh, fixed_path); 54 | 55 | ModelParams::PrintParams(); 56 | 57 | logi << " ContextPomdpNode constructed at the " << Globals::ElapsedTime() 58 | << "th second" << endl; 59 | 60 | controller->RunPlanning(argc, argv); 61 | } 62 | 63 | int main(int argc, char** argv) { 64 | Globals::RecordStartTime(); 65 | srand(unsigned(time(0))); 66 | 67 | ros::init(argc, argv, "context_pomdp"); 68 | ContextPomdpNode context_pomdp_node(argc, argv); 69 | } 70 | -------------------------------------------------------------------------------- /crowd_pomdp_planner/src/context_pomdp_node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ContextPomdpNode.h 3 | * 4 | */ 5 | 6 | #ifndef CROWD_POMDP_H_ 7 | #define CROWD_POMDP_H_ 8 | 9 | #include "controller.h" 10 | 11 | class ContextPomdpNode 12 | { 13 | public: 14 | ContextPomdpNode(int argc, char** argv); 15 | ~ContextPomdpNode() {}; 16 | 17 | Controller* controller; 18 | 19 | bool pathPublished; 20 | }; 21 | 22 | #endif /* CROWD_POMDP_H_ */ 23 | -------------------------------------------------------------------------------- /crowd_pomdp_planner/src/controller.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CONTROLLER_H_ 3 | #define CONTROLLER_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "param.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include "world_model.h" 32 | #include "context_pomdp.h" 33 | #include "core/particle_belief.h" 34 | #include "solver/despot.h" 35 | #include 36 | #include "planner.h" 37 | 38 | class WorldSimulator; 39 | class POMDPSimulator; 40 | 41 | class CrowdBelief; 42 | 43 | using namespace std; 44 | 45 | class Controller: public Planner 46 | { 47 | private: 48 | 49 | WorldSimulator* summit_driving_simulator_; 50 | CrowdBelief* ped_belief_; 51 | DSPOMDP* model_; 52 | ContextPomdp* context_pomdp_; 53 | SolverPrior* prior_; 54 | 55 | ACT_TYPE last_action_; 56 | OBS_TYPE last_obs_; 57 | 58 | double control_freq_; 59 | 60 | ros::NodeHandle& nh_; 61 | ros::Subscriber pathSub_; 62 | ros::Timer timer_; 63 | 64 | public: 65 | 66 | Controller(ros::NodeHandle& nh, bool fixed_path); 67 | ~Controller(); 68 | 69 | private: 70 | 71 | void ControlLoop(const ros::TimerEvent &e); 72 | double StepReward(PomdpStateWorld& state, int action); 73 | 74 | void CreateDefaultPriors(DSPOMDP* model); 75 | DSPOMDP* InitializeModel(option::Option* options); 76 | World* InitializeWorld(std::string& world_type, DSPOMDP* model, option::Option* options); 77 | void InitializeDefaultParameters(); 78 | std::string ChooseSolver(); 79 | 80 | bool RunStep(despot::Solver* solver, World* world, Logger* logger); 81 | void PlanningLoop(despot::Solver*& solver, World* world, Logger* logger); 82 | 83 | public: 84 | int RunPlanning(int argc, char* argv[]); 85 | 86 | public: 87 | static int b_drive_mode; 88 | static int gpu_id; 89 | static int summit_port; 90 | static float time_scale; // scale down the speed of time, value < 1.0 91 | static std::string map_location; 92 | }; 93 | #endif /* CONTROLLER_H_ */ 94 | -------------------------------------------------------------------------------- /msg_builder/msg/ActionDistrib.msg: -------------------------------------------------------------------------------- 1 | std_msgs/Float32[] acc_probs 2 | std_msgs/Float32[] steer_probs 3 | std_msgs/Float32[] lane_probs 4 | std_msgs/Float32[] vel_probs 5 | -------------------------------------------------------------------------------- /msg_builder/msg/ActionReward.msg: -------------------------------------------------------------------------------- 1 | std_msgs/Float32 cur_speed 2 | std_msgs/Float32 target_speed 3 | std_msgs/Float32 acceleration_id 4 | std_msgs/Float32 steering_normalized 5 | std_msgs/Int32 lane_change 6 | std_msgs/Float32 step_reward 7 | 8 | -------------------------------------------------------------------------------- /msg_builder/msg/AgentPathArray.msg: -------------------------------------------------------------------------------- 1 | Header header 2 | AgentPaths[] agents 3 | -------------------------------------------------------------------------------- /msg_builder/msg/AgentPaths.msg: -------------------------------------------------------------------------------- 1 | # update time 2 | time last_update 3 | 4 | # general 5 | int32 id 6 | string type 7 | 8 | # intention (paths) 9 | bool reset_intention 10 | nav_msgs/Path[] path_candidates 11 | bool[] cross_dirs 12 | -------------------------------------------------------------------------------- /msg_builder/msg/CrowdNetworkAgent.msg: -------------------------------------------------------------------------------- 1 | uint32 id 2 | string type 3 | NetworkRoutePoint route_point 4 | -------------------------------------------------------------------------------- /msg_builder/msg/CrowdNetworkAgentArray.msg: -------------------------------------------------------------------------------- 1 | Header header 2 | CrowdNetworkAgent[] agents 3 | -------------------------------------------------------------------------------- /msg_builder/msg/CrowdSidewalkAgent.msg: -------------------------------------------------------------------------------- 1 | uint32 id 2 | string type 3 | SidewalkRoutePoint route_point 4 | bool route_orientation 5 | -------------------------------------------------------------------------------- /msg_builder/msg/CrowdSidewalkAgentArray.msg: -------------------------------------------------------------------------------- 1 | Header header 2 | CrowdSidewalkAgent[] agents 3 | -------------------------------------------------------------------------------- /msg_builder/msg/EulerAngles.msg: -------------------------------------------------------------------------------- 1 | float32 pitch 2 | float32 roll 3 | float32 yaw 4 | -------------------------------------------------------------------------------- /msg_builder/msg/EulerAnglesWithConfidence.msg: -------------------------------------------------------------------------------- 1 | EulerAngles angles 2 | int32 confidence 3 | -------------------------------------------------------------------------------- /msg_builder/msg/Frame.msg: -------------------------------------------------------------------------------- 1 | std_msgs/Header header 2 | int32 numberOfUsers 3 | User[] usersData 4 | -------------------------------------------------------------------------------- /msg_builder/msg/FrameTest.msg: -------------------------------------------------------------------------------- 1 | std_msgs/Header header 2 | sensor_msgs/Image colorImage 3 | Frame frameData 4 | -------------------------------------------------------------------------------- /msg_builder/msg/Gesture.msg: -------------------------------------------------------------------------------- 1 | int32 type 2 | geometry_msgs/Point32 vectorOrigin 3 | geometry_msgs/Vector3 pointingVector -------------------------------------------------------------------------------- /msg_builder/msg/Gestures.msg: -------------------------------------------------------------------------------- 1 | Pointing pointing 2 | Wave wave 3 | -------------------------------------------------------------------------------- /msg_builder/msg/InputImages.msg: -------------------------------------------------------------------------------- 1 | sensor_msgs/Image lane 2 | sensor_msgs/Image hist0 3 | sensor_msgs/Image hist1 4 | sensor_msgs/Image hist2 5 | sensor_msgs/Image hist3 6 | -------------------------------------------------------------------------------- /msg_builder/msg/Landmark.msg: -------------------------------------------------------------------------------- 1 | geometry_msgs/Point location 2 | geometry_msgs/Point32 realWorldCoordinates 3 | -------------------------------------------------------------------------------- /msg_builder/msg/LandmarksInfo.msg: -------------------------------------------------------------------------------- 1 | int32 confidence 2 | Landmark[] landmarks 3 | -------------------------------------------------------------------------------- /msg_builder/msg/LaneSeg.msg: -------------------------------------------------------------------------------- 1 | geometry_msgs/Point32 start 2 | geometry_msgs/Point32 end 3 | -------------------------------------------------------------------------------- /msg_builder/msg/Lanes.msg: -------------------------------------------------------------------------------- 1 | LaneSeg[] lane_segments 2 | -------------------------------------------------------------------------------- /msg_builder/msg/NetworkRoutePoint.msg: -------------------------------------------------------------------------------- 1 | string edge 2 | uint32 lane 3 | uint32 segment 4 | float32 offset 5 | -------------------------------------------------------------------------------- /msg_builder/msg/Obstacles.msg: -------------------------------------------------------------------------------- 1 | geometry_msgs/Polygon[] contours 2 | -------------------------------------------------------------------------------- /msg_builder/msg/PersonModuleState.msg: -------------------------------------------------------------------------------- 1 | #features enables/disabled states 2 | bool isRecognitionEnabled 3 | bool isSkeletonEnabled 4 | bool isGesturesEnabled 5 | bool isLandmarksEnabled 6 | bool isHeadBoundingBoxEnabled 7 | bool isHeadPoseEnabled 8 | bool isTrackingEnabled 9 | 10 | #additional states 11 | int32 trackingState 12 | 13 | int32 TRACKING_STATE_TRACKING=0 14 | int32 TRACKING_STATE_DETECTING=1 15 | -------------------------------------------------------------------------------- /msg_builder/msg/Pointing.msg: -------------------------------------------------------------------------------- 1 | int32 confidence 2 | geometry_msgs/Point32 originColor 3 | geometry_msgs/Point32 originWorld 4 | geometry_msgs/Point32 orientationColor 5 | geometry_msgs/Vector3 orientationWorld 6 | -------------------------------------------------------------------------------- /msg_builder/msg/PomdpCmd.msg: -------------------------------------------------------------------------------- 1 | float32 target_speed 2 | float32 cur_speed 3 | float32 acc 4 | float32 steer 5 | -------------------------------------------------------------------------------- /msg_builder/msg/RectWithConfidence.msg: -------------------------------------------------------------------------------- 1 | int32 confidence 2 | geometry_msgs/Point32[2] rectCorners 3 | -------------------------------------------------------------------------------- /msg_builder/msg/SidewalkRoutePoint.msg: -------------------------------------------------------------------------------- 1 | uint32 polygon_id 2 | uint32 segment_id 3 | float32 offset 4 | -------------------------------------------------------------------------------- /msg_builder/msg/SkeletonJoint.msg: -------------------------------------------------------------------------------- 1 | int32 type 2 | float32 confidence 3 | geometry_msgs/Point location 4 | geometry_msgs/Point32 realWorldCoordinates 5 | 6 | #joint types constants 7 | int32 JOINT_ANKLE_LEFT=0 8 | int32 JOINT_ANKLE_RIGHT=1 9 | int32 JOINT_ELBOW_LEFT=2 10 | int32 JOINT_ELBOW_RIGHT=3 11 | int32 JOINT_FOOT_LEFT=4 12 | int32 JOINT_FOOT_RIGHT=5 13 | int32 JOINT_HAND_LEFT=6 14 | int32 JOINT_HAND_RIGHT=7 15 | int32 JOINT_HAND_TIP_LEFT=8 16 | int32 JOINT_HAND_TIP_RIGHT=9 17 | int32 JOINT_HEAD=10 18 | int32 JOINT_HIP_LEFT=11 19 | int32 JOINT_HIP_RIGHT=12 20 | int32 JOINT_KNEE_LEFT=13 21 | int32 JOINT_KNEE_RIGHT=14 22 | int32 JOINT_NECK=15 23 | int32 JOINT_SHOULDER_LEFT=16 24 | int32 JOINT_SHOULDER_RIGHT=17 25 | int32 JOINT_SPINE_BASE=18 26 | int32 JOINT_SPINE_MID=19 27 | int32 JOINT_SPINE_SHOULDER=20 28 | int32 JOINT_THUMB_LEFT=21 29 | int32 JOINT_THUMB_RIGHT=22 30 | int32 JOINT_WRIST_LEFT=23 31 | int32 JOINT_WRIST_RIGHT=24 32 | int32 JOINT_UNKNOWN=25 33 | -------------------------------------------------------------------------------- /msg_builder/msg/StartGoal.msg: -------------------------------------------------------------------------------- 1 | geometry_msgs/PoseStamped start 2 | geometry_msgs/PoseStamped goal 3 | 4 | -------------------------------------------------------------------------------- /msg_builder/msg/TrafficAgent.msg: -------------------------------------------------------------------------------- 1 | # update time 2 | time last_update 3 | 4 | # general 5 | int32 id 6 | string type 7 | 8 | # geometric information 9 | geometry_msgs/Point32 vel 10 | geometry_msgs/Pose pose 11 | geometry_msgs/Polygon bbox 12 | 13 | -------------------------------------------------------------------------------- /msg_builder/msg/TrafficAgentArray.msg: -------------------------------------------------------------------------------- 1 | Header header 2 | TrafficAgent[] agents 3 | -------------------------------------------------------------------------------- /msg_builder/msg/User.msg: -------------------------------------------------------------------------------- 1 | UserInfo userInfo 2 | geometry_msgs/Point32 centerOfMassImage 3 | geometry_msgs/Point32 centerOfMassWorld 4 | RectWithConfidence userRect 5 | RectWithConfidence headBoundingBox 6 | LandmarksInfo landmarksInfo 7 | EulerAnglesWithConfidence headPose 8 | SkeletonJoint[] skeletonJoints 9 | Gestures gestures 10 | 11 | -------------------------------------------------------------------------------- /msg_builder/msg/UserInfo.msg: -------------------------------------------------------------------------------- 1 | int32 Id 2 | -------------------------------------------------------------------------------- /msg_builder/msg/Wave.msg: -------------------------------------------------------------------------------- 1 | int32 type 2 | 3 | #Wave gesture types 4 | int32 WAVE_NOT_DETECTED=-1 # Wave not detected 5 | int32 WAVE_LEFT_LA=1 # Wave ended with hand motion to the left, in the left area 6 | int32 WAVE_RIGHT_LA=2 # Wave ended with hand motion to the right, in the left area 7 | int32 WAVE_LEFT_RA=3 # Wave ended with hand motion to the left, in the right area 8 | int32 WAVE_RIGHT_RA=4 # Wave ended with hand motion to the right, in the right area 9 | 10 | -------------------------------------------------------------------------------- /msg_builder/msg/car_info.msg: -------------------------------------------------------------------------------- 1 | int32 id 2 | bool initial 3 | float32 max_steer_angle 4 | 5 | geometry_msgs/Point32 car_pos 6 | float32 car_yaw 7 | float32 car_speed 8 | float32 car_steer 9 | 10 | geometry_msgs/Vector3 car_vel 11 | geometry_msgs/Polygon car_bbox 12 | 13 | geometry_msgs/Point32 rear_axle_center 14 | geometry_msgs/Point32 front_axle_center 15 | -------------------------------------------------------------------------------- /msg_builder/msg/cluster.msg: -------------------------------------------------------------------------------- 1 | geometry_msgs/Point32[] points 2 | geometry_msgs/Point32 centroid 3 | float64 width 4 | float64 height 5 | float64 depth 6 | geometry_msgs/Point32[] projected_points 7 | float64 eigen1 8 | float64 eigen2 9 | float64 eigen3 10 | float64 projected_l1 11 | float64 projected_l2 12 | float64 projected_l3 13 | int64 id 14 | time last_update 15 | -------------------------------------------------------------------------------- /msg_builder/msg/clusters.msg: -------------------------------------------------------------------------------- 1 | Header header 2 | cluster[] s 3 | -------------------------------------------------------------------------------- /msg_builder/msg/imitation_data.msg: -------------------------------------------------------------------------------- 1 | car_info cur_car 2 | car_info past_car 3 | peds_info cur_peds 4 | peds_info past_peds 5 | ped_belief[] believes 6 | nav_msgs/Path plan 7 | ActionReward action_reward 8 | -------------------------------------------------------------------------------- /msg_builder/msg/ped_belief.msg: -------------------------------------------------------------------------------- 1 | int64 ped_id 2 | float64[] belief_value 3 | float64 ped_x 4 | float64 ped_y 5 | float64 rob_x 6 | float64 rob_y 7 | int64 action 8 | -------------------------------------------------------------------------------- /msg_builder/msg/ped_info.msg: -------------------------------------------------------------------------------- 1 | geometry_msgs/Point32 ped_pos 2 | int64 ped_id 3 | int64 ped_goal_id 4 | float32 ped_speed 5 | geometry_msgs/Point32 ped_vel 6 | float32 bb_x 7 | float32 bb_y 8 | float32 heading 9 | -------------------------------------------------------------------------------- /msg_builder/msg/ped_local_frame.msg: -------------------------------------------------------------------------------- 1 | int64 ped_id 2 | geometry_msgs/Point32 rob_pose 3 | geometry_msgs/Point32 ped_pose 4 | 5 | Header header 6 | 7 | int64 action 8 | -------------------------------------------------------------------------------- /msg_builder/msg/ped_local_frame_vector.msg: -------------------------------------------------------------------------------- 1 | ped_local_frame[] ped_local 2 | 3 | -------------------------------------------------------------------------------- /msg_builder/msg/pedestrian.msg: -------------------------------------------------------------------------------- 1 | 2 | cluster cluster 3 | geometry_msgs/Point32 local_centroid 4 | geometry_msgs/Point32 global_centroid 5 | 6 | # data association 7 | int32 object_label 8 | float32 confidence 9 | 10 | # update time 11 | time last_update 12 | 13 | -------------------------------------------------------------------------------- /msg_builder/msg/pedestrian_array.msg: -------------------------------------------------------------------------------- 1 | Header header 2 | pedestrian[] pd_vector 3 | -------------------------------------------------------------------------------- /msg_builder/msg/peds_believes.msg: -------------------------------------------------------------------------------- 1 | ped_belief[] believes 2 | float64 cmd_vel 3 | float64 robotx 4 | float64 roboty 5 | float64 robotv 6 | -------------------------------------------------------------------------------- /msg_builder/msg/peds_car_hist.msg: -------------------------------------------------------------------------------- 1 | peds_car_info cur 2 | peds_car_info past -------------------------------------------------------------------------------- /msg_builder/msg/peds_car_info.msg: -------------------------------------------------------------------------------- 1 | car_info car 2 | ped_info[] peds -------------------------------------------------------------------------------- /msg_builder/msg/peds_info.msg: -------------------------------------------------------------------------------- 1 | ped_info[] peds -------------------------------------------------------------------------------- /msg_builder/srv/TensorData.srv: -------------------------------------------------------------------------------- 1 | int32 batchsize 2 | float32[] tensor 3 | string mode 4 | --- 5 | float32[] value 6 | float32[] acc 7 | float32[] ang 8 | -------------------------------------------------------------------------------- /msg_builder/srv/TensorDataHybrid.srv: -------------------------------------------------------------------------------- 1 | int32 batchsize 2 | float32[] tensor 3 | string mode 4 | --- 5 | float32[] value 6 | float32[] acc_pi 7 | float32[] acc_mu 8 | float32[] acc_sigma 9 | float32[] ang 10 | -------------------------------------------------------------------------------- /scripts/check_optimal_params.py: -------------------------------------------------------------------------------- 1 | import glob 2 | 3 | vehicles = ['vehicle.volkswagen.t2', 4 | 'vehicle.bmw.isetta', 5 | 'vehicle.carlamotors.carlacola', 6 | 'vehicle.jeep.wrangler_rubicon', 7 | 'vehicle.nissan.patrol', 8 | 'vehicle.tesla.cybertruck', 9 | 'vehicle.yamaha.yzf', 10 | 'vehicle.bh.crossbike'] 11 | 12 | 13 | if __name__ == "__main__": 14 | for vehicle in vehicles: 15 | flag = vehicle.replace('.', '_') 16 | files = glob.glob(flag + '*.txt') 17 | best_max_error = 10000 18 | best_mean_error = 10000 19 | best_max_error_file = '' 20 | best_mean_error_file = '' 21 | for file_name in files: 22 | with open(file_name, 'r') as file: 23 | lines = file.readlines() 24 | max_error = float(lines[0]) 25 | mean_error = float(lines[1]) 26 | 27 | if max_error < best_max_error: 28 | best_max_error = max_error 29 | best_max_error_file = file_name 30 | 31 | if mean_error < best_mean_error: 32 | best_mean_error = mean_error 33 | best_mean_error_file = file_name 34 | 35 | best_mean_error_file = best_mean_error_file[-15:-4].replace('_',' ').split() 36 | best_max_error_file = best_max_error_file[-15:-4].replace('_',' ').split() 37 | 38 | # print('{} best_max_error: {} value {}'.format(vehicle, best_max_error_file, best_max_error)) 39 | print("model = '{}'\nself.KP = {}\nself.KI = {}\nself.KD = {}\nmean error {}".format(vehicle, best_mean_error_file[0], best_mean_error_file[1], best_mean_error_file[2], best_mean_error)) 40 | # print("model = '{}'\nKP = {}\nKI = {}\nKD = {}".format(vehicle, best_mean_error_file[0], best_mean_error_file[1], best_mean_error_file[2])) 41 | -------------------------------------------------------------------------------- /scripts/launch_docker.py: -------------------------------------------------------------------------------- 1 | import os 2 | from os.path import expanduser 3 | import subprocess 4 | 5 | home = expanduser("~") 6 | 7 | # catkin_ws_path = home + '/workspace/catkin_ws' 8 | catkin_ws_path = home + '/workspace/Context-POMDP' 9 | 10 | summit_path = home + "/summit" 11 | 12 | if not os.path.isdir(catkin_ws_path): 13 | catkin_ws_path = home + '/catkin_ws' 14 | 15 | result_path = home + '/driving_data' 16 | 17 | 18 | # check whether the folders exist: 19 | if not os.path.isdir(result_path): 20 | os.makedirs(result_path) 21 | print("Made result folder " + result_path) 22 | 23 | 24 | if __name__ == '__main__': 25 | import argparse 26 | 27 | parser = argparse.ArgumentParser() 28 | 29 | parser.add_argument('--image', 30 | type=str, 31 | default="cppmayo/melodic_cuda10_1_cudnn7_libtorch_opencv4_ws", 32 | help='Image to launch') 33 | parser.add_argument('--port', 34 | type=int, 35 | default=2000, 36 | help='summit_port') 37 | parser.add_argument('--gpu', 38 | type=int, 39 | default=0, 40 | help='GPU to use') 41 | parser.add_argument('--recordbag', 42 | type=int, 43 | default=0, 44 | help='record ros bags') 45 | parser.add_argument('--mode', 46 | type=str, 47 | default='joint_pomdp', 48 | help='driving mode') 49 | 50 | 51 | config = parser.parse_args() 52 | 53 | additional_mounts = "-v " + catkin_ws_path + ":/root/catkin_ws -v " + summit_path + ":/root/summit " 54 | 55 | cmd_args = "docker run --rm --runtime=nvidia -it --network host " + \ 56 | "-v " + result_path + ":/root/driving_data " + \ 57 | additional_mounts + \ 58 | "-e DISPLAY=${DISPLAY} -v /tmp/.X11-unix:/tmp/.X11-unix " + \ 59 | config.image + " " + str(config.gpu) + " " + str(config.port) \ 60 | + " " + str(config.recordbag) + " " + str(config.mode) 61 | 62 | print(cmd_args) 63 | subprocess.call(cmd_args.split()) 64 | -------------------------------------------------------------------------------- /scripts/summit_simulator.py: -------------------------------------------------------------------------------- 1 | from multiprocessing import Process 2 | import collections 3 | import sys 4 | from os.path import expanduser 5 | 6 | summit_scripts = expanduser("~/summit/PythonAPI/examples") 7 | sys.path.append(summit_scripts) 8 | import gamma_crowd, spawn_imagery, spawn_meshes 9 | 10 | 11 | def print_flush(msg): 12 | print(msg) 13 | sys.stdout.flush() 14 | 15 | 16 | class SimulatorAccessories(Process): 17 | def __init__(self, cmd_args, config): 18 | Process.__init__(self) 19 | self.verbosity = config.verbosity 20 | 21 | Args = collections.namedtuple('args', 'host port pyroport dataset num_car num_bike num_pedestrian seed collision' 22 | ' clearance_car clearance_bike clearance_pedestrian' 23 | ' speed_car speed_bike speed_pedestrian' 24 | ' lane_change_probability cross_probability stuck_speed stuck_duration') 25 | 26 | # Spawn meshes. 27 | self.args = Args( 28 | host='127.0.0.1', 29 | port=cmd_args.port, 30 | pyroport = config.pyro_port, 31 | dataset=config.summit_maploc, 32 | num_car=cmd_args.num_car, 33 | num_bike=cmd_args.num_bike, 34 | num_pedestrian=cmd_args.num_pedestrian, 35 | speed_car=4.0, 36 | speed_bike=2.0, 37 | speed_pedestrian=1.0, 38 | seed=-1, 39 | collision=False, 40 | clearance_car=7.0, 41 | clearance_bike=7.0, 42 | clearance_pedestrian=1.0, 43 | lane_change_probability=0.0, 44 | cross_probability=0.1, 45 | stuck_speed=0.2, 46 | stuck_duration=5.0) 47 | 48 | def run(self): 49 | if self.verbosity > 0: 50 | print_flush("[summit_simulator.py] spawning meshes") 51 | spawn_meshes.main(self.args) 52 | 53 | # Spawn imagery. 54 | if self.verbosity > 0: 55 | print_flush("[summit_simulator.py] spawning imagery") 56 | spawn_imagery.main(self.args) 57 | 58 | # Spawn crowd. 59 | if self.verbosity > 0: 60 | print_flush("[summit_simulator.py] Spawning crowd") 61 | gamma_crowd.main(self.args) 62 | -------------------------------------------------------------------------------- /scripts/timeout.py: -------------------------------------------------------------------------------- 1 | import time 2 | import subprocess 3 | from multiprocessing import Process 4 | 5 | 6 | class TimeoutMonitor(Process): 7 | def __init__(self, pid, timeout, name, verbosity=1): 8 | Process.__init__(self) 9 | self.monitor_pid = pid 10 | self.verbosity = verbosity 11 | self.timeout = timeout 12 | self.proc_name = name 13 | 14 | def run(self): 15 | time.sleep(self.timeout) 16 | subprocess.call('kill ' + str(self.monitor_pid), shell=True) 17 | print("timeout: terminate {} script".format(self.proc_name)) 18 | self.terminate() 19 | -------------------------------------------------------------------------------- /scripts/timeout_inner.py: -------------------------------------------------------------------------------- 1 | from clear_process import clear_process 2 | import sys 3 | import time 4 | 5 | 6 | if __name__ == '__main__': 7 | arg_len = len(sys.argv) 8 | assert(arg_len > 1) 9 | sleep_time = int(sys.argv[1]) 10 | 11 | time.sleep(sleep_time) 12 | 13 | print("timeout_inner: ./clear_process.sh") 14 | 15 | clear_process() -------------------------------------------------------------------------------- /setup/install_opencv4.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get update \ 2 | && sudo apt-get install -y \ 3 | build-essential \ 4 | git \ 5 | wget \ 6 | vim \ 7 | unzip \ 8 | yasm \ 9 | pkg-config \ 10 | libswscale-dev \ 11 | libtbb2 \ 12 | libtbb-dev \ 13 | libjpeg-dev \ 14 | libpng-dev \ 15 | libtiff-dev \ 16 | libavformat-dev \ 17 | libpq-dev 18 | 19 | pip3 install numpy 20 | 21 | cd 22 | export OPENCV_VERSION="4.1.0" 23 | wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip \ 24 | && unzip ${OPENCV_VERSION}.zip \ 25 | && mkdir opencv-${OPENCV_VERSION}/cmake_binary \ 26 | && cd opencv-${OPENCV_VERSION}/cmake_binary \ 27 | && cmake -DBUILD_TIFF=ON \ 28 | -DBUILD_opencv_java=OFF \ 29 | -DWITH_CUDA=OFF \ 30 | -DWITH_OPENGL=ON \ 31 | -DWITH_OPENCL=ON \ 32 | -DWITH_IPP=ON \ 33 | -DWITH_TBB=ON \ 34 | -DWITH_EIGEN=ON \ 35 | -DWITH_V4L=ON \ 36 | -DBUILD_TESTS=OFF \ 37 | -DBUILD_PERF_TESTS=OFF \ 38 | -DCMAKE_BUILD_TYPE=RELEASE \ 39 | -DCMAKE_INSTALL_PREFIX=$(python3.6 -c "import sys; print(sys.prefix)") \ 40 | -DPYTHON_EXECUTABLE=$(which python3.6) \ 41 | -DPYTHON_INCLUDE_DIR=$(python3.6 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ 42 | -DPYTHON_PACKAGES_PATH=$(python3.6 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \ 43 | .. \ 44 | && sudo make install 45 | cd && sudo rm -f ${OPENCV_VERSION}.zip \ 46 | && sudo rm -rf opencv-${OPENCV_VERSION} 47 | sudo find / -name "site-packages" -type d 48 | ls /usr/local/lib/python3.6/dist-packages 49 | sudo ln -sf \ 50 | /usr/lib/python3.6/dist-packages/cv2/python-3.6/cv2.cpython-36m-x86_64-linux-gnu.so \ 51 | /usr/local/lib/python3.6/dist-packages/cv2.so 52 | -------------------------------------------------------------------------------- /setup/install_ros_melodic.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get update && sudo apt-get install -y --no-install-recommends \ 2 | dirmngr \ 3 | gnupg2 4 | 5 | # setup sources.list 6 | sudo echo "deb http://packages.ros.org/ros/ubuntu bionic main" > /etc/apt/sources.list.d/ros-latest.list 7 | 8 | # setup keys 9 | sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 10 | 11 | # setup environment 12 | export LANG=C.UTF-8 13 | export LC_ALL=C.UTF-8 14 | 15 | # install ros packages 16 | export ROS_DISTRO=melodic 17 | sudo apt-get update && sudo apt-get install -y \ 18 | ros-melodic-desktop-full ros-melodic-navigation 19 | 20 | # bootstrap rosdep 21 | rosdep init \ 22 | && rosdep update 23 | 24 | # install bootstrap tools 25 | sudo apt-get update && sudo apt-get install --no-install-recommends -y \ 26 | python-rosdep \ 27 | python-rosinstall \ 28 | python-catkin-tools \ 29 | python-vcstools 30 | -------------------------------------------------------------------------------- /setup/install_torch.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get -y update && apt-get -y upgrade 2 | sudo apt-get -y install g++ git libgflags-dev libgoogle-glog-dev \ 3 | libomp5 libomp-dev libiomp-dev libopenmpi-dev protobuf-compiler \ 4 | python3 python3-pip python3-setuptools python3-yaml wget 5 | 6 | # Install CMake 3.14 7 | 8 | CMAKE=cmake-3.14.1.tar.gz 9 | CMAKE_FOLDER=cmake-3.14.1 10 | cd && wget https://github.com/Kitware/CMake/releases/download/v3.14.1/${CMAKE} 11 | tar xvzf ${CMAKE} && rm ${CMAKE} && cd ${CMAKE_FOLDER} && ./bootstrap --parallel=$(nproc) 12 | make -j$(nproc) && sudo make install 13 | 14 | # Intel MKL installation 15 | 16 | cd && wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB 17 | sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && rm GPG-PUB* 18 | sudo sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list' 19 | sudo apt-get update && sudo apt-get -y install intel-mkl-64bit-2019.1-053 20 | sudo rm /opt/intel/mkl/lib/intel64/*.so 21 | 22 | # Download and build libtorch with MKL support 23 | 24 | export TORCH_CUDA_ARCH_LIST="5.2 6.0 6.1 7.0 7.5" 25 | echo TORCH_CUDA_ARCH_LIST: $TORCH_CUDA_ARCH_LIST 26 | export TORCH_NVCC_FLAGS="-Xfatbin -compress-all" 27 | cd && git clone --recurse-submodules -j8 https://github.com/pytorch/pytorch.git 28 | 29 | # Compile libtorch and install 30 | cd && cd pytorch && mkdir -p build && cd build && BUILD_TEST=OFF USE_NCCL=OFF python3 ../tools/build_libtorch.py 31 | cd && mkdir -p ~/libtorch/include && mkdir -p ~/libtorch/share 32 | cp -r pytorch/build/build/lib ~/libtorch 33 | cp -r pytorch/torch/share/cmake ~/libtorch/share/cmake 34 | for dir in ATen c10 caffe2 torch; do cp -r pytorch/torch/include/$dir ~/libtorch/include; done 35 | 36 | # Compile pytorch and install 37 | pip3 install pyyaml mkl mkl-include setuptools cffi typing 38 | cd && cd pytorch && sudo python3 setup.py install 39 | -------------------------------------------------------------------------------- /setup/requirements_python2.txt: -------------------------------------------------------------------------------- 1 | gdb 2 | matplotlib 3 | psutil 4 | Pyro4 5 | pathlib2 6 | -------------------------------------------------------------------------------- /setup/requirements_python3.txt: -------------------------------------------------------------------------------- 1 | pdb 2 | matplotlib 3 | psutil 4 | Pyro4 5 | pathlib 6 | -------------------------------------------------------------------------------- /setup/setup.sh: -------------------------------------------------------------------------------- 1 | # Pre requisites: 2 | # * CUDA 10.0 3 | # * CUDNN 7 4 | # This setu has only be testes for ubuntu18.04 5 | ## 6 | 7 | echo "========================Installing ROS=========================" 8 | bash install_ros_melodic.sh 9 | echo "========================Installing Torch=========================" 10 | bash install_torch.sh 11 | echo "========================Installing OpenCV=========================" 12 | bash install_opencv4.sh 13 | 14 | if [ -d "~/catkin_ws/src/car_hyp_despot" ] 15 | then 16 | echo "Directory car_hyp_despot exists, not cloning LeTS-Drive-SUMMIT repository." 17 | else 18 | mkdir -p catkin_ws/src 19 | # cd catkin_ws && catkin_make 20 | 21 | cd src 22 | git clone https://github.com/cindycia/LeTS-Drive-SUMMIT.git 23 | mv LeTS-Drive-SUMMIT/* . 24 | mv LeTS-Drive-SUMMIT/.git . 25 | rm -r LeTS-Drive-SUMMIT 26 | fi 27 | 28 | cd catkin_ws/src/IL_contoller && pip install -r requirements.txt 29 | -------------------------------------------------------------------------------- /summit_connector/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(summit_connector) 3 | 4 | find_package(catkin REQUIRED COMPONENTS 5 | rospy 6 | std_msgs 7 | geometry_msgs 8 | nav_msgs 9 | ) 10 | 11 | catkin_package( 12 | CATKIN_DEPENDS 13 | rospy 14 | std_msgs 15 | geometry_msgs 16 | nav_msgs 17 | msg_builder 18 | ) 19 | 20 | include_directories( 21 | ${catkin_INCLUDE_DIRS} 22 | ) 23 | -------------------------------------------------------------------------------- /summit_connector/launch/connector.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 44 | 45 | -------------------------------------------------------------------------------- /summit_connector/launch/indian_cross_16_8_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdaCompNUS/context-pomdp/8a8601c53e68a584b72a133e51e0b14b776474fa/summit_connector/launch/indian_cross_16_8_16.png -------------------------------------------------------------------------------- /summit_connector/launch/map.yaml: -------------------------------------------------------------------------------- 1 | image: indian_cross_16_8_16.png 2 | resolution: 0.0390625 3 | origin: [-20.0, -20.0, 0.000000] 4 | negate: 0 5 | occupied_thresh: 0.65 6 | free_thresh: 0.196 7 | 8 | -------------------------------------------------------------------------------- /summit_connector/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | summit_connector 4 | 0.0.0 5 | The summit_connector package 6 | panpan 7 | TODO 8 | catkin 9 | nav_msgs 10 | geometry_msgs 11 | rospy 12 | std_msgs 13 | crowd_pomdp_planner 14 | msg_builder 15 | nav_msgs 16 | geometry_msgs 17 | rospy 18 | std_msgs 19 | crowd_pomdp_planner 20 | msg_builder 21 | nav_msgs 22 | geometry_msgs 23 | rospy 24 | std_msgs 25 | crowd_pomdp_planner 26 | joy 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /videodev.h: -------------------------------------------------------------------------------- 1 | ../libv4l1-videodev.h --------------------------------------------------------------------------------