-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.cpp
40 lines (33 loc) · 743 Bytes
/
model.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "ffll/FFLLAPI.h"
#include "model.h"
char Model::torcs_base[256];
void Model::set_base(const char *base)
{
sprintf(torcs_base, "%s/%s", getenv("HOME"), base);
}
Model::Model(const char *name)
{
char path[256];
sprintf(path, "%s/%s", torcs_base, name);
model = ffll_new_model();
if(ffll_load_fcl_file(model, path) < 0) {
fprintf(stderr, "Model::load_fcl: %s\n", ffll_get_msg_text(model));
exit(1);
}
child = ffll_new_child(model);
}
Model::~Model()
{
ffll_close_model(model);
}
void Model::set(const int var, const float value)
{
ffll_set_value(model, child, var, value);
}
float Model::compute()
{
return ffll_get_output_value(model, child);
}