hello
parent
ec2884bece
commit
d7f23958c1
|
@ -49,7 +49,7 @@ macro(blt_add_project name source type)
|
|||
project(4p78-final-project)
|
||||
endmacro()
|
||||
|
||||
project(4p78-final-project VERSION 0.0.3)
|
||||
project(4p78-final-project VERSION 0.0.4)
|
||||
|
||||
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
||||
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
||||
|
|
51
src/main.cpp
51
src/main.cpp
|
@ -27,7 +27,6 @@
|
|||
#include <emscripten/fetch.h>
|
||||
#endif
|
||||
|
||||
|
||||
blt::gfx::matrix_state_manager global_matrices;
|
||||
blt::gfx::resource_manager resources;
|
||||
blt::gfx::batch_renderer_2d renderer_2d(resources, global_matrices);
|
||||
|
@ -40,30 +39,35 @@ struct parker_json_t
|
|||
{
|
||||
float motorTargetAngle;
|
||||
float position;
|
||||
|
||||
struct anglePID_t
|
||||
{
|
||||
float setpoint;
|
||||
float input;
|
||||
float output;
|
||||
} anglePID;
|
||||
|
||||
struct ypr_t
|
||||
{
|
||||
float yaw;
|
||||
float pitch;
|
||||
float roll;
|
||||
} ypr;
|
||||
|
||||
struct euler_t
|
||||
{
|
||||
float psi;
|
||||
float theta;
|
||||
float phi;
|
||||
} euler;
|
||||
|
||||
struct gravity_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} gravity;
|
||||
|
||||
struct q_t
|
||||
{
|
||||
float x;
|
||||
|
@ -71,24 +75,28 @@ struct parker_json_t
|
|||
float z;
|
||||
float w;
|
||||
} q;
|
||||
|
||||
struct aa_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} aa;
|
||||
|
||||
struct gy_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} gy;
|
||||
|
||||
struct aaReal_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} aaReal;
|
||||
|
||||
struct aaWorld_t
|
||||
{
|
||||
float x;
|
||||
|
@ -97,6 +105,22 @@ struct parker_json_t
|
|||
} aaWorld;
|
||||
};
|
||||
|
||||
std::string send_get_request(const std::string& url)
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
auto* str = static_cast<char*>(EM_ASM_PTR(
|
||||
{ const v = await fetch('$0', { 'credentials': 'omit', 'headers': { 'User-Agent':
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0', 'Accept': '/', 'Accept-Language': 'en-US,en;q=0.5', 'Priority':
|
||||
'u=4' }, 'method': 'GET', 'mode': 'cors' }); if (!v.ok) { throw v.status; } return stringToNewUTF8(await response.text()); },
|
||||
url.c_str()));
|
||||
std::string str_obj{str};
|
||||
free(str);
|
||||
return str_obj;
|
||||
#else
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void check_for_request()
|
||||
{
|
||||
const auto cur_time = blt::system::getCurrentTimeMilliseconds();
|
||||
|
@ -107,30 +131,6 @@ void check_for_request()
|
|||
std::string parker_hates_this{fuck_you};
|
||||
auto cstr = parker_hates_this.c_str();
|
||||
parker_json_t data{};
|
||||
EM_ASM(
|
||||
{
|
||||
const v = await fetch('http://$0/get_stuff', {
|
||||
'credentials': 'omit',
|
||||
'headers': {
|
||||
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0',
|
||||
'Accept': '/',
|
||||
'Accept-Language': 'en-US,en;q=0.5',
|
||||
'Priority': 'u=4'
|
||||
},
|
||||
'method': 'GET',
|
||||
'mode': 'cors'
|
||||
});
|
||||
if (!v.ok) {
|
||||
return v.status;
|
||||
}
|
||||
|
||||
const j = await v.json();
|
||||
const floatArray = j.values;
|
||||
Module.HEAPF32.set(floatArray, $1 >> 2);
|
||||
},
|
||||
cstr,
|
||||
reinterpret_cast<float*>(&data)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,6 @@ void init(const blt::gfx::window_data&)
|
|||
{
|
||||
using namespace blt::gfx;
|
||||
|
||||
|
||||
global_matrices.create_internals();
|
||||
resources.load_resources();
|
||||
renderer_2d.create();
|
||||
|
|
Loading…
Reference in New Issue