#include "mbs_path.h"
#include "mbs_define.h"
#include "mbs_message.h"
#include "useful_functions.h"
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <iostream>
#include <string>
#include <sstream>
#include <chrono>
#include <thread>
#include <sys/time.h>
#include <ctime>
#include "visu_websocket.h"
#include <fcntl.h>
#include <ws.h>
Classes | |
struct | VisuIn |
input of the 3D window More... | |
Macros | |
#define | MSG_ERR ">> REALTIME >> " |
#define | MSG_PRE " >> " |
Functions | |
void | onopen (ws_cli_conn_t *c) |
This function is called whenever a new connection is opened. More... | |
void | onclose (ws_cli_conn_t *client) |
This function is called whenever a connection is closed. More... | |
void | onmessage (ws_cli_conn_t *client, const unsigned char *msg, uint64_t size, int type) |
Message events goes here. More... | |
int | init_websocket (Realtime_visu *visu, MbsData *mbs_data, int nb_models, int *nb_q, double **q_vec, char **mbs_file, char *mbsz_path, int start_viewpoint, int init_break) |
Initialize the communication with the webserver. More... | |
void | joints_update (Simu_realtime *realtime, int nb_models, int *nb_q, double **q_vec) |
update the joint values for visualization More... | |
void | pause_routine (Simu_realtime *realtime) |
void | update_websocket (Simu_realtime *realtime) |
void | update_plot (Simu_realtime *realtime, double tsim) |
void | free_websocket (void *visu_class) |
close the socket connection More... | |
Variables | |
static uint8_t | key_states [KEYS_LEN] |
static ws_cli_conn_t * | client |
static bool | is_connected = false |
static bool | is_updated = false |
static Simu_realtime * | rt |
bool | pause_sim = false |
static char * | project_data |
long | project_data_size |
VisuIn * | visu_in |
double | t_last_update = 0 |
main update loop for the visualization More... | |
static double | t_last_plot = 0 |
update the realtime plot data More... | |
#define MSG_ERR ">> REALTIME >> " |
#define MSG_PRE " >> " |
void free_websocket | ( | void * | visu_class | ) |
close the socket connection
[in] | visu | data |
int init_websocket | ( | Realtime_visu * | visu, |
MbsData * | mbs_data, | ||
int | nb_models, | ||
int * | nb_q, | ||
double ** | q_vec, | ||
char ** | mbs_file, | ||
char * | mbsz_file, | ||
int | start_viewpoint, | ||
int | init_break | ||
) |
Initialize the communication with the webserver.
The simulation starts in pause or runing according to the option in MbsData::realtime::options::init_break.
[in] | visu | The visualization structure, describing the project. |
[in] | mbs_data | The multibody system, used to retrieve realtime options. |
[in] | nb_models | The number of multibody system in the simulation. |
[in] | nb_q | The number of joint in each multibody system. |
[in] | q_vec | The initial joints value for each multibody system. |
[in] | mbs_file | The multibody files to be loaded. |
[in] | mbsz_path | The multibody project file at mbsz project. |
[in] | start_viewpoint | The initia viewpoint index. |
[in] | init_break | Initialize the simulation paused (!0) or running (1). |
void joints_update | ( | Simu_realtime * | realtime, |
int | nb_models, | ||
int * | nb_q, | ||
double ** | q_vec | ||
) |
update the joint values for visualization
void onclose | ( | ws_cli_conn_t * | client | ) |
This function is called whenever a connection is closed.
client | Client connection. |
void onmessage | ( | ws_cli_conn_t * | client, |
const unsigned char * | msg, | ||
uint64_t | size, | ||
int | type | ||
) |
Message events goes here.
client | Client connection. |
msg | Message content. |
size | Message size. |
type | Message type. |
void onopen | ( | ws_cli_conn_t * | c | ) |
This function is called whenever a new connection is opened.
client | Client connection. |
void pause_routine | ( | Simu_realtime * | realtime | ) |
void update_plot | ( | Simu_realtime * | realtime, |
double | tsim | ||
) |
void update_websocket | ( | Simu_realtime * | realtime | ) |
|
static |
|
static |
|
static |
|
static |
bool pause_sim = false |
|
static |
long project_data_size |
|
static |
|
static |
update the realtime plot data
double t_last_update = 0 |
main update loop for the visualization
VisuIn* visu_in |