Difference between revisions of "HamsterAPICPP"

From cogniteam
Jump to: navigation, search
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:HamsterAPI]]
 
[[Category:HamsterAPI]]
  
HamsterAPI Class Documentation
+
=== HamsterAPI Class Documentation ===
  
 
Hamster class File Description
 
Hamster class File Description
Line 9: Line 9:
  
  
 +
== Constructor: Hamster(const AgentID & agent_id, HamsterClientParameters params = HamsterClientParameters()) ==
  
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
!Method Name !! Constructor: Hamster(const AgentID & agent_id, HamsterClientParameters params = HamsterClientParameters())!
+
!Method Name !! Constructor: Hamster(const AgentID & agent_id, HamsterClientParameters params = HamsterClientParameters())
 
|-
 
|-
 
| Method Description ||
 
| Method Description ||
Line 18: Line 19:
 
* base_address:
 
* base_address:
 
* The network base address to work with
 
* The network base address to work with
  * if the address is 127.0.0 then the connection will always go to loopback
+
  - if the address is 127.0.0 then the connection will always go to loopback
  * Otherwise it will go to base_adress.agent_id
+
  - Otherwise it will go to base_adress.agent_id
  * For example : base_address = 10.0.2 agent_id = 1 so it will connect to 10.0.2.1:port
+
  - For example : base_address = 10.0.2 agent_id = 1 so it will connect to 10.0.2.1:port
 
* port - The port to connect on
 
* port - The port to connect on
 
|-
 
|-
Line 26: Line 27:
 
|}
 
|}
  
 
+
== Image getCameraImage() const ==
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 42: Line 43:
 
|}
 
|}
  
 +
== Pose getPose()const ==
 +
{| class="wikitable"
 +
|-
 +
!Method Name !! Pose getPose()const
 +
|-
 +
| Method Description ||
 +
* Retrieves the global pose of the hamster.
 +
* The global pose is associated with the SLAM part of the hamster.
 +
* Buffer Size - 1.
 +
|-
 +
| Return values ||
 +
* Global Pose
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Empty Buffer.
 +
* Connection Issue.
 +
|}
  
 +
== IMU getIMU()const ==
 +
{| class="wikitable"
 +
|-
 +
! Method Name !! IMU getIMU()const
 +
|-
 +
| Method Description ||
 +
* Retrieves the IMU information from the hamster if an IMU exists.
 +
* Buffer Size - 1.
 +
|-
 +
| Return values || IMU
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Empty Buffer.
 +
* Connection Issue.
 +
|}
  
 +
== GPS getGPS()const ==
 +
{| class="wikitable"
 +
|-
 +
! Method Name !! GPS getGPS()const
 +
|-
 +
| Method Description ||
 +
* Retrieves the GPS information from the hamster is a GPS exists.
 +
* Buffer Size - 1.
 +
|-
 +
| Return values ||GPS
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Empty Buffer.
 +
* Connection Issue.
 +
|}
  
+
== LidarScan getLidarScan()const ==
 
+
{| class="wikitable"
 
+
|-
Method Name
+
!Method Name!! LidarScan getLidarScan()const
Pose getPose()const
+
|-
 
+
| Method Description ||
Method Description
 
Retrieves the global pose of the hamster.
 
The global pose is associated with the SLAM part of the hamster.
 
Buffer Size - 1.
 
 
 
Return values
 
Global Pose
 
Possible Errors (HamsterError)
 
-Empty Buffer.
 
-Connection Issue.
 
 
 
 
 
 
 
Method Name
 
IMU getIMU()const
 
 
 
Method Description
 
Retrieves the IMU information from the hamster if an IMU exists.
 
Buffer Size - 1.
 
 
 
 
 
Return values
 
IMU
 
 
 
Possible Errors (HamsterError)
 
-Empty Buffer.
 
-Connection Issue.
 
 
 
 
 
Method Name
 
GPS getGPS()const
 
 
 
Method Description
 
Retrieves the GPS information from the hamster is a GPS exists.
 
Buffer Size - 1.
 
 
 
Return values
 
GPS
 
 
 
Possible Errors (HamsterError)
 
-Empty Buffer.
 
-Connection Issue.
 
 
 
 
 
Method Name
 
LidarScan getLidarScan()const
 
 
 
Method Description
 
 
Retrieves the 360 degree lidar scan from the hamster.
 
Retrieves the 360 degree lidar scan from the hamster.
 
Buffer Size - 1.
 
Buffer Size - 1.
 
+
|-
Return values
+
| Return values ||
 
LidarScan
 
LidarScan
 +
|-
 +
|  Possible Errors (HamsterError)||
 +
*Empty Buffer.
 +
*Connection Issue.
 +
|}
  
Possible Errors (HamsterError)
+
== ColoredScan getColoredScan()const ==
-Empty Buffer.
+
{| class="wikitable"
-Connection Issue.
+
|-
 
+
!Method Name !!
 
 
 
 
Method Name
 
 
ColoredScan getColoredScan()const
 
ColoredScan getColoredScan()const
 
+
|-
Method Description
+
| Method Description ||
 
Retrieves a ColoredScan. ColoredScan is a combination of the hamster lidar and camera synchronized.
 
Retrieves a ColoredScan. ColoredScan is a combination of the hamster lidar and camera synchronized.
 
It contains the raw lidar scan and the associated pixels RGB color of the image.
 
It contains the raw lidar scan and the associated pixels RGB color of the image.
 
Buffer Size - 1
 
Buffer Size - 1
 
+
|-
Return values
+
| Return values ||
 
ColoredScan
 
ColoredScan
 
+
|-
Possible Errors (HamsterError)
+
| Possible Errors (HamsterError) ||
-Empty Buffer.
+
* Empty Buffer.
-Connection Issue.
+
* Connection Issue.
 
+
|}
  
  
 
 
  
 
+
== Speed getSpeed()const ==
Method Name
+
{| class="wikitable"
Speed getSpeed()const
+
|-
 
+
!Method Name !! Speed getSpeed()const
Method Description
+
|-
 +
| Method Description ||
 
Retrieves the current speed of the hamster.
 
Retrieves the current speed of the hamster.
 
The is usually the speed given by the latest speed command or from the wandering / navigation.
 
The is usually the speed given by the latest speed command or from the wandering / navigation.
 
Buffer Size - 1.
 
Buffer Size - 1.
 
+
|-
Return values
+
| Return values ||
 
Speed
 
Speed
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Empty Buffer.
 +
* Connection Issue.
 +
|}
  
Possible Errors (HamsterError)
 
-Empty Buffer.
 
-Connection Issue.
 
  
 
+
== HamsterMode getHamsterMode()const ==
 
+
{| class="wikitable"
 
+
|-
Method Name
+
!Method Name !!
 
HamsterMode getHamsterMode()const
 
HamsterMode getHamsterMode()const
 
+
|-
Method Description
+
| Method Description ||
 
Retrieves the current mode of the hamster.
 
Retrieves the current mode of the hamster.
 
The available modes are:
 
The available modes are:
- Localization.
+
* Localization.
- Mapping.
+
* Mapping.
 
Buffer Size - 1.
 
Buffer Size - 1.
 
+
|-
Return values
+
Return values ||
 
HamsterMode
 
HamsterMode
 
+
|-
Possible Errors (HamsterError)
+
Possible Errors (HamsterError) ||
-Empty Buffer.
+
* Empty Buffer.
-Connection Issue.
+
* Connection Issue.
 
+
|}
  
  
 
 
  
 
+
== OccupancyGrid getSLAMMap()const ==
Method Name
+
{| class="wikitable"
 +
|-
 +
!Method Name !!
 
OccupancyGrid getSLAMMap()const
 
OccupancyGrid getSLAMMap()const
 
+
|-
Method Description
+
| Method Description ||
 
Retrieves the current SLAM map that was loaded or created by the hamster as an occupancy grid.
 
Retrieves the current SLAM map that was loaded or created by the hamster as an occupancy grid.
 
Buffer Size - 1.
 
Buffer Size - 1.
 
+
|-
Return values
+
| Return values ||
 
OccupancyGrid
 
OccupancyGrid
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Empty Buffer.
 +
* Connection Issue.
 +
|}
  
Possible Errors (HamsterError)
 
-Empty Buffer.
 
-Connection Issue.
 
  
 
+
== HamsterConnections getConnectedHamsters()const ==
 
+
{| class="wikitable"
 
+
|-
Method Name
+
!Method Name !!
 
HamsterConnections getConnectedHamsters()const
 
HamsterConnections getConnectedHamsters()const
 
+
|-
Method Description
+
| Method Description ||
 
Retrieves the currently living hamsters on the network.
 
Retrieves the currently living hamsters on the network.
 
Meaning that for example there are 3 hamsters on the same network
 
Meaning that for example there are 3 hamsters on the same network
Line 197: Line 206:
 
If the current hamster got an heartbeat from all the others, there will be 3 connections on the list.
 
If the current hamster got an heartbeat from all the others, there will be 3 connections on the list.
 
Buffer Size - 1.
 
Buffer Size - 1.
 
+
|-
Return values
+
| Return values ||
 
HamsterConnections
 
HamsterConnections
 
+
|-
Possible Errors (HamsterError)
+
| Possible Errors (HamsterError) ||
-Empty Buffer.
+
* Empty Buffer.
-Connection Issue.
+
* Connection Issue.
 
+
|}
  
 
 
  
 
+
== BatteryState getBatteryState()const ==
Method Name
+
{| class="wikitable"
 +
|-
 +
!Method Name !!
 
BatteryState getBatteryState()const
 
BatteryState getBatteryState()const
 
+
|-
Method Description
+
| Method Description ||
 
Retrieves the current battery state of the hamster.
 
Retrieves the current battery state of the hamster.
 
Buffer Size - 1.
 
Buffer Size - 1.
 
+
|-
Return values
+
| Return values ||
 
BatteryState
 
BatteryState
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Empty Buffer.
 +
* Connection Issue.
 +
|}
  
Possible Errors (HamsterError)
 
-Empty Buffer.
 
-Connection Issue.
 
  
  
 
+
== NetworkState getNetworkState()const ==
 
+
{| class="wikitable"
 
+
|-
Method Name
+
!Method Name !!
 
NetworkState getNetworkState()const
 
NetworkState getNetworkState()const
 
+
|-
Method Description
+
| Method Description ||
 
Retrieves the current network state of the hamster with the network.
 
Retrieves the current network state of the hamster with the network.
 
Buffer Size - 1.
 
Buffer Size - 1.
 
+
|-
Return values
+
| Return values ||
 
NetworkState
 
NetworkState
 
+
|-
Possible Errors (HamsterError)
+
| Possible Errors (HamsterError) ||
-Empty Buffer.
+
* Empty Buffer.
-Connection Issue.
+
* Connection Issue.
 
+
|}
  
  
 
 
  
 
+
== NavigationState getNavigationState()const ==
Method Name
+
{| class="wikitable"
 +
|-
 +
!Method Name !!
 
NavigationState getNavigationState()const
 
NavigationState getNavigationState()const
 
+
|-
Method Description
+
| Method Description ||
 
Retrieves the navigation state of the hamster. The navigation state depends whether there was a goal request or not. There are four types of states:
 
Retrieves the navigation state of the hamster. The navigation state depends whether there was a goal request or not. There are four types of states:
- Offline.
+
* Offline.
- In Progress.
+
* In Progress.
- Reached Goal.
+
* Reached Goal.
- Failure.
+
* Failure.
 
Buffer Size - 1.
 
Buffer Size - 1.
 
+
|-
Return values
+
| Return values ||
 
NavigationState
 
NavigationState
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Empty Buffer.
 +
* Connection Issue.
 +
|}
  
Possible Errors (HamsterError)
 
- Empty Buffer.
 
- Connection Issue.
 
  
 
+
== void sendSpeed(float velocity, float wheels_angle)==
 
+
{| class="wikitable"
 
+
|-
Method Name
+
!Method Name !!
 
void sendSpeed(float velocity, float wheels_angle)
 
void sendSpeed(float velocity, float wheels_angle)
 
+
|-
Method Description
+
| Method Description ||
Sends a speed request to the hamster.
+
* Sends a speed request to the hamster.
If there is an active goal, the speed request will be ignored and an HamsterError will be thrown.
+
* If there is an active goal, the speed request will be ignored and an HamsterError will be thrown.
+
* This method is based on ackermann speed.
This method is based on ackermann speed.
+
|-
 
+
| Return values ||
 
+
|-
Return values
+
| Possible Errors (HamsterError) ||
Possible Errors (HamsterError)
+
* Connection Issue.
- Connection Issue.
+
* Running Goal.
- Running Goal.
+
|}
 
 
  
 
 
  
 
+
== void sendOccupancyGrid(const OccupancyGrid & grid) ==
Method Name
+
{| class="wikitable"
 +
|-
 +
!Method Name !!
 
void sendOccupancyGrid(const OccupancyGrid & grid)
 
void sendOccupancyGrid(const OccupancyGrid & grid)
 
+
|-
Method Description
+
| Method Description ||
 
Sends an Occupancy Grid to the server to be published.
 
Sends an Occupancy Grid to the server to be published.
 
Can be viewed via RViz.
 
Can be viewed via RViz.
 +
|-
 +
| Return values ||
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Connection issue
 +
|}
  
Return values
 
Possible Errors (HamsterError)
 
-Connection issue
 
  
  
 
+
== void switchMode(const HamsterMode & mode) ==
 
+
{| class="wikitable"
 
+
|-
Method Name
+
!Method Name !!
 
void switchMode(const HamsterMode & mode)
 
void switchMode(const HamsterMode & mode)
 
+
|-
Method Description
+
| Method Description ||
 
Switches hamster mode to one of the following:
 
Switches hamster mode to one of the following:
- Mapping.
+
* Mapping.
- Localization.
+
* Localization.
 +
|-
 +
| Return values ||
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Connection Issue.
 +
|}
  
Return values
+
== void navigateTo(const Goal & goal) ==
Possible Errors (HamsterError)
+
{| class="wikitable"
- Connection Issue.
+
|-
 +
!Method Name !! void navigateTo(const Goal & goal)
 +
|-
 +
| Method Description ||
 +
* Navigates to a given goal.
 +
* The goal can be either local goal or global goal.
 +
|-
 +
| Return values ||
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Connection Issue.
 +
|}
  
  
 
+
== void navigateTo(float distance, float angle) ==
Method Name
+
{| class="wikitable"
+
|-
void navigateTo(const Goal & goal)
+
!Method Name !! void navigateTo(float distance, float angle)
Method Description
+
|-
Navigates to a given goal.
+
| Method Description ||
The goal can be either local goal or global goal.
 
 
 
Return values
 
Possible Errors (HamsterError)
 
- Connection Issue.
 
 
 
 
 
 
 
 
 
 
 
 
Method Name
 
void navigateTo(float distance, float angle)
 
 
 
Method Description
 
 
Navigates to a given distance and angle. This is simillar to giving a local goal with distance and angle calculated to X and Y.
 
Navigates to a given distance and angle. This is simillar to giving a local goal with distance and angle calculated to X and Y.
 +
|-
 +
| Return values ||
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Connection Issue.
 +
|}
  
Return values
+
== void setInitialPose(const Pose & pose) ==
Possible Errors (HamsterError)
+
{| class="wikitable"
- Connection Issue.
+
|-
 
+
!Method Name !!
 
 
 
 
Method Name
 
 
void setInitialPose(const Pose & pose)
 
void setInitialPose(const Pose & pose)
 +
|-
 +
|Method Description ||
 +
* Sets the initial position of the agent on the global map.
 +
* This is useful for a starting 0,0 position for mapping or if an agent needs to reposition to a starting position.
 +
|-
 +
|Return values ||
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Connection Issue.
 +
|}
  
Method Description
 
Sets the initial position of the agent on the global map.
 
This is useful for a starting 0,0 position for mapping or if an agent needs to reposition to a starting position.
 
  
Return values
+
== void stopNavigation() ==
Possible Errors (HamsterError)
+
{| class="wikitable"
- Connection Issue.
+
|-
 +
!Method Name !!  void stopNavigation()
 +
|-
 +
| Method Description || Stops the navigation if there is an active goal.
 +
|-
 +
|Return values ||
 +
|-
 +
| Possible Errors (HamsterError) ||
 +
* Connection Issue.
 +
|}
  
  
Method Name
+
== AgentID getAgentID()const ==
void stopNavigation()
+
{| class="wikitable"
 +
|-
 +
!Method Name !! AgentID getAgentID()const
 +
|-
 +
| Method Description || Getter for the current Agent ID.
 +
|-
 +
| Return values || AgentID
 +
|-
 +
|Possible Errors || (HamsterError)
 +
|}
  
Method Description
 
Stops the navigation if there is an active goal.
 
  
Return values
+
== float getLidarResolution()const ==
Possible Errors (HamsterError)
+
{| class="wikitable"
- Connection Issue.
+
|-
 
+
!Method Name !!
 
 
 
 
 
 
 
 
 
Method Name
 
AgentID getAgentID()const
 
Method Description
 
Getter for the current Agent ID.
 
 
 
Return values
 
AgentID
 
 
 
Possible Errors (HamsterError)
 
 
 
 
 
Method Name
 
 
float getLidarResolution()const
 
float getLidarResolution()const
Method Description
+
|-
 +
|Method Description
 
Getter for the lidar resolution
 
Getter for the lidar resolution
 +
|-
 +
|Return values || float
 +
|-
 +
|Possible Errors (HamsterError) ||
 +
|}
  
Return values
 
float
 
  
Possible Errors (HamsterError)
+
== bool isConnected()const ==
 
+
{| class="wikitable"
 
+
|-
Method Name
+
!Method Name !! bool isConnected()const
bool isConnected()const
+
|-
 
+
|Method Description ||
Method Description
+
* Checks whether the client is still connected to the server.
Checks whether the client is still connected to the server.
+
* A connection problem can arise from heartbeat failure or from FIN from the server side.
A connection problem can arise from heartbeat failure or from FIN from the server side.
+
|-
 
+
|Return values ||
Return values
 
 
bool
 
bool
 
+
|-
Possible Errors (HamsterError)
+
|Possible Errors (HamsterError) ||
 
+
|}
 
 
  
 +
== void cleanBuffers() ==
 +
{| class="wikitable"
 +
|-
 +
!Method Name !! void cleanBuffers()
 +
|-
 +
|Method Description ||
 +
* Cleans all the buffers for all the messages (this includes the text messages).
 +
|-
 +
|Return values ||
 +
|-
 +
|Possible Errors (HamsterError) ||
 +
|}
  
Method Name
 
void cleanBuffers()
 
  
Method Description
+
== sendDataMessage ==
Cleans all the buffers for all the messages (this includes the text messages).
+
{| class="wikitable"
 
+
|-
Return values
+
! Method Name !!
Possible Errors (HamsterError)
+
* void sendDataMessage(const AgentID & target_agent_id, const std::string & message)
 
+
* void sendDataMessage(const DataMessage & message)
 
+
|-
Method Name
+
|Method Description ||
● -void sendDataMessage(const AgentID & target_agent_id, const std::string & message)
 
 
 
● -void sendDataMessage(const DataMessage & message);
 
Method Description
 
 
Sends a data message to another hamster. This will be published on the network with the current agent id and the target agent id. If the target is in the network, it will receive it. The following API can be used for messages:
 
Sends a data message to another hamster. This will be published on the network with the current agent id and the target agent id. If the target is in the network, it will receive it. The following API can be used for messages:
- hasDataMessages().
+
* hasDataMessages().
- getLatestDataMessage().
+
* getLatestDataMessage().
- getLatestDataMessages(Amount)
+
* getLatestDataMessages(Amount)
- getDataMessagesAmount().
+
* getDataMessagesAmount().
- clearDataMessagesBuffer().
+
* clearDataMessagesBuffer().
- setDataMessageBufferSize(Amount).
+
* setDataMessageBufferSize(Amount).
- getDataMessageBufferSize().
+
* getDataMessageBufferSize().
- sendDataMessage(Agent, DataMessage). -sendBroadcastDataMessage(DataMessage).
+
* sendDataMessage(Agent, DataMessage).
 +
* sendBroadcastDataMessage(DataMessage).
 +
|-
 +
|Return values ||
 +
|-
 +
|Possible Errors (HamsterError) ||
 +
* Connection Issue.
 +
|}
  
Return values
 
Possible Errors (HamsterError)
 
- Connection Issue.
 
  
 
+
== sendBroadcastDataMessage ==
 
+
{| class="wikitable"
 
+
|-
 
+
!Method Name !!
 
+
* void sendBroadcastDataMessage(const DataMessage & message)
 
+
* void sendBroadcastDataMessage(const std::string & message)
 
+
|-
 
+
|Method Description ||
 
 
 
 
 
 
Method Name
 
-void sendBroadcastDataMessage(const DataMessage & message)
 
 
 
-void sendBroadcastDataMessage(const std::string & message);
 
 
 
 
 
Method Description
 
 
Sends a data message to all the hamsters on the network. Every hamster that see's the message will pick it up. The following API can be used for messages:
 
Sends a data message to all the hamsters on the network. Every hamster that see's the message will pick it up. The following API can be used for messages:
- hasDataMessages().
+
* hasDataMessages().
- getLatestDataMessage().
+
* getLatestDataMessage().
- getLatestDataMessages(Amount).
+
* getLatestDataMessages(Amount).
- getDataMessagesAmount().
+
* getDataMessagesAmount().
- clearDataMessagesBuffer().
+
* clearDataMessagesBuffer().
- setDataMessageBufferSize(Amount).
+
* setDataMessageBufferSize(Amount).
- getDataMessageBufferSize().
+
* getDataMessageBufferSize().
- sendDataMessage(Agent, DataMessage).
+
* sendDataMessage(Agent, DataMessage).
sendBroadcastDataMessage(DataMessage)
+
* sendBroadcastDataMessage(DataMessage)
 +
|-
 +
|Return values ||
 +
|-
 +
|Possible Errors (HamsterError) ||
 +
* Connection Issue.
 +
|}
  
Return values
 
Possible Errors (HamsterError)
 
- Connection Issue.
 
  
 
+
== DataMessage getLatestDataMessage() ==
 
+
{| class="wikitable"
 
+
|-
 
+
!Method Name !!
 
+
* DataMessage getLatestDataMessage() const std::vector<DataMessage> getLatestDataMessages(uint32_t amount)const
 
+
* DataMessage popLatestDataMessage() std::vector<DataMessage> popLatestDataMessages(uint32_t amount)
 
+
|-
 
+
|Method Description ||
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Method Name
 
DataMessage getLatestDataMessage()const
 
 
 
std::vector<DataMessage> getLatestDataMessages(uint32_t amount)const
 
 
 
DataMessage popLatestDataMessage()
 
 
 
std::vector<DataMessage> popLatestDataMessages(uint32_t amount)
 
 
 
 
 
Method Description
 
 
Gets/Pops the data messages that were received from the other agents. Will try to get the max possible messages untill the given amount. The following API can be used for messages:
 
Gets/Pops the data messages that were received from the other agents. Will try to get the max possible messages untill the given amount. The following API can be used for messages:
- hasDataMessages().
+
* hasDataMessages().
- getLatestDataMessage().
+
* getLatestDataMessage().
- getLatestDataMessages(Amount).
+
* getLatestDataMessages(Amount).
- getDataMessagesAmount().
+
* getDataMessagesAmount().
- clearDataMessagesBuffer().
+
* clearDataMessagesBuffer().
- setDataMessageBufferSize(Amount).
+
* setDataMessageBufferSize(Amount).
- getDataMessageBufferSize().
+
* getDataMessageBufferSize().
- sendDataMessage(Agent, DataMessage).
+
* sendDataMessage(Agent, DataMessage).
- sendBroadcastDataMessage(DataMessage).
+
* sendBroadcastDataMessage(DataMessage).
 
Buffer Size - Determined by setDataMessageBufferSize, Defaults to 1000.
 
Buffer Size - Determined by setDataMessageBufferSize, Defaults to 1000.
 
+
|-
Return values
+
|Return values ||
 
DataMessage, std::vector<DataMessage>
 
DataMessage, std::vector<DataMessage>
 +
|-
 +
|Possible Errors (HamsterError) ||
 +
* Empty Buffer.
 +
* Connection Issue.
 +
|}
  
Possible Errors (HamsterError)
 
-Empty Buffer.
 
-Connection Issue.
 
  
 
+
== bool hasDataMessages()const ==
 
+
{| class="wikitable"
Method Name
+
|-
 +
!Method Name !!
 
bool hasDataMessages()const
 
bool hasDataMessages()const
Method Description
+
|-
 +
|Method Description ||
 
Checks whether there are any messages. The following API can be used for messages:
 
Checks whether there are any messages. The following API can be used for messages:
- hasDataMessages().
+
* hasDataMessages().
- getLatestDataMessage().
+
* getLatestDataMessage().
- getLatestDataMessages(Amount).
+
* getLatestDataMessages(Amount).
- getDataMessagesAmount().
+
* getDataMessagesAmount().
- clearDataMessagesBuffer().
+
* clearDataMessagesBuffer().
- setDataMessageBufferSize(Amount).
+
* setDataMessageBufferSize(Amount).
- getDataMessageBufferSize().
+
* getDataMessageBufferSize().
- sendDataMessage(Agent, DataMessage). -sendBroadcastDataMessage(DataMessage).
+
* sendDataMessage(Agent, DataMessage).  
 +
* sendBroadcastDataMessage(DataMessage).
 +
|-
 +
|Return values ||
 +
bool
 +
|-
 +
|Possible Errors ||
 +
|}
  
Return values
 
bool
 
Possible Errors
 
  
Method Name
+
== uint32_t getDataMessagesAmount()const ==
 +
{| class="wikitable"
 +
|-
 +
!Method Name !!
 
uint32_t getDataMessagesAmount()const
 
uint32_t getDataMessagesAmount()const
 
+
|-
Method Description
+
|Method Description ||
 
Getter for the amount of data messages. The following API can be used for messages:
 
Getter for the amount of data messages. The following API can be used for messages:
- hasDataMessages().
+
* hasDataMessages().
- getLatestDataMessage().
+
* getLatestDataMessage().
- getLatestDataMessages(Amount).
+
* getLatestDataMessages(Amount).
- getDataMessagesAmount().
+
* getDataMessagesAmount().
- clearDataMessagesBuffer().
+
* clearDataMessagesBuffer().
- setDataMessageBufferSize(Amount).
+
* setDataMessageBufferSize(Amount).
- getDataMessageBufferSize().
+
* getDataMessageBufferSize().
- sendDataMessage(Agent, DataMessage). - sendBroadcastDataMessage(DataMessage)
+
* sendDataMessage(Agent, DataMessage).
 
+
* sendBroadcastDataMessage(DataMessage)*
Return values
+
|-
 +
|Return values ||
 
uint32_t
 
uint32_t
 +
|-
 +
|Possible Errors (HamsterError) ||
 +
|}
  
Possible Errors (HamsterError)
 
  
 
+
== void clearDataMessagesBuffer() ==
Method Name
+
{| class="wikitable"
 +
|-
 +
!Method Name !!
 
void clearDataMessagesBuffer()
 
void clearDataMessagesBuffer()
 
+
|-
Method Description
+
|Method Description ||
 
Cleans the data message buffer completely.
 
Cleans the data message buffer completely.
 
The following API can be used for messages:
 
The following API can be used for messages:
- hasDataMessages().
+
* hasDataMessages().
- getLatestDataMessage().
+
* getLatestDataMessage().
- getLatestDataMessages(Amount).
+
* getLatestDataMessages(Amount).
- getDataMessagesAmount().
+
* getDataMessagesAmount().
- clearDataMessagesBuffer().
+
* clearDataMessagesBuffer().
- setDataMessageBufferSize(Amount).
+
* setDataMessageBufferSize(Amount).
- getDataMessageBufferSize().
+
* getDataMessageBufferSize().
- sendDataMessage(Agent, DataMessage). - sendBroadcastDataMessage(DataMessage)
+
* sendDataMessage(Agent, DataMessage).  
 +
* sendBroadcastDataMessage(DataMessage)
 +
|-
 +
|Return values ||
 +
|-
 +
|Possible Errors (HamsterError) ||
 +
|}
  
Return values
 
Possible Errors (HamsterError)
 
  
+
== void setDataMessageBufferSize(uint32_t amount) ==
 
+
{| class="wikitable"
 
+
|-
Method Name
+
!Method Name !!
 
 
void setDataMessageBufferSize(uint32_t amount)
 
void setDataMessageBufferSize(uint32_t amount)
 
+
|-
 
+
|Method Description ||
Method Description
 
 
 
Setter for the size of the data message buffer.
 
Setter for the size of the data message buffer.
 
The following API can be used for messages:
 
The following API can be used for messages:
- hasDataMessages().
+
* hasDataMessages().
- getLatestDataMessage().
+
* getLatestDataMessage().
- getLatestDataMessages(Amount).
+
* getLatestDataMessages(Amount).
- getDataMessagesAmount().
+
* getDataMessagesAmount().
- clearDataMessagesBuffer().
+
* clearDataMessagesBuffer().
- setDataMessageBufferSize(Amount).
+
* setDataMessageBufferSize(Amount).
- getDataMessageBufferSize().
+
* getDataMessageBufferSize().
- sendDataMessage(Agent, DataMessage). - sendBroadcastDataMessage(DataMessage)
+
* sendDataMessage(Agent, DataMessage).  
 +
* sendBroadcastDataMessage(DataMessage)
 +
|-
 +
|Return values ||
 +
|-
 +
|Possible Errors (HamsterError) ||
 +
|}
  
  
 
+
== uint32_t getDataMessageBufferSize()const ==
Return values
+
{| class="wikitable"
 
+
|-
Possible Errors (HamsterError)
+
!Method Name !!
 
 
 
 
Method Name
 
 
uint32_t getDataMessageBufferSize()const
 
uint32_t getDataMessageBufferSize()const
Method Description
+
|-
 +
|Method Description ||
 
Getter for the size of the data message buffer.The following API can be used for
 
Getter for the size of the data message buffer.The following API can be used for
 
messages:
 
messages:
- hasDataMessages().
+
* hasDataMessages().
- getLatestDataMessage().
+
* getLatestDataMessage().
- getLatestDataMessages(Amount).
+
* getLatestDataMessages(Amount).
- getDataMessagesAmount().
+
* getDataMessagesAmount().
- clearDataMessagesBuffer().
+
* clearDataMessagesBuffer().
- setDataMessageBufferSize(Amount).
+
* setDataMessageBufferSize(Amount).
- getDataMessageBufferSize().
+
* getDataMessageBufferSize().
- sendDataMessage(Agent, DataMessage). - sendBroadcastDataMessage(DataMessage)
+
* sendDataMessage(Agent, DataMessage).  
 
+
* sendBroadcastDataMessage(DataMessage)
 
+
|-
Return values
+
|Return values ||
 
uint32_t
 
uint32_t
Possible Errors (HamsterError)
+
|-
 +
|Possible Errors (HamsterError) ||
 +
|}
  
  
+
== void reconnect() ==
 
+
{| class="wikitable"
 
+
|-
Method Name
+
!Method Name !!
 
void reconnect()
 
void reconnect()
 
+
|-
Method Description
+
|Method Description ||
 
Tries to reconnect to the server.
 
Tries to reconnect to the server.
 +
|-
 +
|Return values ||
 +
|-
 +
|Possible Errors (HamsterError) ||
 +
* Connection Issue.
 +
|}
  
Return values
 
Possible Errors (HamsterError)
 
- Connection Issue.
 
  
 +
== void disconnect() ==
 +
{| class="wikitable"
 +
|-
 +
!Method Name !! void disconnect()
  
 
+
|-
Method Name
+
|Method Description || Disconnects from the server.
void disconnect()
+
|-
 
+
|Return values ||
Method Description Disconnects from the server.
+
|-
Return values
+
|Possible Errors (HamsterError) ||
Possible Errors (HamsterError)
+
|}
 
 
 
 
 
 
 
 

Latest revision as of 10:33, 28 February 2017


HamsterAPI Class Documentation

Hamster class File Description All methods below belong to the namespace HamsterAPI:: and are a part of the Hamster class HamsterAPIClientCPP/Hamster.h The hamster class is the main interface to the Hamster robot.


Constructor: Hamster(const AgentID & agent_id, HamsterClientParameters params = HamsterClientParameters())

Method Name Constructor: Hamster(const AgentID & agent_id, HamsterClientParameters params = HamsterClientParameters())
Method Description

The client parameters contain the following:

  • base_address:
  • The network base address to work with
- if the address is 127.0.0 then the connection will always go to loopback
- Otherwise it will go to base_adress.agent_id
- For example : base_address = 10.0.2 agent_id = 1 so it will connect to 10.0.2.1:port
  • port - The port to connect on
Return values Possible Errors (HamsterError)

Image getCameraImage() const

Method Name Image getCameraImage() const
Method Description
  • Retrieves the camera image from the hamster
  • Buffer Size - 1
Return values Image
Possible Errors (HamsterError)
  • Empty Buffer
  • Connection Issue

Pose getPose()const

Method Name Pose getPose()const
Method Description
  • Retrieves the global pose of the hamster.
  • The global pose is associated with the SLAM part of the hamster.
  • Buffer Size - 1.
Return values
  • Global Pose
Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.

IMU getIMU()const

Method Name IMU getIMU()const
Method Description
  • Retrieves the IMU information from the hamster if an IMU exists.
  • Buffer Size - 1.
Return values IMU
Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.

GPS getGPS()const

Method Name GPS getGPS()const
Method Description
  • Retrieves the GPS information from the hamster is a GPS exists.
  • Buffer Size - 1.
Return values GPS
Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.

LidarScan getLidarScan()const

Method Name LidarScan getLidarScan()const
Method Description

Retrieves the 360 degree lidar scan from the hamster. Buffer Size - 1.

Return values

LidarScan

Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.

ColoredScan getColoredScan()const

Method Name

ColoredScan getColoredScan()const

Method Description

Retrieves a ColoredScan. ColoredScan is a combination of the hamster lidar and camera synchronized. It contains the raw lidar scan and the associated pixels RGB color of the image. Buffer Size - 1

Return values

ColoredScan

Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.


Speed getSpeed()const

Method Name Speed getSpeed()const
Method Description

Retrieves the current speed of the hamster. The is usually the speed given by the latest speed command or from the wandering / navigation. Buffer Size - 1.

Return values

Speed

Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.


HamsterMode getHamsterMode()const

Method Name

HamsterMode getHamsterMode()const

Method Description

Retrieves the current mode of the hamster. The available modes are:

  • Localization.
  • Mapping.

Buffer Size - 1.

Return values

HamsterMode

Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.


OccupancyGrid getSLAMMap()const

Method Name

OccupancyGrid getSLAMMap()const

Method Description

Retrieves the current SLAM map that was loaded or created by the hamster as an occupancy grid. Buffer Size - 1.

Return values

OccupancyGrid

Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.


HamsterConnections getConnectedHamsters()const

Method Name

HamsterConnections getConnectedHamsters()const

Method Description

Retrieves the currently living hamsters on the network. Meaning that for example there are 3 hamsters on the same network {agent1, agent2, agent3}. If the current hamster got an heartbeat from all the others, there will be 3 connections on the list. Buffer Size - 1.

Return values

HamsterConnections

Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.

BatteryState getBatteryState()const

Method Name

BatteryState getBatteryState()const

Method Description

Retrieves the current battery state of the hamster. Buffer Size - 1.

Return values

BatteryState

Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.


NetworkState getNetworkState()const

Method Name

NetworkState getNetworkState()const

Method Description

Retrieves the current network state of the hamster with the network. Buffer Size - 1.

Return values

NetworkState

Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.


NavigationState getNavigationState()const

Method Name

NavigationState getNavigationState()const

Method Description

Retrieves the navigation state of the hamster. The navigation state depends whether there was a goal request or not. There are four types of states:

  • Offline.
  • In Progress.
  • Reached Goal.
  • Failure.

Buffer Size - 1.

Return values

NavigationState

Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.


void sendSpeed(float velocity, float wheels_angle)

Method Name

void sendSpeed(float velocity, float wheels_angle)

Method Description
  • Sends a speed request to the hamster.
  • If there is an active goal, the speed request will be ignored and an HamsterError will be thrown.
* This method is based on ackermann speed.
Return values
Possible Errors (HamsterError)
  • Connection Issue.
  • Running Goal.

void sendOccupancyGrid(const OccupancyGrid & grid)

Method Name

void sendOccupancyGrid(const OccupancyGrid & grid)

Method Description

Sends an Occupancy Grid to the server to be published. Can be viewed via RViz.

Return values
Possible Errors (HamsterError)
  • Connection issue


void switchMode(const HamsterMode & mode)

Method Name

void switchMode(const HamsterMode & mode)

Method Description

Switches hamster mode to one of the following:

  • Mapping.
  • Localization.
Return values
Possible Errors (HamsterError)
  • Connection Issue.

void navigateTo(const Goal & goal)

Method Name void navigateTo(const Goal & goal)
Method Description
  • Navigates to a given goal.
  • The goal can be either local goal or global goal.
Return values
Possible Errors (HamsterError)
  • Connection Issue.


void navigateTo(float distance, float angle)

Method Name void navigateTo(float distance, float angle)
Method Description

Navigates to a given distance and angle. This is simillar to giving a local goal with distance and angle calculated to X and Y.

Return values
Possible Errors (HamsterError)
  • Connection Issue.

void setInitialPose(const Pose & pose)

Method Name

void setInitialPose(const Pose & pose)

Method Description
  • Sets the initial position of the agent on the global map.
  • This is useful for a starting 0,0 position for mapping or if an agent needs to reposition to a starting position.
Return values
Possible Errors (HamsterError)
  • Connection Issue.


void stopNavigation()

Method Name void stopNavigation()
Method Description Stops the navigation if there is an active goal.
Return values
Possible Errors (HamsterError)
  • Connection Issue.


AgentID getAgentID()const

Method Name AgentID getAgentID()const
Method Description Getter for the current Agent ID.
Return values AgentID
Possible Errors (HamsterError)


float getLidarResolution()const

Method Name

float getLidarResolution()const

Method Description

Getter for the lidar resolution

Return values float
Possible Errors (HamsterError)


bool isConnected()const

Method Name bool isConnected()const
Method Description
  • Checks whether the client is still connected to the server.
  • A connection problem can arise from heartbeat failure or from FIN from the server side.
Return values

bool

Possible Errors (HamsterError)

void cleanBuffers()

Method Name void cleanBuffers()
Method Description
  • Cleans all the buffers for all the messages (this includes the text messages).
Return values
Possible Errors (HamsterError)


sendDataMessage

Method Name
  • void sendDataMessage(const AgentID & target_agent_id, const std::string & message)
  • void sendDataMessage(const DataMessage & message)
Method Description

Sends a data message to another hamster. This will be published on the network with the current agent id and the target agent id. If the target is in the network, it will receive it. The following API can be used for messages:

  • hasDataMessages().
  • getLatestDataMessage().
  • getLatestDataMessages(Amount)
  • getDataMessagesAmount().
  • clearDataMessagesBuffer().
  • setDataMessageBufferSize(Amount).
  • getDataMessageBufferSize().
  • sendDataMessage(Agent, DataMessage).
  • sendBroadcastDataMessage(DataMessage).
Return values
Possible Errors (HamsterError)
  • Connection Issue.


sendBroadcastDataMessage

Method Name
  • void sendBroadcastDataMessage(const DataMessage & message)
  • void sendBroadcastDataMessage(const std::string & message)
Method Description

Sends a data message to all the hamsters on the network. Every hamster that see's the message will pick it up. The following API can be used for messages:

  • hasDataMessages().
  • getLatestDataMessage().
  • getLatestDataMessages(Amount).
  • getDataMessagesAmount().
  • clearDataMessagesBuffer().
  • setDataMessageBufferSize(Amount).
  • getDataMessageBufferSize().
  • sendDataMessage(Agent, DataMessage).
  • sendBroadcastDataMessage(DataMessage)
Return values
Possible Errors (HamsterError)
  • Connection Issue.


DataMessage getLatestDataMessage()

Method Name
  • DataMessage getLatestDataMessage() const std::vector<DataMessage> getLatestDataMessages(uint32_t amount)const
  • DataMessage popLatestDataMessage() std::vector<DataMessage> popLatestDataMessages(uint32_t amount)
Method Description

Gets/Pops the data messages that were received from the other agents. Will try to get the max possible messages untill the given amount. The following API can be used for messages:

  • hasDataMessages().
  • getLatestDataMessage().
  • getLatestDataMessages(Amount).
  • getDataMessagesAmount().
  • clearDataMessagesBuffer().
  • setDataMessageBufferSize(Amount).
  • getDataMessageBufferSize().
  • sendDataMessage(Agent, DataMessage).
  • sendBroadcastDataMessage(DataMessage).

Buffer Size - Determined by setDataMessageBufferSize, Defaults to 1000.

Return values

DataMessage, std::vector<DataMessage>

Possible Errors (HamsterError)
  • Empty Buffer.
  • Connection Issue.


bool hasDataMessages()const

Method Name

bool hasDataMessages()const

Method Description

Checks whether there are any messages. The following API can be used for messages:

  • hasDataMessages().
  • getLatestDataMessage().
  • getLatestDataMessages(Amount).
  • getDataMessagesAmount().
  • clearDataMessagesBuffer().
  • setDataMessageBufferSize(Amount).
  • getDataMessageBufferSize().
  • sendDataMessage(Agent, DataMessage).
  • sendBroadcastDataMessage(DataMessage).
Return values

bool

Possible Errors


uint32_t getDataMessagesAmount()const

Method Name

uint32_t getDataMessagesAmount()const

Method Description

Getter for the amount of data messages. The following API can be used for messages:

  • hasDataMessages().
  • getLatestDataMessage().
  • getLatestDataMessages(Amount).
  • getDataMessagesAmount().
  • clearDataMessagesBuffer().
  • setDataMessageBufferSize(Amount).
  • getDataMessageBufferSize().
  • sendDataMessage(Agent, DataMessage).
  • sendBroadcastDataMessage(DataMessage)*
Return values

uint32_t

Possible Errors (HamsterError)


void clearDataMessagesBuffer()

Method Name

void clearDataMessagesBuffer()

Method Description

Cleans the data message buffer completely. The following API can be used for messages:

  • hasDataMessages().
  • getLatestDataMessage().
  • getLatestDataMessages(Amount).
  • getDataMessagesAmount().
  • clearDataMessagesBuffer().
  • setDataMessageBufferSize(Amount).
  • getDataMessageBufferSize().
  • sendDataMessage(Agent, DataMessage).
  • sendBroadcastDataMessage(DataMessage)
Return values
Possible Errors (HamsterError)


void setDataMessageBufferSize(uint32_t amount)

Method Name

void setDataMessageBufferSize(uint32_t amount)

Method Description

Setter for the size of the data message buffer. The following API can be used for messages:

  • hasDataMessages().
  • getLatestDataMessage().
  • getLatestDataMessages(Amount).
  • getDataMessagesAmount().
  • clearDataMessagesBuffer().
  • setDataMessageBufferSize(Amount).
  • getDataMessageBufferSize().
  • sendDataMessage(Agent, DataMessage).
  • sendBroadcastDataMessage(DataMessage)
Return values
Possible Errors (HamsterError)


uint32_t getDataMessageBufferSize()const

Method Name

uint32_t getDataMessageBufferSize()const

Method Description

Getter for the size of the data message buffer.The following API can be used for messages:

  • hasDataMessages().
  • getLatestDataMessage().
  • getLatestDataMessages(Amount).
  • getDataMessagesAmount().
  • clearDataMessagesBuffer().
  • setDataMessageBufferSize(Amount).
  • getDataMessageBufferSize().
  • sendDataMessage(Agent, DataMessage).
  • sendBroadcastDataMessage(DataMessage)
Return values

uint32_t

Possible Errors (HamsterError)


void reconnect()

Method Name

void reconnect()

Method Description

Tries to reconnect to the server.

Return values
Possible Errors (HamsterError)
  • Connection Issue.


void disconnect()

Method Name void disconnect()
Method Description Disconnects from the server.
Return values
Possible Errors (HamsterError)