├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── bayes_people_tracker
├── CHANGELOG.rst
├── CMakeLists.txt
├── LICENSE
├── README.md
├── config
│ ├── detectors.yaml
│ └── detectors_withnewparams.yaml
├── include
│ └── people_tracker
│ │ ├── asso_exception.h
│ │ ├── flobot_tracking.h
│ │ └── people_tracker.h
├── launch
│ └── people_tracker.launch
├── msg
│ └── PeopleTracker.msg
├── package.xml
└── src
│ └── people_tracker
│ └── people_tracker.cpp
├── bayestracking
├── CHANGELOG.rst
├── CMakeLists.txt
├── Doxyfile.in
├── LICENCE
├── README.md
├── config
│ ├── BayestrackingConfig.cmake.in
│ ├── BayestrackingConfigVersion.cmake.in
│ └── bayestracking.pc.in
├── examples
│ ├── CMakeLists.txt
│ └── simple_2d_tracking.cpp
├── include
│ └── bayes_tracking
│ │ ├── BayesFilter
│ │ ├── CIFlt.hpp
│ │ ├── SIRFlt.hpp
│ │ ├── UDFlt.hpp
│ │ ├── allFilters.hpp
│ │ ├── bayesException.hpp
│ │ ├── bayesFlt.hpp
│ │ ├── covFlt.hpp
│ │ ├── filters
│ │ │ ├── average1.hpp
│ │ │ └── indirect.hpp
│ │ ├── infFlt.hpp
│ │ ├── infRtFlt.hpp
│ │ ├── itrFlt.hpp
│ │ ├── matSup.hpp
│ │ ├── matSupSub.hpp
│ │ ├── models.hpp
│ │ ├── random.hpp
│ │ ├── schemeFlt.hpp
│ │ ├── uBLASmatrix.hpp
│ │ ├── uLAPACK.hpp
│ │ └── unsFlt.hpp
│ │ ├── angle.h
│ │ ├── associationmatrix.h
│ │ ├── ekfilter.h
│ │ ├── jacobianmodel.h
│ │ ├── jpda.h
│ │ ├── models.h
│ │ ├── multitracker.h
│ │ ├── pfilter.h
│ │ ├── synchronizer.h
│ │ ├── trackwin.h
│ │ └── ukfilter.h
├── package.xml
└── src
│ └── bayes_tracking
│ ├── BayesFilter
│ ├── CIFlt.cpp
│ ├── SIRFlt.cpp
│ ├── UDFlt.cpp
│ ├── UdU.cpp
│ ├── bayesFlt.cpp
│ ├── bayesFltAlg.cpp
│ ├── covFlt.cpp
│ ├── infFlt.cpp
│ ├── infRtFlt.cpp
│ ├── itrFlt.cpp
│ ├── matSup.cpp
│ └── unsFlt.cpp
│ ├── associationmatrix.cpp
│ ├── ekfilter.cpp
│ ├── models.cpp
│ ├── pfilter.cpp
│ ├── trackwin.cpp
│ └── ukfilter.cpp
└── object3d_detector
├── CMakeLists.txt
├── README.md
├── config
├── object3d_detector.yaml
├── object3d_detector_ol.yaml
└── vlp16.yaml
├── include
└── svm.h
├── launch
├── object3d_detector.launch
├── object3d_detector.rviz
├── object3d_detector_ol.launch
└── object3d_detector_ol.rviz
├── libsvm
├── README.md
├── grid.py
├── pedestrian.model
└── pedestrian.range
├── package.xml
└── src
├── object3d_detector.cpp
├── object3d_detector_ol.cpp
└── svm.cpp
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Compiled Dynamic libraries
15 | *.so
16 | *.dylib
17 | *.dll
18 |
19 | # Fortran module files
20 | *.mod
21 | *.smod
22 |
23 | # Compiled Static libraries
24 | *.lai
25 | *.la
26 | *.a
27 | *.lib
28 |
29 | # Executables
30 | *.exe
31 | *.out
32 | *.app
33 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | dist: xenial
2 | sudo: required
3 | language: generic
4 | cache: apt
5 |
6 | install:
7 | - sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
8 | - sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
9 | - sudo apt-get update
10 | - sudo apt-get install ros-kinetic-desktop-full ros-kinetic-people-msgs
11 | - source /opt/ros/kinetic/setup.bash
12 | - pip install catkin_pkg empy
13 | - mkdir -p ~/catkin_ws/src
14 | - cd ~/catkin_ws/
15 | - catkin_make
16 | - source devel/setup.bash
17 |
18 | script:
19 | - cd ~/catkin_ws/src
20 | - git clone -b single-sensor-ros-kinetic https://github.com/yzrobot/online_learning.git
21 | - cd ~/catkin_ws
22 | - catkin_make
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Online learning for human classification in 3D LiDAR-based tracking #
2 |
3 | [](https://travis-ci.org/yzrobot/online_learning)
4 | [](https://www.codacy.com/gh/yzrobot/online_learning/dashboard?utm_source=github.com&utm_medium=referral&utm_content=yzrobot/online_learning&utm_campaign=Badge_Grade)
5 | [](https://www.gnu.org/licenses/gpl-3.0)
6 |
7 | :boom: Please check my Ph.D. student's amazing ongoing work (with very high modularity): [efficient_online_learning](https://github.com/epan-utbm/efficient_online_learning) for autonomous driving! :boom:
8 |
9 | This is a ROS-based online learning framework for human classification in 3D LiDAR scans, taking advantage of robust multi-target tracking to avoid the need for data annotation by a human expert.
10 | Please watch the videos below for more details.
11 |
12 | [](https://www.youtube.com/watch?v=bjztHV9rC-0)
13 | [](https://www.youtube.com/watch?v=rmPn7mWssto)
14 |
15 | For a standalone implementation of the clustering method, please refer to: [https://github.com/yzrobot/adaptive_clustering](https://github.com/yzrobot/adaptive_clustering)
16 |
17 | # Install & Build
18 | ```sh
19 | cd catkin_ws/src
20 | // Install prerequisite packages
21 | git clone https://github.com/wg-perception/people.git
22 | git clone https://github.com/DLu/wu_ros_tools.git
23 | sudo apt-get install ros-kinetic-bfl
24 | // The core
25 | git clone https://github.com/yzrobot/online_learning
26 | // Build
27 | cd catkin_ws
28 | catkin_make
29 | ```
30 |
31 | # Run
32 | After catkin_make succeed, modify 'line 3' of online_learning/object3d_detector/launch/object3d_detector.launch, and make the value is the path where your bag files are located:
33 |
34 | ``
35 |
36 | The bag file offered by [Lincoln Centre for Autonomous Systems](http://lcas.lincoln.ac.uk) is in velodyne_msgs/VelodyneScan message type, so we would need related velodyne packages in ROS:
37 | ```bash
38 | $ sudo apt-get install ros-kinetic-velodyne*
39 | ```
40 | Now, the svm should be able to run:
41 | ```bash
42 | $ cd catkin_ws
43 | $ source devel/setup.bash
44 | $ roslaunch object3d_detector object3d_detector.launch
45 | ```
46 |
47 | ## Citation ##
48 | If you are considering using this code, please reference the following:
49 |
50 | ```
51 | @inproceedings{yz17iros,
52 | author = {Zhi Yan and Tom Duckett and Nicola Bellotto},
53 | title = {Online learning for human classification in {3D LiDAR-based} tracking},
54 | booktitle = {Proceedings of the 2017 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)},
55 | pages = {864--871},
56 | address = {Vancouver, Canada},
57 | month = {September},
58 | year = {2017}
59 | }
60 | ```
61 |
--------------------------------------------------------------------------------
/bayes_people_tracker/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package bayes_people_tracker
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | 1.1.8 (2015-09-03)
6 | ------------------
7 |
8 | 1.1.6 (2015-06-24)
9 | ------------------
10 | * 1.1.5
11 | * updated changelogs
12 | * 1.1.4
13 | * updated changelogs
14 | * Contributors: Jenkins
15 |
16 | 1.1.5 (2015-05-22)
17 | ------------------
18 |
19 | 1.1.4 (2015-05-10)
20 | ------------------
21 |
22 | 1.1.3 (2015-04-10)
23 | ------------------
24 |
25 | 1.1.2 (2015-04-07)
26 | ------------------
27 |
28 | 1.1.1 (2015-04-03)
29 | ------------------
30 |
31 | 1.0.0 (2015-03-10)
32 | ------------------
33 | * Nicer print
34 | * Adding ability to switch between Extended and Unscented Kalman Filter
35 | * Making simple_tracking template based.
36 | * Changed config file structure and made necessary changes to the code.
37 | * Adding pose, pose_array and people publishers to connection callback.
38 | * * Publishing a pose array for all detected people to have more generic output
39 | * Added missing bayes tracker parameters to launch files and READMEs
40 | * Starting the mdl tracker is now optional when using the robot launch file. `with_mdl_tracker=true` starts the mdl tracker in addition to the bayes tracker. Default is `false`
41 | * forgot (again) to change default detector.yaml in bayes_people_tracker
42 | * adding visualization to rviz via nav_msgs/Path
43 | * Contributors: Christian Dondrup, Ferdian Jovan
44 |
45 | 0.1.4 (2015-03-06)
46 | ------------------
47 | * Publishin people_msgs/People and adding orientation.
48 | * forgot to undo my config for detectors.yaml in bayes_people_tracker
49 | * provide online stitching poses into trajectories
50 | * add online trajectory construction from /people_tracker/positions
51 | * Contributors: Christian Dondrup, Ferdian Jovan
52 |
53 | 0.1.3 (2015-02-25)
54 | ------------------
55 |
56 | 0.1.1 (2015-02-18)
57 | ------------------
58 |
59 | 0.1.0 (2015-02-18)
60 | ------------------
61 | * Setting correct version number. The changelogs will be regenerated because the ones from the release branch would not be consistent with the changes made in the devel branch.
62 | * Small bug in ros_debug statment
63 | * Changed launch files to new format.
64 | * Changed launch files to new format.
65 | * Contributors: Christian Dondrup
66 |
67 | 0.0.14 (2014-11-23)
68 | -------------------
69 | * Updating changelogs and adjusting version numbers
70 | * 0.0.12
71 | * Adjusting version number.
72 | * Updated changelogs
73 | * 0.0.3
74 | * Updated changelogs
75 | * 0.0.2
76 | * Updated changelog
77 | * 0.0.1
78 | * Created changelogs
79 | * Contributors: Christian Dondrup
80 |
81 | 0.0.13 (2014-10-31 16:14)
82 | -------------------------
83 | * Updating changelogs and manually bumping version number.
84 | * 0.0.11
85 | * Updated changelogs
86 | * 0.0.10
87 | * Updating changelog
88 | * 0.0.9
89 | * Updated changelogs
90 | * 0.0.8
91 | * Updated changelogs
92 | * 0.0.7
93 | * Updated changelogs
94 | * 0.0.6
95 | * Updated changelogs
96 | * 0.0.5
97 | * Updated changelogs
98 | * 0.0.4
99 | * Updating changelogs
100 | * Removing the leg_detector from the run_dependencies of the launch package for indigo release.
101 | leg_detector is not released for indigo yet.
102 | * 0.0.3
103 | * Updated changelogs
104 | * 0.0.2
105 | * Updated changelog
106 | * 0.0.1
107 | * Created changelogs
108 | * 0.0.11
109 | * Updated changelogs
110 | * 0.0.10
111 | * Updating changelog
112 | * 0.0.9
113 | * Updated changelogs
114 | * 0.0.8
115 | * Updated changelogs
116 | * 0.0.7
117 | * Updated changelogs
118 | * 0.0.6
119 | * Updated changelogs
120 | * 0.0.5
121 | * Updated changelogs
122 | * 0.0.4
123 | * Updating changelogs
124 | * Removing the leg_detector from the run_dependencies of the launch package for indigo release.
125 | leg_detector is not released for indigo yet.
126 | * Contributors: Christian Dondrup
127 |
128 | 0.0.12 (2014-10-31 16:07)
129 | -------------------------
130 | * Adjusting version number.
131 | * Updated changelogs
132 | * 0.0.3
133 | * Updated changelogs
134 | * 0.0.2
135 | * Updated changelog
136 | * 0.0.1
137 | * Created changelogs
138 | * Added proper link to paper describing bayes_tracker
139 | * Contributors: Christian Dondrup
140 |
141 | 0.0.11 (2014-10-30 11:18)
142 | -------------------------
143 | * Updated changelogs
144 | * Contributors: Christian Dondrup
145 |
146 | 0.0.10 (2014-10-30 10:19)
147 | -------------------------
148 | * Updating changelog
149 | * Contributors: Christian Dondrup
150 |
151 | 0.0.9 (2014-10-30 09:52)
152 | ------------------------
153 | * Updated changelogs
154 | * Contributors: Christian Dondrup
155 |
156 | 0.0.8 (2014-10-30 09:32)
157 | ------------------------
158 | * Updated changelogs
159 | * Contributors: Christian Dondrup
160 |
161 | 0.0.7 (2014-10-29 20:40)
162 | ------------------------
163 | * Updated changelogs
164 | * Contributors: Christian Dondrup
165 |
166 | 0.0.6 (2014-10-29 20:32)
167 | ------------------------
168 | * Updated changelogs
169 | * Contributors: Christian Dondrup
170 |
171 | 0.0.5 (2014-10-29 18:30)
172 | ------------------------
173 | * Updated changelogs
174 | * Contributors: Christian Dondrup
175 |
176 | 0.0.4 (2014-10-29 18:22)
177 | ------------------------
178 | * Updating changelogs
179 | * Removing the leg_detector from the run_dependencies of the launch package for indigo release.
180 | leg_detector is not released for indigo yet.
181 | * Contributors: Christian Dondrup
182 |
183 | 0.0.3 (2014-10-23)
184 | ------------------
185 | * Updated changelogs
186 | * Added LICENSE files. Fixes `#101 `_
187 | * Contributors: Christian Dondrup, Lucas Beyer
188 |
189 | 0.0.2 (2014-10-18 17:39)
190 | ------------------------
191 | * Updated changelog
192 | * Contributors: Christian Dondrup
193 |
194 | 0.0.1 (2014-10-18 17:28)
195 | ------------------------
196 | * Created changelogs
197 | * Renamed strands_pedestrian_tracking to mdl_people_tracker
198 | This also includes renaming the messages and most of the parameters.
199 | * Forgot to install the config dir.
200 | * Fixed missing things
201 | * Prepared bayes_people_tracker for release.
202 | * Splitting utils package into seperate packages.
203 | * Renamed strands_people_tracker to bayes_people_tracker
204 | * Contributors: Christian Dondrup
205 |
--------------------------------------------------------------------------------
/bayes_people_tracker/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(bayes_people_tracker)
3 |
4 | ## Find catkin macros and libraries
5 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
6 | ## is used, also find other catkin packages
7 | find_package(catkin REQUIRED COMPONENTS
8 | bayes_tracking
9 | geometry_msgs
10 | message_generation
11 | people_msgs
12 | roscpp
13 | std_msgs
14 | tf
15 | visualization_msgs
16 | )
17 | find_package(Boost REQUIRED COMPONENTS thread)
18 |
19 | #######################################
20 | ## Declare ROS messages and services ##
21 | #######################################
22 |
23 | add_message_files(
24 | FILES
25 | PeopleTracker.msg
26 | )
27 |
28 | generate_messages(
29 | DEPENDENCIES
30 | std_msgs
31 | geometry_msgs
32 | )
33 |
34 | ###################################
35 | ## catkin specific configuration ##
36 | ###################################
37 | catkin_package(
38 | INCLUDE_DIRS include
39 | CATKIN_DEPENDS bayes_tracking geometry_msgs roscpp std_msgs tf visualization_msgs
40 | )
41 |
42 | ###########
43 | ## Build ##
44 | ###########
45 |
46 | include_directories(
47 | include
48 | ${catkin_INCLUDE_DIRS}
49 | ${Boost_INCLUDE_DIRS}
50 | )
51 |
52 | ### Offline version
53 | add_executable(bayes_people_tracker
54 | src/people_tracker/people_tracker.cpp
55 | )
56 |
57 | add_dependencies(bayes_people_tracker ${PROJECT_NAME}_generate_messages_cpp ${catkin_EXPORTED_TARGETS})
58 |
59 | target_link_libraries(bayes_people_tracker
60 | ${catkin_LIBRARIES}
61 | ${Boost_LIBRARIES}
62 | )
63 |
64 | ### Online version
65 | #add_definitions(-DONLINE_LEARNING)
66 |
67 | add_executable(bayes_people_tracker_ol
68 | src/people_tracker/people_tracker.cpp
69 | )
70 |
71 | add_dependencies(bayes_people_tracker_ol ${PROJECT_NAME}_generate_messages_cpp ${catkin_EXPORTED_TARGETS})
72 |
73 | target_link_libraries(bayes_people_tracker_ol
74 | ${catkin_LIBRARIES}
75 | ${Boost_LIBRARIES}
76 | )
77 |
78 | target_compile_definitions(bayes_people_tracker_ol PUBLIC ONLINE_LEARNING=1)
79 |
80 | #############
81 | ## Install ##
82 | #############
83 |
84 | install(TARGETS bayes_people_tracker
85 | ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
86 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
87 | RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
88 | )
89 |
90 | install(TARGETS bayes_people_tracker_ol
91 | ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
92 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
93 | RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
94 | )
95 |
96 | install(DIRECTORY include/${PROJECT_NAME}/
97 | DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
98 | FILES_MATCHING PATTERN "*.h"
99 | PATTERN ".git" EXCLUDE
100 | )
101 |
102 | install(DIRECTORY launch
103 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
104 | )
105 |
106 | install(DIRECTORY config
107 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
108 | )
109 |
--------------------------------------------------------------------------------
/bayes_people_tracker/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Christian Dondrup
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | 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, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/bayes_people_tracker/README.md:
--------------------------------------------------------------------------------
1 | ## People Tracker
2 | This package uses the bayes_tracking library developed by Nicola Bellotto (University of Lincoln), please cite with: [10.5281/zenodo.15825](https://zenodo.org/record/15825) and [1]
3 |
4 | The people_tracker uses a single config file to add an arbitrary amount of detectors. The file `config/detectors.yaml` contains the necessary information for the upper_body_detector and the ROS leg_detector (see `to_pose_array` in detector_msg_to_pose_array/README.md):
5 |
6 | ```
7 | bayes_people_tracker:
8 | filter_type: "UKF" # The Kalman filter type: EKF = Extended Kalman Filter, UKF = Uncented Kalman Filter
9 | cv_noise_params: # The noise for the constant velocity prediction model
10 | x: 1.4
11 | y: 1.4
12 | detectors: # Add detectors under this namespace
13 | upper_body_detector: # Name of detector (used internally to identify them). Has to be unique.
14 | topic: "/upper_body_detector/bounding_box_centres" # The topic on which the geometry_msgs/PoseArray is published
15 | cartesian_noise_params: # The noise for the cartesian observation model
16 | x: 0.5
17 | y: 0.5
18 | matching_algorithm: "NNJPDA" # The algorthim to match different detections. NN = Nearest Neighbour, NNJPDA = NN Joint Probability Data Association
19 | leg_detector: # Name of detector (used internally to identify them). Has to be unique.
20 | topic: "/to_pose_array/leg_detector" # The topic on which the geometry_msgs/PoseArray is published
21 | cartesian_noise_params: # The noise for the cartesian observation model
22 | x: 0.2
23 | y: 0.2
24 | matching_algorithm: "NNJPDA" # The algorthim to match different detections. NN = Nearest Neighbour, NNJPDA = NN Joint Probability Data Association
25 | ```
26 |
27 | New detectors are added under the parameter namespace `bayes_people_tracker/detectors`. Let's have a look at the upper body detector as an example:
28 |
29 | ### Tracker Parameters
30 |
31 | The tracker offers two configuration parameters:
32 | * `filter_type`: This specefies which variant of the Kalman filter to use. Currently, it implements an Extended and an Unscented Kalman filter which can be chosen via `EKF` and `UKF`, respectively.
33 | * `cv_noise_params`: parameter is used for the constant velocity prediction model.
34 | * specifies the standard deviation of the x and y velocity.
35 |
36 | ### Detector Parameters
37 |
38 | * For every detector you have to create a new namespace where the name is used as an internal identifier for this detector. Therefore it has to be unique. In this case it is `upper_body_detector`
39 | * The `topic` parameter specifies the topic under which the detections are published. The type has to be `geometry_msgs/PoseArray`. See `to_pose_array` in detector_msg_to_pose_array/README.md if your detector does not publish a PoseArray.
40 | * The `cartesian_noise_params` parameter is used for the Cartesian observation model.
41 | * specifies the standard deviation of x and y.
42 | * `matching_algorithm` specifies the algorithm used to match detections from different sensors/detectors. Currently there are two different algorithms which are based on the Mahalanobis distance of the detections (default being NNJPDA if parameter is misspelled):
43 | * NN: Nearest Neighbour
44 | * NNJPDA: Nearest Neighbour Joint Probability Data Association
45 |
46 | All of these are just normal ROS parameters and can be either specified by the parameter server or using the yaml file in the provided launch file.
47 |
48 | ### Message Type:
49 |
50 | The tracker publishes the following:
51 | * `pose`: A `geometry_msgs/PoseStamped` for the clostes person.
52 | * `pose_array`: A `geometry_msgs/PoseArray` for all detections.
53 | * `people`: A `people_msgs/People` for all detections. Can be used for layerd costmaps.
54 | * `marker_array`: A `visualization_msgs/MarkerArray` showing little stick figures for every detection. Figures are orient according to the direction of velocity.
55 | * `trajectory`: A `geometry_msgs/PoseArray` for human trajectory.
56 | * `positions`: A `bayes_people_tracker/PeopleTracker` message. See below.
57 |
58 | ```
59 | std_msgs/Header header
60 | string[] uuids # Unique uuid5 (NAMESPACE_DNS) person id as string. Id is based on system time on start-up and tracker id. Array index matches ids array index
61 | geometry_msgs/Pose[] poses # The real world poses of the detected people in the given target frame. Default: /map. Array index matches ids/uuids array index
62 | float64[] distances # The distances of the detected persons to the robot (polar coordinates). Array index matches ids array index.
63 | float64[] angles # Angles of the detected persons to the coordinate frames z axis (polar coordinates). Array index matches ids array index.
64 | float64 min_distance # The minimal distance in the distances array.
65 | float64 min_distance_angle # The angle according to the minimal distance.
66 | ```
67 |
68 | The poses will be published in a given `target_frame` (see below) but the distances and angles will always be relative to the robot in the `/base_link` tf frame.
69 |
70 | ### Running
71 | Parameters:
72 |
73 | * `target_frame`: _Default: /base_link_:the tf frame in which the tracked poses will be published.
74 | * `position`: _Default: /people_tracker/positions_: The topic under which the results are published as bayes_people_tracker/PeopleTracker`
75 | * `pose`: _Default: /people_tracker/pose_: The topic under which the closest detected person is published as a geometry_msgs/PoseStamped`
76 | * `pose_array`: _Default: /people_tracker/pose_array_: The topic under which the detections are published as a geometry_msgs/PoseArray`
77 | * `poeple`: _Default: /people_tracker/people_: The topic under which the results are published as people_msgs/People`
78 | * `marker`: _Default /people_tracker/marker_array_: A visualisation marker array.
79 |
80 | You can run the node with:
81 |
82 | ```
83 | roslaunch bayes_people_tracker people_tracker.launch
84 | ```
85 |
86 | This is the recommended way of launching it since this will also read the config file and set the right parameters for the detectors.
87 |
88 | [1] N. Bellotto and H. Hu, “Computationally efficient solutions for tracking people with a mobile robot: an experimental evaluation of bayesian filters,” Autonomous Robots, vol. 28, no. 4, pp. 425–438, 2010.
89 |
--------------------------------------------------------------------------------
/bayes_people_tracker/config/detectors.yaml:
--------------------------------------------------------------------------------
1 | bayes_people_tracker:
2 | filter_type: "UKF" # The Kalman filter type: EKF = Extended Kalman Filter, UKF = Uncented Kalman Filter
3 | cv_noise_params: # The noise for the constant velocity prediction model
4 | x: 1.4
5 | y: 1.4
6 | detectors: # Add detectors under this namespace
7 | upper_body_detector: # Name of detector (used internally to identify them). Has to be unique.
8 | topic: "/upper_body_detector/bounding_box_centres" # The topic on which the geometry_msgs/PoseArray is published
9 | cartesian_noise_params: # The noise for the cartesian observation model
10 | x: 0.5
11 | y: 0.5
12 | matching_algorithm: "NNJPDA" # The algorthim to match different detections. NN = Nearest Neighbour, NNJPDA = NN Joint Probability Data Association
13 | leg_detector: # Name of detector (used internally to identify them). Has to be unique.
14 | topic: "/to_pose_array/leg_detector" # The topic on which the geometry_msgs/PoseArray is published
15 | cartesian_noise_params: # The noise for the cartesian observation model
16 | x: 0.2
17 | y: 0.2
18 | matching_algorithm: "NNJPDA" # The algorthim to match different detections. NN = Nearest Neighbour, NNJPDA = NN Joint Probability Data Association
19 |
--------------------------------------------------------------------------------
/bayes_people_tracker/config/detectors_withnewparams.yaml:
--------------------------------------------------------------------------------
1 | bayes_people_tracker:
2 | filter_type: "UKF" # The Kalman filter type: EKF = Extended Kalman Filter, UKF = Uncented Kalman Filter
3 | cv_noise_params: # The noise for the constant velocity prediction model
4 | x: 1.4
5 | y: 1.4
6 | std_limit: 1.0 # upper limit for the standard deviation of the estimated position
7 | detectors: # Add detectors under this namespace
8 | upper_body_detector: # Name of detector (used internally to identify them). Has to be unique.
9 | topic: "/upper_body_detector/bounding_box_centres" # The topic on which the geometry_msgs/PoseArray is published
10 | cartesian_noise_params: # The noise (standard deviation) for the cartesian observation model
11 | x: 0.5
12 | y: 0.5
13 | matching_algorithm: "NNJPDA" # The algorthim to match different detections. NN = Nearest Neighbour, NNJPDA = NN Joint Probability Data Association
14 | seq_size: 5 # Minimum number of observations for new track creation
15 | seq_time: 0.2 # Minimum interval between observations for new track creation
16 | leg_detector: # Name of detector (used internally to identify them). Has to be unique.
17 | topic: "/to_pose_array/leg_detector" # The topic on which the geometry_msgs/PoseArray is published
18 | cartesian_noise_params: # The noise for the cartesian observation model
19 | x: 0.2
20 | y: 0.2
21 | matching_algorithm: "NNJPDA" # The algorthim to match different detections. NN = Nearest Neighbour, NNJPDA = NN Joint Probability Data Association
22 | seq_size: 4 # Minimum number of observations for new track creation
23 | seq_time: 0.3 # Minimum interval between observations for new track creation
24 |
--------------------------------------------------------------------------------
/bayes_people_tracker/include/people_tracker/asso_exception.h:
--------------------------------------------------------------------------------
1 | #ifndef ASSO_EXCEPTION_H
2 | #define ASSO_EXCEPTION_H
3 |
4 | #include
5 | #include
6 |
7 | using namespace std;
8 |
9 | struct asso_exception: public exception
10 | {
11 | const char* what() const throw()
12 | {
13 | return "Unknown association algorithm!";
14 | }
15 | };
16 |
17 | struct observ_exception: public exception
18 | {
19 | const char* what() const throw()
20 | {
21 | return "Unknown observation model!";
22 | }
23 | };
24 |
25 | struct filter_exception: public exception
26 | {
27 | const char* what() const throw()
28 | {
29 | return "Unknown filter type!";
30 | }
31 | };
32 |
33 | #endif // ASSO_EXCEPTION_H
34 |
--------------------------------------------------------------------------------
/bayes_people_tracker/launch/people_tracker.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/bayes_people_tracker/msg/PeopleTracker.msg:
--------------------------------------------------------------------------------
1 | std_msgs/Header header
2 | string[] uuids # Unique uuid5 (NAMESPACE_DNS) person id as string. Id is based on system time on start-up and tracker id. Array index matches ids array index
3 | geometry_msgs/Pose[] poses # The real world poses of the detected people in the given target frame. Default: /map. Array index matches ids/uuids array index
4 | float64[] distances # The distances of the detected persons to the robot (polar coordinates). Array index matches ids array index.
5 | float64[] angles # Angles of the detected persons to the coordinate frames z axis (polar coordinates). Array index matches ids array index.
6 | float64 min_distance # The minimal distance in the distances array.
7 | float64 min_distance_angle # The angle according to the minimal distance.
8 |
--------------------------------------------------------------------------------
/bayes_people_tracker/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | bayes_people_tracker
4 | 1.1.8
5 | The bayes_people_tracker package
6 |
7 | Christian Dondrup
8 | Zhi Yan
9 |
10 | MIT
11 |
12 | https://github.com/strands-project/strands_perception_people
13 |
14 | Christian Dondrup
15 |
16 | catkin
17 |
18 | boost
19 | bayes_tracking
20 | geometry_msgs
21 | message_generation
22 | people_msgs
23 | roscpp
24 | std_msgs
25 | tf
26 | visualization_msgs
27 | nav_msgs
28 | message_filters
29 |
30 | boost
31 | bayes_tracking
32 | geometry_msgs
33 | message_runtime
34 | people_msgs
35 | roscpp
36 | std_msgs
37 | tf
38 | visualization_msgs
39 | nav_msgs
40 | message_filters
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/bayestracking/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package bayes_tracking
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | 1.0.2 (2014-09-03)
6 | ------------------
7 | * Adding boost as a build an run dependency.
8 | * Changing Licence to GPL
9 | * Contributors: Christian Dondrup
10 |
11 | 1.0.5 (2014-10-29)
12 | ------------------
13 | * Merge pull request `#9 `_ from LCAS/indigo-fix
14 | Trusty/Indigo fix
15 | * Trusty/Indigo fix
16 | * Contributors: Christian Dondrup
17 |
18 | 1.0.4 (2014-10-29)
19 | ------------------
20 | * Merge pull request `#8 `_ from LCAS/opencv
21 | Changing dependency from opencv2 to cv_bridge for indigo release.
22 | * Changing dependency from opencv2 to cv_bridge for indigo release.
23 | * Contributors: Christian Dondrup
24 |
25 | 1.0.3 (2014-09-09)
26 | ------------------
27 | * "Fixing" the missing JPDA
28 | The option of using only JPDA as an association algorithm was a relic from past development and is not supported anymore.
29 | This change just comments the JPDA in the enum, preventing people from trying to use it.
30 | * Using the correct licence now.
31 | * 1.0.2
32 | * Updated changelog for 1.0.2
33 | * Adding boost as a build an run dependency.
34 | * 1.0.1
35 | * Reverting the version number increase.
36 | * Merge pull request `#5 `_ from cdondrup/master
37 | Release preparations
38 | * Contributors: Christian Dondrup
39 |
40 | 1.0.1 (2014-09-02)
41 | ------------------
42 | * Merge pull request `#4 `_ from cdondrup/master
43 | Renamed `bayestracking` to `bayes_tracking` to comply with ros naming conventions.
44 | * Renamed `bayestracking` to `bayes_tracking` to comply with ros naming conventions.
45 | * Merge pull request `#2 `_ from cdondrup/master
46 | Adding optional catkin build
47 | * * Enabling normal cmake build if catkin is not available.
48 | * Updated package.xml and create install targets for ROS release
49 | * Refactored README to markdown
50 | * Refactored bayestracking library to be a catkin package
51 | Created a cleaner file structure by seperating the src from the include files.
52 | * Update README
53 | * Update README
54 | * Now generates cmake config files to enable usage of find_package
55 | * Added the creation of a pkg-config file to make the library easier to use.
56 | * PFilter not working right now in simple_tracking.cpp, but all other tested filters (UKF and EKF) worked very well
57 | * fixed size_t uint issue
58 | * compiles now (but simple_tracking example still gives errors)
59 | * initial import form package
60 | * Contributors: Christian Dondrup, Marc Hanheide
61 |
--------------------------------------------------------------------------------
/bayestracking/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(bayes_tracking)
3 | set(CPACK_PACKAGE_NAME "bayes_tracking")
4 | set(VERSION "1.0.3")
5 |
6 | ## Find catkin macros and libraries if installed
7 | find_package(catkin QUIET)
8 | ## Use catkin macros and include dirs
9 | if(catkin_FOUND)
10 | message(STATUS "Found catkin")
11 | catkin_package(
12 | INCLUDE_DIRS include
13 | LIBRARIES ${PROJECT_NAME}
14 | )
15 | include_directories(
16 | ${catkin_INCLUDE_DIRS}
17 | )
18 | else(catkin_FOUND)
19 | message(STATUS "NOT found catkin")
20 | endif(catkin_FOUND)
21 |
22 | ## Headers
23 | include_directories(
24 | include
25 | )
26 | ## Source files
27 | add_library(${PROJECT_NAME} STATIC
28 | src/bayes_tracking/associationmatrix.cpp
29 | src/bayes_tracking/ekfilter.cpp
30 | src/bayes_tracking/ukfilter.cpp
31 | src/bayes_tracking/pfilter.cpp
32 | ## src/bayes_tracking/trackwin.cpp
33 | src/bayes_tracking/models.cpp
34 | src/bayes_tracking/BayesFilter/bayesFltAlg.cpp
35 | src/bayes_tracking/BayesFilter/bayesFlt.cpp
36 | src/bayes_tracking/BayesFilter/CIFlt.cpp
37 | src/bayes_tracking/BayesFilter/covFlt.cpp
38 | src/bayes_tracking/BayesFilter/infFlt.cpp
39 | src/bayes_tracking/BayesFilter/infRtFlt.cpp
40 | src/bayes_tracking/BayesFilter/itrFlt.cpp
41 | src/bayes_tracking/BayesFilter/matSup.cpp
42 | src/bayes_tracking/BayesFilter/SIRFlt.cpp
43 | src/bayes_tracking/BayesFilter/UDFlt.cpp
44 | src/bayes_tracking/BayesFilter/UdU.cpp
45 | src/bayes_tracking/BayesFilter/unsFlt.cpp
46 | )
47 |
48 | ## Link catkin libraries and set install targets
49 | if(catkin_FOUND)
50 | target_link_libraries(${PROJECT_NAME}
51 | ${catkin_LIBRARIES}
52 | )
53 |
54 | install(TARGETS ${PROJECT_NAME}
55 | ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
56 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
57 | RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
58 | )
59 |
60 | install(DIRECTORY include/${PROJECT_NAME}/
61 | DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
62 | PATTERN ".svn" EXCLUDE
63 | )
64 | endif(catkin_FOUND)
65 |
66 | ## add_subdirectory(examples)
67 |
68 | ## Optional builds: documentation
69 | OPTION (BAYESTRACKING_BUILD_DOC "Generates API documentation" OFF)
70 | if(BAYESTRACKING_BUILD_DOC)
71 | ## Check if doxygen is even installed
72 | find_package(Doxygen)
73 | if (DOXYGEN_FOUND STREQUAL "NO")
74 | message(FATAL_ERROR "Doxygen not found. Please get a copy http://www.doxygen.org")
75 | endif (DOXYGEN_FOUND STREQUAL "NO")
76 |
77 | ## Prepare doxygen configuration file
78 | configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
79 |
80 | ## Add doxygen as target
81 | add_custom_target(doc ALL ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
82 | COMMENT "Generating API documentation with Doxygen" VERBATIM)
83 |
84 | ## Cleanup $build/doc on "make clean"
85 | set_property(DIRECTORY APPEND PROPERTY
86 | ADDITIONAL_MAKE_CLEAN_FILES doc)
87 |
88 | ## Install HTML API documentation and manual pages
89 | set(DOC_PATH "share/doc/${CPACK_PACKAGE_NAME}-${VERSION}")
90 |
91 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html
92 | DESTINATION ${DOC_PATH}
93 | )
94 |
95 | endif(BAYESTRACKING_BUILD_DOC)
96 |
--------------------------------------------------------------------------------
/bayestracking/Doxyfile.in:
--------------------------------------------------------------------------------
1 | PROJECT_NAME = ${CPACK_PACKAGE_NAME}
2 | PROJECT_NUMBER = ${VERSION}
3 | OUTPUT_DIRECTORY = doc
4 | INPUT = ${CMAKE_CURRENT_SOURCE_DIR}/src
5 | GENERATE_LATEX = NO
6 | QUIET = YES
7 | EXTRACT_ALL = YES
8 |
--------------------------------------------------------------------------------
/bayestracking/LICENCE:
--------------------------------------------------------------------------------
1 | This program is free software; you can redistribute it and/or modify
2 | it under the terms of the GNU General Public License as published by
3 | the Free Software Foundation; either version 2 of the License, or
4 | (at your option) any later version.
5 |
6 | This program is distributed in the hope that it will be useful,
7 | but WITHOUT ANY WARRANTY; without even the implied warranty of
8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 | GNU General Public License for more details.
10 |
11 | You should have received a copy of the GNU General Public License
12 | along with this program; if not, write to the
13 | Free Software Foundation, Inc.,
14 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 |
--------------------------------------------------------------------------------
/bayestracking/README.md:
--------------------------------------------------------------------------------
1 | ## BayesTracking - a library for Bayesian tracking
2 |
3 | ### Requirements
4 | * Bayes++ (included in the repository)
5 | * OpenCV 2.x (only to build the examples)
6 |
7 | ### Install (without catkin)
8 | * Extract the library's compressed file
9 | * In the library's directory, create a sub-directory `build`
10 | * Enter in `./build` and run `cmake ..`
11 | * Run `make` to build the library
12 | * Run `make install` (as super user) to install the library and relative header files
13 |
14 | ### Install (ROS version)
15 | * Run `rosdep` to resolve dependencies
16 | * Run `catkin_make`
17 | * Run `catkin_make install` to install the library and headers (optional)
18 |
19 |
20 | _by Nicola Bellotto _
21 |
22 | *cite with this DOI: [10.5281/zenodo.10318](http://dx.doi.org/10.5281/zenodo.10318)*
23 |
--------------------------------------------------------------------------------
/bayestracking/config/BayestrackingConfig.cmake.in:
--------------------------------------------------------------------------------
1 | # - Config file for the bayestracking package
2 | # It defines the following variables
3 | # BAYESTRACKING_INCLUDE_DIRS - include directories for FooBar
4 | # BAYESTRACKING_LIBRARIES - libraries to link against
5 |
6 | # Compute paths
7 | get_filename_component(BAYESTRACKING_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
8 | set(BAYESTRACKING_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
9 |
10 | # Our library dependencies (contains definitions for IMPORTED targets)
11 | if(NOT TARGET bayestracking AND NOT Bayestracking_BINARY_DIR)
12 | include("${BAYESTRACKING_CMAKE_DIR}/BayestrackingTargets.cmake")
13 | endif()
14 |
15 | # These are IMPORTED targets created by FooBarTargets.cmake
16 | set(BAYESTRACKING_LIBRARIES bayestracking)
17 |
--------------------------------------------------------------------------------
/bayestracking/config/BayestrackingConfigVersion.cmake.in:
--------------------------------------------------------------------------------
1 | set(PACKAGE_VERSION "@VERSION@")
2 |
3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible
4 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
5 | set(PACKAGE_VERSION_COMPATIBLE FALSE)
6 | else()
7 | set(PACKAGE_VERSION_COMPATIBLE TRUE)
8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
9 | set(PACKAGE_VERSION_EXACT TRUE)
10 | endif()
11 | endif()
12 |
--------------------------------------------------------------------------------
/bayestracking/config/bayestracking.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@CMAKE_INSTALL_PREFIX@
2 | exec_prefix=${prefix}
3 | libdir=${exec_prefix}/lib
4 | includedir=${prefix}/include
5 |
6 | Name: bayestracking
7 | Description: BayesTracking - a library for Bayesian tracking
8 | Version: @VERSION@
9 | Cflags: -I${includedir}/bayestracking
10 | Libs: -L${libdir} -lbayestracking
11 |
12 |
--------------------------------------------------------------------------------
/bayestracking/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include_directories(../include)
2 |
3 | add_executable(simple_2d_tracking simple_2d_tracking.cpp)
4 |
5 |
6 | find_package( OpenCV REQUIRED )
7 |
8 | target_link_libraries(simple_2d_tracking bayes_tracking ${OpenCV_LIBS})
9 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/CIFlt.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _BAYES_FILTER_CI
2 | #define _BAYES_FILTER_CI
3 |
4 | /*
5 | * Bayes++ the Bayesian Filtering Library
6 | * Copyright (c) 2002 Michael Stevens
7 | * See accompanying Bayes++.htm for terms and conditions of use.
8 | *
9 | * $Id$
10 | */
11 |
12 | /*
13 | * Covariance Intersection Filter Scheme.
14 | *
15 | * References
16 | * [1] "A Non divergent Estimation Algorithm in the Presence of Unknown Correlations"
17 | * Simon J Julier, Jeffrey K Uhlmann
18 | *
19 | * CI provides a generalised consistent method to combine mean and covariances
20 | * of two estimates. The combination can be optimised by choosing a norm of the
21 | * combined correlations. The norm (omega) is restrict to 0..1 inclusive an effectively
22 | * scales the combination
23 | * Here is CI with a predict and observe model to form a filter.
24 | *
25 | * The Omega norm chosen here is the fixed value of 0.5
26 | * The Omega function should be overloaded to produce more useful results
27 | *
28 | * The filter is operated by performing a
29 | * predict, observe
30 | * cycle derived from the Extended_filter
31 | */
32 | #include "bayes_tracking/BayesFilter/bayesFlt.hpp"
33 |
34 | /* Filter namespace */
35 | namespace Bayesian_filter
36 | {
37 |
38 | class CI_scheme : public Extended_kalman_filter
39 | {
40 | public:
41 | CI_scheme (std::size_t x_size, std::size_t z_initialsize = 0);
42 | CI_scheme& operator= (const CI_scheme&);
43 | // Optimise copy assignment to only copy filter state
44 |
45 | void init ();
46 | void update ();
47 | Float predict (Linrz_predict_model& f);
48 | Float observe_innovation (Linrz_uncorrelated_observe_model& h, const FM::Vec& s);
49 | Float observe_innovation (Linrz_correlated_observe_model& h, const FM::Vec& s);
50 |
51 | virtual Float Omega(const FM::SymMatrix& Ai, const FM::SymMatrix& Bi, const FM::SymMatrix& A)
52 | // Determine norm Omega 0..1 for the CI combination
53 | // Default norm is the fixed value 0.5
54 | {
55 | return 0.5;
56 | }
57 |
58 | public: // Exposed Numerical Results
59 | FM::SymMatrix S, SI; // Innovation Covariance and Inverse
60 |
61 | protected: // allow fast operation if z_size remains constant
62 | std::size_t last_z_size;
63 | void observe_size (std::size_t z_size);
64 | };
65 |
66 |
67 | }//namespace
68 | #endif
69 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/UDFlt.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _BAYES_FILTER_UD
2 | #define _BAYES_FILTER_UD
3 | /*
4 | * Bayes++ the Bayesian Filtering Library
5 | * Copyright (c) 2002 Michael Stevens
6 | * See accompanying Bayes++.htm for terms and conditions of use.
7 | *
8 | * $Id$
9 | */
10 |
11 | /*
12 | * UdU' Factorisation of covariance Filter Scheme.
13 | * Implementation of a 'Square-root' linearised Kalman filter
14 | *
15 | * Bierman's UD factorisatised update algorithm using Agee-Turner UdU' factorisation rank 1 update
16 | * Thornton's MWG-S factorisation predict algorithm
17 | * References
18 | * [1] "Factorisation Methods for Discrete Sequential Estimation" Gerald J. Bierman ISBN 0-12-097350-2
19 | * [2] "Kalman Filtering, Theory and Practice", Mohinder S. Grewal, Angus P. Andrews ISBN 0-13-211335-X
20 | *
21 | * A initial observation size may also be specified for efficiency.
22 | *
23 | * The filter is operated by performing a
24 | * predict, observe
25 | * cycle defined by the base class
26 | */
27 | #include "bayes_tracking/BayesFilter/bayesFlt.hpp"
28 |
29 | /* Filter namespace */
30 | namespace Bayesian_filter
31 | {
32 |
33 | class UD_sequential_observe_model : public Linrz_uncorrelated_observe_model
34 | {
35 | public:
36 | UD_sequential_observe_model (std::size_t x_size, std::size_t z_size) :
37 | Linrz_uncorrelated_observe_model(x_size, z_size), Hx_o(x_size)
38 | {}
39 | virtual const FM::Vec& ho (const FM::Vec& x, const std::size_t o) = 0;
40 | /* Supplied model (h) for observation using state x, z allows normalisation and model variation
41 | Fast model of a single element (o) in observation model
42 | Precondition: Hx_o is conformantly dimensioned
43 | Postcondition:
44 | z(k|k-1) = h(x(k|k-1)
45 | Hx_o(x(k-1|k-1) = Jacobian of h with respect to state x (row o)
46 | */
47 | FM::Vec Hx_o;
48 | };
49 |
50 |
51 | class UD_scheme : public Linrz_kalman_filter
52 | {
53 | private:
54 | std::size_t q_max; // Maxiumum size allocated for noise model, constructed before UD
55 | public:
56 | FM::Matrix UD; // UDU factorisation of X with D on diagonal
57 | // Lower triangle used as workspace
58 | FM::Vec s; // Innovation
59 | FM::Vec Sd; // Innovation Covariance
60 |
61 | UD_scheme (std::size_t x_size, std::size_t q_maxsize, std::size_t z_initialsize = 0);
62 | UD_scheme& operator= (const UD_scheme&);
63 | // Optimise copy assignment to only copy filter state
64 |
65 | void init ();
66 | void update ();
67 | Float predict (Linrz_predict_model& f);
68 |
69 | Float observe (Linrz_correlated_observe_model& h, const FM::Vec& z);
70 | /* No solution for Correlated noise and Linrz model */
71 | Float observe (Linrz_uncorrelated_observe_model& h, const FM::Vec& z);
72 | /* General observe */
73 |
74 | Float observe (Linear_correlated_observe_model& h, const FM::Vec& z);
75 | /* Special Linear observe for correlated Z, fast Z decorrelation */
76 | Float observe (UD_sequential_observe_model& h, const FM::Vec& z);
77 | /* Special Linrz observe using fast sequential model */
78 |
79 | protected:
80 | Float predictGq (const FM::Matrix& Fx, const FM::Matrix& G, const FM::Vec& q);
81 | FM::Vec d, dv, v; // predictGQ temporaries
82 | Float observeUD (FM::Vec& gain, Float& alpha, const FM::Vec& h, const Float r);
83 | FM::Vec a, b; // observeUD temporaries
84 | // Observation temporaies
85 | void observe_size (std::size_t z_size);
86 | std::size_t last_z_size;
87 | FM::Vec h1; // Single Observation model
88 | FM::Vec w; // Single Gain
89 | FM::Vec znorm; // Normalised innovation
90 | FM::Vec zpdecol; // Decorrelated zp
91 | FM::Matrix Gz; // Z coupling
92 | FM::Matrix GIHx; // Modified Model for linear decorrelation
93 | };
94 |
95 |
96 | }//namespace
97 | #endif
98 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/allFilters.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _ALL_FILTERS
2 | #define _ALL_FILTERS
3 |
4 | /*
5 | * Bayes++ the Bayesian Filtering Library
6 | * Copyright (c) 2002 Michael Stevens
7 | * See accompanying Bayes++.htm for terms and conditions of use.
8 | *
9 | * $Id$
10 | */
11 |
12 | /*
13 | * Bayesian Filters.
14 | * A Bayesian filters as an Abstract class.
15 | * All filters have similar structure with vary algorithms and numerical properties
16 | */
17 |
18 | #include "bayes_tracking/BayesFilter/UDFlt.hpp"
19 | #include "bayes_tracking/BayesFilter/CIFlt.hpp"
20 | #include "bayes_tracking/BayesFilter/unsFlt.hpp"
21 | #include "bayes_tracking/BayesFilter/covFlt.hpp"
22 | #include "bayes_tracking/BayesFilter/infFlt.hpp"
23 | #include "bayes_tracking/BayesFilter/infRtFlt.hpp"
24 | #include "bayes_tracking/BayesFilter/itrFlt.hpp"
25 | #include "bayes_tracking/BayesFilter/SIRFlt.hpp"
26 | #include "bayes_tracking/BayesFilter/models.hpp"
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/bayesException.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _BAYES_FILTER_EXCEPTION
2 | #define _BAYES_FILTER_EXCEPTION
3 |
4 | /*
5 | * Bayes++ the Bayesian Filtering Library
6 | * Copyright (c) 2002 Michael Stevens
7 | * See accompanying Bayes++.htm for terms and conditions of use.
8 | *
9 | * $Id$
10 | */
11 |
12 | /*
13 | * Exception types: Exception hierarchy for Bayesian filtering
14 | */
15 |
16 | // Common headers required for declerations
17 | #include
18 |
19 | /* Filter namespace */
20 | namespace Bayesian_filter
21 | {
22 |
23 |
24 | class Filter_exception : virtual public std::exception
25 | /*
26 | * Base class for all exception produced by filter hierarchy
27 | */
28 | {
29 | public:
30 | const char *what() const throw()
31 | { return error_description;
32 | }
33 | protected:
34 | Filter_exception (const char* description)
35 | { error_description = description;
36 | }
37 | private:
38 | const char* error_description;
39 | };
40 |
41 | class Logic_exception : virtual public Filter_exception
42 | /*
43 | * Logic Exception
44 | */
45 | {
46 | public:
47 | Logic_exception (const char* description) :
48 | Filter_exception (description)
49 | {}
50 | };
51 |
52 | class Numeric_exception : virtual public Filter_exception
53 | /*
54 | * Numeric Exception
55 | */
56 | {
57 | public:
58 | Numeric_exception (const char* description) :
59 | Filter_exception (description)
60 | {}
61 | };
62 |
63 |
64 | }//namespace
65 | #endif
66 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/covFlt.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _BAYES_FILTER_COVARIANCE
2 | #define _BAYES_FILTER_COVARIANCE
3 |
4 | /*
5 | * Bayes++ the Bayesian Filtering Library
6 | * Copyright (c) 2002 Michael Stevens
7 | * See accompanying Bayes++.htm for terms and conditions of use.
8 | *
9 | * $Id$
10 | */
11 |
12 | /*
13 | * Covariance Filter Scheme.
14 | * Implementation of extended Kalman filter
15 | *
16 | * To work with with Linear and Linrz models
17 | * a) a state separate from covariance predict is used.
18 | * b) a EKF innovation update algorithm is used.
19 | * Discontinuous observe models require that predict is normalised with
20 | * respect to the observation.
21 | *
22 | * A initial observation size may also be specified for efficiency.
23 | *
24 | * The filter is operated by performing a
25 | * predict, observe
26 | * cycle defined by the base class
27 | */
28 | #include "bayes_tracking/BayesFilter/bayesFlt.hpp"
29 |
30 | /* Filter namespace */
31 | namespace Bayesian_filter
32 | {
33 |
34 | class Covariance_scheme : public Extended_kalman_filter
35 | {
36 | public:
37 | Covariance_scheme (std::size_t x_size, std::size_t z_initialsize = 0);
38 | Covariance_scheme& operator= (const Covariance_scheme&);
39 | // Optimise copy assignment to only copy filter state
40 |
41 | void init ();
42 | void update ();
43 |
44 | Float predict (Linrz_predict_model& f);
45 | // Standard Linrz prediction
46 | Float predict (Gaussian_predict_model& f);
47 | // Specialised 'stationary' prediction, only additive noise
48 |
49 | Float observe_innovation (Linrz_uncorrelated_observe_model& h, const FM::Vec& s);
50 | Float observe_innovation (Linrz_correlated_observe_model& h, const FM::Vec& s);
51 |
52 | public: // Exposed Numerical Results
53 | FM::SymMatrix S, SI; // Innovation Covariance and Inverse
54 | FM::Matrix W; // Kalman Gain
55 |
56 | protected: // Permanently allocated temps
57 | FM::RowMatrix tempX;
58 | protected: // allow fast operation if z_size remains constant
59 | std::size_t last_z_size;
60 | void observe_size (std::size_t z_size);
61 | };
62 |
63 |
64 | }//namespace
65 | #endif
66 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/filters/average1.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _BAYES_FILTER_AVERAGE1
2 | #define _BAYES_FILTER_AVERAGE1
3 |
4 | /*
5 | * Bayes++ the Bayesian Filtering Library
6 | * Copyright (c) 2002 Michael Stevens
7 | * See accompanying Bayes++.htm for terms and conditions of use.
8 | *
9 | * $Id$
10 | */
11 |
12 | /*
13 | * Predefined filter: Average1_filter
14 | * A single state averager
15 | */
16 |
17 | /* Filter namespace */
18 | namespace Bayesian_filter
19 | {
20 |
21 | template
22 | class Average1_filter
23 | {
24 | Filter_base ksf; // Kalman State Filter
25 |
26 | typedef typename Filter_base::Float Float;
27 | class Cpredict : public Linear_predict_model
28 | // Constant predict model
29 | {
30 | public:
31 | Cpredict(Float qq) : Linear_predict_model(1, 1)
32 | {
33 | Fx(0,0) = 1.;
34 | q[0] = qq;
35 | G(0,0) = 1.;
36 | }
37 | };
38 |
39 | class Cobserve : public Linear_correlated_observe_model
40 | // Constant observe model
41 | {
42 | public:
43 | Cobserve(Float ZZ) : Linear_correlated_observe_model(1,1)
44 | {
45 | Hx(0,0) = 1.;
46 | Z(0,0) = ZZ;
47 | }
48 | };
49 |
50 | public:
51 | Average1_filter (Float iQ, Float iZ, Float z);
52 | Average1_filter (Float iQ, Float iZ);
53 | Float observe (Float zz);
54 | operator Float () const
55 | /* Returns filtered estimate
56 | */
57 | { if (!bInit)
58 | ksf.error (Logic_exception("Average1 not init"));
59 | return ksf.x[0];
60 | }
61 |
62 | private:
63 | Cpredict f;
64 | Cobserve h;
65 |
66 | bool bInit;
67 | FM::Vec z;
68 | };
69 |
70 |
71 |
72 | template
73 | Average1_filter::Average1_filter (Float iQ, Float iZ, Float zz) :
74 | ksf(1), f(iQ), h(iZ), z(1)
75 | /* Initialise noises and set sizes
76 | * include first observation zz */
77 | {
78 | bInit = false;
79 |
80 | observe (zz);
81 | }
82 |
83 | template
84 | Average1_filter::Average1_filter (Float iQ, Float iZ) :
85 | ksf(1), f(iQ), h(iZ), z(1)
86 | // Initialise noises and set sizes
87 | {
88 | bInit = false;
89 | }
90 |
91 | template
92 | typename Average1_filter::Float Average1_filter::observe(Float zz)
93 | /* Observe z, first call set initial state to z
94 | * Returns filtered estimate
95 | */
96 | {
97 | z[0] = zz;
98 |
99 | if (!bInit) {
100 | ksf.init_kalman (z, h.Z);
101 | bInit = true;
102 | }
103 |
104 | ksf.predict(f);
105 | ksf.observe(h, z);
106 | ksf.update ();
107 |
108 | return ksf.x[0];
109 | }
110 |
111 | }//namespace
112 | #endif
113 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/filters/indirect.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _BAYES_FILTER_INDIRECT
2 | #define _BAYES_FILTER_INDIRECT
3 |
4 | /*
5 | * Bayes++ the Bayesian Filtering Library
6 | * Copyright (c) 2002 Michael Stevens
7 | * See accompanying Bayes++.htm for terms and conditions of use.
8 | *
9 | * $Id$
10 | */
11 |
12 | /*
13 | * Indirect Filter Adaptor
14 | * Hides the details of the indirect operation of the filter
15 | * The error filter uses the same linear models as the direct filter,
16 | * observation error computation (subtraction) is linear!
17 | */
18 |
19 | /* Filter namespace */
20 | namespace Bayesian_filter
21 | {
22 |
23 |
24 | template
25 | class Indirect_state_filter : public State_filter {
26 | /* Indirect state filter
27 | * Estimates state using an associated observation error filter
28 | */
29 | public:
30 | Indirect_state_filter (Error_base& error_filter)
31 | : State_filter(error_filter.x.size()), direct(error_filter)
32 | { // Construct and zero initial error filter
33 | direct.x.clear();
34 | }
35 |
36 | template
37 | void predict (P_model& f)
38 | {
39 | x = f.f(x);
40 | direct.predict(f); // May be optimised for linear f as x = 0
41 | };
42 |
43 | template
44 | void observe (O_model& h, const FM::Vec& z)
45 | {
46 | // Observe error (explicit temporary)
47 | FM::Vec z_error(z.size());
48 | z_error = h.h(x);
49 | z_error -= z;
50 | direct.observe (h, z_error);
51 | // Update State estimate with error
52 | x -= direct.x;
53 | // Reset the error
54 | direct.x.clear();
55 | }
56 |
57 | template
58 | void observe_error (O_model& h, const FM::Vec& z_error)
59 | {
60 | direct.observe (h, z_error);
61 | // Update State estimate with error
62 | x -= direct.x;
63 | // Reset the error
64 | direct.x.clear();
65 | }
66 |
67 | void update ()
68 | /* Update filters state
69 | Updates x(k|k)
70 | */
71 | {}
72 |
73 | private:
74 | Error_base& direct;
75 | };
76 |
77 |
78 | template
79 | class Indirect_kalman_filter : public Kalman_state_filter {
80 | /* Indirect Kalman filter
81 | * Estimates state using an associated observation error filter
82 | */
83 | public:
84 | Indirect_kalman_filter (Error_base& error_filter)
85 | : Kalman_state_filter(error_filter.x.size()), direct(error_filter)
86 | {
87 | }
88 |
89 | void init ()
90 | /* Initialise from state and state covariance
91 | */
92 | {
93 | direct.x.clear(); // Zero initial error
94 | direct.X = X;
95 | direct.init();
96 | }
97 |
98 | template
99 | void predict (P_model& f)
100 | {
101 | x = f.f(x);
102 | direct.predict(f); // May be optimised for linear f as x = 0
103 | };
104 |
105 | template
106 | void observe (O_model& h, const FM::Vec& z)
107 | {
108 | // Observe error (explicit temporary)
109 | FM::Vec z_error(z.size());
110 | z_error = h.h(x);
111 | z_error -= z;
112 | direct.observe (h, z_error);
113 | direct.update();
114 | // Update State estimate with error
115 | x -= direct.x;
116 | // Reset the error
117 | direct.x.clear();
118 | direct.init ();
119 | }
120 |
121 | template
122 | void observe_error (O_model& h, const FM::Vec& z_error)
123 | {
124 | direct.observe (h, z_error);
125 | // Update State estimate with error
126 | x -= direct.x;
127 | // Reset the error
128 | direct.clear();
129 | }
130 |
131 | void update ()
132 | /* Update filters state
133 | Updates x(k|k)
134 | */
135 | {
136 | direct.update();
137 | X = direct.X;
138 | }
139 |
140 | private:
141 | Error_base& direct;
142 | };
143 |
144 |
145 | }//namespace
146 | #endif
147 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/infFlt.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _BAYES_FILTER_INFORMATION
2 | #define _BAYES_FILTER_INFORMATION
3 |
4 | /*
5 | * Bayes++ the Bayesian Filtering Library
6 | * Copyright (c) 2002 Michael Stevens
7 | * See accompanying Bayes++.htm for terms and conditions of use.
8 | *
9 | * $Id$
10 | */
11 |
12 | /*
13 | * Information Filter Scheme.
14 | * A possibly non-linear Information filter
15 | *
16 | * References
17 | * [1] "Stochastic Models, Estimation, and Control} Peter S Maybeck, Academic Press, ISBN 0-12-480701-1
18 | * Section 5.7
19 | * [2] "Kalman Filtering, Theory and Practice", Mohinder S. Grewal, Angus P. Andrews ISBN 0-13-211335-X
20 | * To work with with Linear and Linrz models
21 | * a) a separate state and information (via covariance) predict is used.
22 | * b) a EIF modified innovation update algorithm is used.
23 | *
24 | * Two alternative algorithms are used for predict functions:
25 | * For linrz models an extended predict form is used so information state 'y' is predicted via the
26 | * non-linear function. This requires that X, and Y are invertible so 'x' can be computed.
27 | * For linear invertible models predict can be done directly without computing x
28 | * Discontinuous observe models require that predict is normailised with
29 | * respect to the observation.
30 | * NUMERICS
31 | * The state x is represented by prod(X,y). This may be ill conditioned if the product is
32 | * ill conditioned. At present only the conditioning of X if checked, if y has a large range the product
33 | * may be ill conditioned. This is not checked
34 | *
35 | * The filter is operated by performing a
36 | * predict, observe
37 | * cycle defined by the base class
38 | */
39 | #include "bayes_tracking/BayesFilter/bayesFlt.hpp"
40 |
41 | /* Filter namespace */
42 | namespace Bayesian_filter
43 | {
44 |
45 | class Information_scheme : public Extended_kalman_filter, virtual public Information_state_filter
46 | {
47 | public:
48 | Information_scheme (std::size_t x_size, std::size_t z_initialsize = 0);
49 | Information_scheme& operator= (const Information_scheme&);
50 | // Optimise copy assignment to only copy filter state
51 |
52 | struct Linear_predict_byproducts
53 | {
54 | Linear_predict_byproducts (std::size_t x_size, std::size_t q_size);
55 | FM::SymMatrix A;
56 | FM::Matrix tempG;
57 | FM::SymMatrix B;
58 | FM::Vec y;
59 | };
60 |
61 |
62 | void init ();
63 | void update ();
64 | void init_yY ();
65 | void update_yY ();
66 | // Covariance and information form state interface
67 |
68 | Float predict (Linear_invertable_predict_model& f, Linear_predict_byproducts& b);
69 | // Linear Prediction in information form as in Ref[2]
70 | Float predict (Linear_invertable_predict_model& f)
71 | {
72 | Linear_predict_byproducts b(f.Fx.size1(),f.q.size());
73 | return predict (f, b);
74 | }
75 |
76 | Float predict (Linrz_predict_model& f);
77 | // Extended Prediction via state
78 |
79 | Float observe_innovation (Linrz_uncorrelated_observe_model& h, const FM::Vec& s);
80 | Float observe_innovation (Linrz_correlated_observe_model& h, const FM::Vec& s);
81 |
82 | protected:
83 | bool update_required; // Postcondition of update is not met
84 |
85 | protected: // Permanently allocated temps
86 | FM::RowMatrix tempX;
87 | FM::Vec i;
88 | FM::SymMatrix I;
89 | // allow fast operation if z_size remains constant
90 | FM::SymMatrix ZI;
91 | std::size_t last_z_size;
92 | void observe_size (std::size_t z_size);
93 | };
94 |
95 |
96 | }//namespace
97 | #endif
98 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/infRtFlt.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _BAYES_FILTER_INFORMATION_ROOT
2 | #define _BAYES_FILTER_INFORMATION_ROOT
3 |
4 | /*
5 | * Bayes++ the Bayesian Filtering Library
6 | * Copyright (c) 2002 Michael Stevens
7 | * See accompanying Bayes++.htm for terms and conditions of use.
8 | *
9 | * $Id$
10 | */
11 |
12 | /*
13 | * Information Root Filter Scheme.
14 | * A extended 'Square-root' Information filter as an Abstract class
15 | *
16 | * Algorithm: Square-root information propagation using QR factorisation
17 | * Ref: P. Dyer and S. McReynolds, "Extension of Square-Root Filtering to Include Process Noise",
18 | * [1] Journal of Optimization Theory and Applications, Vol.3 No.6 1969
19 | * Filter maintains r,R where
20 | * inv(R)*inv(R)' = X
21 | * r = R*x
22 | * R is upper triangular but not strictly a Cholesky factor as diagonal may be negative
23 | * Observe algorithm has been extended to include linearised models
24 | * Discontinuous observe models require that state is normalised with respect to the observation.
25 | *
26 | * The filter is operated by performing a
27 | * predict, observe
28 | * cycle defined by the base class
29 | */
30 | #include "bayes_tracking/BayesFilter/bayesFlt.hpp"
31 |
32 | /* Filter namespace */
33 | namespace Bayesian_filter
34 | {
35 |
36 | class Information_root_scheme : public Extended_kalman_filter
37 | {
38 | public:
39 | FM::Vec r; // Information Root state
40 | FM::UTriMatrix R; // Information Root
41 |
42 | Information_root_scheme (std::size_t x_size, std::size_t z_initialsize = 0);
43 |
44 | void init ();
45 | void update ();
46 | // Covariance form state interface
47 |
48 | Float predict (Linrz_predict_model& f, const FM::ColMatrix& invFx, bool linear_r);
49 | /* Generalised form, using precomputed inverse of f.Fx */
50 | Float predict (Linrz_predict_model& f);
51 | /* Use linrz form for r, computes inverse model using inverse_Fx */
52 | Float predict (Linear_predict_model& f);
53 | /* Use linear form for r, computes inverse model using inverse_Fx */
54 | Float predict (Linear_invertable_predict_model& f)
55 | /* Use linear form for r, and use inv.Fx from invertible model */
56 | {
57 | return predict(f, f.inv.Fx, true);
58 | }
59 |
60 | Float observe_innovation (Linrz_uncorrelated_observe_model& h, const FM::Vec& s);
61 | Float observe_innovation (Linrz_correlated_observe_model& h, const FM::Vec& s);
62 | // Extended_kalman_filter observe
63 |
64 | static void inverse_Fx (FM::DenseColMatrix& invFx, const FM::Matrix& Fx);
65 | /* Numerical Inversion of Fx using LU factorisation */
66 | };
67 |
68 |
69 | /*
70 | * Information Root Filter Scheme with exposed information state
71 | * Augments Information_root_filter with y,Y in the interface
72 | */
73 |
74 | class Information_root_info_scheme : public Information_root_scheme, virtual public Information_state_filter
75 | {
76 | public:
77 | Information_root_info_scheme (std::size_t x_size, std::size_t z_initialsize = 0);
78 |
79 | void init_yY ();
80 | void update_yY ();
81 | // Information form state interface
82 | };
83 |
84 |
85 | }//namespace
86 | #endif
87 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/itrFlt.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _BAYES_FILTER_ITERATED_COVARIANCE
2 | #define _BAYES_FILTER_ITERATED_COVARIANCE
3 |
4 | /*
5 | * Bayes++ the Bayesian Filtering Library
6 | * Copyright (c) 2002 Michael Stevens
7 | * See accompanying Bayes++.htm for terms and conditions of use.
8 | *
9 | * $Id$
10 | */
11 |
12 | /*
13 | * Iterated Covariance Filter Scheme.
14 | * A non-linear Covariance (Kalman) filter with relinearisation and iteration
15 | *
16 | * The observe algorithm uses the iterated non-linear formulation
17 | * from Bar-Shalom and Fortmann p.119 (full scheme)
18 | * Discontinuous observe models require that state is normalised with
19 | * respect to the observation.
20 | *
21 | * The filter is operated by performing a
22 | * predict, observe
23 | * cycle defined by the base class
24 | */
25 | #include "bayes_tracking/BayesFilter/bayesFlt.hpp"
26 |
27 | /* Filter namespace */
28 | namespace Bayesian_filter
29 | {
30 |
31 | class Iterated_covariance_scheme;
32 |
33 | class Iterated_observe_model : virtual public Observe_model_base
34 | /* Linrz observation model which can be iterated
35 | Hx can be relinearised
36 | */
37 | {
38 | protected: // model is not sufficient, it is used to build observe model's
39 | Iterated_observe_model ()
40 | {}
41 | public:
42 | virtual void relinearise (const FM::Vec& x) = 0;
43 | // Relinearised about state x
44 | };
45 |
46 |
47 | class Iterated_terminator : public Bayes_base
48 | /*
49 | * Termination condition for filter Iteration
50 | * Used by iterated observe to parameterise termination condition
51 | * If iteration continues, the terminator must also relinearise the model about the filters new state
52 | *
53 | * Defaults to immediately terminating the iteration
54 | *
55 | * A more useful terminator can built by derivation.
56 | * For example terminator constructed with a reference to the filter and model can
57 | * detect convergence of x and/or X
58 | */
59 | {
60 | public:
61 | virtual bool term_or_relinearize (const Iterated_covariance_scheme& f)
62 | {
63 | return true;
64 | }
65 | };
66 |
67 | class Counted_iterated_terminator : public Iterated_terminator
68 | /* Termination condition with a simple fixed number of iterations
69 | */
70 | {
71 | public:
72 | Counted_iterated_terminator (Iterated_observe_model& model, unsigned iterations) :
73 | m(model), i(iterations)
74 | {}
75 | bool term_or_relinearize (const Iterated_covariance_scheme& f);
76 | Iterated_observe_model& m;
77 | unsigned i;
78 | };
79 |
80 |
81 |
82 | class Iterated_covariance_scheme : public Linrz_kalman_filter
83 | {
84 | public:
85 | Iterated_covariance_scheme (std::size_t x_size, std::size_t z_initialsize = 0);
86 | /* Initialised filter requires an addition iteration limit for the
87 | observe algorithm */
88 | Iterated_covariance_scheme& operator= (const Iterated_covariance_scheme&);
89 | // Optimise copy assignment to only copy filter state
90 |
91 | void init ();
92 | void update ();
93 | Float predict (Linrz_predict_model& f);
94 |
95 | Float observe (Linrz_uncorrelated_observe_model& h, Iterated_terminator& term, const FM::Vec& z);
96 | Float observe (Linrz_correlated_observe_model& h, Iterated_terminator& term, const FM::Vec& z);
97 | // Observe with iteration
98 | Float observe (Linrz_uncorrelated_observe_model& h, const FM::Vec& z)
99 | { // Observe with default termination
100 | Iterated_terminator term;
101 | return observe (h, term, z);
102 | }
103 | Float observe (Linrz_correlated_observe_model& h, const FM::Vec& z)
104 | { // Observe with default termination
105 | Iterated_terminator term;
106 | return observe (h, term, z);
107 | }
108 |
109 | public: // Exposed Numerical Results
110 | FM::SymMatrix S, SI; // Innovation Covariance and Inverse
111 |
112 | protected: // Permanently allocated temps
113 | FM::RowMatrix tempX;
114 |
115 | protected: // allow fast operation if z_size remains constant
116 | std::size_t last_z_size;
117 | void observe_size (std::size_t z_size);
118 | // Permanently allocated temps
119 | FM::Vec s;
120 | FM::Matrix HxT;
121 | };
122 |
123 |
124 | }//namespace
125 | #endif
126 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/matSup.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _BAYES_FILTER_MATRIX_SUPPORT
2 | #define _BAYES_FILTER_MATRIX_SUPPORT
3 |
4 | /*
5 | * Bayes++ the Bayesian Filtering Library
6 | * Copyright (c) 2002 Michael Stevens
7 | * See accompanying Bayes++.htm for terms and conditions of use.
8 | *
9 | * $Id$
10 | */
11 |
12 | /*
13 | * Matrix support functions for filter classes
14 | * Members of the Bayesian_filter_matrix namespace are used in the
15 | * interface of Bayesian_filter and for internal operations.
16 | * Be aware! These functions and their implementation are more likely to change
17 | * then those in Bayesian_filter.
18 | */
19 |
20 | /* Filter Matrix Namespace */
21 | namespace Bayesian_filter_matrix
22 | {
23 |
24 |
25 | /*
26 | * Assertion support
27 | */
28 | #ifndef NDEBUG
29 | void assert_isPSD (const SymMatrix &M);
30 | #else
31 | inline void assert_isPSD (const SymMatrix &M) {}
32 | #endif
33 |
34 | /*
35 | * Local support functions
36 | */
37 | bool isPSD (const SymMatrix &M);
38 | bool isSymmetric (const Matrix &M);
39 | void forceSymmetric (Matrix &M, bool bUpperToLower = false);
40 |
41 | /*
42 | * UdU' and LdL' and UU' Cholesky Factorisation and function
43 | * Very important to manipulate PD and PSD matrices
44 | *
45 | * Return values:
46 | * Many algorithms return a value_type which is a reciprocal condition number
47 | * These values are documented for each algorithm and are important way to
48 | * determine the validity of the results
49 | */
50 | Vec::value_type UdUrcond (const Vec& d);
51 | RowMatrix::value_type UdUrcond (const RowMatrix& UD);
52 | RowMatrix::value_type UdUrcond (const RowMatrix& UD, std::size_t n);
53 | UTriMatrix::value_type UCrcond (const UTriMatrix& UC);
54 | SymMatrix::value_type UdUdet (const SymMatrix& UD);
55 |
56 | // In-place factorisations
57 | RowMatrix::value_type UdUfactor_variant1 (RowMatrix& M, std::size_t n);
58 | RowMatrix::value_type UdUfactor_variant2 (RowMatrix& M, std::size_t n);
59 | inline RowMatrix::value_type UdUfactor (RowMatrix& M, std::size_t n)
60 | { return UdUfactor_variant2(M,n);
61 | }
62 | LTriMatrix::value_type LdLfactor (LTriMatrix& M, std::size_t n);
63 | UTriMatrix::value_type UCfactor (UTriMatrix& M, std::size_t n);
64 |
65 | // Copy factorisations
66 | RowMatrix::value_type UdUfactor (RowMatrix& UD, const SymMatrix& M);
67 | LTriMatrix::value_type LdLfactor (LTriMatrix& LD, const SymMatrix& M);
68 | UTriMatrix::value_type UCfactor (UTriMatrix& UC, const SymMatrix& M);
69 |
70 | // Factor manipulations
71 | bool UdUinverse (RowMatrix& UD);
72 | bool UTinverse (UTriMatrix& U);
73 | void UdUrecompose_transpose (RowMatrix& M);
74 | void UdUrecompose (RowMatrix& M);
75 | void UdUrecompose (SymMatrix& X, const RowMatrix& M);
76 | void UdUfromUCholesky (RowMatrix& U);
77 | void UdUseperate (RowMatrix& U, Vec& d, const RowMatrix& UD);
78 | void Lzero (RowMatrix& M);
79 | void Uzero (RowMatrix& M);
80 |
81 | /*
82 | * Functions using UdU factorisation:
83 | * inverse of Positive Definite matrix returning rcond
84 | */
85 | SymMatrix::value_type UdUinversePDignoreInfinity (SymMatrix& M);
86 | SymMatrix::value_type UdUinversePD (SymMatrix& M);
87 | SymMatrix::value_type UdUinversePD (SymMatrix& M, SymMatrix::value_type& detM);
88 | SymMatrix::value_type UdUinversePD (SymMatrix& MI, const SymMatrix& M);
89 | SymMatrix::value_type UdUinversePD (SymMatrix& MI, SymMatrix::value_type& detM, const SymMatrix& M);
90 |
91 |
92 | }//namespace
93 |
94 | #endif
95 |
--------------------------------------------------------------------------------
/bayestracking/include/bayes_tracking/BayesFilter/matSupSub.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Bayes++ the Bayesian Filtering Library
3 | * Copyright (c) 2002 Michael Stevens
4 | * See accompanying Bayes++.htm for terms and conditions of use.
5 | *
6 | * $Id$
7 | */
8 |
9 | /*
10 | * Matrix types for filter classes
11 | * Provides the predefined type 'Vec' and a variety of 'Matrix' types
12 | * Replace this header to substitute alternative matrix support
13 | *
14 | * Everything in namespace Bayes_filter_matrix is intended to support the matrix storage
15 | * and algebra requirements of the library. Therefore the interfaces and implementation is
16 | * not intended to be stable.
17 | */
18 |
19 | /*
20 | * Use the Boost uBLAS Basic Linear Algebra library
21 | * That is boost::numeric::ublas
22 | * Thanks to Joerg Walter and Mathias Koch for an excellent library!
23 | *
24 | * Gappy matrix support: The macros BAYES_FILTER_(SPARSE/COMPRESSED/COORDINATE) control experimental gappy matrix support
25 | * When enabled the default storage types are replaced with their sparse equivalents
26 | */
27 |
28 | #include
29 | #if !(BOOST_VERSION >= 103200)
30 | #error Requires Boost 1.32.0 or later
31 | #endif
32 |
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #if defined(BAYES_FILTER_MAPPED) || defined(BAYES_FILTER_COMPRESSED) || defined(BAYES_FILTER_COORDINATE)
41 | #include