chrono::utils::ChSocketCommunication Class Reference

Description

Class for socket communication interface.

Typically, a Chrono program can instance an object from this class and use it to communicate with a 3rd party simulation tool at each time step. The communication is based on TCP sockets, where vectors of scalar values are exchanged back and forth. In this case, Chrono will work as a server, waiting for a client to talk with.

#include <ChSocketCommunication.h>

Public Member Functions

 ChSocketCommunication (utils::ChSocketFramework &framework, int n_in_values, int n_out_values)
 Create a co-simulation interface. More...
 
bool WaitConnection (int port)
 Wait for a client to connect to the interface, on a given port, and wait until not connected. More...
 
bool SendData (double time, ChVectorConstRef out_data)
 Exchange data with the client, by sending a vector of floating point values over TCP socket connection. More...
 
bool ReceiveData (double &time, ChVectorRef in_data)
 Exchange data with the client, by receiving a vector of floating point values over TCP socket connection (values are double precision, little endian, 4 bytes each) External time is also received as first value.
 

Constructor & Destructor Documentation

◆ ChSocketCommunication()

chrono::utils::ChSocketCommunication::ChSocketCommunication ( utils::ChSocketFramework framework,
int  n_in_values,
int  n_out_values 
)

Create a co-simulation interface.

Parameters
frameworksocket framework
n_in_valuesnumber of scalar variables to receive each timestep
n_out_valuesnumber of scalar variables to send each timestep

Member Function Documentation

◆ SendData()

bool chrono::utils::ChSocketCommunication::SendData ( double  time,
ChVectorConstRef  out_data 
)

Exchange data with the client, by sending a vector of floating point values over TCP socket connection.

Values are double precision, little endian, 4 bytes each. The simulator time is passed as first argument.

◆ WaitConnection()

bool chrono::utils::ChSocketCommunication::WaitConnection ( int  port)

Wait for a client to connect to the interface, on a given port, and wait until not connected.

The argument 'port' is a free port number, for example 50009.


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono/utils/ChSocketCommunication.h
  • /builds/uwsbel/chrono/src/chrono/utils/ChSocketCommunication.cpp