Public Member Functions | Private Member Functions | Private Attributes
rail::spatial_temporal_learning::worldlib::remote::SpatialWorldClient Class Reference

The main MySQL client connection to the spatial world database. More...

#include <SpatialWorldClient.h>

Inheritance diagram for rail::spatial_temporal_learning::worldlib::remote::SpatialWorldClient:
Inheritance graph
[legend]

List of all members.

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_

Detailed Description

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.


Constructor & Destructor Documentation

Create a new SpatialWorldClient.

Creates a new Client by copying the values from the given SpatialWorldClient. A new connection is made if one exists.

Parameters:
clientThe 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.

Parameters:
hostThe host of the database.
portThe host port of the database.
userThe user of the database.
passwordThe password for the user of the database.
databaseThe database name.

Member Function Documentation

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.

Parameters:
itemThe Item observed in the world.
surfaceThe Surface the Item was observed on.
poseThe 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.

Parameters:
observationThe 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.

Parameters:
itemThe Item observed in the world.
surfaceThe Surface the Item was observed on.
poseThe Pose of the Item with respect to the Surface.

Definition at line 78 of file SpatialWorldClient.cpp.

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.

Returns:
True if a connection has been successfully made.

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.

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.

Parameters:
item_nameThe Item name to get the most frequent surface for (case is not important).
Returns:
The name of the Surface.

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.

Parameters:
item_nameThe Item to get the most frequent surface for.
Returns:
The name of the Surface.

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.

Parameters:
item_nameThe Item name to load observations for (case is not important).
surface_nameThe Surface name to load observations for (case is not important).
observationsThe 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.

Parameters:
item_nameThe Item name to load observations for (case is not important).
observationsThe 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.

Parameters:
surface_frame_idThe Surface name to load observations for (case **is** important).
observationsThe 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.

Parameters:
surface_nameThe Surface name to load observations for (case is not important).
observationsThe 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.

Parameters:
observationsThe array of observations to fill once loaded.
where_clauseThe SQL where clause of a select on the observations.
limitThe SQL return limit (defaults to 0 meaning unlimited).
order_byThe 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.

Parameters:
item_nameThe name of the Item (case is not important).
surface_nameThe name of the Surface (case is not important).
Returns:
The PersistenceModel loaded.

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.

Parameters:
itemThe Item.
surfaceThe Surface.
Returns:
The PersistenceModel loaded.

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.

Parameters:
namesThe 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.

Parameters:
item_nameThe name of the Item (case is not important).
item_nameThe name of the Surface (case is not important).
Returns:
Returns true if the Item still exists on a given Surface (i.e., it was not removed yet).

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.

Parameters:
itemThe Item.
surfaceThe Surface.
Returns:
Returns true if the Item has ever been observed on a given 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.

Parameters:
item_nameThe name of the Item (case is not important).
surface_nameThe name of the Surface (case is not important).
Returns:
Returns true if the Item has ever been observed on a given Surface.
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.

Parameters:
ItemThe Item.
surfaceThe Surface.
removed_observedThe 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.

Parameters:
item_nameThe name of the Item (case is not important).
surface_nameThe name of the Surface (case is not important).
removed_observedThe time the Item was observed removed (defaults to now).

Update the given observation.

Update the given observation in the database with its current fields. If no connection is made, no effect is made.

Parameters:
observationThe SpatialWorldObservation to update in the database.

Definition at line 188 of file SpatialWorldClient.cpp.


Member Data Documentation

Random number generator.

Definition at line 292 of file SpatialWorldClient.h.


The documentation for this class was generated from the following files:


worldlib
Author(s): Russell Toris
autogenerated on Fri Feb 12 2016 00:24:19