Class RemoteInterface
Defined in File remote_interface.h
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public std::enable_shared_from_this< RemoteInterface >
Class Documentation
-
class RemoteInterface : public std::enable_shared_from_this<RemoteInterface>
Simple remote interface to access the dynamic state estimates of an rc_visard device as data streams.
It offers methods to
interface the rc_dynamics module on the rc_visard device, i.e. starting, stopping, and checking its state
manage data streams, i.e. adding, deleting, and checking destinations of the streams
an easy-to-use convenience function to directly start listening to a specific data stream (see createReceiverForStream())
NOTE: For convenience, a RemoteInterface object automatically keeps track of all data stream destinations requested by itself on the rc_visard device, and deletes them again when it is going to be destructed. Therefore, it is highly important that a RemoteInterface is destructed properly. In order to do so it, is recommended to wrap method calls of RemoteInterface objects with try-catch-blocks as they might throw exceptions and therefore avoid proper destruction of the object.
Public Types
-
using Ptr = std::shared_ptr<RemoteInterface>
Public Functions
-
virtual ~RemoteInterface()
-
bool checkSystemReady()
Connects with rc_visard and checks the system state of the rc_visard device
- Returns:
true, if system is ready, false otherwise
-
std::string getDynamicsState()
Returns the current state of rc_dynamics module
- Returns:
the current state.
-
std::string getSlamState()
Returns the current state of rc_slam module
- Returns:
the current state.
-
std::string getStereoInsState()
Returns the current state of rc_stereo_ins module
- Returns:
the current state.
-
std::string start()
Sets rc_dynamics module to running state. Only start the Stereo INS. To start SLAM use startSlam(). To restart use the restart() method.
- Throws:
InvalidState – if the entered state does not match the known states in State
- Returns:
the entered state. Note that this can be an intermediate state.
-
std::string startSlam()
Sets rc_dynamics module to running state. Also starts up the Stereo INS, if not already running.
- Throws:
InvalidState – if the entered state does not match the known states in State
- Returns:
the entered state. Note that this can be an intermediate state.
-
std::string restart()
Restarts the rc_dynamics module to Stereo INS only mode. Equivalent to stop() and start()
- Throws:
InvalidState – if the entered state does not match the known states in State
- Returns:
the entered state. Note that this can be an intermediate state.
-
std::string restartSlam()
Restarts the rc_dynamics module to SLAM mode. Equivalent to stop() and startSlam()
- Throws:
InvalidState – if the entered state does not match the known states in State
- Returns:
the entered state. Note that this can be an intermediate state.
-
std::string stop()
Stops rc_dynamics module. If SLAM is running it will be stopped too.
- Throws:
InvalidState – if the entered state does not match the known states in State
- Returns:
the entered state. Note that this can be an intermediate state.
-
std::string stopSlam()
Stops only the SLAM module (via the rc_dynamics module). The Stereo INS will keep running.
- Throws:
InvalidState – if the entered state does not match the known states in State
- Returns:
the entered state. Note that this can be an intermediate state.
-
std::string resetSlam()
Resets the SLAM module The Stereo INS will keep running, if it is.
- Throws:
InvalidState – if the entered state does not match the known states in State
- Returns:
the entered state (of the SLAM module). Note that this can be an intermediate state.
-
ReturnCode saveSlamMap(unsigned int timeout_ms = 0)
Saves the SLAM map on the sensor.
- Parameters:
timeout_ms – timeout in ms for the call (default 0: no timeout)
- Returns:
return code indicating success and string message
-
ReturnCode loadSlamMap(unsigned int timeout_ms = 0)
Loads the SLAM map on the sensor.
- Parameters:
timeout_ms – timeout in ms for the call (default 0: no timeout)
- Returns:
return code indicating success and string message
-
ReturnCode removeSlamMap(unsigned int timeout_ms = 0)
Removes the SLAM map on the sensor.
- Parameters:
timeout_ms – timeout in ms for the call (default 0: no timeout)
- Returns:
return code indicating success and string message
-
std::list<std::string> getAvailableStreams()
Returns a list all available streams on rc_visard
- Returns:
-
std::string getPbMsgTypeOfStream(const std::string &stream)
Returns the name of the protobuf message class that corresponds to a given data stream and is required for de-serializing the respective messages.
- Parameters:
stream – a specific rc_dynamics data stream (e.g. “pose”, “pose_rt” or “dynamics”)
- Returns:
the corresponding protobuf message type as string (e.g. “Frame” or “Dynamics”)
-
std::list<std::string> getDestinationsOfStream(const std::string &stream)
Returns a list of all destinations registered to the specified rc_dynamics stream. Streams here are represented as their destinations using IP address and port number.
- Parameters:
stream – a specific rc_dynamics data stream (e.g. “pose” or “dynamics”)
- Returns:
list of destinations of represented as strings, e.g. “192.168.0.1:30000”
-
void addDestinationToStream(const std::string &stream, const std::string &destination)
Adds a destination to a stream, i.e. request rc_visard to stream data of the specified type to the given destination.
- Parameters:
stream – stream type, e.g. “pose”, “pose_rt” or “dynamics”
destination – string-represented destination of the data stream, e.g. “192.168.0.1:30000”
-
void deleteDestinationFromStream(const std::string &stream, const std::string &destination)
Deletes a destination from a stream, i.e. request rc_visard to stop streaming data of the specified type to the given destination.
- Parameters:
stream – stream type, e.g. “pose”, “pose_rt” or “dynamics”
destination – string-represented destination of the data stream, e.g. “192.168.0.1:30000”
-
void deleteDestinationsFromStream(const std::string &stream, const std::list<std::string> &destinations)
Deletes given destinations from a stream, i.e. request rc_visard to stop streaming data of the specified type to the given destinations.
- Parameters:
stream – stream type, e.g. “pose”, “pose_rt” or “dynamics”
destinations – list string-represented destination of the data stream, e.g. “192.168.0.1:30000”
-
roboception::msgs::Trajectory getSlamTrajectory(const TrajectoryTime &start = TrajectoryTime::RelativeToStart(), const TrajectoryTime &end = TrajectoryTime::RelativeToEnd(), unsigned int timeout_ms = 0)
Returns the Slam trajectory from the sensor.
Using the start and end arguments only a subsection of the trajectory can be queried. If both are left empy, the full trajectory is returned.
- Parameters:
start – specifies the start of the returned trajectory subsection (if empty, the trajectory is returned from its very beginning)
end – specifies the end of the returned trajectory subsection (if empty, the trajectory is included up to its very end)
-
roboception::msgs::Frame getCam2ImuTransform(unsigned int timeout_ms = 0)
Returns the transformation from camera to IMU coordinate frame.
This is equivalent to the cam2imu_transform in the Dynamics message.
- Parameters:
timeout_ms – timeout in ms for the call (default 0: no timeout)
-
DataReceiver::Ptr createReceiverForStream(const std::string &stream, const std::string &dest_interface = "", unsigned int dest_port = 0)
Convenience method that automatically
1) creates a data receiver (including binding socket to a local network interface) 2) adds a destination to the respective stream on rc_visard device 3) waits/checks for the stream being established 4) (removes the destination automatically from rc_visard device if data receiver is no longer used)
Stream can only be established successfully if rc_dynamics module is running on rc_visard, see (re)start(_slam) methods.
If desired interface for receiving is unspecified (or “”) this host’s network interfaces are scanned to find a suitable IP address among those. Similar, if port number is unspecified (or 0) it will be assigned arbitrarily as available by network interface layer.
- Parameters:
dest_interface – empty or one of this hosts network interfaces, e.g. “eth0”
dest_port – 0 or this hosts port number
- Returns:
true, if stream could be initialized successfully
Public Static Functions
-
static Ptr create(const std::string &rc_visard_ip, unsigned int requests_timeout = 5000)
Creates a local instance of rc_visard’s remote pose interface
- Parameters:
rc_visard_ip – rc_visard’s inet address as string, e.g “192.168.0.12”
requests_timeout – timeout in [ms] for doing REST-API calls, which don’t have an explicit timeout parameter
Protected Functions
-
RemoteInterface(const std::string &rc_visard_ip, unsigned int requests_timeout = 5000)
-
void cleanUpRequestedStreams()
-
void checkStreamTypeAvailable(const std::string &stream)
-
std::string callDynamicsService(std::string service_name)
Common functionality for start(), startSlam(), stop(), …
-
ReturnCode callSlamService(std::string service_name, unsigned int timeout_ms = 0)
call slam services which have a return code with value and message
-
std::string getState(const std::string &node)
Protected Attributes
-
std::string visard_addrs_
-
bool initialized_
indicates if remote_interface was initialized properly at least once, see checkSystemReady()
-
float visard_version_
rc_visard’s firmware version as double, i.e. major.minor, e.g. 1.6
-
std::map<std::string, std::list<std::string>> req_streams_
-
std::list<std::string> avail_streams_
-
std::map<std::string, std::string> protobuf_map_
-
std::string base_url_
-
int timeout_curl_
Protected Static Attributes
-
static std::map<std::string, RemoteInterface::Ptr> remote_interfaces_
-
class DynamicsNotRunning : public std::runtime_error
Thrown if rc_dynamics is requested to receive dynamics data but component is not running.
Public Functions
-
inline explicit DynamicsNotRunning(std::string state)
-
inline explicit DynamicsNotRunning(std::string state)
-
class InvalidState : public std::runtime_error
Thrown if the current_state response of the dynamics service does not correspond to those in the State struct
Public Functions
-
inline explicit InvalidState(std::string encountered_state)
-
inline explicit InvalidState(std::string encountered_state)
-
class NotAccepted : public std::runtime_error
Thrown if a service call is not accepted.
Public Functions
-
inline explicit NotAccepted(std::string service_name)
-
inline explicit NotAccepted(std::string service_name)
-
class NotAvailable : public std::runtime_error
Thrown if a REST API call is rejected because of 404; i.e. URL not found.
Public Functions
-
inline explicit NotAvailable(std::string url)
-
inline explicit NotAvailable(std::string url)
-
struct ReturnCode
-
struct State
An enum mirroring the state-machine states enum in rc_dynamics/dynamicsRos.h. The latter is only available on the visard, therefore not included directly.
Public Static Attributes
-
static const std::string IDLE
Not yet started or stopped.
-
static const std::string RUNNING
Stereo INS is running.
-
static const std::string FATAL
An error has occured. May be resolvable by stopping.
-
static const std::string STOPPING
Intermediate state while transitioning to IDLE (e.g. from RUNNING)
-
static const std::string WAITING_FOR_INS
Waiting for IMU data, will proceed to RUNNING.
-
static const std::string WAITING_FOR_INS_AND_SLAM
Waiting for IMU data, will proceed to WAITING_FOR_SLAM.
-
static const std::string WAITING_FOR_SLAM
Stereo INS is running, waiting for SLAM data, will proceed to RUNNING_WITH_SLAM
-
static const std::string RUNNING_WITH_SLAM
Stereo INS and SLAM are running.
-
static const std::string IDLE