The main MySQL client connection to the spatial world database. More...
#include <SpatialWorldClient.h>
Public Member Functions | |
void | addObservation (const world::Item &item, const world::Surface &surface, const geometry::Pose &pose) const |
Add a new Observation to the spatial world database. | |
void | addObservation (const world::Observation &observation) const |
Add a new Observation to the spatial world database. | |
void | addObservations (const std::vector< world::Observation > &observations) const |
Add several observations to the spatial world database. | |
void | clearAllEntities () const |
Clear all entries in the spatial world database. | |
virtual bool | connect () |
Create a connection to the spatial world database. | |
std::string | getMostFrequentSurfaceName (const std::string &item_name) const |
Get the most frequent surface name for the given Item. | |
std::string | getMostFrequentSurfaceName (const world::Item &item) const |
Get the most frequent surface name for the given Item. | |
void | getObservationsByItemAndSurfaceName (const std::string &item_name, const std::string &surface_name, std::vector< SpatialWorldObservation > &observations) const |
Get all observations for a given Item and Surface name. | |
void | getObservationsByItemName (const std::string &item_name, std::vector< SpatialWorldObservation > &observations) const |
Get all observations for a given Item name. | |
void | getObservationsBySurfaceFrameID (const std::string &surface_frame_id, std::vector< SpatialWorldObservation > &observations) const |
Get all observations for a given Surface frame ID. | |
void | getObservationsBySurfaceName (const std::string &surface_name, std::vector< SpatialWorldObservation > &observations) const |
Get all observations for a given Surface name. | |
model::PersistenceModel | getPersistenceModel (const std::string &item_name, const std::string &surface_name) const |
Get the PersistenceModel associated with the Item on a Surface. | |
model::PersistenceModel | getPersistenceModel (const world::Item &item, const world::Surface &surface) const |
Get the PersistenceModel associated with the Item on a Surface. | |
void | getUniqueSurfaceNames (std::vector< std::string > &names) const |
Get a list of unique surface names. | |
bool | itemExistsOnSurface (const std::string &item_name, const std::string &surface_name) const |
Check if an Item still exists on a given Surface. | |
bool | itemObservedOnSurface (const world::Item &item, const world::Surface &surface) const |
Check if an Item has ever been seen on a given Surface. | |
bool | itemObservedOnSurface (const std::string &item_name, const std::string &surface_name) const |
Check if an Item has ever been seen on a given Surface. | |
void | markObservationsAsRemoved (const world::Item &item, const world::Surface &surface, const ros::Time &removed_observed=ros::Time::now()) |
Mark the given Item on the given Surface as being removed. | |
void | markObservationsAsRemoved (const std::string &item_name, const std::string &surface_name, const ros::Time &removed_observed=ros::Time::now()) |
Mark the given Item on the given Surface as being removed. | |
SpatialWorldClient (const SpatialWorldClient &client) | |
Create a new SpatialWorldClient. | |
SpatialWorldClient (const std::string &host, const uint16_t port, const std::string &user, const std::string &password, const std::string &database) | |
Create a new SpatialWorldClient. | |
void | updateObservation (const SpatialWorldObservation &observation) const |
Update the given observation. | |
Private Member Functions | |
void | createTable () |
Create the spatial world table (sws). | |
void | getObservationsHelper (std::vector< SpatialWorldObservation > &observations, const std::string &where_clause, const uint32_t limit=0, const std::string &order_by="`time` ASC") const |
Get all observations based on a given SQL where clause. | |
Private Attributes | |
boost::mt19937 | random_ |
The main MySQL client connection to the spatial world database.
The spatial world SQL client can communicate with a MySQL database containing the spatial world database.
Definition at line 41 of file SpatialWorldClient.h.
SpatialWorldClient::SpatialWorldClient | ( | const SpatialWorldClient & | client | ) |
Create a new SpatialWorldClient.
Creates a new Client by copying the values from the given SpatialWorldClient. A new connection is made if one exists.
client | The SpatialWorldClient to copy. |
Definition at line 26 of file SpatialWorldClient.cpp.
rail::spatial_temporal_learning::worldlib::remote::SpatialWorldClient::SpatialWorldClient | ( | const std::string & | host, |
const uint16_t | port, | ||
const std::string & | user, | ||
const std::string & | password, | ||
const std::string & | database | ||
) |
Create a new SpatialWorldClient.
Creates a new SpatialWorldClient with the given connection information. A connection is not made by default.
host | The host of the database. |
port | The host port of the database. |
user | The user of the database. |
password | The password for the user of the database. |
database | The database name. |
void SpatialWorldClient::addObservation | ( | const world::Item & | item, |
const world::Surface & | surface, | ||
const geometry::Pose & | pose | ||
) | const |
Add a new Observation to the spatial world database.
Attempts to add an Observation to the spatial world database. If no connection is made, no effect is made. This will create default timestamps for all values.
item | The Item observed in the world. |
surface | The Surface the Item was observed on. |
pose | The Pose of the Item with respect to the Surface. |
Definition at line 87 of file SpatialWorldClient.cpp.
void SpatialWorldClient::addObservation | ( | const world::Observation & | observation | ) | const |
Add a new Observation to the spatial world database.
Attempts to add an Observation to the spatial world database. If no connection is made, no effect is made.
observation | The Observation observed in the world. |
Definition at line 94 of file SpatialWorldClient.cpp.
void SpatialWorldClient::addObservations | ( | const std::vector< world::Observation > & | observations | ) | const |
Add several observations to the spatial world database.
Attempts to add observations to the spatial world database. If no connection is made, no effect is made.
item | The Item observed in the world. |
surface | The Surface the Item was observed on. |
pose | The Pose of the Item with respect to the Surface. |
Definition at line 78 of file SpatialWorldClient.cpp.
void SpatialWorldClient::clearAllEntities | ( | ) | const |
Clear all entries in the spatial world database.
Attempts to clear all entries in the spatial world database. If no connection is made, no effect is made.
Definition at line 68 of file SpatialWorldClient.cpp.
bool SpatialWorldClient::connect | ( | ) | [virtual] |
Create a connection to the spatial world database.
Attempts to create a connection to the spatial world database. Tables are created if they do not exist yet. A flag is returned to indicate the success.
Reimplemented from rail::spatial_temporal_learning::worldlib::remote::SqlClient.
Definition at line 35 of file SpatialWorldClient.cpp.
void SpatialWorldClient::createTable | ( | ) | [private] |
Create the spatial world table (sws).
Attempts to create the spatial world table (sws). If no connection is made, no effect is made.
Definition at line 43 of file SpatialWorldClient.cpp.
std::string rail::spatial_temporal_learning::worldlib::remote::SpatialWorldClient::getMostFrequentSurfaceName | ( | const std::string & | item_name | ) | const |
Get the most frequent surface name for the given Item.
Get the name of the surface the the given item has been seen on the most.
item_name | The Item name to get the most frequent surface for (case is not important). |
string SpatialWorldClient::getMostFrequentSurfaceName | ( | const world::Item & | item | ) | const |
Get the most frequent surface name for the given Item.
Get the name of the surface the the given item has been seen on the most.
item_name | The Item to get the most frequent surface for. |
Definition at line 160 of file SpatialWorldClient.cpp.
void SpatialWorldClient::getObservationsByItemAndSurfaceName | ( | const std::string & | item_name, |
const std::string & | surface_name, | ||
std::vector< SpatialWorldObservation > & | observations | ||
) | const |
Get all observations for a given Item and Surface name.
Load all observations for a given Item and Surface name and store them in the given vector. If no connection is made, no effect is made.
item_name | The Item name to load observations for (case is not important). |
surface_name | The Surface name to load observations for (case is not important). |
observations | The array of observations to fill once loaded. |
Definition at line 143 of file SpatialWorldClient.cpp.
void SpatialWorldClient::getObservationsByItemName | ( | const std::string & | item_name, |
std::vector< SpatialWorldObservation > & | observations | ||
) | const |
Get all observations for a given Item name.
Load all observations for a given Item name and store them in the given vector. If no connection is made, no effect is made.
item_name | The Item name to load observations for (case is not important). |
observations | The array of observations to fill once loaded. |
Definition at line 127 of file SpatialWorldClient.cpp.
void SpatialWorldClient::getObservationsBySurfaceFrameID | ( | const std::string & | surface_frame_id, |
std::vector< SpatialWorldObservation > & | observations | ||
) | const |
Get all observations for a given Surface frame ID.
Load all observations for a given Surface frame ID and store them in the given vector. Note that this function is case sensitive. If no connection is made, no effect is made.
surface_frame_id | The Surface name to load observations for (case **is** important). |
observations | The array of observations to fill once loaded. |
Definition at line 152 of file SpatialWorldClient.cpp.
void SpatialWorldClient::getObservationsBySurfaceName | ( | const std::string & | surface_name, |
std::vector< SpatialWorldObservation > & | observations | ||
) | const |
Get all observations for a given Surface name.
Load all observations for a given Surface name and store them in the given vector. If no connection is made, no effect is made.
surface_name | The Surface name to load observations for (case is not important). |
observations | The array of observations to fill once loaded. |
Definition at line 135 of file SpatialWorldClient.cpp.
void SpatialWorldClient::getObservationsHelper | ( | std::vector< SpatialWorldObservation > & | observations, |
const std::string & | where_clause, | ||
const uint32_t | limit = 0 , |
||
const std::string & | order_by = "`time` ASC" |
||
) | const [private] |
Get all observations based on a given SQL where clause.
Load all observations for a given where clause and store them in the given vector. If no connection is made, no effect is made. This is meant for internal use only.
observations | The array of observations to fill once loaded. |
where_clause | The SQL where clause of a select on the observations. |
limit | The SQL return limit (defaults to 0 meaning unlimited). |
order_by | The SQL ordering constraint (defaults to ascending `time` field; i.e., oldest first). |
Definition at line 359 of file SpatialWorldClient.cpp.
model::PersistenceModel rail::spatial_temporal_learning::worldlib::remote::SpatialWorldClient::getPersistenceModel | ( | const std::string & | item_name, |
const std::string & | surface_name | ||
) | const |
Get the PersistenceModel associated with the Item on a Surface.
Get the PersistenceModel associated with the Item on a Surface. This will calculate parameters based on data from the spatial world database.
item_name | The name of the Item (case is not important). |
surface_name | The name of the Surface (case is not important). |
PersistenceModel SpatialWorldClient::getPersistenceModel | ( | const world::Item & | item, |
const world::Surface & | surface | ||
) | const |
Get the PersistenceModel associated with the Item on a Surface.
Get the PersistenceModel associated with the Item on a Surface. This will calculate parameters based on data from the spatial world database.
item | The Item. |
surface | The Surface. |
Definition at line 335 of file SpatialWorldClient.cpp.
void SpatialWorldClient::getUniqueSurfaceNames | ( | std::vector< std::string > & | names | ) | const |
Get a list of unique surface names.
Get a unique list of surface names and store them in the given vector.
names | The vector to store the name list in. |
Definition at line 312 of file SpatialWorldClient.cpp.
bool SpatialWorldClient::itemExistsOnSurface | ( | const std::string & | item_name, |
const std::string & | surface_name | ||
) | const |
Check if an Item still exists on a given Surface.
Check if the Item still exists on a given Surface (i.e., it was not removed yet). If no connection is made false is returned.
item_name | The name of the Item (case is not important). |
item_name | The name of the Surface (case is not important). |
Definition at line 209 of file SpatialWorldClient.cpp.
bool SpatialWorldClient::itemObservedOnSurface | ( | const world::Item & | item, |
const world::Surface & | surface | ||
) | const |
Check if an Item has ever been seen on a given Surface.
Check if an Item has ever been seen on a given Surface. If no connection is made false is returned.
item | The Item. |
surface | The Surface. |
Definition at line 230 of file SpatialWorldClient.cpp.
bool rail::spatial_temporal_learning::worldlib::remote::SpatialWorldClient::itemObservedOnSurface | ( | const std::string & | item_name, |
const std::string & | surface_name | ||
) | const |
Check if an Item has ever been seen on a given Surface.
Check if an Item has ever been seen on a given Surface. If no connection is made false is returned.
item_name | The name of the Item (case is not important). |
surface_name | The name of the Surface (case is not important). |
void SpatialWorldClient::markObservationsAsRemoved | ( | const world::Item & | item, |
const world::Surface & | surface, | ||
const ros::Time & | removed_observed = ros::Time::now() |
||
) |
Mark the given Item on the given Surface as being removed.
Mark the given Item on the given Surface as being removed. This will set the observed removal time for all current observations to now and set an estimated time for removal for the longest observation. If no connection is made, or if the Item was not currently on the Surface, no effect is made.
Item | The Item. |
surface | The Surface. |
removed_observed | The time the Item was observed removed (defaults to now). |
Definition at line 255 of file SpatialWorldClient.cpp.
void rail::spatial_temporal_learning::worldlib::remote::SpatialWorldClient::markObservationsAsRemoved | ( | const std::string & | item_name, |
const std::string & | surface_name, | ||
const ros::Time & | removed_observed = ros::Time::now() |
||
) |
Mark the given Item on the given Surface as being removed.
Mark the given Item on the given Surface as being removed. This will set the observed removal time for all current observations to now and set an estimated time for removal for the longest observation. If no connection is made, or if the Item was not currently on the Surface, no effect is made.
item_name | The name of the Item (case is not important). |
surface_name | The name of the Surface (case is not important). |
removed_observed | The time the Item was observed removed (defaults to now). |
void SpatialWorldClient::updateObservation | ( | const SpatialWorldObservation & | observation | ) | const |
Update the given observation.
Update the given observation in the database with its current fields. If no connection is made, no effect is made.
observation | The SpatialWorldObservation to update in the database. |
Definition at line 188 of file SpatialWorldClient.cpp.
boost::mt19937 rail::spatial_temporal_learning::worldlib::remote::SpatialWorldClient::random_ [private] |
Random number generator.
Definition at line 292 of file SpatialWorldClient.h.