This package provides support for localising agents in a topological map, based on topological_navigation
.
It uses particle filter for performing state estimation. This code is based on https://ras.papercept.net/proceedings/IROS20/0879.pdf.
The code exploits the fact that generally a topological map nodes are sparsely connected - particles can only jump from a node to another if they are connected through an edge - to perform the computation efficiently.
This node assumes that topological_navigation
is running, in particular check that
- the topological map is loaded in the DB
- the
topological_map_manager
is running.
Launch localisation node with:
roslaunch bayesian_topological_localisation topological_localisation.launch
The node provide the service /bayesian_topological_localisation/localise_agent
To register a new agent.
The srv is:
string name # identifier of the agent to track
uint64 n_particles # number of particle to use
bool do_prediction # if to perform prediction steps when observations are not available
float64 prediction_rate # rate at which predictions are performed
---
bool success # true if the registration of new agent localisation was successful
Call the service /bayesian_topological_localisation/stop_localise
, with srv:
string name # identifier for the agent
---
bool success # true if the localisation is stopped
The localisation node needs observations in order to localise and agent - e.g. robot_1
- on the map.
There are two ways an observation can be provided listed below. Each type of observation can be provided through a topic or by calling a service. If calling the service you will get the localisation result straight away in your service response. Each time you send an observation you have to set the parameter identifying
(False
by default) which indicates whether the observation uniquely identifies the target (e.g. GPS identifier) or not (e.g. LIDAR).
- topic modality: To be published to topic
/robot_1/pose_obs
(msg typegeometry_msgs/PoseWithCovarianceStamped
). The message has to provide a pose (x, y) and a variance for the pose as a covariance matrix:[var_x, 0 , 0, 0, 0, 0, 0 , var_y, 0, 0, 0, 0, 0 , 0 , 0, 0, 0, 0, 0 , 0 , 0, 0, 0, 0, 0 , 0 , 0, 0, 0, 0, 0 , 0 , 0, 0, 0, 0]
- service modality: Call
/robot_1/update_pose_obs
(srv typetopological_navigation_msgs/UpdatePoseObservation
), the request parameterpose
is ageometry_msgs/PoseWithCovarianceStamped
and has to be filled as for the topic modality.
-
topic modality: To be published to topic
/robot_1/likelihood_obs
(msg typetopological_navigation_msgs/DistributionStamped
). The message has to contain a list of nodes names with a list of values for the likelihood, one for each node. The message does not need to contain all the nodes in the map, the one that have a likelihood non-zero are sufficient. -
service modality: Call
/robot_1/update_likelihood_obs
(srv typetopological_navigation_msgs/UpdateLikelihoodObservation
), the request parameterlikelihood
is atopological_navigation_msgs/DistributionStamped
and has to be filled as for the topic modality.
The node position for an agent - e.g. robot_1
- that is being localised is published latch to topic /robot_1/estimated_node
. The package also provides the probability distribution of the agent location published latch to topic /robot_1/current_prob_dist
as a list of nodes and with their corresponding probability.
In order to visualize the localisation result - for agent robot_1
for example - on rviz add:
- a
Marker
attached to topic/robot_1/estimated_node_viz
- a
MarkerArray
attached to topic/robot_1/particles_viz
The node provides some services to perform inference into the future, the services work on a copy of the particle filter they therefore do not affect to current state of the localisation.
Call /robot_1/predict_stateless
(srv type topological_navigation_msgs/Predict
) specifying
secs_from_now
: how many seconds into the future you want to predictprediction_rate
: the rate of prediction, ifsecs_from_now = 10
andprediction_rate = 1
the node will perform 10 prediction steps to give the final predictionreturn_history
: (defaultFalse
) ifTrue
returns the prediction result at all prediction steps, rather than just the final prediction atsecs_from_now
.
Call /robot_1/update_stateless
(srv type topological_navigation_msgs/UpdatePriorLikelihoodObservation
) specifying
prior
: The prior distribution of nodeslikelihood
: the likelihood ditribution. Returns the posterior distribution computed from prior and likelihood and the estimated node.
The PF implements two mechanisms for preventing the particles distribution to diverge.
- monitoring entropy: at each step, the entropy of the distribution over the topological map is computed, whenever this falls below a threshold the particles do not jump to node that are not connected anymore. The threshould (default value: 0.6) can be set with the service
/bayesian_topological_localisation/set_entropy_lower_bound
. - monitoring observation distance: every time the PF receives a new observation we compute the Jensen-Shannon Distance between the current distribution and the normalised observation. If this is higher than a threshold and the observation is identifying (see "Sending observations" section above) then 1) we re-initialise the particles with the distribution of the observation; and 2) we restart jumping to non connected nodes (if the entropy monitor was triggered before). The threshould (default value: 0.975) can be set with the service
/bayesian_topological_localisation/set_JSD_upper_bound
.