libhybrid
A library for discretized Hybrid Dynamical Systems
libhybrid.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright 2018 - Matteo Ragni, Matteo Cocetti - University of Trento
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
22 
23 #ifndef LIBHYBRID_H_
24 #define LIBHYBRID_H_
25 
59 #ifndef HYB_FLOAT_TYPE
60 #define HYB_FLOAT_TYPE double
61 #endif
64 #define RK4_FLOAT_TYPE HYB_FLOAT_TYPE
65 #include "librk4.h"
66 
73 typedef enum hyb_bool {
74  hyb_false = 0,
76 } hyb_bool;
77 
107 typedef void (*hyb_flow_map)(hyb_float *xdot, hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p);
108 
137 typedef void (*hyb_jump_map)(hyb_float *xp, hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p);
138 
167 typedef void (*hyb_jump_map)(hyb_float *xp, hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p);
168 
169 
195 typedef hyb_bool (*hyb_jump_set)(hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p);
196 
197 
223 typedef hyb_bool (*hyb_flow_set)(hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p);
224 
225 
226 typedef void (*hyb_out_map)(hyb_float *y, hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p);
227 
235 #ifndef HYB_JUMP_LOGIC
236 #define HYB_JUMP_LOGIC 1
237 #endif
238 
242 typedef struct hyb_opts {
243  size_t y_size;
244  size_t x_size;
253 } hyb_opts;
254 
255 #define HYB_GET_OPTS(S) ((hyb_opts *)S)
256 #define HYB_SEND_OPTS(S) ((void *)S)
258 typedef enum hyb_errorcode {
266 } hyb_errorcode;
267 
286 hyb_errorcode hyb_main_loop(hyb_opts *opts, hyb_float *y, hyb_float *xp, hyb_float tau, const hyb_float *x, const hyb_float *u, const hyb_float **p);
287 
301 void hyb_flow_map_wrapper(hyb_float *dx, hyb_float tau, const hyb_float *x, const hyb_float *u, const hyb_float **p, void *vopts);
302 
303 #endif /* LIBHYBRID_H_ */
void(* hyb_flow_map)(hyb_float *xdot, hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p)
Callback definition for the Flow Map.
Definition: libhybrid.h:107
size_t x_size
Definition: libhybrid.h:244
hyb_errorcode
Definition: libhybrid.h:258
void(* hyb_jump_map)(hyb_float *xp, hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p)
Callback definition for the Jump Map.
Definition: libhybrid.h:137
hyb_float J_horizon
Definition: libhybrid.h:247
#define HYB_FLOAT_TYPE
Definition: libhybrid.h:60
Options structure for the hybrid system.
Definition: libhybrid.h:242
size_t y_size
Definition: libhybrid.h:243
struct hyb_opts hyb_opts
Options structure for the hybrid system.
hyb_jump_map J
Definition: libhybrid.h:249
hyb_errorcode hyb_main_loop(hyb_opts *opts, hyb_float *y, hyb_float *xp, hyb_float tau, const hyb_float *x, const hyb_float *u, const hyb_float **p)
Hybrid system main loop.
Definition: libhybrid.c:31
hyb_jump_set D
Definition: libhybrid.h:251
void hyb_flow_map_wrapper(hyb_float *dx, hyb_float tau, const hyb_float *x, const hyb_float *u, const hyb_float **p, void *vopts)
Internal callback for discretization step.
Definition: libhybrid.c:66
hyb_bool
libhybrid boolean type is actually an enum
Definition: libhybrid.h:73
hyb_float T_horizon
Definition: libhybrid.h:246
hyb_out_map Y
Definition: libhybrid.h:250
hyb_flow_set C
Definition: libhybrid.h:252
hyb_bool(* hyb_jump_set)(hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p)
Callback definition for the Jump Set.
Definition: libhybrid.h:195
hyb_float Ts
Definition: libhybrid.h:245
hyb_flow_map F
Definition: libhybrid.h:248
void(* hyb_out_map)(hyb_float *y, hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p)
Definition: libhybrid.h:226
hyb_bool(* hyb_flow_set)(hyb_float t, hyb_float j, const hyb_float *x, const hyb_float *u, const hyb_float **p)
Callback definition for the Flow Set.
Definition: libhybrid.h:223
HYB_FLOAT_TYPE hyb_float
Definition: libhybrid.h:62