Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
robotran
mbsysc
Commits
08131e36
Commit
08131e36
authored
Apr 22, 2015
by
Nicolas Van der Noot
Browse files
user init speed factor
parent
fa717436
Changes
3
Hide whitespace changes
Inline
Side-by-side
MBprojects/PendulumSpringC/userfctR/realtime/user_realtime_options.c
View file @
08131e36
...
...
@@ -26,6 +26,10 @@
* back in time. When the buffers are full, they erase the oldest values with the new
* ones (rotating buffer). If you put a value <= 0, the size is automatically computed
* so that the buffer is big enough for the whole simulation.
* * options->init_speed_factor: initial speed factor (default: 1.0)
* For speed factors equal or higher than one, this factor should be an integer.
* For speed factors in ]0;1[, this factor is set as 2^x, where x is a negative integer.
* So, if your factor does not match these requirements, it will be rounded to fulfill them.
*
* * SDL plots options
* * options->curve_width: curves width in number of pixels (default: 3)
...
...
MBsysC/mbs_common/mbs_realtime/realtime/realtime.c
View file @
08131e36
...
...
@@ -243,6 +243,8 @@ Realtime_option* init_Realtime_option()
options
->
buffer_size
=
-
1
;
///< size of the buffer for java and sdl
options
->
init_speed_factor
=
1
.
0
;
///< initial speed factor
// SDL plots and interactions
options
->
curve_width
=
3
;
///< plot curve width in number of pixels
options
->
screen_width
=
660
;
///< plot screen width in number of pixels
...
...
@@ -325,6 +327,12 @@ void check_user_realtime_options(Realtime_option *options)
}
// warnings generated
if
(
options
->
init_speed_factor
<=
0
.
0
)
{
printf
(
"Real-time options warning: init_speed_factor (%f) <= 0.0; set to 1.0.
\n
"
,
options
->
init_speed_factor
);
options
->
init_speed_factor
=
1
.
0
;
}
if
(
options
->
start_viewpoint
<
-
1
)
{
printf
(
"Real-time options warning: start_viewpoint (%d) < -1; set to 0.
\n
"
,
options
->
start_viewpoint
);
...
...
@@ -564,14 +572,14 @@ Simu_realtime* init_simu_realtime(MbsData* mbs_data, Realtime_option *options, i
realtime
->
simu_quit
=
0
;
// quit the simulation
realtime
->
simu_break
=
options
->
init_break
;
// break in the simulation at the beginning
realtime
->
last_break
=
options
->
final_break
;
// break in the simulation at the end
realtime
->
simu_speed_flag
=
0
;
// normal
simulation speed
realtime
->
simu_speed_flag
=
get_simu_speed_flag
(
options
->
init_speed_factor
);
//
simulation speed
flag
// end of the simulation time (in s)
realtime
->
last_tsim
=
tsim
;
// simulation speed
realtime
->
last_real_simu_speed_factor
=
1
.
0
;
realtime
->
real_simu_speed_factor
=
1
.
0
;
realtime
->
last_real_simu_speed_factor
=
get_simu_speed_factor
(
realtime
->
simu_speed_flag
)
;
realtime
->
real_simu_speed_factor
=
realtime
->
last_real_simu_speed_factor
;
// constraints structure
realtime
->
constraints
=
constraints
;
...
...
@@ -694,7 +702,7 @@ void update_simu_realtime(Simu_realtime *realtime)
realtime
->
next_tsim_gate
=
min_next_tsim
;
}
/*! \brief get
f
imulation factor de
f
pending on the 'simu_speed_flag' flag
/*! \brief get
s
imulation factor depending on the 'simu_speed_flag' flag
*
* \param[in] simu_speed_flag index used to compute the speed factor
* \return speed factor
...
...
@@ -715,6 +723,34 @@ double get_simu_speed_factor(int simu_speed_flag)
}
}
/*! \brief get the 'simu_speed_flag' flag depending on simulation factor
*
* \param[in] simu_speed_factor speed factor
* \return index used to compute the speed factor
*/
int
get_simu_speed_flag
(
double
simu_speed_factor
)
{
double
float_flag
;
// safety
if
(
simu_speed_factor
<=
0
.
0
)
{
return
0
;
}
if
(
simu_speed_factor
>=
1
.
0
)
{
float_flag
=
simu_speed_factor
-
1
.
0
;
}
else
{
float_flag
=
-
(
log
(
1
.
0
/
simu_speed_factor
)
/
log
(
2
.
0
));
}
// round to integer
return
((
float_flag
-
floor
(
float_flag
)
>
0
.
5
)
?
ceil
(
float_flag
)
:
floor
(
float_flag
));
}
/*! \brief update the real-time constraints after a break
*
* \param[in,out] realtime real-time structure
...
...
MBsysC/mbs_common/mbs_realtime/realtime/realtime.h
View file @
08131e36
...
...
@@ -59,6 +59,8 @@ typedef struct Realtime_option
int
buffer_size
;
///< size of the buffer for java and sdl
double
init_speed_factor
;
///< initial speed factor
// SDL plots and interactions
int
curve_width
;
///< plot curve width in number of pixels
int
screen_width
;
///< plot screen width in number of pixels
...
...
@@ -164,6 +166,7 @@ void update_simu_realtime(Simu_realtime *realtime);
void
update_realtime_constraint
(
Realtime_constraint
*
constraint
,
int
simu_speed_flag
);
void
update_realtime_constraints_break
(
Simu_realtime
*
realtime
,
int
delta_break_u_sec
);
double
get_simu_speed_factor
(
int
simu_speed_flag
);
int
get_simu_speed_flag
(
double
simu_speed_factor
);
Realtime_option
*
init_Realtime_option
();
void
free_Realtime_option
(
Realtime_option
*
option
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment