mc_control::ControllerClient Struct Reference

#include <mc_control/ControllerClient.h>

Collaboration diagram for mc_control::ControllerClient:

Public Member Functions

 ControllerClient ()
 
 ControllerClient (const std::string &sub_conn_uri, const std::string &push_conn_uri, double timeout=0)
 
 ControllerClient (ControllerServer &server, mc_rtc::gui::StateBuilder &gui)
 
 ControllerClient (const ControllerClient &)=delete
 
ControllerClientoperator= (const ControllerClient &)=delete
 
 ~ControllerClient ()
 
void connect (const std::string &sub_conn_uri, const std::string &push_conn_uri)
 
void connect (ControllerServer &server, mc_rtc::gui::StateBuilder &gui)
 
void send_request (const ElementId &id, const mc_rtc::Configuration &data)
 
template<typename T >
void send_request (const ElementId &id, const T &data)
 
void send_request (const ElementId &id)
 
void raw_request (const ElementId &id, const mc_rtc::Configuration &data, std::string &out)
 
template<typename T >
void raw_request (const ElementId &id, const T &data, std::string &out)
 
void raw_request (const ElementId &id, std::string &out)
 
void timeout (double t)
 
double timeout ()
 
void run (std::vector< char > &buffer, std::chrono::system_clock::time_point &t_last_received)
 
void run (const char *buffer, size_t bufferSize)
 

Protected Member Functions

void start ()
 
void reconnect (const std::string &sub_conn_uri, const std::string &push_conn_uri)
 
void stop ()
 
void handle_gui_state (mc_rtc::Configuration state)
 
void handle_category (const std::vector< std::string > &parent, const std::string &category, const mc_rtc::Configuration &data)
 
void handle_widget (const ElementId &id, const mc_rtc::Configuration &data)
 
virtual void started ()
 
virtual void stopped ()
 
virtual void category (const std::vector< std::string > &parent, const std::string &category)
 
virtual void label (const ElementId &id, const std::string &)
 
virtual void array_label (const ElementId &id, const std::vector< std::string > &, const Eigen::VectorXd &)
 
virtual void button (const ElementId &id)
 
virtual void checkbox (const ElementId &id, bool)
 
virtual void string_input (const ElementId &id, const std::string &)
 
virtual void integer_input (const ElementId &id, int)
 
virtual void number_input (const ElementId &id, double)
 
virtual void number_slider (const ElementId &id, double, double, double)
 
virtual void array_input (const ElementId &id, const std::vector< std::string > &, const Eigen::VectorXd &)
 
virtual void combo_input (const ElementId &id, const std::vector< std::string > &, const std::string &)
 
virtual void data_combo_input (const ElementId &id, const std::vector< std::string > &, const std::string &)
 
virtual void point3d (const ElementId &id, const ElementId &, bool, const Eigen::Vector3d &, const mc_rtc::gui::PointConfig &)
 
virtual void trajectory (const ElementId &id, const std::vector< Eigen::Vector3d > &, const mc_rtc::gui::LineConfig &)
 
virtual void trajectory (const ElementId &id, const std::vector< sva::PTransformd > &, const mc_rtc::gui::LineConfig &)
 
virtual void trajectory (const ElementId &id, const Eigen::Vector3d &, const mc_rtc::gui::LineConfig &)
 
virtual void trajectory (const ElementId &id, const sva::PTransformd &, const mc_rtc::gui::LineConfig &)
 
virtual void polygon (const ElementId &id, const std::vector< std::vector< Eigen::Vector3d >> &, const mc_rtc::gui::Color &)
 
virtual void polygon (const ElementId &id, const std::vector< std::vector< Eigen::Vector3d >> &points, const mc_rtc::gui::LineConfig &config)
 
virtual void polyhedron (const ElementId &id, const std::vector< std::array< Eigen::Vector3d, 3 >> &triangles, const std::vector< std::array< mc_rtc::gui::Color, 3 >> &colors, const mc_rtc::gui::PolyhedronConfig &config)
 
virtual void polyhedron (const ElementId &id, const std::vector< Eigen::Vector3d > &vertices, const std::vector< std::array< size_t, 3 >> &triangles, const std::vector< mc_rtc::gui::Color > &colors, const mc_rtc::gui::PolyhedronConfig &config)
 
virtual void force (const ElementId &id, const ElementId &, const sva::ForceVecd &, const sva::PTransformd &, const mc_rtc::gui::ForceConfig &, bool)
 
virtual void arrow (const ElementId &id, const ElementId &, const Eigen::Vector3d &, const Eigen::Vector3d &, const mc_rtc::gui::ArrowConfig &, bool)
 
virtual void rotation (const ElementId &id, const ElementId &, bool, const sva::PTransformd &)
 
virtual void transform (const ElementId &id, const ElementId &, bool, const sva::PTransformd &)
 
virtual void xytheta (const ElementId &id, const ElementId &, bool, const Eigen::Vector3d &, double)
 
virtual void table_start (const ElementId &id, const std::vector< std::string > &)
 
virtual void table_row (const ElementId &, const std::vector< std::string > &)
 
virtual void table_end (const ElementId &)
 
virtual void robot (const ElementId &id, const std::vector< std::string > &, const std::vector< std::vector< double >> &, const sva::PTransformd &)
 
virtual void robot_msg (const ElementId &id, const mc_rtc::gui::RobotMsgData &)
 
virtual void visual (const ElementId &id, [[maybe_unused]] const rbd::parsers::Visual &visual, [[maybe_unused]] const sva::PTransformd &pose)
 
virtual void schema (const ElementId &id, const std::string &)
 
virtual void form (const ElementId &id)
 
virtual void form_checkbox (const ElementId &, const std::string &, bool, bool)
 
virtual void form_checkbox (const ElementId &formId, const std::string &name, bool required, bool default_, bool)
 
virtual void form_integer_input (const ElementId &, const std::string &, bool, int)
 
virtual void form_integer_input (const ElementId &formId, const std::string &name, bool required, int default_, bool)
 
virtual void form_number_input (const ElementId &, const std::string &, bool, double)
 
virtual void form_number_input (const ElementId &formId, const std::string &name, bool required, double default_, bool)
 
virtual void form_string_input (const ElementId &, const std::string &, bool, const std::string &)
 
virtual void form_string_input (const ElementId &formId, const std::string &name, bool required, const std::string &default_, bool)
 
virtual void form_array_input (const ElementId &, const std::string &, bool, const Eigen::VectorXd &, bool)
 
virtual void form_array_input (const ElementId &formId, const std::string &name, bool required, const Eigen::VectorXd &default_, bool fixed_size, bool)
 
virtual void form_array_input (const ElementId &formId, const std::string &name, bool required, const std::vector< std::string > &, const Eigen::VectorXd &default_, bool fixed_size, bool default_from_user)
 
virtual void form_combo_input (const ElementId &, const std::string &, bool, const std::vector< std::string > &, bool)
 
virtual void form_combo_input (const ElementId &formId, const std::string &name, bool required, const std::vector< std::string > &values, bool send_index, int)
 
virtual void form_data_combo_input (const ElementId &, const std::string &, bool, const std::vector< std::string > &, bool)
 
virtual void form_point3d_input (const ElementId &, const std::string &, bool, const Eigen::Vector3d &, bool, bool)
 
virtual void form_rotation_input (const ElementId &, const std::string &, bool, const sva::PTransformd &, bool, bool)
 
virtual void form_transform_input (const ElementId &, const std::string &, bool, const sva::PTransformd &, bool, bool)
 
virtual void start_form_object_input (const std::string &, bool)
 
virtual void end_form_object_input ()
 
virtual void start_form_generic_array_input (const std::string &, bool, std::optional< std::vector< Configuration >>)
 
virtual void end_form_generic_array_input ()
 
virtual void start_form_one_of_input (const std::string &, bool, const std::optional< std::pair< size_t, Configuration >> &)
 
virtual void end_form_one_of_input ()
 
virtual void start_plot (uint64_t, const std::string &)
 
virtual void plot_setup_xaxis (uint64_t, const std::string &, const mc_rtc::gui::plot::Range &)
 
virtual void plot_setup_yaxis_left (uint64_t, const std::string &, const mc_rtc::gui::plot::Range &)
 
virtual void plot_setup_yaxis_right (uint64_t, const std::string &, const mc_rtc::gui::plot::Range &)
 
virtual void plot_point (uint64_t, uint64_t, const std::string &, double, double, mc_rtc::gui::Color, mc_rtc::gui::plot::Style, mc_rtc::gui::plot::Side)
 
virtual void plot_polygon (uint64_t, uint64_t, const std::string &, const mc_rtc::gui::plot::PolygonDescription &, mc_rtc::gui::plot::Side)
 
virtual void plot_polygons (uint64_t, uint64_t, const std::string &, const std::vector< mc_rtc::gui::plot::PolygonDescription > &, mc_rtc::gui::plot::Side)
 
virtual void end_plot (uint64_t)
 

Protected Attributes

bool run_ = true
 
int sub_socket_ = -1
 
std::thread sub_th_
 
int push_socket_ = -1
 
double timeout_
 
mc_rtc::Configuration data_
 
ControllerServerserver_ = nullptr
 
mc_rtc::gui::StateBuildergui_ = nullptr
 

Detailed Description

Receives data and interact with a ControllerServer

  • Uses a SUB socket to receive the data stream
  • Uses a REQ socket to send requests

Constructor & Destructor Documentation

◆ ControllerClient() [1/4]

mc_control::ControllerClient::ControllerClient ( )

Constructor

Default (disconnected) client

◆ ControllerClient() [2/4]

mc_control::ControllerClient::ControllerClient ( const std::string &  sub_conn_uri,
const std::string &  push_conn_uri,
double  timeout = 0 
)

Constructor

Parameters
sub_conn_uriURI the SUB socket should connect to
push_conn_uriURI the PUSH socket should connect to
timeoutAfter timeout has elapsed without receiving messages from the SUB socket, pass an empty message to handle_gui_state. It should be expressed in secondd. If timeout <= 0, this is ignored.

Check nanomsg documentation for supported protocols

◆ ControllerClient() [3/4]

mc_control::ControllerClient::ControllerClient ( ControllerServer server,
mc_rtc::gui::StateBuilder gui 
)

Constructor

Parameters
serverIn-memory ControllerServer instance
guiGUI updated by the server

◆ ControllerClient() [4/4]

mc_control::ControllerClient::ControllerClient ( const ControllerClient )
delete

◆ ~ControllerClient()

mc_control::ControllerClient::~ControllerClient ( )

Member Function Documentation

◆ array_input()

virtual void mc_control::ControllerClient::array_input ( const ElementId id,
const std::vector< std::string > &  ,
const Eigen::VectorXd &   
)
inlineprotectedvirtual

Should be implemented to create a widget able to input array of numbers

◆ array_label()

virtual void mc_control::ControllerClient::array_label ( const ElementId id,
const std::vector< std::string > &  ,
const Eigen::VectorXd &   
)
inlineprotectedvirtual

Should be implemented to create a label for a numeric array

category Category under which the label appears label Name of the data labels Per-dimension label (can be empty) data Data to display

◆ arrow()

virtual void mc_control::ControllerClient::arrow ( const ElementId id,
const ElementId ,
const Eigen::Vector3d &  ,
const Eigen::Vector3d &  ,
const mc_rtc::gui::ArrowConfig ,
bool   
)
inlineprotectedvirtual

Should display an arrow in 3D environment

◆ button()

virtual void mc_control::ControllerClient::button ( const ElementId id)
inlineprotectedvirtual

Should be implemented to create a button

◆ category()

virtual void mc_control::ControllerClient::category ( const std::vector< std::string > &  parent,
const std::string &  category 
)
inlineprotectedvirtual

Should be implemented to create a new category container

◆ checkbox()

virtual void mc_control::ControllerClient::checkbox ( const ElementId id,
bool   
)
inlineprotectedvirtual

Should be implemented to create a checkbox

◆ combo_input()

virtual void mc_control::ControllerClient::combo_input ( const ElementId id,
const std::vector< std::string > &  ,
const std::string &   
)
inlineprotectedvirtual

Should be implemented to create a widget able to select one string among many

◆ connect() [1/2]

void mc_control::ControllerClient::connect ( const std::string &  sub_conn_uri,
const std::string &  push_conn_uri 
)

Connect to the provided uris

◆ connect() [2/2]

void mc_control::ControllerClient::connect ( ControllerServer server,
mc_rtc::gui::StateBuilder gui 
)

Connect to an in-memory server

◆ data_combo_input()

virtual void mc_control::ControllerClient::data_combo_input ( const ElementId id,
const std::vector< std::string > &  ,
const std::string &   
)
inlineprotectedvirtual

Should be implemented to create a widget able to select one string among entries available in the data part of the GUI message

◆ end_form_generic_array_input()

virtual void mc_control::ControllerClient::end_form_generic_array_input ( )
inlineprotectedvirtual

Pendant to start_form_generic_array_input

After this call, all calls related to form elements must be interpreted as belonging to the form's parent

◆ end_form_object_input()

virtual void mc_control::ControllerClient::end_form_object_input ( )
inlineprotectedvirtual

Pendant to start_form_object_input

After this call, all calls related to form elements must be interpreted as belonging to the form's parent

◆ end_form_one_of_input()

virtual void mc_control::ControllerClient::end_form_one_of_input ( )
inlineprotectedvirtual

Pendant to start_form_one_of_input

After this call, all calls related to form elements must be interpreted as belonging to the form's parent

◆ end_plot()

virtual void mc_control::ControllerClient::end_plot ( uint64_t  )
inlineprotectedvirtual

Called when no more data for a plot will come this iteration

This typically should refresh the log display

◆ force()

virtual void mc_control::ControllerClient::force ( const ElementId id,
const ElementId ,
const sva::ForceVecd &  ,
const sva::PTransformd &  ,
const mc_rtc::gui::ForceConfig ,
bool   
)
inlineprotectedvirtual

Should display a force in 3D environment

◆ form()

virtual void mc_control::ControllerClient::form ( const ElementId id)
inlineprotectedvirtual

Create a form

◆ form_array_input() [1/3]

virtual void mc_control::ControllerClient::form_array_input ( const ElementId ,
const std::string &  ,
bool  ,
const Eigen::VectorXd &  ,
bool   
)
inlineprotectedvirtual

An array input within a form

This is kept for backward compatibility, mc_rtc never calls this version and you should implement the full version

◆ form_array_input() [2/3]

virtual void mc_control::ControllerClient::form_array_input ( const ElementId formId,
const std::string &  name,
bool  required,
const Eigen::VectorXd &  default_,
bool  fixed_size,
bool   
)
inlineprotectedvirtual

An array input within a form

This is kept for backward compatibility, mc_rtc never calls this version and you should implement the full version

◆ form_array_input() [3/3]

virtual void mc_control::ControllerClient::form_array_input ( const ElementId formId,
const std::string &  name,
bool  required,
const std::vector< std::string > &  ,
const Eigen::VectorXd &  default_,
bool  fixed_size,
bool  default_from_user 
)
inlineprotectedvirtual

An array input within a form

◆ form_checkbox() [1/2]

virtual void mc_control::ControllerClient::form_checkbox ( const ElementId ,
const std::string &  ,
bool  ,
bool   
)
inlineprotectedvirtual

A checkbox within a form

This is kept for backward compatibility, mc_rtc never calls this version and you should implement the full version

◆ form_checkbox() [2/2]

virtual void mc_control::ControllerClient::form_checkbox ( const ElementId formId,
const std::string &  name,
bool  required,
bool  default_,
bool   
)
inlineprotectedvirtual

A checkbox within a form

◆ form_combo_input() [1/2]

virtual void mc_control::ControllerClient::form_combo_input ( const ElementId ,
const std::string &  ,
bool  ,
const std::vector< std::string > &  ,
bool   
)
inlineprotectedvirtual

A combo input within a form

This is kept for backward compatibility, mc_rtc never calls this version and you should implement the full version

◆ form_combo_input() [2/2]

virtual void mc_control::ControllerClient::form_combo_input ( const ElementId formId,
const std::string &  name,
bool  required,
const std::vector< std::string > &  values,
bool  send_index,
int   
)
inlineprotectedvirtual

A combo input within a form

formId Identifier of the form

name Name of the entry

required If true, it must hold a value when the form is sent

values Possible values

send_index If true, the implementation should send back the index rather than the value

◆ form_data_combo_input()

virtual void mc_control::ControllerClient::form_data_combo_input ( const ElementId ,
const std::string &  ,
bool  ,
const std::vector< std::string > &  ,
bool   
)
inlineprotectedvirtual

A data combo input within a form

formId Identifier of the form

name Name of the entry

required If true, it must hold a value when the form is sent

ref Reference to GUI data store, can reference other fields of the form, e.g. {"$R0", "surfaces"} depends on the value of the R0 entry in the form

send_index If true, the implementation should send back the index in the list rather than the value

◆ form_integer_input() [1/2]

virtual void mc_control::ControllerClient::form_integer_input ( const ElementId ,
const std::string &  ,
bool  ,
int   
)
inlineprotectedvirtual

An integer input within a form

This is kept for backward compatibility, mc_rtc never calls this version and you should implement the full version

◆ form_integer_input() [2/2]

virtual void mc_control::ControllerClient::form_integer_input ( const ElementId formId,
const std::string &  name,
bool  required,
int  default_,
bool   
)
inlineprotectedvirtual

An integer input within a form

◆ form_number_input() [1/2]

virtual void mc_control::ControllerClient::form_number_input ( const ElementId ,
const std::string &  ,
bool  ,
double   
)
inlineprotectedvirtual

A number input within a form

This is kept for backward compatibility, mc_rtc never calls this version and you should implement the full version

◆ form_number_input() [2/2]

virtual void mc_control::ControllerClient::form_number_input ( const ElementId formId,
const std::string &  name,
bool  required,
double  default_,
bool   
)
inlineprotectedvirtual

A number input within a form

◆ form_point3d_input()

virtual void mc_control::ControllerClient::form_point3d_input ( const ElementId ,
const std::string &  ,
bool  ,
const Eigen::Vector3d &  ,
bool  ,
bool   
)
inlineprotectedvirtual

A 3D point that can be edited within a Form

formId Identifier of the form

name Name of the entry

required If true, it must hold a value when the form is sent

default_ Default value in the form

default_from_user Default is provided by the user

interactive Should display an interactive marker

◆ form_rotation_input()

virtual void mc_control::ControllerClient::form_rotation_input ( const ElementId ,
const std::string &  ,
bool  ,
const sva::PTransformd &  ,
bool  ,
bool   
)
inlineprotectedvirtual

A rotation that can be edited within a Form

Note: this requires a PTransformd to place the rotation in space but only the rotation should be provided in the callback

formId Identifier of the form

name Name of the entry

required If true, it must hold a value when the form is sent

default_ Default value in the form

default_from_user Default is provided by the user

interactive Should display an interactive marker

◆ form_string_input() [1/2]

virtual void mc_control::ControllerClient::form_string_input ( const ElementId ,
const std::string &  ,
bool  ,
const std::string &   
)
inlineprotectedvirtual

A string input within a form

This is kept for backward compatibility, mc_rtc never calls this version and you should implement the full version

◆ form_string_input() [2/2]

virtual void mc_control::ControllerClient::form_string_input ( const ElementId formId,
const std::string &  name,
bool  required,
const std::string &  default_,
bool   
)
inlineprotectedvirtual

A string input within a form

◆ form_transform_input()

virtual void mc_control::ControllerClient::form_transform_input ( const ElementId ,
const std::string &  ,
bool  ,
const sva::PTransformd &  ,
bool  ,
bool   
)
inlineprotectedvirtual

A transform that can be edited within a Form

formId Identifier of the form

name Name of the entry

required If true, it must hold a value when the form is sent

default_ Default value in the form

default_from_user Default is provided by the user

interactive Should display an interactive marker

◆ handle_category()

void mc_control::ControllerClient::handle_category ( const std::vector< std::string > &  parent,
const std::string &  category,
const mc_rtc::Configuration data 
)
protected

◆ handle_gui_state()

void mc_control::ControllerClient::handle_gui_state ( mc_rtc::Configuration  state)
protected

◆ handle_widget()

void mc_control::ControllerClient::handle_widget ( const ElementId id,
const mc_rtc::Configuration data 
)
protected

◆ integer_input()

virtual void mc_control::ControllerClient::integer_input ( const ElementId id,
int   
)
inlineprotectedvirtual

Should be implemented to create a widget able to input integers

◆ label()

virtual void mc_control::ControllerClient::label ( const ElementId id,
const std::string &   
)
inlineprotectedvirtual

Should be implemented to create a label for data that can be displayed as string

◆ number_input()

virtual void mc_control::ControllerClient::number_input ( const ElementId id,
double   
)
inlineprotectedvirtual

Should be implemented to create a widget able to input numbers

◆ number_slider()

virtual void mc_control::ControllerClient::number_slider ( const ElementId id,
double  ,
double  ,
double   
)
inlineprotectedvirtual

◆ operator=()

ControllerClient& mc_control::ControllerClient::operator= ( const ControllerClient )
delete

◆ plot_point()

virtual void mc_control::ControllerClient::plot_point ( uint64_t  ,
uint64_t  ,
const std::string &  ,
double  ,
double  ,
mc_rtc::gui::Color  ,
mc_rtc::gui::plot::Style  ,
mc_rtc::gui::plot::Side   
)
inlineprotectedvirtual

Add data to be displayed on a plot

id Plot id

did Id for this data, this is strictly increasing from 0 to the number of plots - 1

legend Legend for this data

x X value

y Y value

style How to link data points together

side Add on the Y left or right side

◆ plot_polygon()

virtual void mc_control::ControllerClient::plot_polygon ( uint64_t  ,
uint64_t  ,
const std::string &  ,
const mc_rtc::gui::plot::PolygonDescription ,
mc_rtc::gui::plot::Side   
)
inlineprotectedvirtual

Plot a polygon

id Id for the plot

did Id for this polygon

legen Legend to describe this polygon

polygon Description of the polygon

side Side where the polygon should be displayed

◆ plot_polygons()

virtual void mc_control::ControllerClient::plot_polygons ( uint64_t  ,
uint64_t  ,
const std::string &  ,
const std::vector< mc_rtc::gui::plot::PolygonDescription > &  ,
mc_rtc::gui::plot::Side   
)
inlineprotectedvirtual

Plot several polygons under the same legend

id Id for the plot

did Id for these polygons

legen Legend to describe these polygons

polygons Description of the polygons

side Side where the polygons should be displayed

◆ plot_setup_xaxis()

virtual void mc_control::ControllerClient::plot_setup_xaxis ( uint64_t  ,
const std::string &  ,
const mc_rtc::gui::plot::Range  
)
inlineprotectedvirtual

Setup the X-axis

id Plot id

legend Legend on the X-axis

range Range on the X-axis plot

◆ plot_setup_yaxis_left()

virtual void mc_control::ControllerClient::plot_setup_yaxis_left ( uint64_t  ,
const std::string &  ,
const mc_rtc::gui::plot::Range  
)
inlineprotectedvirtual

Setup the Y-axis on the left side

id Plot id

legend Legend on the Y-axis

range Range on the Y-axis plot

◆ plot_setup_yaxis_right()

virtual void mc_control::ControllerClient::plot_setup_yaxis_right ( uint64_t  ,
const std::string &  ,
const mc_rtc::gui::plot::Range  
)
inlineprotectedvirtual

Setup the Y-axis on the right side

id Plot id

legend Legend on the Y-axis

range Range on the Y-axis plot

◆ point3d()

virtual void mc_control::ControllerClient::point3d ( const ElementId id,
const ElementId ,
bool  ,
const Eigen::Vector3d &  ,
const mc_rtc::gui::PointConfig  
)
inlineprotectedvirtual

Should display an interactive point in 3D environment

requestId should be in requests instead of id

bool ro indicates whether this point is interactive or not

◆ polygon() [1/2]

virtual void mc_control::ControllerClient::polygon ( const ElementId id,
const std::vector< std::vector< Eigen::Vector3d >> &  ,
const mc_rtc::gui::Color  
)
inlineprotectedvirtual

Should display a list of polygons of 3d points in 3D environment

For backward compatibility, this version has the default implementation and the version that accepts a LineConfig configuration instead of a Color is implemented in terms of this one. The opposite makes more sense in actual implementation of ControllerClient.

points Each entry in the vector is a polygon described by its 3D points

color Color of the polygon

◆ polygon() [2/2]

virtual void mc_control::ControllerClient::polygon ( const ElementId id,
const std::vector< std::vector< Eigen::Vector3d >> &  points,
const mc_rtc::gui::LineConfig config 
)
inlineprotectedvirtual

Should display a list of polygons of 3D points in 3D environment

For backward compatibility, this version is implemented to forward the call to the color variant, the concrete implementation makes more sense the other way around.

points Each entry in the vector is a polygon described by its 3D points

config Describe how to display the polygon

◆ polyhedron() [1/2]

virtual void mc_control::ControllerClient::polyhedron ( const ElementId id,
const std::vector< Eigen::Vector3d > &  vertices,
const std::vector< std::array< size_t, 3 >> &  triangles,
const std::vector< mc_rtc::gui::Color > &  colors,
const mc_rtc::gui::PolyhedronConfig config 
)
protectedvirtual

Should display a polyhedron

The polygon is described by a list of vertices and a list of triangles

A triangle list version is also available, this default implementation calls that by default.

Parameters
colorsmight be empty
configcontains additional information about handling the drawing

◆ polyhedron() [2/2]

virtual void mc_control::ControllerClient::polyhedron ( const ElementId id,
const std::vector< std::array< Eigen::Vector3d, 3 >> &  triangles,
const std::vector< std::array< mc_rtc::gui::Color, 3 >> &  colors,
const mc_rtc::gui::PolyhedronConfig config 
)
protectedvirtual

Should display a polyhedron

The polyhedron is described by a list of clockwise-ordered triangles.

A vertices/triangles version is also available, this default implementation calls that by default.

Parameters
colorsmight be empty
configcontains additional information about handling the drawing

◆ raw_request() [1/3]

void mc_control::ControllerClient::raw_request ( const ElementId id,
const mc_rtc::Configuration data,
std::string &  out 
)

Get the raw request data

out.c_str() can be used to send requests to the raw data interface of ControllerServer

◆ raw_request() [2/3]

template<typename T >
void mc_control::ControllerClient::raw_request ( const ElementId id,
const T &  data,
std::string &  out 
)
inline

Helper for raw request in simple cases

◆ raw_request() [3/3]

void mc_control::ControllerClient::raw_request ( const ElementId id,
std::string &  out 
)

Helper for the void case

◆ reconnect()

void mc_control::ControllerClient::reconnect ( const std::string &  sub_conn_uri,
const std::string &  push_conn_uri 
)
protected

Connect/Reconnect the client and start receiving data asap

Parameters
sub_conn_uriURI the SUB socket should connect to
push_conn_uriURI the PUSH socket should connect to

Check nanomsg documentation for supported protocols

◆ robot()

virtual void mc_control::ControllerClient::robot ( const ElementId id,
const std::vector< std::string > &  ,
const std::vector< std::vector< double >> &  ,
const sva::PTransformd &   
)
inlineprotectedvirtual

Should display a robot model, the RobotModule can be created using parameters, its configuration is in \q and its world position is in posW

◆ robot_msg()

virtual void mc_control::ControllerClient::robot_msg ( const ElementId id,
const mc_rtc::gui::RobotMsgData  
)
inlineprotectedvirtual

◆ rotation()

virtual void mc_control::ControllerClient::rotation ( const ElementId id,
const ElementId ,
bool  ,
const sva::PTransformd &   
)
inlineprotectedvirtual

Should display a rotation in 3D environment

requestId should be in requests instead of id

bool ro indicates whether this point is interactive or not

◆ run() [1/2]

void mc_control::ControllerClient::run ( const char *  buffer,
size_t  bufferSize 
)

Run with raw data received from any possible way

Parameters
bufferData to be processed
bufferSizeSize of data

◆ run() [2/2]

void mc_control::ControllerClient::run ( std::vector< char > &  buffer,
std::chrono::system_clock::time_point &  t_last_received 
)

Check if there is an available message from the server and process it

This is the synchronous pendant to start()

Parameters
bufferBuffer to receive data from the server, if it is too small, the buffer is resized and the message is discarded
t_last_receivedTime when the last message was received, it is updated if the client receives a message. If a message has not been received since timeout() then act as if we received an empty message (server offline).

◆ schema()

virtual void mc_control::ControllerClient::schema ( const ElementId id,
const std::string &   
)
inlineprotectedvirtual

Should display a form to send schema-based request to the server

schema is the schema directory relative to mc_rtc JSON schema installation

◆ send_request() [1/3]

void mc_control::ControllerClient::send_request ( const ElementId id)

Helper for the void case

◆ send_request() [2/3]

void mc_control::ControllerClient::send_request ( const ElementId id,
const mc_rtc::Configuration data 
)

Send a request to the given element in the given category using data

◆ send_request() [3/3]

template<typename T >
void mc_control::ControllerClient::send_request ( const ElementId id,
const T &  data 
)
inline

Helper for send_request in simple cases

◆ start()

void mc_control::ControllerClient::start ( )
protected

Should be called when the client is ready to receive data

◆ start_form_generic_array_input()

virtual void mc_control::ControllerClient::start_form_generic_array_input ( const std::string &  ,
bool  ,
std::optional< std::vector< Configuration >>   
)
inlineprotectedvirtual

Starts a generic array input

The next call related to form elements must be interpreted as describing the type of members the array expects

name Name of the array this generates

required If true, it must hold a value (can be an empty array) when the form is sent

data Existing data in the array, must be sent along with the form if provided

◆ start_form_object_input()

virtual void mc_control::ControllerClient::start_form_object_input ( const std::string &  ,
bool   
)
inlineprotectedvirtual

Starts a form within a form

After this call, all calls related to form elements must be interpreted as belonging to this sub-form

name Name of the object

required If true, it must hold a value when the form is sent

◆ start_form_one_of_input()

virtual void mc_control::ControllerClient::start_form_one_of_input ( const std::string &  ,
bool  ,
const std::optional< std::pair< size_t, Configuration >> &   
)
inlineprotectedvirtual

Start a one-of input within a form

After this call, each call related to form elements is one option offered by the one-of selector. The name of the element should be used to distinguish the selected type

name Name of the one-of selection

required If true, it must hold a valid value when sent

data Active data

◆ start_plot()

virtual void mc_control::ControllerClient::start_plot ( uint64_t  ,
const std::string &   
)
inlineprotectedvirtual

Called when new plot data arrives

This should open a new plotting window with the provided title.

id The plot id, this serves to disambiguate plots with the same title that are started right after closing the previous one

title Title of the plot

◆ started()

virtual void mc_control::ControllerClient::started ( )
inlineprotectedvirtual

Called when a message starts being processed, can be used to lock the GUI

◆ stop()

void mc_control::ControllerClient::stop ( )
protected

Kill the connection and data flow

◆ stopped()

virtual void mc_control::ControllerClient::stopped ( )
inlineprotectedvirtual

Called when a message has been processed

◆ string_input()

virtual void mc_control::ControllerClient::string_input ( const ElementId id,
const std::string &   
)
inlineprotectedvirtual

Should be implemented to create a widget able to input strings

◆ table_end()

virtual void mc_control::ControllerClient::table_end ( const ElementId )
inlineprotectedvirtual

Called to close a table identified by id

◆ table_row()

virtual void mc_control::ControllerClient::table_row ( const ElementId ,
const std::vector< std::string > &   
)
inlineprotectedvirtual

Called for each element appearing in the table identified by id

◆ table_start()

virtual void mc_control::ControllerClient::table_start ( const ElementId id,
const std::vector< std::string > &   
)
inlineprotectedvirtual

Called when a table starts

◆ timeout() [1/2]

double mc_control::ControllerClient::timeout ( )

Get the current timeout

◆ timeout() [2/2]

void mc_control::ControllerClient::timeout ( double  t)

Set the timeout of the SUB socket

◆ trajectory() [1/4]

virtual void mc_control::ControllerClient::trajectory ( const ElementId id,
const Eigen::Vector3d &  ,
const mc_rtc::gui::LineConfig  
)
inlineprotectedvirtual

Should display a trajectory of points, points are added one by one by the server

point New point added to the trajectory

◆ trajectory() [2/4]

virtual void mc_control::ControllerClient::trajectory ( const ElementId id,
const std::vector< Eigen::Vector3d > &  ,
const mc_rtc::gui::LineConfig  
)
inlineprotectedvirtual

Should display a trajectory of 3d points in 3D environment

points Vector of 3D points

◆ trajectory() [3/4]

virtual void mc_control::ControllerClient::trajectory ( const ElementId id,
const std::vector< sva::PTransformd > &  ,
const mc_rtc::gui::LineConfig  
)
inlineprotectedvirtual

Should display a trajectory of transforms in 3D environment

points Vector of poses

◆ trajectory() [4/4]

virtual void mc_control::ControllerClient::trajectory ( const ElementId id,
const sva::PTransformd &  ,
const mc_rtc::gui::LineConfig  
)
inlineprotectedvirtual

Should display a trajectory of points, points are added one by one by the server

point New point added to the trajectory

◆ transform()

virtual void mc_control::ControllerClient::transform ( const ElementId id,
const ElementId ,
bool  ,
const sva::PTransformd &   
)
inlineprotectedvirtual

Should display a PTransform in 3D environment

requestId should be in requests instead of id

bool ro indicates whether this point is interactive or not

◆ visual()

virtual void mc_control::ControllerClient::visual ( const ElementId id,
[[maybe_unused] ] const rbd::parsers::Visual &  visual,
[[maybe_unused] ] const sva::PTransformd &  pose 
)
inlineprotectedvirtual

Should display the visual element visual at the position pose

◆ xytheta()

virtual void mc_control::ControllerClient::xytheta ( const ElementId id,
const ElementId ,
bool  ,
const Eigen::Vector3d &  ,
double   
)
inlineprotectedvirtual

Should display X,Y,theta in a 3D environment

requestId should be in requests instead of id

bool ro indicates whether this point is interactive or not

Member Data Documentation

◆ data_

mc_rtc::Configuration mc_control::ControllerClient::data_
protected

◆ gui_

mc_rtc::gui::StateBuilder* mc_control::ControllerClient::gui_ = nullptr
protected

◆ push_socket_

int mc_control::ControllerClient::push_socket_ = -1
protected

◆ run_

bool mc_control::ControllerClient::run_ = true
protected

◆ server_

ControllerServer* mc_control::ControllerClient::server_ = nullptr
protected

◆ sub_socket_

int mc_control::ControllerClient::sub_socket_ = -1
protected

◆ sub_th_

std::thread mc_control::ControllerClient::sub_th_
protected

◆ timeout_

double mc_control::ControllerClient::timeout_
protected

The documentation for this struct was generated from the following file: