├── .gitignore
├── .make
├── README.html
├── README.md
├── beautify-settings.mk
├── beautify.mk
├── build.mk
├── mappings.imp
├── problem-template.mk
├── stack.mk
├── template.mk
└── uncrustify.cfg
├── .ros-scripts
├── .rosinstall
├── build_boost_148.sh
├── build_vrep_plugin.sh
├── get_boost_148.sh
├── patch_boost_148.sh
└── run.sh
├── CMakeLists.txt
├── Makefile
├── README.html
├── README.md
├── docs
├── .scripts
│ ├── make-links.sh
│ └── make-ref-links.sh
├── Doxyfile
├── Makefile
├── Making_A_New_Model.html
├── Making_A_New_Model.md
├── Overview.html
├── Overview.md
├── ROS_VREP_Guide.html
├── ROS_VREP_Guide.md
├── doxygen_links
│ ├── Build_System.md
│ ├── New_Model.md
│ ├── Overview.md
│ ├── Quick_Start.md
│ └── Ros_Tag.md
└── style.css
├── launch
└── tag.launch
├── license
├── BSD.txt
├── GPL-2.0.txt
├── MIT.txt
└── license.txt
├── msg
└── VrepInfo.msg
├── package.xml
├── problems
├── Makefile
├── conttag
│ ├── Makefile
│ ├── default.cfg
│ └── maps
│ │ ├── map.txt
│ │ └── map_tag.txt
├── homecare
│ ├── Makefile
│ ├── changes
│ │ └── change.txt
│ ├── default.cfg
│ └── maps
│ │ ├── pathMap.txt
│ │ └── typeMap.txt
├── pushbox
│ ├── Makefile
│ ├── default.cfg
│ └── maps
│ │ └── map_free_paper.txt
├── rocksample
│ ├── Makefile
│ ├── changes
│ │ ├── changes-11-11.txt
│ │ ├── changes-7-8.txt
│ │ ├── changes.txt
│ │ └── changes2.txt
│ ├── default-11-11.cfg
│ ├── default.cfg
│ └── maps
│ │ ├── map-11-11.txt
│ │ ├── map-7-1.txt
│ │ ├── map-7-2.txt
│ │ ├── map-7-3.txt
│ │ ├── map-7-8-obstacles.txt
│ │ └── map-7-8.txt
└── tag
│ ├── Makefile
│ ├── changes
│ ├── mid-wall.txt
│ └── tag-changes.txt
│ ├── default.cfg
│ ├── maps
│ └── map.txt
│ └── vrep_scenes
│ └── tag.ttt
├── src
├── LinkedHashSet.hpp
├── Makefile
├── RandomAccessSet.hpp
├── check_headers.sh
├── defs.hpp
├── global.cpp
├── global.hpp
├── options
│ ├── Makefile
│ ├── inih
│ │ ├── LICENSE.txt
│ │ ├── Makefile
│ │ ├── README.txt
│ │ ├── ini.c
│ │ └── ini.h
│ ├── option_parser.cpp
│ ├── option_parser.hpp
│ └── tclap
│ │ ├── AUTHORS
│ │ ├── Arg.h
│ │ ├── ArgException.h
│ │ ├── ArgTraits.h
│ │ ├── COPYING
│ │ ├── CmdLine.h
│ │ ├── CmdLineInterface.h
│ │ ├── CmdLineOutput.h
│ │ ├── Constraint.h
│ │ ├── DocBookOutput.h
│ │ ├── HelpVisitor.h
│ │ ├── IgnoreRestVisitor.h
│ │ ├── MultiArg.h
│ │ ├── MultiSwitchArg.h
│ │ ├── OptionalUnlabeledTracker.h
│ │ ├── StandardTraits.h
│ │ ├── StdOutput.h
│ │ ├── SwitchArg.h
│ │ ├── UnlabeledMultiArg.h
│ │ ├── UnlabeledValueArg.h
│ │ ├── ValueArg.h
│ │ ├── ValuesConstraint.h
│ │ ├── VersionVisitor.h
│ │ ├── Visitor.h
│ │ ├── XorHandler.h
│ │ └── ZshCompletionOutput.h
├── problems
│ ├── Makefile
│ ├── conttag
│ │ ├── ContTagAction.hpp
│ │ ├── ContTagModel.cpp
│ │ ├── ContTagModel.hpp
│ │ ├── ContTagObservation.hpp
│ │ ├── ContTagOptions.hpp
│ │ ├── ContTagPosition.hpp
│ │ ├── ContTagState.hpp
│ │ ├── ContTagTextSerializer.cpp
│ │ ├── ContTagTextSerializer.hpp
│ │ ├── Makefile
│ │ ├── map2d.hpp
│ │ ├── simulate.cpp
│ │ └── solve.cpp
│ ├── homecare
│ │ ├── HomecareAction.cpp
│ │ ├── HomecareAction.hpp
│ │ ├── HomecareModel.cpp
│ │ ├── HomecareModel.hpp
│ │ ├── HomecareObservation.cpp
│ │ ├── HomecareObservation.hpp
│ │ ├── HomecareOptions.hpp
│ │ ├── HomecareState.cpp
│ │ ├── HomecareState.hpp
│ │ ├── HomecareTextSerializer.cpp
│ │ ├── HomecareTextSerializer.hpp
│ │ ├── Makefile
│ │ ├── simulate.cpp
│ │ ├── solve.cpp
│ │ └── stest.cpp
│ ├── pushbox
│ │ ├── Action2d.hpp
│ │ ├── BearingObservation.hpp
│ │ ├── Makefile
│ │ ├── Map2d.hpp
│ │ ├── Position2d.hpp
│ │ ├── PushBoxModel.cpp
│ │ ├── PushBoxModel.hpp
│ │ ├── PushBoxOptions.hpp
│ │ ├── PushBoxTextSerializer.cpp
│ │ ├── PushBoxTextSerializer.hpp
│ │ ├── StateRobotWithOpponent2d.hpp
│ │ ├── TruncatedNormalDistribution.hpp
│ │ ├── simulate.cpp
│ │ └── solve.cpp
│ ├── rocksample
│ │ ├── LegalActionsPool.cpp
│ │ ├── LegalActionsPool.hpp
│ │ ├── Makefile
│ │ ├── PreferredActionsPool.cpp
│ │ ├── PreferredActionsPool.hpp
│ │ ├── RockSampleAction.cpp
│ │ ├── RockSampleAction.hpp
│ │ ├── RockSampleMdpSolver.cpp
│ │ ├── RockSampleMdpSolver.hpp
│ │ ├── RockSampleModel.cpp
│ │ ├── RockSampleModel.hpp
│ │ ├── RockSampleObservation.cpp
│ │ ├── RockSampleObservation.hpp
│ │ ├── RockSampleOptions.hpp
│ │ ├── RockSampleState.cpp
│ │ ├── RockSampleState.hpp
│ │ ├── RockSampleTextSerializer.cpp
│ │ ├── RockSampleTextSerializer.hpp
│ │ ├── position_history.cpp
│ │ ├── position_history.hpp
│ │ ├── simulate.cpp
│ │ ├── smart_history.cpp
│ │ ├── smart_history.hpp
│ │ ├── solve.cpp
│ │ └── stest.cpp
│ ├── shared
│ │ ├── GridPosition.hpp
│ │ ├── Makefile
│ │ ├── ModelWithProgramOptions.hpp
│ │ ├── SharedOptions.hpp
│ │ ├── geometry
│ │ │ ├── Makefile
│ │ │ ├── Point2D.cpp
│ │ │ ├── Point2D.hpp
│ │ │ ├── RTree.cpp
│ │ │ ├── RTree.hpp
│ │ │ ├── Rectangle2D.cpp
│ │ │ ├── Rectangle2D.hpp
│ │ │ ├── Vector2D.cpp
│ │ │ ├── Vector2D.hpp
│ │ │ ├── utilities.cpp
│ │ │ └── utilities.hpp
│ │ ├── parsers.cpp
│ │ ├── parsers.hpp
│ │ ├── policy_iteration.cpp
│ │ ├── policy_iteration.hpp
│ │ ├── ros
│ │ │ ├── ScanToPcl.cpp
│ │ │ ├── TapirNode.hpp
│ │ │ ├── VrepHelper.cpp
│ │ │ └── VrepHelper.hpp
│ │ ├── simulate.hpp
│ │ ├── solve.hpp
│ │ └── stest.hpp
│ └── tag
│ │ ├── Makefile
│ │ ├── TagAction.cpp
│ │ ├── TagAction.hpp
│ │ ├── TagMdpSolver.cpp
│ │ ├── TagMdpSolver.hpp
│ │ ├── TagModel.cpp
│ │ ├── TagModel.hpp
│ │ ├── TagObservation.cpp
│ │ ├── TagObservation.hpp
│ │ ├── TagOptions.hpp
│ │ ├── TagState.cpp
│ │ ├── TagState.hpp
│ │ ├── TagTextSerializer.cpp
│ │ ├── TagTextSerializer.hpp
│ │ ├── ros
│ │ ├── TagNode.cpp
│ │ └── TagNode.hpp
│ │ ├── simulate.cpp
│ │ ├── solve.cpp
│ │ └── stest.cpp
└── solver
│ ├── ActionNode.cpp
│ ├── ActionNode.hpp
│ ├── Agent.cpp
│ ├── Agent.hpp
│ ├── BeliefNode.cpp
│ ├── BeliefNode.hpp
│ ├── BeliefTree.cpp
│ ├── BeliefTree.hpp
│ ├── Histories.cpp
│ ├── Histories.hpp
│ ├── HistoryEntry.cpp
│ ├── HistoryEntry.hpp
│ ├── HistorySequence.cpp
│ ├── HistorySequence.hpp
│ ├── Makefile
│ ├── Simulator.cpp
│ ├── Simulator.hpp
│ ├── Solver.cpp
│ ├── Solver.hpp
│ ├── StateInfo.cpp
│ ├── StateInfo.hpp
│ ├── StatePool.cpp
│ ├── StatePool.hpp
│ ├── abstract-problem
│ ├── Action.hpp
│ ├── DiscretizedPoint.cpp
│ ├── DiscretizedPoint.hpp
│ ├── HistoricalData.hpp
│ ├── Makefile
│ ├── Model.cpp
│ ├── Model.hpp
│ ├── ModelChange.hpp
│ ├── Observation.hpp
│ ├── Options.hpp
│ ├── Point.hpp
│ ├── State.hpp
│ ├── TransitionParameters.hpp
│ ├── Vector.cpp
│ ├── Vector.hpp
│ ├── VectorState.hpp
│ └── heuristics
│ │ ├── HeuristicFunction.hpp
│ │ ├── Makefile
│ │ ├── RolloutHeuristic.cpp
│ │ └── RolloutHeuristic.hpp
│ ├── belief-estimators
│ ├── Makefile
│ ├── estimators.cpp
│ └── estimators.hpp
│ ├── cached_values.hpp
│ ├── changes
│ ├── ChangeFlags.hpp
│ ├── DefaultHistoryCorrector.cpp
│ ├── DefaultHistoryCorrector.hpp
│ ├── HistoryCorrector.hpp
│ └── Makefile
│ ├── indexing
│ ├── FlaggingVisitor.cpp
│ ├── FlaggingVisitor.hpp
│ ├── Makefile
│ ├── RTree.cpp
│ ├── RTree.hpp
│ ├── SpatialIndexVisitor.cpp
│ ├── SpatialIndexVisitor.hpp
│ └── StateIndex.hpp
│ ├── mappings
│ ├── Makefile
│ ├── actions
│ │ ├── ActionMapping.hpp
│ │ ├── ActionMappingEntry.hpp
│ │ ├── ActionPool.hpp
│ │ ├── Makefile
│ │ ├── continuous_actions.cpp
│ │ ├── continuous_actions.hpp
│ │ ├── discretized_actions.cpp
│ │ ├── discretized_actions.hpp
│ │ ├── enumerated_actions.cpp
│ │ └── enumerated_actions.hpp
│ └── observations
│ │ ├── Makefile
│ │ ├── ObservationMapping.hpp
│ │ ├── ObservationMappingEntry.hpp
│ │ ├── ObservationPool.hpp
│ │ ├── approximate_observations.cpp
│ │ ├── approximate_observations.hpp
│ │ ├── discrete_observations.cpp
│ │ ├── discrete_observations.hpp
│ │ ├── enumerated_observations.cpp
│ │ └── enumerated_observations.hpp
│ ├── search
│ ├── Makefile
│ ├── MultipleStrategiesExp3.cpp
│ ├── MultipleStrategiesExp3.hpp
│ ├── SearchStatus.hpp
│ ├── action-choosers
│ │ ├── Makefile
│ │ ├── choosers.cpp
│ │ ├── choosers.hpp
│ │ ├── gps_choosers.cpp
│ │ └── gps_choosers.hpp
│ ├── search_interface.cpp
│ ├── search_interface.hpp
│ └── steppers
│ │ ├── Makefile
│ │ ├── default_rollout.cpp
│ │ ├── default_rollout.hpp
│ │ ├── gps_search.cpp
│ │ ├── gps_search.hpp
│ │ ├── nn_rollout.cpp
│ │ ├── nn_rollout.hpp
│ │ ├── ucb_search.cpp
│ │ └── ucb_search.hpp
│ └── serialization
│ ├── Makefile
│ ├── Serializer.hpp
│ ├── TextSerializer.cpp
│ └── TextSerializer.hpp
└── srv
├── simRosCopyPasteObjects.srv
├── simRosGetObjectHandle.srv
├── simRosGetObjectPose.srv
├── simRosLoadScene.srv
├── simRosSetObjectPosition.srv
├── simRosStartSimulation.srv
└── simRosStopSimulation.srv
/.gitignore:
--------------------------------------------------------------------------------
1 | # Eclipse settings
2 | /.cproject
3 | /.project
4 | /.settings
5 | /EMPTY_HEADER.hpp
6 |
7 | # Local configuration settings
8 | /*local.make
9 |
10 | # Boost 1.48 built from source
11 | boost_1_48_0
12 |
13 | # Automatically generated documentation
14 | docs/html
15 | docs/generated
16 |
17 | # Binaries
18 | /builds
19 | /build
20 | simulate-ros
21 | simulate
22 | solve
23 | solve-mdp
24 | stest
25 |
26 | # Logging outputs
27 | core
28 | *.log
29 | *.pol
30 | *.pol2
31 | *.m
32 | *.prof
33 |
34 | # backup files
35 | *~
36 |
--------------------------------------------------------------------------------
/.make/beautify-settings.mk:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------
2 | # Configuration of code cleaners.
3 | # ----------------------------------------------------------------------
4 | BEAUTIFY_CFG := $(ROOT)/.make/uncrustify.cfg
5 | BEAUTIFY_CMD := uncrustify -c $(BEAUTIFY_CFG)
6 | BEAUTIFY_FLAGS := --no-backup
7 |
8 | IWYU_MAPPING_FILE := $(ROOT)/.make/mappings.imp
9 | IWYU_CMD := include-what-you-use
10 | IWYU_FLAGS := -Xiwyu --mapping_file=$(IWYU_MAPPING_FILE) -Xiwyu --verbose=3
11 |
12 | IWYU_FIX_CMD := fix-includes
13 | IWYU_FIX_FLAGS := --separate_c_cxx
14 | IWYU_FIX_FLAGS += --nosafe_headers --comments $(INCDIRS)
15 | IWYU_FIX_FLAGS += -o $(dir $@)
16 |
17 | # ----------------------------------------------------------------------
18 | # Code cleaner recipes.
19 | # ----------------------------------------------------------------------
20 | BEAUTIFY_RECIPE := $(BEAUTIFY_CMD) $(BEAUTIFY_FLAGS) $<
21 | IWYU_CXX_RECIPE := $(IWYU_CMD) $(IWYU_FLAGS) $(CPPFLAGS) $(CXXFLAGS_BASE) $< 2>&1 | tee $@
22 | IWYU_CC_RECIPE := $(IWYU_CMD) $(IWYU_FLAGS) $(CPPFLAGS) $(CFLAGS) $< 2>&1 | tee $@
23 | IWYU_FIX_RECIPE := $(IWYU_FIX_CMD) $(IWYU_FIX_FLAGS) < $< 2>&1 | tee $@
24 | IWYU_FORCE_RECIPE := echo "\#include \"../EMPTY_HEADER.hpp\"" >> $<
25 | IWYU_DOFIX_RECIPE := cp -p $(dir $@)/$* $<
26 |
27 | # ----------------------------------------------------------------------
28 | # Code cleaning targets.
29 | # ----------------------------------------------------------------------
30 | .PHONY: beautify-all iwyu-all iwyu-fix-all iwyu-force-all iwyu-dofix-all iwyu-clean-all
31 | .PHONY: beautify iwyu iwyu-fix iwyu-force iwyu-dofix iwyu-clean
32 |
33 | beautify: beautify-all ;
34 | iwyu: iwyu-all ;
35 | iwyu-fix: iwyu-fix-all ;
36 | iwyu-force: iwyu-force-all ;
37 | iwyu-dofix: iwyu-dofix-all ;
38 | iwyu-clean: iwyu-clean-all ;
39 |
40 | iwyu-clean-all:
41 | @rm -rf iwyu-out
42 | clean: iwyu-clean-all
43 |
--------------------------------------------------------------------------------
/.make/build.mk:
--------------------------------------------------------------------------------
1 | # Include a configuration for building just the object files
2 | build-$(MODULE_NAME): $$(OBJS_$(MODULE_NAME))
3 |
--------------------------------------------------------------------------------
/.make/stack.mk:
--------------------------------------------------------------------------------
1 | sp := $(sp).x
2 | dirstack_$(sp) := $(d)
3 | d := $(dir)
4 |
5 | # Default: name=directory; no children.
6 | MODULE_NAME := $(d)
7 | CHILD_DIRS :=
8 |
9 | include $(d)/Makefile
10 | NAME_$(d) := $(MODULE_NAME)
11 | CHILD_DIRS_$(MODULE_NAME) := $(CHILD_DIRS)
12 | PATH_$(MODULE_NAME) := $(d)
13 | ALL_OBJS_$(MODULE_NAME) := $(OBJS_$(MODULE_NAME))
14 |
15 | define child_template
16 | dir := $(d)/$(1)
17 | include .make/stack.mk
18 | endef
19 | $(foreach directory,$(CHILD_DIRS),$(eval $(call child_template,$(directory))))
20 |
21 | define child_objs_template
22 | ALL_OBJS_$(NAME_$(d)) += $(ALL_OBJS_$(NAME_$(d)/$(1)))
23 | endef
24 | $(foreach directory,$(CHILD_DIRS_$(NAME_$(d))),$(eval $(call child_objs_template,$(directory))))
25 |
26 | d := $(dirstack_$(sp))
27 | sp := $(basename $(sp))
28 |
--------------------------------------------------------------------------------
/.make/uncrustify.cfg:
--------------------------------------------------------------------------------
1 | newlines = lf
2 |
3 | indent_columns = 4
4 | indent_with_tabs = 0
5 |
6 | indent_class = true
7 | indent_access_spec = 3
8 |
9 | #indent_continue = 8
10 | indent_align_assign = false
11 | indent_func_call_param = true
12 | indent_func_def_param = true
13 | indent_func_proto_param = true
14 | indent_func_class_param = true
15 | indent_func_ctor_var_param = true
16 | indent_template_param = true
17 | indent_func_param_double = true
18 |
19 | sp_before_ptr_star = force
20 | sp_after_ptr_star = remove
21 | sp_before_byref = force
22 | sp_after_byref = remove
23 |
24 | sp_angle_shift = remove
25 | sp_permit_cpp11_shift = true
26 |
27 | align_var_def_star_style = 1
28 | align_var_def_amp_style = 1
29 | align_typedef_star_style = 1
30 | align_typedef_amp_style = 1
31 |
32 | sp_func_def_paren = remove
33 | sp_cparen_oparen = remove
34 | sp_func_proto_paren = remove
35 | sp_func_call_paren = remove
36 | sp_after_tparen_close = remove
37 | nl_fdef_brace = remove
38 |
39 | sp_fparen_brace = force
40 | sp_after_comma = force
41 |
42 | code_width = 80
43 | pos_comma = trail
44 | pos_assign = trail
45 | pos_class_comma = trail
46 | pos_class_colon = trail
47 |
48 | pos_arith = lead
49 | pos_bool = lead
50 | pos_compare = lead
51 | pos_conditional = lead
52 |
53 | nl_remove_extra_newlines = 0
54 |
--------------------------------------------------------------------------------
/.ros-scripts/.rosinstall:
--------------------------------------------------------------------------------
1 | - git:
2 | local-name: octomap_mapping
3 | uri: https://github.com/OctoMap/octomap_mapping.git
4 | version: indigo-devel
5 | - git:
6 | local-name: husky_description
7 | uri: https://github.com/husky/husky_description.git
8 | version: hydro-devel
9 |
--------------------------------------------------------------------------------
/.ros-scripts/build_boost_148.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ -z "$TAPIR_BOOST_148" ]
3 | then
4 | echo "ERROR: No target directory specified for Boost"
5 | exit 1
6 | fi
7 |
8 | echo "Compile Boost 1.48?"
9 | select yn in "Yes" "No"
10 | do
11 | if [ "$yn" = "Yes" ]
12 | then
13 | cd tapir_boost_install/boost_1_48_0
14 | ./bootstrap.sh --prefix="$TAPIR_BOOST_148"
15 | echo "Building Boost."
16 | echo "This could take a long time..."
17 | sleep 1
18 | ./b2 install -j8
19 | cd ../..
20 | rm -rf tapir_boost_install
21 | exit 0
22 | else
23 | exit 1
24 | fi
25 | done
26 |
--------------------------------------------------------------------------------
/.ros-scripts/build_vrep_plugin.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # This script will automatically rebuild the V-REP ROS plugin, which causes
3 | # trouble on Ubuntu 14.04
4 |
5 | if [ -z "$VREP_DIR" ]
6 | then
7 | echo "Please set VREP_DIR in the root Makefile and run this script"
8 | echo "via the command 'make vrep_plugin' instead."
9 | exit 1
10 | fi
11 |
12 | if [ -z "$ROS_SCRIPT" ]
13 | then
14 | echo "Please set ROS_SCRIPT in the root Makefile and run this script"
15 | echo "via the command 'make vrep_plugin' instead."
16 | exit 2
17 | fi
18 |
19 | if [ ! -d "$VREP_DIR/programming/ros_packages" ]
20 | then
21 | echo "ERROR: V-REP code not found. Please set VREP_DIR correctly,"
22 | echo "or download and extract V-REP in \"$VREP_DIR\""
23 | exit 3
24 | fi
25 |
26 | . "$ROS_SCRIPT"
27 |
28 | ROS_VERSION=$(rosversion -d)
29 | PATCH_PLUGIN=false
30 | DISABLE_OTHER_INTERFACE=false
31 | if [ -z "$ROS_VERSION" ]
32 | then
33 | echo "ROS not found. Perhaps you have set the ROS_SCRIPT variable in"
34 | echo "the root Makefile incorrectly?"
35 | exit 4
36 | elif [ "$ROS_VERSION" = "hydro" ]
37 | then
38 | echo "ROS Hydro detected."
39 | elif [ "$ROS_VERSION" = "indigo" ]
40 | then
41 | echo "ROS Indigo detected."
42 | PATCH_PLUGIN=true
43 | else
44 | echo "ROS $ROS_VERSION detected."
45 | sudo apt-get install libopencv-dev
46 | # New V-REP interface doesn't seem to compile, use old plugin
47 | DISABLE_OTHER_INTERFACE=true
48 | fi
49 |
50 | JOY=$(env ROS_CACHE_TIMEOUT=0 rospack list-names | grep joy)
51 | if [ -z "$JOY" ]
52 | then
53 | echo "ROS joystick package not found!"
54 | sudo apt-get install ros-$ROS_VERSION-joy
55 | JOY=$(env ROS_CACHE_TIMEOUT=0 rospack list-names | grep joy)
56 | if [ -z "$JOY" ]
57 | then
58 | echo "Failed to install the ROS joystick package."
59 | echo "Please install it before re-running this script."
60 | exit 5
61 | fi
62 | fi
63 |
64 | echo "Copying V-REP code"
65 |
66 | mkdir -p vrep_plugin_build/src
67 | cd vrep_plugin_build
68 | cp -r $VREP_DIR/programming/ros_packages/* src
69 |
70 | if $DISABLE_OTHER_INTERFACE
71 | then
72 | rm -rf src/v_repExtRosInterface
73 | fi
74 |
75 | if $PATCH_PLUGIN
76 | then
77 | sed -i 's/hydro/indigo/g' src/vrep_plugin/CMakeLists.txt
78 | echo "V-REP code patched for ROS Indigo"
79 | fi
80 |
81 | echo "Building V-REP plugin..."
82 | sleep 0.5
83 | catkin_make
84 |
85 | echo "Moving plugin to V-REP directory"
86 | cp -i devel/lib/libv_repExtRos.so $VREP_DIR/
87 | cd ..
88 | rm -rf vrep_plugin_build
89 | echo "Finished!"
90 |
--------------------------------------------------------------------------------
/.ros-scripts/get_boost_148.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # If the temporary directory exists, we don't do anything.
3 | if [ -f tapir_boost_install/boost_1_48_0/bootstrap.sh ]
4 | then
5 | exit 0
6 | fi
7 |
8 | VERSION=$(lsb_release -a 2> /dev/null | grep Release | cut -d ':' -f 2)
9 | VERSION="${VERSION#"${VERSION%%[![:space:]]*}"}" # remove leading whitespace characters
10 | VERSION="${VERSION%"${VERSION##*[![:space:]]}"}" # remove trailing whitespace characters
11 | if [ "$VERSION" != "12.04" ]
12 | then
13 | echo "WARNING: If you have Ubuntu > 12.04 you shouldn't need to install Boost from source..."
14 | fi
15 |
16 | mkdir tapir_boost_install
17 | cd tapir_boost_install
18 | HAS_ARCHIVE=false
19 | if [ -f boost_1_48_0.tar.bz2 ]
20 | then
21 | if [ $(md5sum boost_1_48_0.tar.bz2 | cut -d " " -f 1) == "d1e9a7a7f532bb031a3c175d86688d95" ]
22 | then
23 | HAS_ARCHIVE=true
24 | else
25 | rm boost_1_48_0.tar.bz2
26 | fi
27 | fi
28 | if [ $HAS_ARCHIVE = "false" ]
29 | then
30 | wget "downloads.sourceforge.net/project/boost/boost/1.48.0/boost_1_48_0.tar.bz2"
31 | fi
32 | echo "Extracting Boost source code..."
33 | tar jxf boost_1_48_0.tar.bz2
34 |
--------------------------------------------------------------------------------
/.ros-scripts/patch_boost_148.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo "Patching Boost Header..."
3 | perl -pi -e 's/defined\(_GLIBCXX__PTHREADS\)$/defined(_GLIBCXX__PTHREADS) \\\n || defined(_GLIBCXX_HAS_GTHREADS)/' tapir_boost_install/boost_1_48_0/boost/config/stdlib/libstdcpp3.hpp
4 |
--------------------------------------------------------------------------------
/.ros-scripts/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # This script automatically starts the TAPIR interface with ROS and V-REP
3 | if [ -z "$TAPIR_DIR" ]
4 | then
5 | echo "Set the environemnt variable TAPIR_DIR, or run this script"
6 | echo "via ./simulate-ros in the problem directory."
7 | exit 1
8 | fi
9 |
10 | if [ -z "$TAPIR_WS_DIR" ]
11 | then
12 | echo "Set the environemnt variable TAPIR_WS_DIR, or run this script"
13 | echo "via ./simulate-ros in the problem directory."
14 | exit 2
15 | fi
16 |
17 | if [ -z "$VREP_DIR" ]
18 | then
19 | echo "Set the environemnt variable VREP_DIR, or run this script"
20 | echo "via ./simulate-ros in the problem directory."
21 | exit 3
22 | fi
23 |
24 | if [ "$1" = "tracker" ]
25 | then
26 | VREP_SCENE="$TAPIR_DIR/problems/tracker/vrep-scenes/zones.ttt"
27 | LAUNCH=tracker_zones.launch
28 | else
29 | VREP_SCENE="$TAPIR_DIR/problems/tag/vrep-scenes/tag.ttt"
30 | LAUNCH=tag.launch
31 |
32 | fi
33 |
34 | # Check for catkin workspace setup.sh
35 | WS_SETUP_SCRIPT="$TAPIR_WS_DIR/devel/setup.sh"
36 | if [ -f "$WS_SETUP_SCRIPT" ]
37 | then
38 | . $WS_SETUP_SCRIPT
39 | echo "Successfully sourced ROS workspace environment variables"
40 | else
41 | echo "ERROR: The TAPIR workspace is not set up; please re-run \"make ros\""
42 | echo "to set it up, or refer to README.md for further detail."
43 | exit 4
44 | fi
45 |
46 | # Check if V-REP is running
47 | MUST_START_VREP=false
48 | if ! pgrep vrep > /dev/null
49 | then
50 | if [ -e "$VREP_DIR/vrep.sh" ]; then
51 | MUST_START_VREP=true
52 | else
53 | echo "ERROR: vrep.sh not found in $VREP_DIR"
54 | echo "Please set VREP_DIR correctly in the root Makefile and re-run"
55 | echo "the command \"make ros-scripts\""
56 | exit 5
57 | fi
58 | fi
59 |
60 | # Start the roscore
61 | x-terminal-emulator -e sh -c ". $WS_SETUP_SCRIPT; roscore; sh"
62 |
63 | if $MUST_START_VREP
64 | then
65 | sleep 1
66 | echo "Starting V-REP..."
67 | x-terminal-emulator -e sh -c ". $WS_SETUP_SCRIPT; cd $VREP_DIR; ./vrep.sh; sh"
68 | if [ "$1" = "tracker" ]
69 | then
70 | sleep 3
71 | fi
72 | fi
73 |
74 | # Now do a roslaunch!
75 | echo "Launching $LAUNCH"
76 | roslaunch tapir "$LAUNCH"
77 |
--------------------------------------------------------------------------------
/docs/.scripts/make-links.sh:
--------------------------------------------------------------------------------
1 | grep -Po "(?<=\[)[^\]]*?[^\\\\](?=\]($|[^:\[\(]))" $1 | env LC_COLLATE=C sort | uniq | while read -r line
2 | do
3 | echo [$line]: $line
4 | done
5 |
--------------------------------------------------------------------------------
/docs/.scripts/make-ref-links.sh:
--------------------------------------------------------------------------------
1 | echo [TOC]
2 | echo
3 | grep -Po "(?<=\[)[^\]]*?[^\\\\](?=\]($|[^:\[\(]))" $1 | env LC_COLLATE=C sort | uniq | while read -r line
4 | do
5 | echo [$line]: @ref $line
6 | done
7 |
--------------------------------------------------------------------------------
/docs/doxygen_links/Build_System.md:
--------------------------------------------------------------------------------
1 | [build.mk]: @ref build.mk
2 | [problem-template.mk]: @ref problem-template.mk
3 | [stack.mk]: @ref stack.mk
4 | [template.mk]: @ref template.mk
5 |
--------------------------------------------------------------------------------
/docs/doxygen_links/Overview.md:
--------------------------------------------------------------------------------
1 | [TOC]
2 |
3 | [../.make]: @ref LINK_DISABLED
4 | [../.make/README.md]: @ref docs/generated/Build_System.md
5 | [../.ros-scripts]: @ref LINK_DISABLED
6 | [../CMakeLists.txt]: @ref LINK_DISABLED
7 | [../Makefile]: @ref LINK_DISABLED
8 | [../README.md]: @ref docs/generated/Quick_Start.md
9 | [../docs]: @ref docs
10 | [../docs/Making_A_New_Model.md]: @ref docs/generated/New_Model.md
11 | [../docs/html]: @ref LINK_DISABLED
12 | [../docs/html/index.html]: @ref LINK_DISABLED
13 | [../launch]: @ref LINK_DISABLED
14 | [../msg]: @ref LINK_DISABLED
15 | [../problems]: @ref problems
16 | [../problems/rocksample]: @ref problems/rocksample
17 | [../problems/tag]: @ref problems/tag
18 | [../problems/tag/default.cfg]: @ref problems/tag/default.cfg
19 | [../src]: @ref src
20 | [../src/options]: @ref src/options
21 | [../src/options/inih]: @ref LINK_DISABLED
22 | [../src/options/tclap]: @ref LINK_DISABLED
23 | [../src/problems]: @ref src/problems
24 | [../src/problems/rocksample]: @ref src/problems/rocksample
25 | [../src/problems/shared]: @ref src/problems/shared
26 | [../src/problems/tag]: @ref src/problems/tag
27 | [../src/solver]: @ref src/solver
28 | [../srv]: @ref LINK_DISABLED
29 | [Options]: @ref Options
30 | [TagOptions]: @ref tag::TagOptions
31 |
--------------------------------------------------------------------------------
/docs/doxygen_links/Quick_Start.md:
--------------------------------------------------------------------------------
1 | [TOC]
2 |
3 | [docs/ROS_VREP_Guide.md]: docs/generated/Ros_Tag.md
4 | [docs/Making_A_New_Model.md]: @ref docs/generated/New_Model.md
5 | [problems]: @ref problems
6 | [problems/rocksample/default.cfg]: @ref problems/rocksample/default.cfg
7 | [src/problems]: @ref src/problems
8 | [src/problems/Makefile]: @ref src/problems
9 | [src/problems/tag/Makefile]: @ref src/problems/tag
10 | [src/problems/tag/TagModel.hpp]: @ref src/problems/tag/TagModel.hpp
11 | [src/problems/tag/ros/TagVrep.cpp]: @ref src/problems/tag/ros/TagVrep.cpp
12 | [src/solver/Simulator.hpp]: @ref src/solver/Simulator.hpp
13 |
--------------------------------------------------------------------------------
/docs/doxygen_links/Ros_Tag.md:
--------------------------------------------------------------------------------
1 | [TOC]
2 |
3 |
4 | [TapirNode]: @ref TapirNode
5 | [Simulator]: @ref solver::Simulator
6 | [TagNode]: @ref tag::TagNode
7 | [TagModel]: @ref tag::TagModel
8 | [../docs/Making_A_New_Model.md]: @ref docs/generated/New_Model.md
9 | [../README.md]: @ref docs/generated/Quick_Start.md
10 |
--------------------------------------------------------------------------------
/docs/style.css:
--------------------------------------------------------------------------------
1 | h1,
2 | h2,
3 | h3,
4 | h4,
5 | h5,
6 | h6,
7 | p,
8 | blockquote {
9 | margin: 0;
10 | padding: 0;
11 | }
12 | body {
13 | font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", Arial, sans-serif;
14 | font-size: 13px;
15 | line-height: 18px;
16 | color: #737373;
17 | margin: 10px 10px 10px 20px;
18 | }
19 | a {
20 | color: #0069d6;
21 | }
22 | a:hover {
23 | color: #0050a3;
24 | text-decoration: none;
25 | }
26 | a img {
27 | border: none;
28 | }
29 | p {
30 | margin-bottom: 9px;
31 | }
32 | h1,
33 | h2,
34 | h3,
35 | h4,
36 | h5,
37 | h6 {
38 | color: #404040;
39 | line-height: 36px;
40 | }
41 | h1 {
42 | margin-bottom: 18px;
43 | font-size: 30px;
44 | }
45 | h2 {
46 | font-size: 24px;
47 | }
48 | h3 {
49 | font-size: 18px;
50 | }
51 | h4 {
52 | font-size: 16px;
53 | }
54 | h5 {
55 | font-size: 14px;
56 | }
57 | h6 {
58 | font-size: 13px;
59 | }
60 | hr {
61 | margin: 0 0 19px;
62 | border: 0;
63 | border-bottom: 1px solid #aaa;
64 | }
65 | blockquote {
66 | padding: 13px 13px 21px 15px;
67 | margin-bottom: 18px;
68 | font-family:georgia,serif;
69 | font-style: italic;
70 | }
71 | blockquote:before {
72 | content:"\201C";
73 | font-size:40px;
74 | margin-left:-10px;
75 | font-family:georgia,serif;
76 | color:#eee;
77 | }
78 | blockquote p {
79 | font-size: 14px;
80 | font-weight: 300;
81 | line-height: 18px;
82 | margin-bottom: 0;
83 | font-style: italic;
84 | }
85 | code, pre {
86 | padding: 0 3px 2px;
87 | font-family: Monaco, Andale Mono, Courier New, monospace;
88 | -webkit-border-radius: 3px;
89 | -moz-border-radius: 3px;
90 | border-radius: 3px;
91 | }
92 | code {
93 | background-color: #fee9cc;
94 | color: rgba(0, 0, 0, 0.75);
95 | padding: 1px 3px;
96 | font-size: 12px;
97 | }
98 | pre {
99 | display: block;
100 | padding: 14px;
101 | margin: 0 0 18px;
102 | line-height: 16px;
103 | font-size: 11px;
104 | border: 1px dashed #ccc;
105 | border: 1px dashed rgba(0, 0, 0, 0.15);
106 | -webkit-border-radius: 3px;
107 | -moz-border-radius: 3px;
108 | border-radius: 3px;
109 | white-space: pre;
110 | white-space: pre-wrap;
111 | word-wrap: break-word;
112 | }
113 | pre code {
114 | background-color: #fdfdfd;
115 | color:#737373;
116 | font-size: 11px;
117 | }
118 | @media screen and (min-width: 768px) {
119 | body {
120 | width: 748px;
121 | margin:10px auto;
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/launch/tag.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/license/BSD.txt:
--------------------------------------------------------------------------------
1 |
2 | The "inih" library is distributed under the New BSD license:
3 |
4 | Copyright (c) 2009, Brush Technology
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are met:
9 | * Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 | * Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 | * Neither the name of Brush Technology nor the names of its contributors
15 | may be used to endorse or promote products derived from this software
16 | without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY
19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY
22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/license/MIT.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2006-2011 by Mike Smoot
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/license/license.txt:
--------------------------------------------------------------------------------
1 | License
2 |
3 | Copyright (c) 2014 by the University of Queensland.
4 |
5 | TAPIR is licensed under EITHER (your option):
6 | 1. GNU GPL V2.
7 | 2. TAPIR commercial license (please contact us at rdl.algorithm@itee.uq.edu.au for details).
8 |
9 | TAPIR makes use of inih (http://code.google.com/p/inih/) and tclap (http://www.google.com/#q=tclap) to parse program options. The code inih is released under the New BSD License, while the code tclap is released under the MIT License.
10 |
--------------------------------------------------------------------------------
/msg/VrepInfo.msg:
--------------------------------------------------------------------------------
1 | std_msgs/Header headerInfo
2 | std_msgs/Int32 simulatorState
3 | std_msgs/Float32 simulationTime
4 | std_msgs/Float32 timeStep
5 |
--------------------------------------------------------------------------------
/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | tapir
4 | 0.0.0
5 | The tapir package
6 |
7 |
8 |
9 |
10 | joshua
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 | roslib
44 | roscpp
45 | std_msgs
46 | geometry_msgs
47 | tf
48 | message_generation
49 | laser_geometry
50 | roslib
51 | roscpp
52 | std_msgs
53 | geometry_msgs
54 | tf
55 | message_runtime
56 | laser_geometry
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/problems/Makefile:
--------------------------------------------------------------------------------
1 | REDIRECT =
2 | .PHONY: $(MAKECMDGOALS) call-upwards
3 | $(MAKECMDGOALS): call-upwards ;
4 | call-upwards:
5 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
6 |
--------------------------------------------------------------------------------
/problems/conttag/Makefile:
--------------------------------------------------------------------------------
1 | REDIRECT = conttag
2 | .PHONY: $(MAKECMDGOALS) call-upwards
3 | $(MAKECMDGOALS): call-upwards ;
4 | call-upwards:
5 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
6 |
--------------------------------------------------------------------------------
/problems/conttag/default.cfg:
--------------------------------------------------------------------------------
1 | # seed = 1
2 |
3 | # General-purpose settings.
4 | color = false
5 | verbose = true
6 |
7 | [ABT]
8 | # Whether to keep track of states in an index data structure
9 | useStateIndex = false
10 |
11 | # The number of trajectories to simulate per time step (0 => wait for timeout)
12 | historiesPerStep = 0
13 |
14 | # The maximum time to spend on each step, in milliseconds (0 => no time limit)
15 | stepTimeout = 1000
16 | #solveTimeout = 1000
17 |
18 | # If this is set to "true", ABT will prune the tree after every step.
19 | pruneEveryStep = true
20 |
21 | # If this is set to "true", ABT will reset the tree instead of modifying it when
22 | # changes occur.
23 | resetOnChanges = false
24 |
25 | # The minimum number of particles for the current belief state in a simulation.
26 | # Extra particles will be resampled via a particle filter if the particle count
27 | # for the *current* belief state drops below this number during simulation.
28 | minParticleCount = 5000
29 |
30 | # The maximum depth to search in the tree, relative to the current belief.
31 | maximumDepth = 50
32 | # True if the above horizon is relative to the initial belief, and false
33 | # if it's relative to the current belief.
34 | isAbsoluteHorizon = false
35 |
36 | searchHeuristic = default()
37 | searchStrategy = gps(searchType=golden, dimensions=1, explorationCoefficient=100, newSearchPointCoefficient=4, minimumVisitsBeforeChildCreation=1, minimumChildCreationDistance=0.05)
38 | recommendationStrategy = gpsmax(searchType=golden, dimensions=1, recommendationMode=robust)
39 |
40 | estimator = mean()
41 |
42 | [problem]
43 | discountFactor = 0.95
44 |
45 | mapPath = maps/map_tag.txt
46 | moveCost = 1
47 | tagSuccessReward = 10
48 | tagFailPenalty = 10
49 | collisionPenalty = 0
50 |
51 | sizeX = 10
52 | sizeY = 10
53 |
54 | moveDistance = 1
55 | humanMoveDistance = 1
56 | sensorAngleInner = 0;
57 | sensorAngleOuter = 45;
58 | #sensorAngleOuter = 0;
59 |
60 | moveUncertainty = 0
61 | actionUncertainty = 0
62 | observationUncertainty = 0.0
63 | humanAngleUncertainty = 22.5
64 |
65 | fixedActionResolution = 0
66 |
67 | [changes]
68 | hasChanges = false
69 | changesPath = changes/mid-wall.txt
70 | areDynamic = true
71 |
72 | [simulation]
73 | loadInitialPolicy = true
74 | savePolicy = false
75 | nSteps = 90
76 | nRuns = 1
77 |
78 | [ros]
79 | # Path to the V-REP scene file
80 | # vrepScenePath = vrep_scenes/tag.ttt
81 |
--------------------------------------------------------------------------------
/problems/conttag/maps/map.txt:
--------------------------------------------------------------------------------
1 | #####...s...######
2 | #####.......######
3 | #####.......######
4 | ..................
5 | ..................
6 | ..................
7 | ..................
--------------------------------------------------------------------------------
/problems/conttag/maps/map_tag.txt:
--------------------------------------------------------------------------------
1 | #####...##
2 | #####...##
3 | #####...##
4 | ..........
5 | ..........
--------------------------------------------------------------------------------
/problems/homecare/Makefile:
--------------------------------------------------------------------------------
1 | REDIRECT = homecare
2 | .PHONY: $(MAKECMDGOALS) call-upwards
3 | $(MAKECMDGOALS): call-upwards ;
4 | call-upwards:
5 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
6 |
--------------------------------------------------------------------------------
/problems/homecare/changes/change.txt:
--------------------------------------------------------------------------------
1 | t 5 : 1
2 | Add W: (25, 0) (25, 0)
3 | t 60 : 1
4 | Add W: (25, 49) (25, 49)
5 | t 90 : 1
6 | Add W: (0, 25) (0, 25)
7 | t 120 : 1
8 | Add W: (49, 25) (49, 25)
9 |
10 |
--------------------------------------------------------------------------------
/problems/homecare/default.cfg:
--------------------------------------------------------------------------------
1 | # General-purpose settings.
2 | color = false
3 | verbose = true
4 |
5 | [ABT]
6 | # Whether to keep track of states in an index data structure
7 | useStateIndex = false
8 |
9 | # The number of trajectories to simulate per time step (0 => wait for timeout)
10 | historiesPerStep = 10000
11 |
12 | # The maximum time to spend on each step, in milliseconds (0 => no time limit)
13 | stepTimeout = 1000
14 |
15 | # If this is set to "true", ABT will prune the tree after every step.
16 | pruneEveryStep = true
17 |
18 | # If this is set to "true", ABT will reset the tree instead of modifying it whe
19 | # changes occur.
20 | resetOnChanges = false
21 |
22 | # The minimum number of particles for the current belief state in a simulation.
23 | # Extra particles will be resampled via a particle filter if the particle count
24 | # for the *current* belief state drops below this number during simulation.
25 | minParticleCount = 5000
26 |
27 | # The maximum depth to search in the tree.
28 | maximumDepth = 150
29 | # True if the above horizon is relative to the initial belief, and false
30 | # if it's relative to the current belief.
31 | isAbsoluteHorizon = false
32 |
33 | searchHeuristic = default()
34 | searchStrategy = ucb(20.0)
35 | estimator = mean()
36 |
37 | [problem]
38 | discountFactor = 0.95
39 | pathMapFilename = maps/pathMap.txt
40 | typeMapFilename = maps/typeMap.txt
41 | moveCost = 100
42 | helpReward = 5500
43 | targetWStayProbability = 0.9
44 | targetStayProbability = 0.5
45 | moveAccuracy = 0.8
46 | regionSensorAccuracy = 0.9
47 | callProbability = 0.1
48 | continueCallProbability = 1
49 |
50 | [changes]
51 | hasChanges = false
52 | changesPath = changes/change.txt
53 | areDynamic = true
54 |
55 | [simulation]
56 | loadInitialPolicy = true
57 | savePolicy = false
58 | nSteps = 150
59 | nRuns = 1
60 |
--------------------------------------------------------------------------------
/problems/homecare/maps/pathMap.txt:
--------------------------------------------------------------------------------
1 | 50 50
2 | dlllllllllllllllnlllllllllllllllllllnlllllllllllll
3 | d000000000000u11d0000000000000000u11d000000000000u
4 | d000000000000u11d0000000000000000u11d000000000000u
5 | d000000000000u11d0000000000000000u11d000000000000u
6 | d000000000000u11d0000000000000000u11d000000000000u
7 | d000000000000u11d0000000000000000u11d000000000000u
8 | d000000000000u11d0000000000000000u11d000000000000u
9 | d000000000000u11d0000000000000000u11d000000000000u
10 | d000000000000u11d0000000000000000u11d000000000000u
11 | d000000000000u11d0000000000000000u11d000000000000u
12 | d000000000000u11d0000000000000000u11d000000000000u
13 | d000000000000ulll0000000000000000ulll000000000000u
14 | d000000000000000000000000000000000000000000000000u
15 | d000000000000000000000000000000000000000000000000u
16 | d000000000000000000000000000000000000000000000000u
17 | mrrrrrrrrrrrrrd00000000000000000000rrrrrrrrrrrrrru
18 | d1111111111111d00000000000000000000u1111111111111u
19 | d1111111111111d00000000000000000000u1111111111111u
20 | dllllllllllllll00000000000000000000ulllllllllllllo
21 | d000000000000000000000000000000000000000000000000u
22 | d000000000000000000000000000000000000000000000000u
23 | d000000000000000000000000000000000000000000000000u
24 | d000000000000000000000000000000000000000000000000u
25 | d000000000000000000000000000000000000000000000000u
26 | d000000000000000000000000000000000000000000000000u
27 | d000000000000000000000000000000000000000000000000u
28 | d000000000000000000000000000000000000000000000000u
29 | d000000000000000000000000000000000000000000000000u
30 | d000000000000000000000000000000000000000000000000u
31 | d000000000000000000000000000000000000000000000000u
32 | d000000000000000000000000000000000000000000000000u
33 | mrrrrrrrrrrrrrd00000000000000000000rrrrrrrrrrrrrru
34 | d1111111111111d00000000000000000000u1111111111111u
35 | d1111111111111d00000000000000000000u1111111111111u
36 | dllllllllllllll00000000000000000000ulllllllllllllo
37 | d000000000000000000000000000000000000000000000000u
38 | d000000000000000000000000000000000000000000000000u
39 | d000000000000000000000000000000000000000000000000u
40 | d000000000000rrrd0000000000000000rrrd000000000000u
41 | d000000000000u11d0000000000000000u11d000000000000u
42 | d000000000000u11d0000000000000000u11d000000000000u
43 | d000000000000u11d0000000000000000u11d000000000000u
44 | d000000000000u11d0000000000000000u11d000000000000u
45 | d000000000000u11d0000000000000000u11d000000000000u
46 | d000000000000u11d0000000000000000u11d000000000000u
47 | d000000000000u11d0000000000000000u11d000000000000u
48 | d000000000000u11d0000000000000000u11d000000000000u
49 | d000000000000u11d0000000000000000u11d000000000000u
50 | d000000000000u11d0000000000000000u11d000000000000u
51 | rrrrrrrrrrrrrprrrrrrrrrrrrrrrrrrrprrrrrrrrrrrrrrru
--------------------------------------------------------------------------------
/problems/homecare/maps/typeMap.txt:
--------------------------------------------------------------------------------
1 | 50 50
2 | woooooooooooooooooooooooooooooooooooooooooooooooow
3 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
4 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
5 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
6 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
7 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
8 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
9 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
10 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
11 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
12 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
13 | oooooooooooooottoooooooooooooooooottoooooooooooooo
14 | oooooooooooooooooooooooooooooooooooooooooooooooooo
15 | oooooooooooooooooooooooooooooooooooooooooooooooooo
16 | oooooooooooooooooooooooooooooooooooooooooooooooooo
17 | oooooooooooooooooooooooooooooooooooooooooooooooooo
18 | o1111111111111toooooooooooooooooooot1111111111111o
19 | o1111111111111toooooooooooooooooooot1111111111111o
20 | oooooooooooooooooooooooooooooooooooooooooooooooooo
21 | oooooooooooooooooooooooooooooooooooooooooooooooooo
22 | oooooooooooooooooooooooooooooooooooooooooooooooooo
23 | oooooooooooooooooooooooooooooooooooooooooooooooooo
24 | oooooooooooooooooooooooooooooooooooooooooooooooooo
25 | ooooooooooooooooooooooosssoooooooooooooooooooooooo
26 | ooooooooooooooooooooooosssoooooooooooooooooooooooo
27 | ooooooooooooooooooooooosssoooooooooooooooooooooooo
28 | oooooooooooooooooooooooooooooooooooooooooooooooooo
29 | oooooooooooooooooooooooooooooooooooooooooooooooooo
30 | oooooooooooooooooooooooooooooooooooooooooooooooooo
31 | oooooooooooooooooooooooooooooooooooooooooooooooooo
32 | oooooooooooooooooooooooooooooooooooooooooooooooooo
33 | oooooooooooooooooooooooooooooooooooooooooooooooooo
34 | o1111111111111toooooooooooooooooooot1111111111111o
35 | o1111111111111toooooooooooooooooooot1111111111111o
36 | oooooooooooooooooooooooooooooooooooooooooooooooooo
37 | oooooooooooooooooooooooooooooooooooooooooooooooooo
38 | oooooooooooooooooooooooooooooooooooooooooooooooooo
39 | oooooooooooooooooooooooooooooooooooooooooooooooooo
40 | oooooooooooooottoooooooooooooooooottoooooooooooooo
41 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
42 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
43 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
44 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
45 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
46 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
47 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
48 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
49 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
50 | oooooooooooooo11oooooooooooooooooo11oooooooooooooo
51 | woooooooooooooooooooooooooooooooooooooooooooooooow
--------------------------------------------------------------------------------
/problems/pushbox/Makefile:
--------------------------------------------------------------------------------
1 | REDIRECT = pushbox
2 | .PHONY: $(MAKECMDGOALS) call-upwards
3 | $(MAKECMDGOALS): call-upwards ;
4 | call-upwards:
5 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
6 |
--------------------------------------------------------------------------------
/problems/pushbox/default.cfg:
--------------------------------------------------------------------------------
1 | # seed = 1
2 |
3 | # General-purpose settings.
4 | color = false
5 | verbose = true
6 |
7 | [ABT]
8 | # Whether to keep track of states in an index data structure
9 | useStateIndex = false
10 |
11 | # The number of trajectories to simulate per time step (0 => wait for timeout)
12 | historiesPerStep = 0
13 |
14 | # The maximum time to spend on each step, in milliseconds (0 => no time limit)
15 | stepTimeout = 3000
16 | #solveTimeout = 1000
17 |
18 | # If this is set to "true", ABT will prune the tree after every step.
19 | pruneEveryStep = true
20 |
21 | # If this is set to "true", ABT will reset the tree instead of modifying it when
22 | # changes occur.
23 | resetOnChanges = false
24 |
25 | # The minimum number of particles for the current belief state in a simulation.
26 | # Extra particles will be resampled via a particle filter if the particle count
27 | # for the *current* belief state drops below this number during simulation.
28 | minParticleCount = 5000
29 |
30 | #maxParticleCreationAttempts = 100000
31 |
32 | # The maximum depth to search in the tree, relative to the current belief.
33 | maximumDepth = 3
34 | # True if the above horizon is relative to the initial belief, and false
35 | # if it's relative to the current belief.
36 | isAbsoluteHorizon = false
37 |
38 | searchHeuristic = default()
39 |
40 |
41 | searchStrategy = gps(searchType=compass, dimensions=2, explorationCoefficient=100000, newSearchPointCoefficient=5, minimumVisitsBeforeChildCreation=1, minimumChildCreationDistance=0.2, initialCompassRadiusRatio=0.3333)
42 | recommendationStrategy = gpsmax(searchType=compass, dimensions=2, recommendationMode=robust)
43 |
44 | estimator = mean()
45 |
46 | [problem]
47 | discountFactor = 0.95
48 |
49 | mapPath = maps/map_free_paper.txt
50 | moveCost = 10
51 | goalReward = 1000
52 | collisionPenalty = 1000
53 |
54 | sizeX = 10
55 | sizeY = 10
56 |
57 |
58 | # startPositionX = 1
59 | # startPositionY = 3
60 |
61 | # goalPositionX = 8
62 | # goalPositionY = 6
63 | # goalRadius = 0.5
64 |
65 | moveUncertainty = 0.0
66 | actionUncertainty = 0.0
67 | boxPositionMoveUncertainty = 0.1
68 | boxSpeedUncertainty = 0.1
69 | initialBoxPositionUncertainty = 2
70 |
71 | # this is measured in degrees. So make it large to have an effect.
72 | #observationUncertainty = 20
73 | observationUncertainty = 0
74 |
75 | # the number of sectors the bearing measurement is split into. e.g. 4 means 90 degree resolution
76 | observationBuckets = 12
77 |
78 | fixedActionResolution = 0
79 |
80 |
81 | [changes]
82 | hasChanges = false
83 | changesPath = changes/mid-wall.txt
84 | areDynamic = true
85 |
86 | [simulation]
87 | loadInitialPolicy = true
88 | savePolicy = false
89 | nSteps = 50
90 | nRuns = 1
91 |
92 | [ros]
93 | # Path to the V-REP scene file
94 | # vrepScenePath = vrep_scenes/tag.ttt
95 |
--------------------------------------------------------------------------------
/problems/pushbox/maps/map_free_paper.txt:
--------------------------------------------------------------------------------
1 | ############
2 | #.......####
3 | #....s..g###
4 | #..........#
5 | #..........#
6 | #..........#
7 | #....b.....#
8 | #..........#
9 | #..........#
10 | #..........#
11 | #..........#
12 | ############
--------------------------------------------------------------------------------
/problems/rocksample/Makefile:
--------------------------------------------------------------------------------
1 | REDIRECT = rocksample
2 | .PHONY: $(MAKECMDGOALS) call-upwards
3 | $(MAKECMDGOALS): call-upwards ;
4 | call-upwards:
5 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
6 |
--------------------------------------------------------------------------------
/problems/rocksample/changes/changes-11-11.txt:
--------------------------------------------------------------------------------
1 | t 5 : 1
2 | Add Obstacles: (4, 2) (4, 6)
3 | t 8 : 2
4 | Add Obstacles: (2, 11) (5, 11)
5 | Add Obstacles: (5, 10) (5, 10)
6 | t 15 : 1
7 | Add Obstacles: (4, 1) (4, 3)
8 | t 18 : 1
9 | Remove Obstacles: (2, 11) (3, 11)
10 | t 23 : 2
11 | Add Obstacles: (8, 5) (8, 7)
12 | Add Obstacles: (9, 0) (9, 3)
13 | t 27 : 2
14 | Remove Obstacles: (5, 10) (5, 10)
15 | Remove Obstacles: (8, 5) (8, 7)
16 |
--------------------------------------------------------------------------------
/problems/rocksample/changes/changes-7-8.txt:
--------------------------------------------------------------------------------
1 | t 3 : 1
2 | Add Obstacles: (0, 4) (0, 4)
3 | t 5 : 1
4 | Add Obstacles: (1, 1) (1, 3)
5 | t 9 : 1
6 | Add Obstacles: (4, 1) (4, 3)
7 | t 12 : 1
8 | Add Obstacles: (2, 6) (2, 6)
9 | t 18 : 2
10 | Remove Obstacles: (0, 4) (0, 4)
11 | Remove Obstacles: (2, 6) (2, 6)
12 |
--------------------------------------------------------------------------------
/problems/rocksample/changes/changes.txt:
--------------------------------------------------------------------------------
1 | t 5 : 1
2 | Add Obstacles: (4, 1) (4, 4)
3 | t 25 : 2
4 | Remove Obstacles: (0, 4) (0, 4)
5 | Remove Obstacles: (2, 6) (2, 6)
6 |
--------------------------------------------------------------------------------
/problems/rocksample/changes/changes2.txt:
--------------------------------------------------------------------------------
1 | t 5 : 1
2 | Add Obstacles: (4, 1) (4, 4)
3 |
--------------------------------------------------------------------------------
/problems/rocksample/default-11-11.cfg:
--------------------------------------------------------------------------------
1 | # General-purpose settings.
2 | color = false
3 | verbose = true
4 |
5 | [ABT]
6 | # Whether to keep track of states in an index data structure
7 | useStateIndex = false
8 |
9 | # The number of trajectories to simulate per time step (0 => wait for timeout)
10 | historiesPerStep = 0
11 |
12 | # The maximum time to spend on each step, in milliseconds (0 => no time limit)
13 | stepTimeout = 1000
14 |
15 | # If this is set to "true", ABT will prune the tree after every step.
16 | pruneEveryStep = true
17 |
18 | # If this is set to "true", ABT will reset the tree instead of modifying it when
19 | # changes occur.
20 | resetOnChanges = false
21 |
22 | # The minimum number of particles for the current belief state in a simulation.
23 | # Extra particles will be resampled via a particle filter if the particle count
24 | # for the *current* belief state drops below this number during simulation.
25 | minParticleCount = 1000
26 |
27 | # The maximum depth to search in the tree, relative to the current belief.
28 | maximumDepth = 90
29 | # True if the above horizon is relative to the initial belief, and false
30 | # if it's relative to the current belief.
31 | isAbsoluteHorizon = false
32 |
33 | searchHeuristic = exactMdp()
34 | searchStrategy = ucb(5.0)
35 | estimator = mean()
36 |
37 | [problem]
38 | discountFactor = 0.95
39 |
40 | mapPath = maps/map-11-11.txt
41 | goodRockReward = 10
42 | badRockPenalty = 10
43 | exitReward = 10
44 | illegalMovePenalty = 100
45 | halfEfficiencyDistance = 20
46 |
47 | [changes]
48 | hasChanges = false
49 | changesPath = changes/changes-11-11.txt
50 | areDynamic = true
51 |
52 | [heuristics]
53 | # history-based heuristic type:
54 | # none/legal/preferred
55 | type = legal
56 | # Restricted search: searches only the given category
57 | # all / legal /preferred
58 | search = legal
59 | # Restricted rollout : randomly chooses from the given category
60 | # all / legal / preferred
61 | rollout = legal
62 |
63 | # Initialises preferred actions to have biased initial q-values.
64 | usePreferredInit = false
65 | preferredQValue = 0.0
66 | preferredVisitCount = 0
67 |
68 | [simulation]
69 | loadInitialPolicy = true
70 | savePolicy = false
71 | nSteps = 150
72 | nRuns = 1
73 |
--------------------------------------------------------------------------------
/problems/rocksample/default.cfg:
--------------------------------------------------------------------------------
1 | # General-purpose settings.
2 | color = false
3 | verbose = true
4 |
5 | [ABT]
6 | # Whether to keep track of states in an index data structure
7 | useStateIndex = false
8 |
9 | # The number of trajectories to simulate per time step (0 => wait for timeout)
10 | historiesPerStep = 0
11 |
12 | # The maximum time to spend on each step, in milliseconds (0 => no time limit)
13 | stepTimeout = 1000
14 |
15 | # If this is set to "true", ABT will prune the tree after every step.
16 | pruneEveryStep = false
17 |
18 | # If this is set to "true", ABT will reset the tree instead of modifying it when
19 | # changes occur.
20 | resetOnChanges = false
21 |
22 | # The minimum number of particles for the current belief state in a simulation.
23 | # Extra particles will be resampled via a particle filter if the particle count
24 | # for the *current* belief state drops below this number during simulation.
25 | minParticleCount = 1000
26 |
27 | # The maximum depth to search in the tree, relative to the current belief.
28 | maximumDepth = 90
29 | # True if the above horizon is relative to the initial belief, and false
30 | # if it's relative to the current belief.
31 | isAbsoluteHorizon = false
32 |
33 | searchHeuristic = exactMdp()
34 | searchStrategy = ucb(5.0)
35 | estimator = mean()
36 |
37 | [problem]
38 | discountFactor = 0.95
39 |
40 | mapPath = maps/map-7-8.txt
41 | goodRockReward = 10
42 | badRockPenalty = 10
43 | exitReward = 10
44 | illegalMovePenalty = 100
45 | halfEfficiencyDistance = 20
46 |
47 | [changes]
48 | hasChanges = false
49 | changesPath = changes/changes-7-8.txt
50 | areDynamic = true
51 |
52 | [heuristics]
53 | # history-based heuristic type:
54 | # none/legal/preferred
55 | type = legal
56 | # Restricted search: searches only the given category
57 | # all / legal /preferred
58 | search = legal
59 | # Restricted rollout : randomly chooses from the given category
60 | # all / legal / preferred
61 | rollout = legal
62 |
63 | # Initialises preferred actions to have biased initial q-values.
64 | usePreferredInit = false
65 | preferredQValue = 0.0
66 | preferredVisitCount = 0
67 |
68 | [simulation]
69 | loadInitialPolicy = true
70 | savePolicy = false
71 | nSteps = 150
72 | nRuns = 1
73 |
--------------------------------------------------------------------------------
/problems/rocksample/maps/map-11-11.txt:
--------------------------------------------------------------------------------
1 | 11 12
2 | ...........G
3 | .........o.G
4 | .o.o.o.....G
5 | o..........G
6 | ...........G
7 | S..........G
8 | ..o........G
9 | o..oo....o.G
10 | ...........G
11 | ......o....G
12 | ...........G
13 |
--------------------------------------------------------------------------------
/problems/rocksample/maps/map-7-1.txt:
--------------------------------------------------------------------------------
1 | 7 8
2 | .......G
3 | .......G
4 | ...o...G
5 | S......G
6 | .......G
7 | .......G
8 | .......G
9 |
--------------------------------------------------------------------------------
/problems/rocksample/maps/map-7-2.txt:
--------------------------------------------------------------------------------
1 | 7 8
2 | .o.....G
3 | .......G
4 | .......G
5 | S.....oG
6 | .......G
7 | .......G
8 | .......G
9 |
--------------------------------------------------------------------------------
/problems/rocksample/maps/map-7-3.txt:
--------------------------------------------------------------------------------
1 | 7 8
2 | .o.....G
3 | .......G
4 | ...o...G
5 | S......G
6 | .......G
7 | .......G
8 | ..o....G
9 |
--------------------------------------------------------------------------------
/problems/rocksample/maps/map-7-8-obstacles.txt:
--------------------------------------------------------------------------------
1 | 7 8
2 | .o..X..G
3 | XXX.Xo.G
4 | ..oo.XXG
5 | S....XoG
6 | .....X.G
7 | o..o.X.G
8 | ..o....G
9 |
--------------------------------------------------------------------------------
/problems/rocksample/maps/map-7-8.txt:
--------------------------------------------------------------------------------
1 | 7 8
2 | .o.....G
3 | .....o.G
4 | ..oo...G
5 | S.....oG
6 | .......G
7 | o..o...G
8 | ..o....G
9 |
--------------------------------------------------------------------------------
/problems/tag/Makefile:
--------------------------------------------------------------------------------
1 | REDIRECT = tag
2 | .PHONY: $(MAKECMDGOALS) call-upwards
3 | $(MAKECMDGOALS): call-upwards ;
4 | call-upwards:
5 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
6 |
--------------------------------------------------------------------------------
/problems/tag/changes/mid-wall.txt:
--------------------------------------------------------------------------------
1 | t 5 : 1
2 | Add Obstacles: (3, 6) (4, 6)
3 | t 10 : 4
4 | Remove Obstacles: (0, 0) (2, 0)
5 | Remove Obstacles: (0, 0) (0, 4)
6 | Remove Obstacles: (0, 8) (0, 9)
7 | Remove Obstacles: (0, 9) (2, 9)
8 |
--------------------------------------------------------------------------------
/problems/tag/changes/tag-changes.txt:
--------------------------------------------------------------------------------
1 | t 3 : 1
2 | Add Obstacles: (3, 6) (4, 6)
3 | t 5 : 1
4 | Remove Obstacles: (0, 0) (2, 0)
5 | t 8 : 1
6 | Remove Obstacles: (0, 0) (0, 4)
7 | t 10 : 2
8 | Remove Obstacles: (0, 8) (0, 9)
9 | Remove Obstacles: (0, 9) (2, 9)
10 |
--------------------------------------------------------------------------------
/problems/tag/default.cfg:
--------------------------------------------------------------------------------
1 | # General-purpose settings.
2 | color = false
3 | verbose = true
4 |
5 | [ABT]
6 | # Whether to keep track of states in an index data structure
7 | useStateIndex = false
8 |
9 | # The number of trajectories to simulate per time step (0 => wait for timeout)
10 | historiesPerStep = 0
11 |
12 | # The maximum time to spend on each step, in milliseconds (0 => no time limit)
13 | stepTimeout = 1000
14 |
15 | # If this is set to "true", ABT will prune the tree after every step.
16 | pruneEveryStep = false
17 |
18 | # If this is set to "true", ABT will reset the tree instead of modifying it when
19 | # changes occur.
20 | resetOnChanges = false
21 |
22 | # The minimum number of particles for the current belief state in a simulation.
23 | # Extra particles will be resampled via a particle filter if the particle count
24 | # for the *current* belief state drops below this number during simulation.
25 | minParticleCount = 5000
26 |
27 | # The maximum depth to search in the tree, relative to the current belief.
28 | maximumDepth = 90
29 | # True if the above horizon is relative to the initial belief, and false
30 | # if it's relative to the current belief.
31 | isAbsoluteHorizon = true
32 |
33 | searchHeuristic = default()
34 | searchStrategy = ucb(10.0)
35 | estimator = mean()
36 |
37 | [problem]
38 | discountFactor = 0.95
39 |
40 | mapPath = maps/map.txt
41 | moveCost = 1
42 | tagReward = 10
43 | failedTagPenalty = 10
44 | opponentStayProbability = 0.2
45 |
46 | [changes]
47 | hasChanges = false
48 | changesPath = changes/mid-wall.txt
49 | areDynamic = true
50 |
51 | [simulation]
52 | loadInitialPolicy = true
53 | savePolicy = false
54 | nSteps = 90
55 | nRuns = 1
56 |
57 | [ros]
58 | # Path to the V-REP scene file
59 | vrepScenePath = vrep_scenes/tag.ttt
60 |
--------------------------------------------------------------------------------
/problems/tag/maps/map.txt:
--------------------------------------------------------------------------------
1 | 5 10
2 | XXXXX...XX
3 | XXXXX...XX
4 | XXXXX...XX
5 | ..........
6 | ..........
7 |
--------------------------------------------------------------------------------
/problems/tag/vrep_scenes/tag.ttt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rdl-algorithm/tapir/b613c1c287853b2165ea1392a133496f338d8170/problems/tag/vrep_scenes/tag.ttt
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = global
2 | CHILD_DIRS := options solver problems
3 |
4 | ifdef HAS_ROOT_MAKEFILE
5 |
6 | include .make/template.mk
7 | include .make/build.mk
8 |
9 | else
10 | REDIRECT=$(MODULE_NAME)
11 | .PHONY: $(MAKECMDGOALS) call-upwards
12 | $(MAKECMDGOALS): call-upwards ;
13 | call-upwards:
14 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
15 | endif
16 |
--------------------------------------------------------------------------------
/src/check_headers.sh:
--------------------------------------------------------------------------------
1 | files=$(find -name "*pp" -print)
2 | need_doc=
3 | for f in $files
4 | do
5 | doc="$(grep -m 1 "^/\*\*" $f)"
6 | if [[ ${doc:0:10} != '/** @file ' ]]
7 | then
8 | need_doc+="$f "
9 | else
10 | name=${doc:10}
11 | if [[ $f == ${f%%$name} ]]
12 | then
13 | echo "WRONG NAME FOR $f: $name"
14 | fi
15 | fi
16 | done
17 | echo "MISSING DOC COMMENTS:"
18 | for f in $need_doc
19 | do
20 | echo $f
21 | done
22 |
--------------------------------------------------------------------------------
/src/defs.hpp:
--------------------------------------------------------------------------------
1 | /** @file defs.hpp
2 | *
3 | * Some key definitions and macros for C++ programs.
4 | */
5 | #ifndef DEFS_HPP_
6 | #define DEFS_HPP_
7 |
8 | /** A macro for quoting strings. */
9 | #define QUOTE(str) #str
10 | /** A macro that quotes properly, by first expanding other macros, and then quoting that. */
11 | #define EXPAND_AND_QUOTE(str) QUOTE(str)
12 |
13 |
14 | /** A macro used to delete all copy- and move-constructors and -assignment operators */
15 | #define _NO_COPY_OR_MOVE(ClassName) \
16 | ClassName(ClassName const &) = delete; \
17 | ClassName(ClassName &&) = delete; \
18 | ClassName &operator=(ClassName const &) = delete; \
19 | ClassName &operator=(ClassName &&) = delete
20 |
21 | // If we're not using C++1y / C++14, we need to define our own std::make_unique
22 | #if __cplusplus <= 201103L
23 | /** We use an inclusion guard to make sure this definition is only included once. */
24 | #ifndef __STD__MAKE__UNIQUE___
25 | #define __STD__MAKE__UNIQUE___
26 | namespace std {
27 | /** SFINAE struct for single objects. */
28 | template struct _Unique_if {
29 | /** Return type - a single object wrapped in a unique_ptr. */
30 | typedef unique_ptr _Single_object;
31 | };
32 |
33 | /** SFINAE struct for arrays with unknown bounds. */
34 | template struct _Unique_if {
35 | /** Return type - an array wrapped in a unique_ptr. */
36 | typedef unique_ptr _Unknown_bound;
37 | };
38 |
39 | /** SFINAE struct for arrays with known bounds. */
40 | template struct _Unique_if {
41 | /** No return type, since make_unique is disallowed for arrays with known bounds. */
42 | typedef void _Known_bound;
43 | };
44 |
45 | /** The standard single-object make_unique. */
46 | template
47 | typename _Unique_if::_Single_object
48 | make_unique(Args&&... args) {
49 | return unique_ptr(new T(std::forward(args)...));
50 | }
51 |
52 | /** Construction of arrays with unknown bound. */
53 | template
54 | typename _Unique_if::_Unknown_bound
55 | make_unique(size_t n) {
56 | typedef typename remove_extent::type U;
57 | return unique_ptr(new U[n]());
58 | }
59 |
60 | /** Construction of arrays with a known bound is disallowed. */
61 | template
62 | typename _Unique_if::_Known_bound
63 | make_unique(Args&&...) = delete;
64 | }
65 | #endif
66 | #endif
67 |
68 | #endif /* DEFS_HPP_ */
69 |
--------------------------------------------------------------------------------
/src/global.cpp:
--------------------------------------------------------------------------------
1 | /** @file global.cpp
2 | *
3 | * Implementation for show_message() - a great place for breakpoints!
4 | */
5 | #include "global.hpp"
6 |
7 | #include
8 | #include
9 |
10 | #include "solver/abstract-problem/Point.hpp"
11 |
12 | namespace tapir {
13 | std::string get_current_directory() {
14 | char *buffer = getcwd(nullptr, 0);
15 | if (buffer == nullptr) {
16 | debug::show_message("ERROR: Failed to get current path.");
17 | std::exit(4);
18 | }
19 | std::string dir(buffer);
20 | free(buffer);
21 | return dir;
22 | }
23 |
24 | void change_directory(std::string &dir) {
25 | if (chdir(dir.c_str())) {
26 | std::ostringstream oss;
27 | oss << "ERROR: Failed to change path to " << dir;
28 | debug::show_message(oss.str());
29 | std::exit(3);
30 | }
31 | }
32 | } /* namespace tapir */
33 |
34 |
35 | namespace debug {
36 | void show_message(std::string message, bool print, bool bp_branch) {
37 | if (print) {
38 | std::cerr << message << std::endl;
39 | }
40 | if (bp_branch) {
41 | std::cerr << "";
42 | }
43 | }
44 |
45 | /** Instantiation of the to_string template for easier printing of points in GDB. */
46 | template std::string to_string(solver::Point &);
47 | } /* namespace debug */
48 |
--------------------------------------------------------------------------------
/src/options/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = options
2 | CHILD_DIRS := inih
3 |
4 | ifdef HAS_ROOT_MAKEFILE
5 |
6 | include .make/template.mk
7 | include .make/build.mk
8 |
9 | else
10 | REDIRECT=$(MODULE_NAME)
11 | .PHONY: $(MAKECMDGOALS) call-upwards
12 | $(MAKECMDGOALS): call-upwards ;
13 | call-upwards:
14 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
15 | endif
16 |
--------------------------------------------------------------------------------
/src/options/inih/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | The "inih" library is distributed under the New BSD license:
3 |
4 | Copyright (c) 2009, Brush Technology
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are met:
9 | * Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 | * Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 | * Neither the name of Brush Technology nor the names of its contributors
15 | may be used to endorse or promote products derived from this software
16 | without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY
19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY
22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/src/options/inih/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = inih
2 |
3 | ifdef HAS_ROOT_MAKEFILE
4 |
5 | include .make/template.mk
6 | include .make/build.mk
7 |
8 | else
9 | REDIRECT=$(MODULE_NAME)
10 | .PHONY: $(MAKECMDGOALS) call-upwards
11 | $(MAKECMDGOALS): call-upwards ;
12 | call-upwards:
13 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
14 | endif
15 |
--------------------------------------------------------------------------------
/src/options/inih/README.txt:
--------------------------------------------------------------------------------
1 |
2 | inih is a simple .INI file parser written in C, released under the New BSD
3 | license (see LICENSE.txt). Go to the project home page for more info:
4 |
5 | http://code.google.com/p/inih/
6 |
--------------------------------------------------------------------------------
/src/options/inih/ini.h:
--------------------------------------------------------------------------------
1 | /* inih -- simple .INI file parser
2 |
3 | inih is released under the New BSD license (see LICENSE.txt). Go to the project
4 | home page for more info:
5 |
6 | http://code.google.com/p/inih/
7 |
8 | */
9 |
10 | #ifndef __INI_H__
11 | #define __INI_H__
12 |
13 | /* Make this header file easier to include in C++ code */
14 | #ifdef __cplusplus
15 | extern "C" {
16 | #endif
17 |
18 | #include
19 |
20 | /* Parse given INI-style file. May have [section]s, name=value pairs
21 | (whitespace stripped), and comments starting with ';' (semicolon). Section
22 | is "" if name=value pair parsed before any section heading. name:value
23 | pairs are also supported as a concession to Python's ConfigParser.
24 |
25 | For each name=value pair parsed, call handler function with given user
26 | pointer as well as section, name, and value (data only valid for duration
27 | of handler call). Handler should return nonzero on success, zero on error.
28 |
29 | Returns 0 on success, line number of first error on parse error (doesn't
30 | stop on first error), -1 on file open error, or -2 on memory allocation
31 | error (only when INI_USE_STACK is zero).
32 | */
33 | int ini_parse(const char* filename,
34 | int (*handler)(void* user, const char* section,
35 | const char* name, const char* value),
36 | void* user);
37 |
38 | /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
39 | close the file when it's finished -- the caller must do that. */
40 | int ini_parse_file(FILE* file,
41 | int (*handler)(void* user, const char* section,
42 | const char* name, const char* value),
43 | void* user);
44 |
45 | /* Nonzero to allow multi-line value parsing, in the style of Python's
46 | ConfigParser. If allowed, ini_parse() will call the handler with the same
47 | name for each subsequent line parsed. */
48 | #ifndef INI_ALLOW_MULTILINE
49 | #define INI_ALLOW_MULTILINE 1
50 | #endif
51 |
52 | /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
53 | the file. See http://code.google.com/p/inih/issues/detail?id=21 */
54 | #ifndef INI_ALLOW_BOM
55 | #define INI_ALLOW_BOM 1
56 | #endif
57 |
58 | /* Nonzero to use stack, zero to use heap (malloc/free). */
59 | #ifndef INI_USE_STACK
60 | #define INI_USE_STACK 1
61 | #endif
62 |
63 | /* Stop parsing on first error (default is to keep parsing). */
64 | #ifndef INI_STOP_ON_FIRST_ERROR
65 | #define INI_STOP_ON_FIRST_ERROR 0
66 | #endif
67 |
68 | /* Maximum line length for any line in INI file. */
69 | #ifndef INI_MAX_LINE
70 | #define INI_MAX_LINE 2000
71 | #endif
72 |
73 | #ifdef __cplusplus
74 | }
75 | #endif
76 |
77 | #endif /* __INI_H__ */
78 |
--------------------------------------------------------------------------------
/src/options/tclap/AUTHORS:
--------------------------------------------------------------------------------
1 |
2 | original author: Michael E. Smoot
3 | invaluable contributions: Daniel Aarno
4 | more contributions: Erik Zeek
5 | more contributions: Fabien Carmagnac (Tinbergen-AM)
6 | outstanding editing: Carol Smoot
7 |
--------------------------------------------------------------------------------
/src/options/tclap/COPYING:
--------------------------------------------------------------------------------
1 |
2 |
3 | Copyright (c) 2003 Michael E. Smoot
4 |
5 | Permission is hereby granted, free of charge, to any person
6 | obtaining a copy of this software and associated documentation
7 | files (the "Software"), to deal in the Software without restriction,
8 | including without limitation the rights to use, copy, modify, merge,
9 | publish, distribute, sublicense, and/or sell copies of the Software,
10 | and to permit persons to whom the Software is furnished to do so,
11 | subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/options/tclap/CmdLineOutput.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /******************************************************************************
4 | *
5 | * file: CmdLineOutput.h
6 | *
7 | * Copyright (c) 2004, Michael E. Smoot
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 | #ifndef TCLAP_CMDLINEOUTPUT_H
24 | #define TCLAP_CMDLINEOUTPUT_H
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | namespace TCLAP {
34 |
35 | class CmdLineInterface;
36 | class ArgException;
37 |
38 | /**
39 | * The interface that any output object must implement.
40 | */
41 | class CmdLineOutput
42 | {
43 |
44 | public:
45 |
46 | /**
47 | * Virtual destructor.
48 | */
49 | virtual ~CmdLineOutput() {}
50 |
51 | /**
52 | * Generates some sort of output for the USAGE.
53 | * \param c - The CmdLine object the output is generated for.
54 | */
55 | virtual void usage(CmdLineInterface& c)=0;
56 |
57 | /**
58 | * Generates some sort of output for the version.
59 | * \param c - The CmdLine object the output is generated for.
60 | */
61 | virtual void version(CmdLineInterface& c)=0;
62 |
63 | /**
64 | * Generates some sort of output for a failure.
65 | * \param c - The CmdLine object the output is generated for.
66 | * \param e - The ArgException that caused the failure.
67 | */
68 | virtual void failure( CmdLineInterface& c,
69 | ArgException& e )=0;
70 |
71 | };
72 |
73 | } //namespace TCLAP
74 | #endif
75 |
--------------------------------------------------------------------------------
/src/options/tclap/Constraint.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: Constraint.h
5 | *
6 | * Copyright (c) 2005, Michael E. Smoot
7 | * All rights reverved.
8 | *
9 | * See the file COPYING in the top directory of this distribution for
10 | * more information.
11 | *
12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 | * DEALINGS IN THE SOFTWARE.
19 | *
20 | *****************************************************************************/
21 |
22 | #ifndef TCLAP_CONSTRAINT_H
23 | #define TCLAP_CONSTRAINT_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | namespace TCLAP {
33 |
34 | /**
35 | * The interface that defines the interaction between the Arg and Constraint.
36 | */
37 | template
38 | class Constraint
39 | {
40 |
41 | public:
42 | /**
43 | * Returns a description of the Constraint.
44 | */
45 | virtual std::string description() const =0;
46 |
47 | /**
48 | * Returns the short ID for the Constraint.
49 | */
50 | virtual std::string shortID() const =0;
51 |
52 | /**
53 | * The method used to verify that the value parsed from the command
54 | * line meets the constraint.
55 | * \param value - The value that will be checked.
56 | */
57 | virtual bool check(const T& value) const =0;
58 |
59 | /**
60 | * Destructor.
61 | * Silences warnings about Constraint being a base class with virtual
62 | * functions but without a virtual destructor.
63 | */
64 | virtual ~Constraint() { ; }
65 | };
66 |
67 | } //namespace TCLAP
68 | #endif
69 |
--------------------------------------------------------------------------------
/src/options/tclap/HelpVisitor.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: HelpVisitor.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot .
7 | * All rights reverved.
8 | *
9 | * See the file COPYING in the top directory of this distribution for
10 | * more information.
11 | *
12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 | * DEALINGS IN THE SOFTWARE.
19 | *
20 | *****************************************************************************/
21 |
22 | #ifndef TCLAP_HELP_VISITOR_H
23 | #define TCLAP_HELP_VISITOR_H
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | namespace TCLAP {
30 |
31 | /**
32 | * A Visitor object that calls the usage method of the given CmdLineOutput
33 | * object for the specified CmdLine object.
34 | */
35 | class HelpVisitor: public Visitor
36 | {
37 | private:
38 | /**
39 | * Prevent accidental copying.
40 | */
41 | HelpVisitor(const HelpVisitor& rhs);
42 | HelpVisitor& operator=(const HelpVisitor& rhs);
43 |
44 | protected:
45 |
46 | /**
47 | * The CmdLine the output will be generated for.
48 | */
49 | CmdLineInterface* _cmd;
50 |
51 | /**
52 | * The output object.
53 | */
54 | CmdLineOutput** _out;
55 |
56 | public:
57 |
58 | /**
59 | * Constructor.
60 | * \param cmd - The CmdLine the output will be generated for.
61 | * \param out - The type of output.
62 | */
63 | HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out)
64 | : Visitor(), _cmd( cmd ), _out( out ) { }
65 |
66 | /**
67 | * Calls the usage method of the CmdLineOutput for the
68 | * specified CmdLine.
69 | */
70 | void visit() { (*_out)->usage(*_cmd); throw ExitException(0); }
71 |
72 | };
73 |
74 | }
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/src/options/tclap/IgnoreRestVisitor.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: IgnoreRestVisitor.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot .
7 | * All rights reverved.
8 | *
9 | * See the file COPYING in the top directory of this distribution for
10 | * more information.
11 | *
12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 | * DEALINGS IN THE SOFTWARE.
19 | *
20 | *****************************************************************************/
21 |
22 |
23 | #ifndef TCLAP_IGNORE_REST_VISITOR_H
24 | #define TCLAP_IGNORE_REST_VISITOR_H
25 |
26 | #include
27 | #include
28 |
29 | namespace TCLAP {
30 |
31 | /**
32 | * A Vistor that tells the CmdLine to begin ignoring arguments after
33 | * this one is parsed.
34 | */
35 | class IgnoreRestVisitor: public Visitor
36 | {
37 | public:
38 |
39 | /**
40 | * Constructor.
41 | */
42 | IgnoreRestVisitor() : Visitor() {}
43 |
44 | /**
45 | * Sets Arg::_ignoreRest.
46 | */
47 | void visit() { Arg::beginIgnoring(); }
48 | };
49 |
50 | }
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/src/options/tclap/OptionalUnlabeledTracker.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /******************************************************************************
4 | *
5 | * file: OptionalUnlabeledTracker.h
6 | *
7 | * Copyright (c) 2005, Michael E. Smoot .
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 |
24 | #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H
25 | #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H
26 |
27 | #include
28 |
29 | namespace TCLAP {
30 |
31 | class OptionalUnlabeledTracker
32 | {
33 |
34 | public:
35 |
36 | static void check( bool req, const std::string& argName );
37 |
38 | static void gotOptional() { alreadyOptionalRef() = true; }
39 |
40 | static bool& alreadyOptional() { return alreadyOptionalRef(); }
41 |
42 | private:
43 |
44 | static bool& alreadyOptionalRef() { static bool ct = false; return ct; }
45 | };
46 |
47 |
48 | inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName )
49 | {
50 | if ( OptionalUnlabeledTracker::alreadyOptional() )
51 | throw( SpecificationException(
52 | "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg",
53 | argName ) );
54 |
55 | if ( !req )
56 | OptionalUnlabeledTracker::gotOptional();
57 | }
58 |
59 |
60 | } // namespace TCLAP
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/src/options/tclap/VersionVisitor.h:
--------------------------------------------------------------------------------
1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2 |
3 | /******************************************************************************
4 | *
5 | * file: VersionVisitor.h
6 | *
7 | * Copyright (c) 2003, Michael E. Smoot .
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 |
24 | #ifndef TCLAP_VERSION_VISITOR_H
25 | #define TCLAP_VERSION_VISITOR_H
26 |
27 | #include
28 | #include
29 | #include
30 |
31 | namespace TCLAP {
32 |
33 | /**
34 | * A Vistor that will call the version method of the given CmdLineOutput
35 | * for the specified CmdLine object and then exit.
36 | */
37 | class VersionVisitor: public Visitor
38 | {
39 | private:
40 | /**
41 | * Prevent accidental copying
42 | */
43 | VersionVisitor(const VersionVisitor& rhs);
44 | VersionVisitor& operator=(const VersionVisitor& rhs);
45 |
46 | protected:
47 |
48 | /**
49 | * The CmdLine of interest.
50 | */
51 | CmdLineInterface* _cmd;
52 |
53 | /**
54 | * The output object.
55 | */
56 | CmdLineOutput** _out;
57 |
58 | public:
59 |
60 | /**
61 | * Constructor.
62 | * \param cmd - The CmdLine the output is generated for.
63 | * \param out - The type of output.
64 | */
65 | VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out )
66 | : Visitor(), _cmd( cmd ), _out( out ) { }
67 |
68 | /**
69 | * Calls the version method of the output object using the
70 | * specified CmdLine.
71 | */
72 | void visit() {
73 | (*_out)->version(*_cmd);
74 | throw ExitException(0);
75 | }
76 |
77 | };
78 |
79 | }
80 |
81 | #endif
82 |
--------------------------------------------------------------------------------
/src/options/tclap/Visitor.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: Visitor.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot .
7 | * All rights reverved.
8 | *
9 | * See the file COPYING in the top directory of this distribution for
10 | * more information.
11 | *
12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 | * DEALINGS IN THE SOFTWARE.
19 | *
20 | *****************************************************************************/
21 |
22 |
23 | #ifndef TCLAP_VISITOR_H
24 | #define TCLAP_VISITOR_H
25 |
26 | namespace TCLAP {
27 |
28 | /**
29 | * A base class that defines the interface for visitors.
30 | */
31 | class Visitor
32 | {
33 | public:
34 |
35 | /**
36 | * Constructor. Does nothing.
37 | */
38 | Visitor() { }
39 |
40 | /**
41 | * Destructor. Does nothing.
42 | */
43 | virtual ~Visitor() { }
44 |
45 | /**
46 | * Does nothing. Should be overridden by child.
47 | */
48 | virtual void visit() { }
49 | };
50 |
51 | }
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/src/problems/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = problems
2 | CHILD_DIRS := shared rocksample tag homecare pushbox conttag
3 |
4 | ifdef HAS_ROOT_MAKEFILE
5 |
6 | problems: $(CHILD_DIRS)
7 |
8 | include .make/template.mk
9 |
10 | else
11 | REDIRECT=$(MODULE_NAME)
12 | .PHONY: $(MAKECMDGOALS) call-upwards
13 | $(MAKECMDGOALS): call-upwards ;
14 | call-upwards:
15 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
16 | endif
17 |
--------------------------------------------------------------------------------
/src/problems/conttag/ContTagObservation.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include // for size_t
4 |
5 | #include // for ostream
6 | #include // for vector
7 |
8 | #include "global.hpp" // for RandomGenerator
9 |
10 | #include "solver/abstract-problem/DiscretizedPoint.hpp"
11 | #include "solver/abstract-problem/Observation.hpp"
12 |
13 | #include "ContTagPosition.hpp"
14 |
15 | namespace conttag {
16 | class ContTagModel;
17 |
18 | /** A class representing an observation in the Tag POMDP.
19 | *
20 | * This includes an observation of the robot's own position, and a boolean flag representing
21 | * whether or not the robot sees the opponent (and hence is on the same grid square).
22 | */
23 | class ContTagObservation final: public solver::Point {
24 | typedef ContTagObservation This;
25 | public:
26 | ContTagObservation(const bool theSeen): seen(theSeen) {};
27 |
28 | virtual ~ContTagObservation() = default;
29 | _NO_COPY_OR_MOVE(ContTagObservation);
30 |
31 | std::unique_ptr copy() const override {
32 | return std::make_unique(seen);
33 | }
34 |
35 | double distanceTo(solver::Observation const &otherObs) const override {
36 | This const &other = static_cast(otherObs);
37 | return (seen == other.seen) ? 0 : 1;
38 | }
39 |
40 | bool equals(solver::Observation const &otherObs) const override {
41 | This const &other = static_cast(otherObs);
42 | return seen == other.seen;
43 | }
44 |
45 | std::size_t hash() const override {
46 | return std::hash()(seen);
47 | }
48 |
49 | void print(std::ostream &os) const override {
50 | os << (seen ? "seen" : "not_seen");
51 | }
52 |
53 | /** Returns the position the robot has observed itself in. */
54 | bool isSeen() const { return seen; }
55 |
56 | private:
57 | /** The position the robot sees itself in. */
58 | bool seen;
59 | };
60 | } /* namespace contnav */
61 |
--------------------------------------------------------------------------------
/src/problems/conttag/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = conttag
2 | TARGET_NAMES := solve simulate
3 |
4 | ifdef HAS_ROOT_MAKEFILE
5 |
6 | include .make/problem-template.mk
7 |
8 | else
9 | REDIRECT=$(MODULE_NAME)
10 | .PHONY: $(MAKECMDGOALS) call-upwards
11 | $(MAKECMDGOALS): call-upwards ;
12 | call-upwards:
13 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
14 | endif
15 |
--------------------------------------------------------------------------------
/src/problems/conttag/simulate.cpp:
--------------------------------------------------------------------------------
1 | /** @file conttag/simulate.cpp
2 | *
3 | * Defines the main method for the "simulate" executable for the Tag POMDP, which runs online
4 | * simulations to test the performance of the solver.
5 | */
6 | #include "problems/shared/simulate.hpp"
7 |
8 | #include "ContTagModel.hpp" // for TagModel
9 | #include "ContTagOptions.hpp" // for TagOptions
10 |
11 | /** The main method for the "simulate" executable for Tag. */
12 | int main(int argc, char const *argv[]) {
13 | return simulate(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/problems/conttag/solve.cpp:
--------------------------------------------------------------------------------
1 | /** @file conttag/solve.cpp
2 | *
3 | * Defines the main method for the "solve" executable for the Tag POMDP, which generates an
4 | * initial policy.
5 | */
6 | #include "problems/shared/solve.hpp"
7 |
8 | #include "ContTagModel.hpp" // for TagModel
9 | #include "ContTagOptions.hpp" // for TagOptions
10 |
11 | /** The main method for the "solve" executable for Tag. */
12 | int main(int argc, char const *argv[]) {
13 | return solve(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/problems/homecare/HomecareAction.cpp:
--------------------------------------------------------------------------------
1 | /** @file HomecareAction.cpp
2 | *
3 | * Contains the implementations for the methods of the HomecareAction class.
4 | */
5 | #include "HomecareAction.hpp"
6 |
7 | #include // for size_t
8 |
9 | #include // for copy
10 | #include // for ostream_iterator
11 | #include // for operator<<, ostream
12 | #include // for vector, operator==, _Bit_const_iterator, _Bit_iterator_base, hash, vector<>::const_iterator
13 |
14 | #include "global.hpp"
15 |
16 | #include "problems/shared/GridPosition.hpp" // for GridPosition, operator==, operator<<
17 | #include "solver/abstract-problem/State.hpp" // for State
18 |
19 | namespace homecare {
20 | HomecareAction::HomecareAction(ActionType actionType):
21 | actionType_(actionType) {
22 | }
23 |
24 | HomecareAction::HomecareAction(long code) :
25 | actionType_(static_cast(code)) {
26 | }
27 |
28 | std::unique_ptr HomecareAction::copy() const {
29 | return std::make_unique(actionType_);
30 | }
31 |
32 | double HomecareAction::distanceTo(solver::Action const &/*otherAction*/) const {
33 | return 0;
34 | }
35 |
36 | void HomecareAction::print(std::ostream &os) const {
37 | switch (actionType_) {
38 | case ActionType::NORTH:
39 | os << "NORTH";
40 | break;
41 | case ActionType::NORTH_EAST:
42 | os << "NORTH_EAST";
43 | break;
44 | case ActionType::EAST:
45 | os << "EAST";
46 | break;
47 | case ActionType::SOUTH_EAST:
48 | os << "SOUTH_EAST";
49 | break;
50 | case ActionType::SOUTH:
51 | os << "SOUTH";
52 | break;
53 | case ActionType::SOUTH_WEST:
54 | os << "SOUTH_WEST";
55 | break;
56 | case ActionType::WEST:
57 | os << "WEST";
58 | break;
59 | case ActionType::NORTH_WEST:
60 | os << "NORTH_WEST";
61 | break;
62 | case ActionType::WAIT:
63 | os << "WAIT";
64 | break;
65 | default:
66 | os << "ERROR-" << static_cast(actionType_);
67 | break;
68 | }
69 | }
70 |
71 | long HomecareAction::getBinNumber() const {
72 | return static_cast(actionType_);
73 | }
74 | ActionType HomecareAction::getActionType() const {
75 | return actionType_;
76 | }
77 | } /* namespace homecare */
78 |
--------------------------------------------------------------------------------
/src/problems/homecare/HomecareAction.hpp:
--------------------------------------------------------------------------------
1 | /** @file HomecareAction.hpp
2 | *
3 | * Defines the HomecareAction class, which represents an action for the Homecare problem, and also the
4 | * ActionType enumeration, which enumerates the different types of actions for Homecare.
5 | */
6 | #ifndef HOMECARE_ACTION_HPP_
7 | #define HOMECARE_ACTION_HPP_
8 |
9 | #include // for size_t
10 |
11 | #include // for ostream
12 | #include // for vector
13 |
14 | #include "solver/abstract-problem/Action.hpp"
15 | #include "solver/abstract-problem/DiscretizedPoint.hpp" // for DiscretizedPoint
16 |
17 | namespace homecare {
18 |
19 | /** An enumeration of all the available actions in the Homecare PODMP. */
20 | enum class ActionType : long {
21 | NORTH = 0,
22 | NORTH_EAST = 1,
23 | EAST = 2,
24 | SOUTH_EAST = 3,
25 | SOUTH = 4,
26 | SOUTH_WEST = 5,
27 | WEST = 6,
28 | NORTH_WEST = 7,
29 | WAIT = 8,
30 | };
31 |
32 | /** A class representing an action in the Homecare POMDP.
33 | *
34 | * This class also implements solver::DiscretizedPoint so that the solver can use a simplistic
35 | * enumerated action mapping approach (EnumeratedActionPool) to store the available actions from
36 | * each belief node.
37 | */
38 | class HomecareAction : public solver::DiscretizedPoint {
39 | friend class HomecareTextSerializer;
40 | public:
41 | /** Constructs a new action from the given ActionType. */
42 | HomecareAction(ActionType actionType);
43 | /** Constructs a new action from the given integer code. */
44 | HomecareAction(long code);
45 |
46 | virtual ~HomecareAction() = default;
47 | _NO_COPY_OR_MOVE(HomecareAction);
48 |
49 | std::unique_ptr copy() const override;
50 | double distanceTo(solver::Action const &otherAction) const override;
51 | void print(std::ostream &os) const override;
52 |
53 | long getBinNumber() const override;
54 | /** Returns the ActionType of this action. */
55 | ActionType getActionType() const;
56 | private:
57 | /** The ActionType for this action in the Homecare POMDP. */
58 | ActionType actionType_;
59 | };
60 | } /* namespace homecare */
61 |
62 | #endif /* HOMECARE_ACTION_HPP_ */
63 |
--------------------------------------------------------------------------------
/src/problems/homecare/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = homecare
2 |
3 | ifdef HAS_ROOT_MAKEFILE
4 |
5 | TARGET_NAMES := solve simulate
6 | include .make/problem-template.mk
7 |
8 | else
9 | ROOT = ../../..
10 | include $(ROOT)/.make/redirect.mk
11 | endif
12 |
--------------------------------------------------------------------------------
/src/problems/homecare/simulate.cpp:
--------------------------------------------------------------------------------
1 | /** @file homecare/simulate.cpp
2 | *
3 | * Defines the main method for the "simulate" executable for the Homecare POMDP, which runs online
4 | * simulations to test the performance of the solver.
5 | */
6 | #include "problems/shared/simulate.hpp"
7 |
8 | #include "HomecareModel.hpp" // for HomecareModel
9 | #include "HomecareOptions.hpp" // for HomecareOptions
10 |
11 | /** The main method for the "simulate" executable for Homecare. */
12 | int main(int argc, char const *argv[]) {
13 | return simulate(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/problems/homecare/solve.cpp:
--------------------------------------------------------------------------------
1 | /** @file homecare/solve.cpp
2 | *
3 | * Defines the main method for the "solve" executable for the Homecare POMDP, which generates an
4 | * initial policy.
5 | */
6 | #include "problems/shared/solve.hpp"
7 |
8 | #include "HomecareModel.hpp" // for HomecareModel
9 | #include "HomecareOptions.hpp" // for HomecareOptions
10 |
11 | /** The main method for the "solve" executable for Homecare. */
12 | int main(int argc, char const *argv[]) {
13 | return solve(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/problems/homecare/stest.cpp:
--------------------------------------------------------------------------------
1 | /** @file homecare/stest.cpp
2 | *
3 | * Defines the main method for the "stest" executable for the Homecare POMDP, which tests the
4 | * serialization methods for Homecare by deserializing and re-serializing a policy file.
5 | */
6 | #include "problems/shared/stest.hpp"
7 |
8 | #include "HomecareModel.hpp" // for HomecareModel
9 | #include "HomecareOptions.hpp" // for HomecareOptions
10 |
11 | /** The main method for the "stest" executable for Homecare. */
12 | int main(int argc, char const *argv[]) {
13 | return stest(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/problems/pushbox/BearingObservation.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include // for size_t
4 |
5 | #include // for ostream
6 | #include // for vector
7 |
8 | #include "global.hpp" // for RandomGenerator
9 |
10 | #include "solver/abstract-problem/DiscretizedPoint.hpp"
11 | #include "solver/abstract-problem/Observation.hpp"
12 |
13 |
14 | namespace pushbox {
15 |
16 |
17 | /** A class representing an observation of a bearing sensor
18 | *
19 | */
20 | class BearingObservationDiscrete: public solver::Point {
21 | typedef BearingObservationDiscrete This;
22 | public:
23 |
24 | BearingObservationDiscrete(int theBearing, int numberOfBuckets, const bool wasPushed): bearing(theBearing), buckets(numberOfBuckets), pushed(wasPushed) {};
25 |
26 | _NO_COPY_OR_MOVE(BearingObservationDiscrete);
27 |
28 | virtual std::unique_ptr copy() const {
29 | return std::make_unique(bearing, buckets, pushed);
30 | }
31 |
32 | double distanceTo(solver::Observation const &otherObs) const override {
33 | This const &other = static_cast(otherObs);
34 | return ((bearing-other.bearing) % buckets) + ( pushed == other.pushed ? 0 : buckets);
35 | }
36 |
37 | bool equals(solver::Observation const &otherObs) const override {
38 | This const &other = static_cast(otherObs);
39 | return (bearing == other.bearing) && (pushed == other.pushed);
40 | }
41 |
42 | std::size_t hash() const override {
43 | return std::hash()(bearing);
44 | }
45 |
46 | void print(std::ostream &os) const override {
47 | os << bearing << (pushed ? " pushed" : " normal");
48 | }
49 |
50 | /** Returns the bearing. */
51 | int getBearing() const { return bearing; }
52 |
53 | /** Returns the number of buckets. */
54 | int getBuckets() const { return buckets; }
55 |
56 | /** returns the pushed status */
57 | bool getPushed() const { return pushed; }
58 |
59 | private:
60 | /** The position the robot sees itself in. */
61 | int bearing;
62 | int buckets;
63 | bool pushed;
64 | };
65 |
66 |
67 |
68 | } /* namespace pushbox */
69 |
70 |
71 |
--------------------------------------------------------------------------------
/src/problems/pushbox/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = pushbox
2 | TARGET_NAMES := solve simulate
3 |
4 | ifdef HAS_ROOT_MAKEFILE
5 |
6 | include .make/problem-template.mk
7 |
8 | else
9 | REDIRECT=$(MODULE_NAME)
10 | .PHONY: $(MAKECMDGOALS) call-upwards
11 | $(MAKECMDGOALS): call-upwards ;
12 | call-upwards:
13 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
14 | endif
15 |
--------------------------------------------------------------------------------
/src/problems/pushbox/TruncatedNormalDistribution.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 |
4 | #include
5 |
6 | namespace pushbox {
7 |
8 | class TruncatedNormalDistribution {
9 | public:
10 | TruncatedNormalDistribution(const double theMean = 0.0, const double stddev = 1.0 ): mean(theMean), lowerBound(mean-stddev), upperBound(mean+stddev), zeroStdDev(stddev==0), normalDistribution(mean, stddev) {}
11 | template
12 | double operator()(URNG& g) {
13 | if (zeroStdDev) return lowerBound;
14 | while (true) {
15 | double result = normalDistribution(g);
16 | if ( (result >= lowerBound) && (result <= upperBound) ) {
17 | return result;
18 | }
19 | }
20 | }
21 | bool hasZeroStdDev() const { return zeroStdDev; }
22 | double getMean() const { return mean; }
23 | private:
24 | double mean;
25 | double lowerBound;
26 | double upperBound;
27 | bool zeroStdDev;
28 | std::normal_distribution normalDistribution;
29 | };
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/problems/pushbox/simulate.cpp:
--------------------------------------------------------------------------------
1 | /** @file pushbox/simulate.cpp
2 | *
3 | * Defines the main method for the "simulate" executable for the Tag POMDP, which runs online
4 | * simulations to test the performance of the solver.
5 | */
6 | #include "problems/shared/simulate.hpp"
7 |
8 | #include "PushBoxModel.hpp"
9 |
10 | /** The main method for the "simulate" executable for Tag. */
11 | int main(int argc, char const *argv[]) {
12 | return simulate(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/src/problems/pushbox/solve.cpp:
--------------------------------------------------------------------------------
1 | /** @file pushbox/solve.cpp
2 | *
3 | * Defines the main method for the "solve" executable for the Tag POMDP, which generates an
4 | * initial policy.
5 | */
6 | #include "problems/shared/solve.hpp"
7 |
8 | #include "PushBoxModel.hpp"
9 |
10 | /** The main method for the "solve" executable for Tag. */
11 | int main(int argc, char const *argv[]) {
12 | return solve(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/src/problems/rocksample/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = rocksample
2 | TARGET_NAMES := solve simulate
3 |
4 | ifdef HAS_ROOT_MAKEFILE
5 |
6 | include .make/problem-template.mk
7 |
8 | else
9 | REDIRECT=$(MODULE_NAME)
10 | .PHONY: $(MAKECMDGOALS) call-upwards
11 | $(MAKECMDGOALS): call-upwards ;
12 | call-upwards:
13 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
14 | endif
15 |
--------------------------------------------------------------------------------
/src/problems/rocksample/PreferredActionsPool.cpp:
--------------------------------------------------------------------------------
1 | /** @file PreferredActionsPool.cpp
2 | *
3 | * Contains the implementation of the mapping classes for dealing with preferred actions in the
4 | * RockSample problem, a la POMCP's "smart" tree knowledge.
5 | */
6 | #include "PreferredActionsPool.hpp"
7 |
8 | #include "RockSampleAction.hpp"
9 | #include "RockSampleModel.hpp"
10 | #include "smart_history.hpp"
11 |
12 | namespace rocksample {
13 | PreferredActionsPool::PreferredActionsPool(RockSampleModel *model) :
14 | EnumeratedActionPool(model, model->getAllActionsInOrder()),
15 | model_(model) {
16 | }
17 |
18 | std::vector PreferredActionsPool::createBinSequence(solver::BeliefNode *node) {
19 | solver::HistoricalData const *data = node->getHistoricalData();
20 | RockSampleModel::RSActionCategory category = model_->getSearchActionCategory();
21 | if (category == RockSampleModel::RSActionCategory::LEGAL) {
22 | std::vector bins = static_cast(data)->generateLegalActions();
23 | std::shuffle(bins.begin(), bins.end(), *model_->getRandomGenerator());
24 | return std::move(bins);
25 | } else if (category == RockSampleModel::RSActionCategory::PREFERRED) {
26 | std::vector bins = static_cast(data)->generatePreferredActions();
27 | std::shuffle(bins.begin(), bins.end(), *model_->getRandomGenerator());
28 | return std::move(bins);
29 | } else {
30 | return EnumeratedActionPool::createBinSequence(node);
31 | }
32 | }
33 |
34 | std::unique_ptr PreferredActionsPool::createActionMapping(
35 | solver::BeliefNode *node) {
36 | std::unique_ptr discMap = (
37 | std::make_unique(node, this, createBinSequence(node)));
38 |
39 | PositionAndRockData const &data =
40 | static_cast(*node->getHistoricalData());
41 |
42 | if (model_->usingPreferredInit()) {
43 | for (RockSampleAction const &action : data.generatePreferredActions()) {
44 | long visitCount = model_->getPreferredVisitCount();
45 | discMap->getEntry(action)->update(visitCount, visitCount * model_->getPreferredQValue());
46 | }
47 | }
48 |
49 | return std::move(discMap);
50 | }
51 | } /* namespace rocksample */
52 |
--------------------------------------------------------------------------------
/src/problems/rocksample/PreferredActionsPool.hpp:
--------------------------------------------------------------------------------
1 | /** @file PreferredActionsPool.hpp
2 | *
3 | * Contains an ActionPool implementation for preferred actions in RockSample.
4 | *
5 | * This is done by using the "smart" historical data stored within a PositionAndRockData instance
6 | * in order to determine which actions are preferred. This implementation follows the "smart"
7 | * data for RockSample used in POMCP, and allows for the same functionality.
8 | *
9 | * NOTE: Preferred actions are not currently updated in response to model changes!
10 | */
11 | #ifndef ROCKSAMPLE_PREFERREDACTIONSPOOL_HPP_
12 | #define ROCKSAMPLE_PREFERREDACTIONSPOOL_HPP_
13 |
14 | #include
15 | #include
16 |
17 | #include "solver/mappings/actions/enumerated_actions.hpp"
18 |
19 | namespace solver {
20 | class ActionMapping;
21 | class BeliefNode;
22 | class HistoricalData;
23 | }
24 |
25 | namespace rocksample {
26 | class RockSampleModel;
27 |
28 | /** An implementation of ActionPool for preferred actions in RockSample.
29 | *
30 | * The basic functionality comes from EnumeratedActionPool; this class also customizes the
31 | * createBinSequence() method to control which actions are considered legal and what order they
32 | * are chosen in.
33 | * The createActionMapping() method is also modified - if preferred initialization is used, the
34 | * Q-values and visit counts for preferred actions can be initialized to non-zero values,
35 | * a la the "SMART rollout knowledge" in POMCP.
36 | */
37 | class PreferredActionsPool: public solver::EnumeratedActionPool {
38 | public:
39 | /** Initializes a new PreferredActionsPool instance associated with the given model. */
40 | PreferredActionsPool(RockSampleModel *model);
41 | virtual ~PreferredActionsPool() = default;
42 | _NO_COPY_OR_MOVE(PreferredActionsPool);
43 |
44 | virtual std::vector createBinSequence(solver::BeliefNode *node) override;
45 |
46 | virtual std::unique_ptr createActionMapping(solver::BeliefNode *node)
47 | override;
48 |
49 | private:
50 | /** The RockSampleModel instance this pool is assoicated with. */
51 | RockSampleModel *model_;
52 | };
53 | } /* namespace rocksample */
54 |
55 | #endif /* ROCKSAMPLE_PREFERREDACTIONSPOOL_HPP_ */
56 |
--------------------------------------------------------------------------------
/src/problems/rocksample/RockSampleAction.cpp:
--------------------------------------------------------------------------------
1 | /** @file RockSampleAction.cpp
2 | *
3 | * Contains the implementations for the methods of the RockSampleAction class.
4 | */
5 | #include "RockSampleAction.hpp"
6 |
7 | #include // for size_t
8 | #include
9 |
10 | #include // for copy
11 | #include // for ostream_iterator
12 | #include // for operator<<, ostream
13 | #include // for vector, operator==, _Bit_const_iterator, _Bit_iterator_base, hash, vector<>::const_iterator
14 |
15 | #include "global.hpp"
16 | #include "problems/shared/GridPosition.hpp" // for GridPosition, operator==, operator<<
17 | #include "solver/abstract-problem/State.hpp" // for State
18 |
19 | namespace rocksample {
20 | RockSampleAction::RockSampleAction(ActionType actionType, uint8_t rockNo) :
21 | actionType_(actionType),
22 | rockNo_(rockNo) {
23 | }
24 |
25 | RockSampleAction::RockSampleAction(long code) :
26 | actionType_(code <= 5 ? static_cast(code) : ActionType::CHECK),
27 | rockNo_(actionType_ == ActionType::CHECK ? code-5 : 0) {
28 | }
29 |
30 | std::unique_ptr RockSampleAction::copy() const {
31 | return std::make_unique(actionType_,rockNo_);
32 | }
33 |
34 | double RockSampleAction::distanceTo(solver::Action const &/*otherAction*/) const {
35 | return 0;
36 | }
37 |
38 | void RockSampleAction::print(std::ostream &os) const {
39 | os << actionType_;
40 | if (actionType_ == ActionType::CHECK) {
41 | os << static_cast(rockNo_);
42 | }
43 | }
44 |
45 | long RockSampleAction::getBinNumber() const {
46 | long code = static_cast(actionType_);
47 | if (actionType_ == ActionType::CHECK) {
48 | code += rockNo_;
49 | }
50 | return code;
51 | }
52 |
53 | ActionType RockSampleAction::getActionType() const {
54 | return actionType_;
55 | }
56 |
57 | long RockSampleAction::getRockNo() const {
58 | return rockNo_;
59 | }
60 | } /* namespace rocksample */
61 |
--------------------------------------------------------------------------------
/src/problems/rocksample/RockSampleObservation.cpp:
--------------------------------------------------------------------------------
1 | /** @file RockSampleObservation.cpp
2 | *
3 | * Contains the implementations for the methods of RockSampleObservation.
4 | */
5 | #include "RockSampleObservation.hpp"
6 |
7 | #include // for size_t
8 |
9 | #include // for copy
10 | #include // for ostream_iterator
11 | #include // for operator<<, ostream
12 | #include // for vector, operator==, _Bit_const_iterator, _Bit_iterator_base, hash, vector<>::const_iterator
13 |
14 | #include "global.hpp"
15 | #include "problems/shared/GridPosition.hpp" // for GridPosition, operator==, operator<<
16 | #include "solver/abstract-problem/Observation.hpp" // for Observation
17 |
18 | namespace rocksample {
19 |
20 | RockSampleObservation::RockSampleObservation() :
21 | isEmpty_(true),
22 | isGood_(false) {
23 | }
24 |
25 | RockSampleObservation::RockSampleObservation(bool _isGood) :
26 | isEmpty_(false),
27 | isGood_(_isGood) {
28 | }
29 |
30 | RockSampleObservation::RockSampleObservation(bool _isEmpty, bool _isGood) :
31 | isEmpty_(_isEmpty),
32 | isGood_(_isGood) {
33 | }
34 |
35 | RockSampleObservation::RockSampleObservation(long code) :
36 | isEmpty_(code == 0),
37 | isGood_(code == 1) {
38 | }
39 |
40 | std::unique_ptr RockSampleObservation::copy() const {
41 | return std::make_unique(isEmpty_,isGood_);
42 | }
43 |
44 | double RockSampleObservation::distanceTo(solver::Observation const &otherObs) const {
45 | RockSampleObservation const &other =
46 | static_cast(otherObs);
47 | return isGood_ == other.isGood_ ? 0 : 1;
48 | }
49 |
50 | bool RockSampleObservation::equals(solver::Observation const &otherObs) const {
51 | RockSampleObservation const &other =
52 | static_cast(otherObs);
53 | return isGood_ == other.isGood_;
54 | }
55 |
56 | std::size_t RockSampleObservation::hash() const {
57 | return isGood_ ? 1 : 0;
58 | }
59 |
60 | void RockSampleObservation::print(std::ostream &os) const {
61 | if (isEmpty_) {
62 | os << "NONE";
63 | } else if (isGood_) {
64 | os << "GOOD";
65 | } else {
66 | os << "BAD";
67 | }
68 | }
69 |
70 | long RockSampleObservation::getBinNumber() const {
71 | return isEmpty_ ? 0 : (isGood_ ? 1 : 2);
72 | }
73 |
74 | bool RockSampleObservation::isEmpty() const {
75 | return isEmpty_;
76 | }
77 |
78 | bool RockSampleObservation::isGood() const {
79 | return isGood_;
80 | }
81 | }
82 | /* namespace rocksample */
83 |
--------------------------------------------------------------------------------
/src/problems/rocksample/RockSampleObservation.hpp:
--------------------------------------------------------------------------------
1 | /** @file RockSampleObservation.hpp
2 | *
3 | * Defines the RockSampleObservation class, which represents an observation in the RockSample POMDP.
4 | */
5 | #ifndef ROCKSAMPLE_OBSERVATION_HPP_
6 | #define ROCKSAMPLE_OBSERVATION_HPP_
7 |
8 | #include // for size_t
9 |
10 | #include // for ostream
11 | #include // for vector
12 |
13 | #include "solver/abstract-problem/DiscretizedPoint.hpp"
14 | #include "solver/abstract-problem/Observation.hpp"
15 |
16 | #include "global.hpp" // for RandomGenerator
17 |
18 | namespace rocksample {
19 | /** A class representing an observation in the RockSample POMDP.
20 | *
21 | * This is represented by two boolean flags; one for whether or not any observation was made,
22 | * and one for whether the rock was seen as good or bad if an observation was, in fact, made.
23 | *
24 | * This class also implements solver::DiscretizedPoint so that the solver can use a simplistic
25 | * enumerated observation mapping approach (EnumeratedObservationPool) to store the possible
26 | * observations from each ActionNode.
27 | */
28 | class RockSampleObservation : public solver::DiscretizedPoint {
29 | friend class RockSampleTextSerializer;
30 |
31 | public:
32 | /** Constructs a new, empty observation. */
33 | RockSampleObservation();
34 | /** Constructs a non-empty observation, which is good iff _isGood is true. */
35 | RockSampleObservation(bool _isGood);
36 | /** Constructs a new observation with the given values for whether it is empty, and whether it
37 | * is good.
38 | */
39 | RockSampleObservation(bool _isEmpty, bool _isGood);
40 | /** Constructs a new observation from the given integer code. */
41 | RockSampleObservation(long code);
42 |
43 | virtual ~RockSampleObservation() = default;
44 | _NO_COPY_OR_MOVE(RockSampleObservation);
45 |
46 | std::unique_ptr copy() const override;
47 | double distanceTo(solver::Observation const &otherObs) const override;
48 | bool equals(solver::Observation const &otherObs) const override;
49 | std::size_t hash() const override;
50 | void print(std::ostream &os) const override;
51 |
52 | long getBinNumber() const override;
53 |
54 | /** Returns true iff this observation is empty. */
55 | bool isEmpty() const;
56 | /** Returns true iff this observation is good. */
57 | bool isGood() const;
58 |
59 | private:
60 | /** True iff this observation is empty. */
61 | bool isEmpty_;
62 | /** True iff this observation is good. */
63 | bool isGood_;
64 | };
65 | } /* namespace rocksample */
66 |
67 | #endif /* ROCKSAMPLE_OBSERVATION_HPP_ */
68 |
--------------------------------------------------------------------------------
/src/problems/rocksample/position_history.hpp:
--------------------------------------------------------------------------------
1 | /** @file position_history.hpp
2 | *
3 | * Defines a class to keep track of the position of the robot in RockSample.
4 | *
5 | * This is useful, since the position is fully observable but is not included in observations.
6 | */
7 | #ifndef ROCKSAMPLE_POSITION_HISTORY_HPP_
8 | #define ROCKSAMPLE_POSITION_HISTORY_HPP_
9 |
10 | #include
11 | #include
12 |
13 | #include "solver/abstract-problem/HistoricalData.hpp"
14 |
15 | #include "solver/serialization/TextSerializer.hpp"
16 |
17 | #include "problems/shared/GridPosition.hpp"
18 |
19 | namespace rocksample {
20 | class RockSampleAction;
21 | class RockSampleModel;
22 |
23 | /** A class to store the robot position associated with a given belief node.
24 | *
25 | * Since the robot position in RockSample is fully observable, all particles in any belief will
26 | * in fact have the same position, which is stored here.
27 | */
28 | class PositionData : public solver::HistoricalData {
29 | friend class PositionDataTextSerializer;
30 | public:
31 | /** Creates a new PositionData instance for the given model, and located in the given grid
32 | * square.
33 | */
34 | PositionData(RockSampleModel *model, GridPosition position);
35 | virtual ~PositionData() = default;
36 | _NO_COPY_OR_MOVE(PositionData);
37 |
38 | std::unique_ptr copy() const;
39 |
40 | std::unique_ptr createChild(
41 | solver::Action const &action,
42 | solver::Observation const &observation) const override;
43 |
44 | /** Generates the legal actions that are available from this position. */
45 | std::vector generateLegalActions() const;
46 |
47 | /** Returns the grid position for this PositionData instance. */
48 | GridPosition getPosition() const;
49 |
50 | void print(std::ostream &os) const override;
51 |
52 | private:
53 | /** The RockSampleModel instance this PositionData instance is associated with. */
54 | RockSampleModel *model_;
55 | /** The grid position of this PositionData. */
56 | GridPosition position_;
57 | };
58 |
59 | /** An implementation of the serialization methods for the PositionData class. */
60 | class PositionDataTextSerializer : virtual public solver::TextSerializer {
61 | public:
62 | void saveHistoricalData(solver::HistoricalData const *data, std::ostream &os) override;
63 | std::unique_ptr loadHistoricalData(std::istream &is) override;
64 | };
65 | } /* namespace rocksample */
66 |
67 | #endif /* ROCKSAMPLE_POSITION_HISTORY_HPP_ */
68 |
--------------------------------------------------------------------------------
/src/problems/rocksample/simulate.cpp:
--------------------------------------------------------------------------------
1 | /** @file rocksample/simulate.cpp
2 | *
3 | * Defines the main method for the "simulate" executable for the RockSample POMDP, which runs
4 | * online simulations to test the performance of the solver.
5 | */
6 | #include "problems/shared/simulate.hpp"
7 |
8 | #include "RockSampleModel.hpp" // for RockSampleModel
9 | #include "RockSampleOptions.hpp" // for RockSampleOptions
10 |
11 | /** The main method for the "simulate" executable for RockSample. */
12 | int main(int argc, char const *argv[]) {
13 | return simulate(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/problems/rocksample/solve.cpp:
--------------------------------------------------------------------------------
1 | /** @file rocksample/solve.cpp
2 | *
3 | * Defines the main method for the "solve" executable for the RockSample POMDP, which generates an
4 | * initial policy.
5 | */
6 | #include "problems/shared/solve.hpp"
7 |
8 | #include "RockSampleModel.hpp" // for RockSampleModel
9 | #include "RockSampleOptions.hpp" // for RockSampleOptions
10 |
11 | /** The main method for the "solve" executable for RockSample. */
12 | int main(int argc, char const *argv[]) {
13 | return solve(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/problems/rocksample/stest.cpp:
--------------------------------------------------------------------------------
1 | /** @file rocksample/stest.cpp
2 | *
3 | * Defines the main method for the "stest" executable for the RockSample POMDP, which tests the
4 | * serialization methods for RockSample by deserializing and re-serializing a policy file.
5 | */
6 | #include "problems/shared/stest.hpp"
7 |
8 | #include "RockSampleModel.hpp" // for RockSampleModel
9 | #include "RockSampleOptions.hpp" // for RockSampleOptions
10 |
11 | /** The main method for the "stest" executable for RockSample. */
12 | int main(int argc, char const *argv[]) {
13 | return stest(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/problems/shared/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = shared
2 | CHILD_DIRS := geometry
3 |
4 | ifdef HAS_ROOT_MAKEFILE
5 |
6 | include .make/template.mk
7 | include .make/build.mk
8 |
9 | else
10 | REDIRECT=$(MODULE_NAME)
11 | .PHONY: $(MAKECMDGOALS) call-upwards
12 | $(MAKECMDGOALS): call-upwards ;
13 | call-upwards:
14 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
15 | endif
16 |
--------------------------------------------------------------------------------
/src/problems/shared/geometry/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = geometry
2 |
3 | ifdef HAS_ROOT_MAKEFILE
4 |
5 | include .make/template.mk
6 | include .make/build.mk
7 |
8 | else
9 | REDIRECT=$(MODULE_NAME)
10 | .PHONY: $(MAKECMDGOALS) call-upwards
11 | $(MAKECMDGOALS): call-upwards ;
12 | call-upwards:
13 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
14 | endif
15 |
--------------------------------------------------------------------------------
/src/problems/shared/geometry/Point2D.cpp:
--------------------------------------------------------------------------------
1 | /** @file Point2D.cpp
2 | *
3 | * Contains implementations for the methods of the Point2D class.
4 | */
5 | #include "problems/shared/geometry/Point2D.hpp"
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | #include "global.hpp"
13 |
14 | #include "solver/abstract-problem/Point.hpp"
15 | #include "solver/abstract-problem/Vector.hpp"
16 |
17 | #include "problems/shared/geometry/Vector2D.hpp"
18 |
19 | namespace geometry {
20 | Point2D::Point2D() :
21 | Point2D(0.0, 0.0) {
22 | }
23 |
24 | Point2D::Point2D(double x, double y) :
25 | x_(x),
26 | y_(y) {
27 | }
28 |
29 | Point2D::~Point2D() {
30 | }
31 |
32 | std::unique_ptr Point2D::copy() const {
33 | return std::make_unique(*this);
34 | }
35 |
36 | double Point2D::distanceTo(const Point& otherPoint) const {
37 | Point2D const &other = static_cast(otherPoint);
38 | return std::sqrt(std::pow(x_ - other.x_, 2) + std::pow(y_ - other.y_, 2));
39 | }
40 |
41 | bool Point2D::equals(const Point& otherPoint) const {
42 | Point2D const &other = static_cast(otherPoint);
43 | return (x_ == other.x_ && y_ == other.y_);
44 | }
45 |
46 | std::size_t Point2D::hash() const {
47 | std::size_t hashValue = 0;
48 | tapir::hash_combine(hashValue, x_);
49 | tapir::hash_combine(hashValue, y_);
50 | return hashValue;
51 | }
52 |
53 | void Point2D::print(std::ostream& os) const {
54 | os << "(" << x_ << ", " << y_ << ")";
55 | }
56 |
57 | void Point2D::loadFrom(std::istream &is) {
58 | std::string tmpStr;
59 | std::getline(is, tmpStr, '(');
60 | std::getline(is, tmpStr, ',');
61 | std::istringstream(tmpStr) >> x_;
62 | std::getline(is, tmpStr, ')');
63 | std::istringstream(tmpStr) >> y_;
64 | }
65 |
66 | std::vector Point2D::asVector() const {
67 | return std::vector {x_, y_};
68 | }
69 |
70 | double Point2D::getX() const {
71 | return x_;
72 | }
73 |
74 | double Point2D::getY() const {
75 | return y_;
76 | }
77 | } /* namespace geometry */
78 |
--------------------------------------------------------------------------------
/src/problems/shared/geometry/Point2D.hpp:
--------------------------------------------------------------------------------
1 | /** @file Point2D.hpp
2 | *
3 | * Defines the Point2D class, which represents a point in 2-D Euclidean space.
4 | */
5 | #ifndef GEOMETRY_POINT2D_HPP_
6 | #define GEOMETRY_POINT2D_HPP_
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #include "solver/abstract-problem/Point.hpp"
13 | #include "solver/abstract-problem/Vector.hpp"
14 |
15 | namespace geometry {
16 | class Vector2D;
17 |
18 | /** A class modeling a point in 2-D space. */
19 | class Point2D: public solver::Vector {
20 | public:
21 | /** Creates a new Point2D at (0, 0). */
22 | Point2D();
23 | /** Creates a new Point2D with coordinates (x, y). */
24 | Point2D(double x, double y);
25 |
26 | virtual ~Point2D();
27 |
28 | virtual std::unique_ptr copy() const override;
29 | virtual double distanceTo(solver::Point const &otherPoint) const override;
30 | virtual bool equals(solver::Point const &otherPoint) const override;
31 | virtual std::size_t hash() const override;
32 |
33 | virtual void print(std::ostream &os) const override;
34 | /** Loads the contents of this point from the given input stream. */
35 | virtual void loadFrom(std::istream &is);
36 |
37 | virtual std::vector asVector() const override;
38 |
39 | /** Returns the x coordinate of this point. */
40 | double getX() const;
41 | /** Returns the y coordinate of this point. */
42 | double getY() const;
43 |
44 | private:
45 | /** The x coordinate of this point. */
46 | double x_;
47 | /** The y coordinate of this point. */
48 | double y_;
49 |
50 | /** Adds a vector to this point. The definition is given in Vector2D.hpp. */
51 | friend Point2D &operator+=(Point2D &p, Vector2D const &v);
52 | };
53 |
54 | /** We define operator>> to allow easier serialization of Point2D; operator<< is already defined
55 | * by the base Point class.
56 | */
57 | inline std::istream &operator>>(std::istream &is, Point2D &point) {
58 | point.loadFrom(is);
59 | return is;
60 | }
61 | } /* namespace geometry */
62 |
63 | #endif /* GEOMETRY_POINT2D_HPP_ */
64 |
--------------------------------------------------------------------------------
/src/problems/shared/geometry/RTree.cpp:
--------------------------------------------------------------------------------
1 | /** @file geometry/RTree.cpp
2 | *
3 | * Contains the implementation for the geometry::RTree class.
4 | */
5 | #include "problems/shared/geometry/RTree.hpp"
6 |
7 | #include
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | #include "global.hpp"
14 |
15 | namespace geometry {
16 | RTree::RTree(unsigned int nSDim) :
17 | nSDim_(nSDim),
18 | properties_(nullptr),
19 | storageManager_(nullptr),
20 | tree_(nullptr) {
21 | reset();
22 | }
23 |
24 | void RTree::reset() {
25 | properties_ = std::make_unique();
26 | Tools::Variant var;
27 |
28 | var.m_varType = Tools::VT_ULONG;
29 | var.m_val.ulVal = nSDim_;
30 | properties_->setProperty("Dimension", var);
31 |
32 | var.m_varType = Tools::VT_ULONG;
33 | var.m_val.ulVal = 100;
34 | properties_->setProperty("IndexCapacity", var);
35 |
36 | var.m_varType = Tools::VT_ULONG;
37 | var.m_val.ulVal = 100;
38 | properties_->setProperty("LeafCapacity", var);
39 |
40 | var.m_varType = Tools::VT_DOUBLE;
41 | var.m_val.dblVal = 0.7;
42 | properties_->setProperty("FillFactor", var);
43 |
44 | var.m_varType = Tools::VT_LONG;
45 | var.m_val.lVal = SpatialIndex::RTree::RV_RSTAR;
46 | properties_->setProperty("TreeVariant", var);
47 |
48 | tree_.reset(nullptr);
49 | storageManager_.reset(
50 | SpatialIndex::StorageManager::returnMemoryStorageManager(*properties_));
51 | tree_.reset(SpatialIndex::RTree::returnRTree(*storageManager_, *properties_));
52 | }
53 |
54 | SpatialIndex::ISpatialIndex *RTree::getTree() {
55 | return tree_.get();
56 | }
57 |
58 | } /* namespace geometry */
59 |
--------------------------------------------------------------------------------
/src/problems/shared/geometry/RTree.hpp:
--------------------------------------------------------------------------------
1 | /** @file geometry/RTree.hpp
2 | *
3 | * Defines the geometry::RTree class, which wraps the R*-tree implementation in
4 | * libspatialindex.
5 | */
6 | #ifndef GEOMETRY_RTREE_HPP_
7 | #define GEOMETRY_RTREE_HPP_
8 |
9 | #include
10 |
11 | #include
12 | #include
13 |
14 | #include "global.hpp"
15 |
16 | namespace geometry {
17 |
18 | /** A wrapper class for the R*-tree implementation in libspatialindex; the main function of this
19 | * class is to set up the properties and storage manager for the R*-tree.
20 | */
21 | class RTree {
22 | public:
23 | /** Constructs a new RTree with the given number of spatial dimensions. */
24 | RTree(unsigned int nSDim);
25 | virtual ~RTree() = default;
26 | _NO_COPY_OR_MOVE(RTree);
27 |
28 | /** Resets the RTree to be completely empty. */
29 | virtual void reset();
30 |
31 | /** Returns the ISpatialIndex contained within the tree. */
32 | SpatialIndex::ISpatialIndex *getTree();
33 |
34 | private:
35 | /** The number of spatial dimensions for the tree. */
36 | unsigned int nSDim_;
37 | /** The set of properties for the tree. */
38 | std::unique_ptr properties_;
39 | /** The storage manager for the tree. */
40 | std::unique_ptr storageManager_;
41 | /** The actual R*-tree instance itself. */
42 | std::unique_ptr tree_;
43 | };
44 | } /* namespace geometry */
45 |
46 | #endif /* GEOMETRY_RTREE_HPP_ */
47 |
--------------------------------------------------------------------------------
/src/problems/shared/geometry/utilities.cpp:
--------------------------------------------------------------------------------
1 | /** @file utilities.cpp
2 | *
3 | * Contains implementations of utility functions for geometric calculations.
4 | */
5 | #include "utilities.hpp"
6 |
7 | #include
8 |
9 | namespace geometry {
10 | double normalizeTurn(double turn) {
11 | double numRotations;
12 | turn = std::modf(turn, &numRotations);
13 | if (turn <= -0.5) {
14 | turn += 1;
15 | } else if (turn > 0.5) {
16 | turn -= 1;
17 | }
18 | return turn;
19 | }
20 | } /* namespace geometry */
21 |
--------------------------------------------------------------------------------
/src/problems/shared/geometry/utilities.hpp:
--------------------------------------------------------------------------------
1 | /** @file utilities.hpp
2 | *
3 | * Defines some utility functions for use with geometric calculations.
4 | */
5 | #ifndef GEOMETRY_UTILITIES_HPP_
6 | #define GEOMETRY_UTILITIES_HPP_
7 |
8 | /** A namespace holding utility classes and functions related to 2-D geometry. */
9 | namespace geometry {
10 | /** Normalizes the given turn amount to a quantity between -0.5 (exclusive) and 0.5 (inclusive). */
11 | double normalizeTurn(double turn);
12 | } /* namespace geometry */
13 |
14 | #endif /* GEOMETRY_UTILITIES_HPP_ */
15 |
--------------------------------------------------------------------------------
/src/problems/shared/ros/ScanToPcl.cpp:
--------------------------------------------------------------------------------
1 | /** @file ScanToPcl.cpp
2 | *
3 | * A simple ROS node that subscribes to the laser scan data published by V-REP, and then
4 | * re-publishes it as a PointCould2 message which can then be used by the Octomap server.
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | /** An event listener to respond to laser scan data from V-REP. */
12 | void scanCallback(const sensor_msgs::LaserScan::ConstPtr& msg);
13 |
14 | /** This utility instance does the work of converting the laser data to a point cloud. */
15 | laser_geometry::LaserProjection projector;
16 | /** A Publisher for publishing the point cloud. */
17 | ros::Publisher pclPub;
18 |
19 | /** The main method for this laser data conversion node, which converts V-REP laser data messages
20 | * to PointCloud2 messages.
21 | */
22 | int main(int argc, char **argv) {
23 | ros::init(argc, argv, "scan_to_pcl_node");
24 | ros::NodeHandle node;
25 | pclPub = node.advertise("cloud_in", 1);
26 | ros::Subscriber scanSub = node.subscribe("/vrep/front_scan", 1, scanCallback);
27 | ros::spin();
28 | }
29 |
30 | void scanCallback(const sensor_msgs::LaserScan::ConstPtr& msg) {
31 | sensor_msgs::PointCloud2 cloud;
32 | projector.projectLaser(*msg, cloud);
33 | pclPub.publish(cloud);
34 | }
35 |
--------------------------------------------------------------------------------
/src/problems/tag/Makefile:
--------------------------------------------------------------------------------
1 | MODULE_NAME = tag
2 | TARGET_NAMES := solve simulate
3 |
4 | ifdef HAS_ROOT_MAKEFILE
5 |
6 | include .make/problem-template.mk
7 |
8 | else
9 | REDIRECT=$(MODULE_NAME)
10 | .PHONY: $(MAKECMDGOALS) call-upwards
11 | $(MAKECMDGOALS): call-upwards ;
12 | call-upwards:
13 | @$(MAKE) --no-print-directory -C .. $(MAKECMDGOALS) REDIRECT=$(REDIRECT)
14 | endif
15 |
--------------------------------------------------------------------------------
/src/problems/tag/TagAction.cpp:
--------------------------------------------------------------------------------
1 | /** @file TagAction.cpp
2 | *
3 | * Contains the implementations for the methods of the TagAction class.
4 | */
5 | #include "TagAction.hpp"
6 |
7 | #include // for size_t
8 |
9 | #include // for copy
10 | #include // for ostream_iterator
11 | #include // for operator<<, ostream
12 | #include // for vector, operator==, _Bit_const_iterator, _Bit_iterator_base, hash, vector<>::const_iterator
13 |
14 | #include "global.hpp"
15 |
16 | #include "problems/shared/GridPosition.hpp" // for GridPosition, operator==, operator<<
17 | #include "solver/abstract-problem/State.hpp" // for State
18 |
19 | namespace tag {
20 | TagAction::TagAction(ActionType actionType):
21 | actionType_(actionType) {
22 | }
23 |
24 | TagAction::TagAction(long code) :
25 | actionType_(static_cast(code)) {
26 | }
27 |
28 | std::unique_ptr TagAction::copy() const {
29 | return std::make_unique(actionType_);
30 | }
31 |
32 | double TagAction::distanceTo(solver::Action const &/*otherAction*/) const {
33 | return 0;
34 | }
35 |
36 | void TagAction::print(std::ostream &os) const {
37 | switch (actionType_) {
38 | case ActionType::NORTH:
39 | os << "NORTH";
40 | break;
41 | case ActionType::EAST:
42 | os << "EAST";
43 | break;
44 | case ActionType::SOUTH:
45 | os << "SOUTH";
46 | break;
47 | case ActionType::WEST:
48 | os << "WEST";
49 | break;
50 | case ActionType::TAG:
51 | os << "TAG";
52 | break;
53 | default:
54 | os << "ERROR-" << static_cast(actionType_);
55 | break;
56 | }
57 | }
58 |
59 | long TagAction::getBinNumber() const {
60 | return static_cast(actionType_);
61 | }
62 | ActionType TagAction::getActionType() const {
63 | return actionType_;
64 | }
65 | } /* namespace tag */
66 |
--------------------------------------------------------------------------------
/src/problems/tag/TagAction.hpp:
--------------------------------------------------------------------------------
1 | /** @file TagAction.hpp
2 | *
3 | * Defines the TagAction class, which represents an action for the Tag problem, and also the
4 | * ActionType enumeration, which enumerates the different types of actions for Tag.
5 | */
6 | #ifndef TAG_ACTION_HPP_
7 | #define TAG_ACTION_HPP_
8 |
9 | #include // for size_t
10 |
11 | #include // for ostream
12 | #include // for vector
13 |
14 | #include "solver/abstract-problem/Action.hpp"
15 | #include "solver/abstract-problem/DiscretizedPoint.hpp" // for DiscretizedPoint
16 |
17 | namespace tag {
18 |
19 | /** An enumeration of all the available actions in the Tag PODMP. */
20 | enum class ActionType : long {
21 | /** The action to move north. */
22 | NORTH = 0,
23 | /** The action to move east. */
24 | EAST = 1,
25 | /** The action to move south. */
26 | SOUTH = 2,
27 | /** The action to move west. */
28 | WEST = 3,
29 | /** The action to attempt to tag the opponent. */
30 | TAG = 4,
31 | };
32 |
33 | /** A class representing an action in the Tag POMDP.
34 | *
35 | * This class also implements solver::DiscretizedPoint so that the solver can use a simplistic
36 | * enumerated action mapping approach (EnumeratedActionPool) to store the available actions from
37 | * each belief node.
38 | */
39 | class TagAction : public solver::DiscretizedPoint {
40 | friend class TagTextSerializer;
41 | public:
42 | /** Constructs a new action from the given ActionType. */
43 | TagAction(ActionType actionType);
44 | /** Constructs a new action from the given integer code. */
45 | TagAction(long code);
46 |
47 | virtual ~TagAction() = default;
48 | _NO_COPY_OR_MOVE(TagAction);
49 |
50 | std::unique_ptr copy() const override;
51 | double distanceTo(solver::Action const &otherAction) const override;
52 | void print(std::ostream &os) const override;
53 |
54 | long getBinNumber() const override;
55 | /** Returns the ActionType of this action. */
56 | ActionType getActionType() const;
57 |
58 | private:
59 | /** The ActionType for this action in the Tag POMDP. */
60 | ActionType actionType_;
61 | };
62 | } /* namespace tag */
63 |
64 | #endif /* TAG_ACTION_HPP_ */
65 |
--------------------------------------------------------------------------------
/src/problems/tag/TagMdpSolver.hpp:
--------------------------------------------------------------------------------
1 | /** @file TagMdpSolver.hpp
2 | *
3 | * Defines the TagMdpSolver class, which solves the fully observable version of Tag in order to
4 | * serve as a heuristic function for the POMDP.
5 | *
6 | * This file also contains the definition for TagMdpParser, which allows this heuristic to be
7 | * selected via the string "exactMdp()" in the configuration file.
8 | */
9 | #ifndef TAG_MDPSOLVER_HPP_
10 | #define TAG_MDPSOLVER_HPP_
11 |
12 | #include
13 | #include
14 | #include
15 |
16 | #include "global.hpp"
17 |
18 | #include "problems/shared/parsers.hpp"
19 |
20 | #include "solver/abstract-problem/heuristics/HeuristicFunction.hpp"
21 |
22 | #include "TagState.hpp"
23 |
24 | namespace tag {
25 | class TagModel;
26 |
27 | /** A class that solves the fully observable version of Tag and stores the calculated value for
28 | * each state.
29 | */
30 | class TagMdpSolver {
31 | public:
32 | /** Creates a new TagMdpSolver which will be tied to the given TagModel instance. */
33 | TagMdpSolver(TagModel *model);
34 | virtual ~TagMdpSolver() = default;
35 | _NO_COPY_OR_MOVE(TagMdpSolver);
36 |
37 | /** Solves the MDP, using the current state of the */
38 | void solve();
39 |
40 | /** Returns the calculated MDP value for the given state. */
41 | double getValue(TagState const &state) const;
42 |
43 | private:
44 | /** The model instance this MDP solver is associated with. */
45 | TagModel *model_;
46 | /** A map to hold the calculated value for each non-terminal state. */
47 | std::unordered_map valueMap_;
48 | };
49 |
50 | /** A class to parse the command-line heuristic setting for the case "exactMdp()". */
51 | class TagMdpParser : public shared::Parser {
52 | public:
53 | /** Creates a new MDP parser associated with the given TagModel instance. */
54 | TagMdpParser(TagModel *model);
55 | virtual ~TagMdpParser() = default;
56 | _NO_COPY_OR_MOVE(TagMdpParser);
57 |
58 | /** Creates a solver::HeuristicFunction associated with the stored TagModel instance.
59 | *
60 | * This heuristic can then be used by the ABT algorithm.
61 | */
62 | virtual solver::HeuristicFunction parse(solver::Solver *solver, std::vector args);
63 |
64 | private:
65 | /** The TagModel instance this heuristic parser is associated with. */
66 | TagModel *model_;
67 | };
68 | } /* namespace tag */
69 |
70 | #endif /* TAG_MDPSOLVER_HPP_ */
71 |
--------------------------------------------------------------------------------
/src/problems/tag/TagObservation.cpp:
--------------------------------------------------------------------------------
1 | /** @file TagObservation.cpp
2 | *
3 | * Contains the implementations for the methods of TagObservation.
4 | */
5 | #include "TagObservation.hpp"
6 |
7 | #include // for size_t
8 |
9 | #include // for copy
10 | #include // for ostream_iterator
11 | #include // for operator<<, ostream
12 | #include // for vector, operator==, _Bit_const_iterator, _Bit_iterator_base, hash, vector<>::const_iterator
13 |
14 | #include "global.hpp"
15 |
16 | #include "problems/shared/GridPosition.hpp" // for GridPosition, operator==, operator<<
17 | #include "solver/abstract-problem/Observation.hpp" // for Observation
18 |
19 | #include "TagModel.hpp"
20 |
21 | namespace tag {
22 | TagObservation::TagObservation(GridPosition position,
23 | bool _seesOpponent) :
24 | position_(position),
25 | seesOpponent_(_seesOpponent) {
26 | }
27 | std::unique_ptr
28 | TagObservation::copy() const {
29 | return std::make_unique(position_, seesOpponent_);
30 | }
31 |
32 | double TagObservation::distanceTo(
33 | solver::Observation const &otherObs) const {
34 | TagObservation const &other =
35 | static_cast(otherObs);
36 | return seesOpponent_ == other.seesOpponent_ ? 0 : 1;
37 | }
38 |
39 | bool TagObservation::equals(
40 | solver::Observation const &otherObs) const {
41 | TagObservation const &other =
42 | static_cast(otherObs);
43 | return position_ == other.position_ && seesOpponent_ == other.seesOpponent_;
44 | }
45 |
46 | std::size_t TagObservation::hash() const {
47 | std::size_t hashValue = 0;
48 | tapir::hash_combine(hashValue, position_.i);
49 | tapir::hash_combine(hashValue, position_.j);
50 | tapir::hash_combine(hashValue, seesOpponent_);
51 | return hashValue;
52 | }
53 |
54 | void TagObservation::print(std::ostream &os) const {
55 | os << position_ << " ";
56 | if (seesOpponent_) {
57 | os << "SEEN";
58 | } else {
59 | os << "UNSEEN";
60 | }
61 | }
62 |
63 | GridPosition TagObservation::getPosition() const {
64 | return position_;
65 | }
66 |
67 | bool TagObservation::seesOpponent() const {
68 | return seesOpponent_;
69 | }
70 | }
71 | /* namespace tag */
72 |
--------------------------------------------------------------------------------
/src/problems/tag/TagObservation.hpp:
--------------------------------------------------------------------------------
1 | /** @file TagObservation.hpp
2 | *
3 | * Defines the TagObservation class, which represents an observation in the Tag POMDP.
4 | */
5 | #ifndef TAG_OBSERVATION_HPP_
6 | #define TAG_OBSERVATION_HPP_
7 |
8 | #include // for size_t
9 |
10 | #include // for ostream
11 | #include // for vector
12 |
13 | #include "global.hpp" // for RandomGenerator
14 |
15 | #include "problems/shared/GridPosition.hpp"
16 | #include "solver/abstract-problem/DiscretizedPoint.hpp"
17 | #include "solver/abstract-problem/Observation.hpp"
18 |
19 | namespace tag {
20 | class TagModel;
21 |
22 | /** A class representing an observation in the Tag POMDP.
23 | *
24 | * This includes an observation of the robot's own position, and a boolean flag representing
25 | * whether or not the robot sees the opponent (and hence is on the same grid square).
26 | */
27 | class TagObservation : public solver::Point {
28 | friend class TagTextSerializer;
29 | public:
30 | /** Constructs a new TagObservation for the given robot position; seesOpponent should be true
31 | * iff the robot sees the opponent due to being on the same square.
32 | */
33 | TagObservation(GridPosition myPosition, bool seesOpponent = false);
34 |
35 | virtual ~TagObservation() = default;
36 | _NO_COPY_OR_MOVE(TagObservation);
37 |
38 | std::unique_ptr copy() const override;
39 | double distanceTo(solver::Observation const &otherObs) const override;
40 | bool equals(solver::Observation const &otherObs) const override;
41 | std::size_t hash() const override;
42 | void print(std::ostream &os) const override;
43 |
44 | /** Returns the position the robot has observed itself in. */
45 | GridPosition getPosition() const;
46 | /** Returns true iff the robot sees the opponent in the same square it is in. */
47 | bool seesOpponent() const;
48 |
49 | private:
50 | /** The position the robot sees itself in. */
51 | GridPosition position_;
52 | /** True iff the robot sees the opponent in the same square it is in. */
53 | bool seesOpponent_;
54 | };
55 | } /* namespace tag */
56 | #endif /* TAG_OBSERVATION_HPP_ */
57 |
--------------------------------------------------------------------------------
/src/problems/tag/TagOptions.hpp:
--------------------------------------------------------------------------------
1 | /** @file TagOptions.hpp
2 | *
3 | * Defines the TagOptions class, which specifies the configuration settings available for the
4 | * Tag problem.
5 | */
6 | #ifndef TAGOPTIONS_HPP_
7 | #define TAGOPTIONS_HPP_
8 |
9 | #include // for string
10 |
11 | #include "problems/shared/SharedOptions.hpp"
12 |
13 | namespace tag {
14 | /** A class defining the configuration settings for the Tag problem. */
15 | struct TagOptions : public shared::SharedOptions {
16 | TagOptions() = default;
17 | virtual ~TagOptions() = default;
18 |
19 | /* -------- Settings specific to the Tag POMDP -------- */
20 | /** Path to the map file (relative to SharedOptions::baseConfigPath) */
21 | std::string mapPath = "";
22 | /** Cost per move. */
23 | double moveCost = 0.0;
24 | /** Reward for tagging. */
25 | double tagReward = 0.0;
26 | /** Penalty for a failed tag attempt. */
27 | double failedTagPenalty = 0.0;
28 | /** Probability the opponent will stay in place. */
29 | double opponentStayProbability = 0.0;
30 | /** Path to vrep scene tag.ttt */
31 | std::string vrepScenePath = "";
32 |
33 | /** Constructs an OptionParser instance that will parse configuration settings for the Tag
34 | * problem into an instance of TagOptions.
35 | */
36 | static std::unique_ptr makeParser(bool simulating) {
37 | std::unique_ptr parser = SharedOptions::makeParser(simulating,
38 | EXPAND_AND_QUOTE(ROOT_PATH) "/problems/tag");
39 | addTagOptions(parser.get());
40 | return std::move(parser);
41 | }
42 |
43 | /** Adds the core configuration settings for the Tag problem to the given parser. */
44 | static void addTagOptions(options::OptionParser *parser) {
45 | parser->addOption("problem", "mapPath", &TagOptions::mapPath);
46 | parser->addValueArg("problem", "mapPath", &TagOptions::mapPath,
47 | "", "map", "the path to the map file (relative to the base config path)", "path");
48 |
49 | parser->addOption("problem", "moveCost", &TagOptions::moveCost);
50 | parser->addOption("problem", "tagReward", &TagOptions::tagReward);
51 | parser->addOption("problem", "failedTagPenalty", &TagOptions::failedTagPenalty);
52 | parser->addOption("problem", "opponentStayProbability",
53 | &TagOptions::opponentStayProbability);
54 | parser->addOptionWithDefault("ros", "vrepScenePath",
55 | &TagOptions::vrepScenePath, "");
56 | }
57 | };
58 | } /* namespace tag */
59 |
60 | #endif /* TAGOPTIONS_HPP_ */
61 |
--------------------------------------------------------------------------------
/src/problems/tag/simulate.cpp:
--------------------------------------------------------------------------------
1 | /** @file problems/tag/simulate.cpp
2 | *
3 | * Defines the main method for the "simulate" executable for the Tag POMDP, which runs online
4 | * simulations to test the performance of the solver.
5 | */
6 | #include "problems/shared/simulate.hpp"
7 |
8 | #include "TagModel.hpp" // for TagModel
9 | #include "TagOptions.hpp" // for TagOptions
10 |
11 | /** The main method for the "simulate" executable for Tag. */
12 | int main(int argc, char const *argv[]) {
13 | return simulate(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/problems/tag/solve.cpp:
--------------------------------------------------------------------------------
1 | /** @file problems/tag/solve.cpp
2 | *
3 | * Defines the main method for the "solve" executable for the Tag POMDP, which generates an
4 | * initial policy.
5 | */
6 | #include "problems/shared/solve.hpp"
7 |
8 | #include "TagModel.hpp" // for TagModel
9 | #include "TagOptions.hpp" // for TagOptions
10 |
11 | /** The main method for the "solve" executable for Tag. */
12 | int main(int argc, char const *argv[]) {
13 | return solve(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/problems/tag/stest.cpp:
--------------------------------------------------------------------------------
1 | /** @file tag/stest.cpp
2 | *
3 | * Defines the main method for the "stest" executable for the Tag POMDP, which tests the
4 | * serialization methods for Tag by deserializing and re-serializing a policy file.
5 | */
6 | #include "problems/shared/stest.hpp"
7 |
8 | #include "TagModel.hpp" // for TagModel
9 | #include "TagOptions.hpp" // for TagOptions
10 |
11 | /** The main method for the "stest" executable for Tag. */
12 | int main(int argc, char const *argv[]) {
13 | return stest(argc, argv);
14 | }
15 |
--------------------------------------------------------------------------------
/src/solver/ActionNode.cpp:
--------------------------------------------------------------------------------
1 | /** @file ActionNode.cpp
2 | *
3 | * Contains the implementation of ActionNode.
4 | */
5 | #include "solver/ActionNode.hpp"
6 |
7 | #include // for unique_ptr
8 | #include // for make_pair, move, pair
9 | #include // for vector
10 |
11 | #include "global.hpp" // for make_unique
12 |
13 | #include "solver/BeliefNode.hpp"
14 | #include "solver/Solver.hpp"
15 |
16 | #include "solver/belief-estimators/estimators.hpp"
17 |
18 | #include "solver/abstract-problem/Action.hpp" // for Action
19 | #include "solver/abstract-problem/Observation.hpp" // for Observation
20 |
21 | #include "solver/mappings/actions/ActionPool.hpp" // for ActionPool
22 | #include "solver/mappings/observations/ObservationMapping.hpp" // for ObservationMapping
23 |
24 | namespace solver {
25 | ActionNode::ActionNode() :
26 | parentEntry_(nullptr),
27 | observationMap_(nullptr) {
28 | }
29 |
30 | ActionNode::ActionNode(ActionMappingEntry *parentEntry) :
31 | parentEntry_(parentEntry),
32 | observationMap_(nullptr) {
33 | }
34 |
35 | // Default destructor
36 | ActionNode::~ActionNode() {
37 | }
38 |
39 | /* -------------------- Tree-related getters ---------------------- */
40 | ObservationMapping *ActionNode::getMapping() const {
41 | return observationMap_.get();
42 | }
43 | ActionMappingEntry *ActionNode::getParentEntry() const {
44 | return parentEntry_;
45 | }
46 | BeliefNode *ActionNode::getParentBelief() const {
47 | return parentEntry_->getMapping()->getOwner();
48 | }
49 | BeliefNode *ActionNode::getChild(Observation const &obs) const {
50 | return observationMap_->getBelief(obs);
51 | }
52 |
53 |
54 | /* ============================ PRIVATE ============================ */
55 |
56 |
57 | /* -------------------- Tree-related setters ---------------------- */
58 | void ActionNode::setMapping(std::unique_ptr mapping) {
59 | observationMap_ = std::move(mapping);
60 | }
61 |
62 | /* -------------------- Tree-related methods ---------------------- */
63 | std::pair ActionNode::createOrGetChild(Solver */*solver*/,
64 | Observation const &obs) {
65 | BeliefNode *childNode = getChild(obs);
66 | bool added = false;
67 | if (childNode == nullptr) {
68 | childNode = observationMap_->createBelief(obs);
69 | added = true;
70 | }
71 | return std::make_pair(childNode, added);
72 | }
73 | } /* namespace solver */
74 |
--------------------------------------------------------------------------------
/src/solver/Agent.cpp:
--------------------------------------------------------------------------------
1 | /** @file Agent.cpp
2 | *
3 | * Contains the implementation of the Agent class.
4 | */
5 | #include "solver/Agent.hpp"
6 |
7 | #include "solver/BeliefNode.hpp"
8 | #include "solver/BeliefTree.hpp"
9 | #include "solver/Solver.hpp"
10 |
11 | namespace solver {
12 |
13 | Agent::Agent(Solver *solver) :
14 | solver_(solver),
15 | currentBelief_(solver_->getPolicy()->getRoot()) {
16 | }
17 |
18 | Solver *Agent::getSolver() const {
19 | return solver_;
20 | }
21 | std::unique_ptr Agent::getPreferredAction() const {
22 | return currentBelief_->getRecommendedAction();
23 | }
24 | BeliefNode *Agent::getCurrentBelief() const {
25 | return currentBelief_;
26 | }
27 |
28 | void Agent::setCurrentBelief(BeliefNode *belief) {
29 | currentBelief_ = belief;
30 | }
31 | void Agent::updateBelief(Action const &action, Observation const &observation) {
32 | currentBelief_ = currentBelief_->createOrGetChild(action, observation);
33 | }
34 | } /* namespace solver */
35 |
--------------------------------------------------------------------------------
/src/solver/Agent.hpp:
--------------------------------------------------------------------------------
1 | /** @file Agent.hpp
2 | *
3 | * Contains the Agent class, which represents an actual agent embedded in an environment.
4 | *
5 | * This is a general class that should allow ABT to interface with external sensors; it is
6 | * also used by the Simulator class to test performance of the algorithm.
7 | */
8 | #ifndef SOLVER_AGENT_HPP_
9 | #define SOLVER_AGENT_HPP_
10 |
11 | #include
12 |
13 | #include "global.hpp"
14 |
15 | #include "solver/abstract-problem/Action.hpp"
16 | #include "solver/abstract-problem/Observation.hpp"
17 |
18 | namespace solver {
19 | class BeliefNode;
20 | class Solver;
21 |
22 | /** Represents an agent embedded within an environment.
23 | *
24 | * The agent is tied to a solver, which in turn has an associated model of the environment and
25 | * uses the ABT algorithm to find a good policy for the agent to take.
26 | *
27 | * The agent represents its current state by associating it with a node in the solver's belief tree.
28 | *
29 | * Note that multiple agents can use the same solver, as the belief tree representation
30 | * is not tied to the state of a specific agent.
31 | */
32 | class Agent {
33 | public:
34 | /** Constructs a new agent associated with the given solver. The initial belief will start
35 | * at the root node of the solver. */
36 | Agent(Solver *solver);
37 | ~Agent() = default;
38 | _NO_COPY_OR_MOVE(Agent);
39 |
40 | /** Returns the solver being used by this agent. */
41 | Solver *getSolver() const;
42 | /** Returns the agent's current choice of action. */
43 | std::unique_ptr getPreferredAction() const;
44 | /** Returns the current belief of the agent (as a BeliefNode within the solver's belief tree). */
45 | BeliefNode *getCurrentBelief() const;
46 |
47 | /** Sets the current belief of this agent to the given BeliefNode. */
48 | void setCurrentBelief(BeliefNode *belief);
49 | /** Updates the belief of this agent based on an action and observation. */
50 | void updateBelief(Action const &action, Observation const &observation);
51 |
52 | private:
53 | /** The solver used by this agent. */
54 | Solver *solver_;
55 | /** The belief node in the tree that represents this agent's current belief. */
56 | BeliefNode *currentBelief_;
57 | };
58 |
59 | } /* namespace solver */
60 |
61 | #endif /* SOLVER_AGENT_HPP_ */
62 |
63 |
--------------------------------------------------------------------------------
/src/solver/Histories.cpp:
--------------------------------------------------------------------------------
1 | /** @file Histories.cpp
2 | *
3 | * Contains the implementation of the Histories class
4 | */
5 | #include "solver/Histories.hpp"
6 |
7 | #include // for move
8 |
9 | #include "global.hpp" // for make_unique
10 |
11 | #include "solver/HistoryEntry.hpp" // for HistoryEntry
12 | #include "solver/HistorySequence.hpp" // for HistorySequence
13 |
14 | namespace solver {
15 | Histories::Histories() :
16 | sequencesById_() {
17 | }
18 |
19 | /* ------------------- Retrieving sequences ------------------- */
20 | long Histories::getNumberOfSequences() const {
21 | return sequencesById_.size();
22 | }
23 | HistorySequence *Histories::getSequence(long seqId) const {
24 | return sequencesById_[seqId].get();
25 | }
26 |
27 |
28 | /* ============================ PRIVATE ============================ */
29 |
30 |
31 | /* ---------------- Adding / removing sequences ---------------- */
32 | void Histories::reset() {
33 | sequencesById_.clear();
34 | }
35 | HistorySequence *Histories::createSequence() {
36 | std::unique_ptr histSeq(
37 | std::make_unique(sequencesById_.size()));
38 | HistorySequence *rawPtr = histSeq.get();
39 | sequencesById_.push_back(std::move(histSeq));
40 | return rawPtr;
41 | }
42 | void Histories::deleteSequence(HistorySequence *sequence) {
43 | // Retrieve the current ID of the sequence, which should be its position in the vector.
44 | long seqId = sequence->id_;
45 |
46 | if (sequencesById_[seqId].get() != sequence) {
47 | debug::show_message("ERROR: sequence ID does not match its index!");
48 | }
49 |
50 | // Deregister and clear the sequence.
51 | sequence->erase();
52 | if (seqId < static_cast(sequencesById_.size()) - 1) {
53 | sequencesById_[seqId] = std::move(sequencesById_[sequencesById_.size()-1]);
54 | sequencesById_[seqId]->id_ = seqId;
55 | }
56 | sequencesById_.pop_back();
57 | }
58 | } /* namespace solver */
59 |
--------------------------------------------------------------------------------
/src/solver/Histories.hpp:
--------------------------------------------------------------------------------
1 | /** @file Histories.hpp
2 | *
3 | * Contains the Histories class, which represents a collection of history sequences.
4 | *
5 | * This class owns the associated sequences, which are stored in a vector of unique_ptr
6 | */
7 | #ifndef SOLVER_HISTORIES_HPP_
8 | #define SOLVER_HISTORIES_HPP_
9 |
10 | #include