Wiselib
|
Basic neighborhood operations. More...
#include <localization_neighborhood.h>
Public Types | |
typedef OsModel_P | OsModel |
typedef node_id_t_P | node_id_t |
typedef NeighborInfo_P | NeighborInfo |
typedef NeighborInfo::NodeSet | NodeSet |
typedef NeighborInfo::DistanceMap | DistanceMap |
typedef NeighborInfoMap_P | NeighborInfoMap |
typedef NeighborInfoMap::iterator | NeighborhoodIterator |
typedef Arithmatic_P | Arithmatic |
Public Member Functions | |
NeighborInfoMap | get_neighborhood (void) |
construction / destruction | |
LocalizationNeighborhood () | |
~LocalizationNeighborhood () | |
owner info | |
void | set_source (node_id_t) |
Set the node this neighborhood belongs to. | |
node_id_t | source (void) |
add/update nodes to neighborhood | |
void | update_anchor (node_id_t, Vec< Arithmatic >, Arithmatic=UNKNOWN_DISTANCE) |
Update an anchor with given data. | |
void | update_neighbor (node_id_t, Arithmatic) |
Update a neighbor with given data. | |
void | update_nneighbor (node_id_t, node_id_t, Arithmatic) |
Update a neighbor of a neighbor with given data, so that the neighbor's neighborhood is filled/updated. | |
void | update_nneighbors (node_id_t, DistanceMap &) |
Update neighbors of a neighbor with given data, so that the neighbor's neighborhood is filled/updated. | |
reference nodes and sound-check | |
void | set_ref_node (node_id_t, node_id_t) |
Set a reference node of a neighbor. | |
void | update_ref_node (node_id_t, node_id_t) |
Set a reference node of a neighbor. | |
template<typename NodeList_P > | |
void | update_ref_nodes (node_id_t node, const NodeList_P &nl) |
Set reference nodes of a neighbor. | |
NodeSet | ref_nodes (void) |
void | add_sound (node_id_t) |
Add sound neighbor. | |
bool | is_sound (void) |
To decide, whether the neighborhood is sound or not, the number of intersection of reference and sound nodes is taken. | |
information about neighborhood | |
bool | has_anchor (node_id_t) |
bool | has_neighbor (node_id_t) |
bool | has_nneighbor (node_id_t, node_id_t) |
bool | has_valid_neighbor (node_id_t) |
This method checks, whether a neighbor exits or not, and is valid. | |
bool | has_valid_nneighbor (node_id_t, node_id_t) |
This method checks, whether a neighbor of neighbor exits or not, and is valid. | |
distance information | |
Arithmatic | neighbor_distance (node_id_t) |
Arithmatic | nneighbor_distance (node_id_t, node_id_t) |
Returns the distance between given neighbors. | |
DistanceMap | neighbor_distance_map (void) |
special information | |
int | valid_anchor_cnt (void) |
This method count the number of valid anchors. | |
int | anchor_cnt () |
This method count the number of anchors, whether they are valid or not. | |
int | confident_neighbor_cnt (void) |
This method count the number of confident neighbors. | |
Arithmatic | avg_neighbor_confidence (void) |
This method computes the average confidence of all confident neighbors. | |
work on the neighborhood | |
void | reassign_twins (Arithmatic) |
This method passes all pairs of neighbors and decide, whether they are twins or not on the basis of given measure, and set the second neighbor to a twin in positive cases. | |
iterators and general functions on neighboorhood | |
NeighborhoodIterator | begin_neighborhood (void) |
NeighborhoodIterator | end_neighborhood (void) |
size_t | size (void) |
NeighborhoodIterator | find (node_id_t node) |
Basic neighborhood operations.
This class combines neighbors to a neighborhood. In addition to basic methods such like adding an anchor or neighbor, there are operations on the neighborhood like counting anchors or something alike.
At first, there are the above mentioned basic methods like adding/updating anchors or neighbors, methods for searching certain anchors/neighbors in the neighborhood, same with distances, and simply methods which return iterators.
To add more information to a neighbor, you have to direct access the LocalizationNeighborInfo via find_w() and resulting iterator.
Second there is a chance to decide, whether the neighborhood is sound or not. This means, that the received information is unique. The neighborhood is sound, if there are at least three/four valid anchors, for which the data is received by different neighbors. Moreover, e.g. the LocalizationIterLaterationModule does this, you can add so called sound neighbors, so that the intersection of unique anchors and sound nodes has to be greater or equal than three/four.
The sound nodes are stored in separate set
At last there are operations on the neighborhood. On the one hand the varying like reassign_twins(), on the other hand just const ones like valid_anchor_cnt() or confident_neighbor_cnt().
typedef Arithmatic_P wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::Arithmatic |
typedef NeighborInfo::DistanceMap wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::DistanceMap |
typedef NeighborInfoMap::iterator wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::NeighborhoodIterator |
typedef NeighborInfo_P wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::NeighborInfo |
typedef NeighborInfoMap_P wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::NeighborInfoMap |
typedef node_id_t_P wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::node_id_t |
typedef NeighborInfo::NodeSet wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::NodeSet |
typedef OsModel_P wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::OsModel |
wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::LocalizationNeighborhood | ( | ) |
wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::~LocalizationNeighborhood | ( | ) |
void wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::add_sound | ( | node_id_t | node | ) |
Add sound neighbor.
The sound nodes are stored in separate set.
int wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::anchor_cnt | ( | ) |
This method count the number of anchors, whether they are valid or not.
LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::Arithmatic wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::avg_neighbor_confidence | ( | void | ) |
This method computes the average confidence of all confident neighbors.
Confident means, that there is a position and distance known, the neighbor is not a twin and has a confidence != 0.
NeighborhoodIterator wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::begin_neighborhood | ( | void | ) | [inline] |
int wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::confident_neighbor_cnt | ( | void | ) |
This method count the number of confident neighbors.
Confident means, that there is a position and distance known, the neighbor is not a twin and has a confidence != 0.
NeighborhoodIterator wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::end_neighborhood | ( | void | ) | [inline] |
NeighborhoodIterator wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::find | ( | node_id_t | node | ) | [inline] |
Node | neighbor to search for |
NeighborInfoMap wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::get_neighborhood | ( | void | ) | [inline] |
bool wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::has_anchor | ( | node_id_t | node | ) |
Node | anchor to search for |
bool wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::has_neighbor | ( | node_id_t | node | ) |
bool wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::has_nneighbor | ( | node_id_t | node, |
node_id_t | neighbor | ||
) |
Node | source neighbor |
Node | neighbor of neighbor to search for |
bool wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::has_valid_neighbor | ( | node_id_t | node | ) |
This method checks, whether a neighbor exits or not, and is valid.
Unlike LocalizationNeighborInfo::is_valid valid in this case just means, that there exists a distance to this neighbor.
Node | neighbor to search for |
bool wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::has_valid_nneighbor | ( | node_id_t | node, |
node_id_t | neighbor | ||
) |
This method checks, whether a neighbor of neighbor exits or not, and is valid.
Unlike LocalizationNeighborInfo::is_valid valid in this case just means, that there exists a distance of given neighbor to his neighbor.
Node | source neighbor |
Node | neighbor of neighbor to search for |
bool wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::is_sound | ( | void | ) |
To decide, whether the neighborhood is sound or not, the number of intersection of reference and sound nodes is taken.
If this number is greater or eual than three/four, neighborhood is sound.
true
, if neighborhood is sound. false
otherwise LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::Arithmatic wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::neighbor_distance | ( | node_id_t | node | ) |
Node | neighbor to search for |
LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::DistanceMap wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::neighbor_distance_map | ( | void | ) |
LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::Arithmatic wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::nneighbor_distance | ( | node_id_t | node, |
node_id_t | neighbor | ||
) |
Returns the distance between given neighbors.
If both distances are known, the mean of both is returned. If none is known, UNKNOWN_DISTANCE is returned.
Node | source neighbor |
Node | neighbor of neighbor to search for |
void wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::reassign_twins | ( | Arithmatic | twin_measure | ) |
This method passes all pairs of neighbors and decide, whether they are twins or not on the basis of given measure, and set the second neighbor to a twin in positive cases.
The result is, that there is only one neighbor on one position in the neighborhood, which is not a twin.
Arithmatic | Measure to decide, whether a neighbor is near enough to be a twin |
LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::NodeSet wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::ref_nodes | ( | void | ) |
void wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::set_ref_node | ( | node_id_t | node, |
node_id_t | ref | ||
) |
Set a reference node of a neighbor.
Old one(s) will be deleted and new one set.
Node | neighbor to update |
Node | reference node |
void wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::set_source | ( | node_id_t | source | ) |
Set the node this neighborhood belongs to.
Node | belonging Node |
size_t wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::size | ( | void | ) | [inline] |
node_id_t_P wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::source | ( | void | ) |
void wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::update_anchor | ( | node_id_t | node, |
Vec< Arithmatic > | pos, | ||
Arithmatic | distance = UNKNOWN_DISTANCE |
||
) |
Update an anchor with given data.
If the anchor does not exist, it is created and inserted in the neighborhood.
Node | anchor to insert/update |
Vec | position of anchor |
Arithmatic | distance to anchor. if distance is not known, the default value is localization::UNKNOWN_DISTANCE |
void wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::update_neighbor | ( | node_id_t | node, |
Arithmatic | distance | ||
) |
Update a neighbor with given data.
If the neighbor does not exist, it is created and inserted in the neighborhood.
Node | neighbor to insert/update |
Arithmatic | distance to neighbor |
void wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::update_nneighbor | ( | node_id_t | node, |
node_id_t | neighbor, | ||
Arithmatic | distance | ||
) |
Update a neighbor of a neighbor with given data, so that the neighbor's neighborhood is filled/updated.
If both Nodes exists in source neighborhood, the update happens in both ways.
Node | neighbor to update |
Node | neighbor of above mentioned neighbor |
Arithmatic | distance between Nodes |
void wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::update_nneighbors | ( | node_id_t | node, |
DistanceMap & | dm | ||
) |
Update neighbors of a neighbor with given data, so that the neighbor's neighborhood is filled/updated.
Node | neighbor to update |
localization::DistanceMap | neighbors of above mentioned neighbor |
void wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::update_ref_node | ( | node_id_t | node, |
node_id_t | ref | ||
) |
Set a reference node of a neighbor.
Old one(s) will be deleted and new one set.
Till now this method has the same functionality as set_ref_node(). Maybe later there will be a check, if the update results in a better sound-check following of this it is decided, whether the update happens or not.
Node | neighbor to update |
Node | reference node |
void wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::update_ref_nodes | ( | node_id_t | node, |
const NodeList_P & | nl | ||
) | [inline] |
Set reference nodes of a neighbor.
Old one(s) will be deleted and new one(s) set.
Node | neighbor to update |
Node | reference nodes |
int wiselib::LocalizationNeighborhood< OsModel_P, node_id_t_P, NeighborInfo_P, NeighborInfoMap_P, Arithmatic_P >::valid_anchor_cnt | ( | void | ) |
This method count the number of valid anchors.
Valid means, that there is a distance to this anchor known and it has a position.