-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from baylessj/wasm
Check path validity in GUI
- Loading branch information
Showing
18 changed files
with
3,342 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,3 +68,5 @@ plz-out | |
|
||
**.eslintcache | ||
coverage.info | ||
.next | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/bin/bash | ||
find include/ -iname *.hpp | xargs clang-format -i -style=file | ||
find src/ -iname *.cpp | xargs clang-format -i -style=file | ||
find tst/ -iname *.cpp | xargs clang-format -i -style=file | ||
find main/include/ -iname *.hpp | xargs clang-format -i -style=file | ||
find main/src/ -iname *.cpp | xargs clang-format -i -style=file | ||
find main/test/ -iname *.cpp | xargs clang-format -i -style=file | ||
find main/viscompat/ -iname *.cpp | xargs clang-format -i -style=file | ||
find wasm/ -iname *.cpp | xargs clang-format -i -style=file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
genrule( | ||
name = "gen_test", | ||
srcs = ["web_shim.cpp", "//main:squiggles_srcs"], | ||
outs = [ | ||
"squiggles.js", | ||
], | ||
cmd = [ | ||
"./tools/emsdk/upstream/emscripten/emcc $SRCS -s DISABLE_EXCEPTION_CATCHING=2 -s WASM=1 -s MODULARIZE=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]' -s EXPORT_NAME=\"'squiggles'\" -s SINGLE_FILE=1 -I main/include --std=gnu++17 -o squiggles.js", | ||
"cp squiggles.js ../../../../web/public/js/squiggles.js", | ||
], | ||
deps = [ | ||
# pulling in the squiggles source directly since we need to rebuild the | ||
# library with emcc rather than gcc to link properly | ||
"//main:squiggles_srcs", | ||
"//main:squiggles_hdrs", | ||
"//tools:emcc_lib", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include "emscripten.h" | ||
#include "squiggles.hpp" | ||
#include <exception> | ||
|
||
using namespace squiggles; | ||
|
||
extern "C" { | ||
|
||
EMSCRIPTEN_KEEPALIVE | ||
double linvels() { | ||
auto model = std::make_shared<TankModel>(0.4, Constraints(1.0)); | ||
return model->linear_to_wheel_vels(1.0, 1.0)[0]; | ||
} | ||
|
||
// struct GenerateOutput { | ||
// double x; | ||
// double y; | ||
// double yaw; | ||
// double vel; | ||
// double wheel_0; | ||
// double wheel_1; | ||
// double curvature; | ||
// }; | ||
|
||
// EMSCRIPTEN_KEEPALIVE | ||
// std::vector<GenerateOutput> generate(double sx, | ||
// double sy, | ||
// double syaw, | ||
// double sv, | ||
// double gx, | ||
// double gy, | ||
// double gyaw, | ||
// double gv, | ||
// double max_vel, | ||
// double max_accel, | ||
// double max_jerk, | ||
// double track_width) { | ||
// if (!sx) return std::vector<GenerateOutput>(); | ||
// auto constraints = Constraints(max_vel, max_accel, max_jerk); | ||
// auto model = std::make_shared<TankModel>(track_width, constraints); | ||
// auto spline = SplineGenerator(constraints, model, 0.1); | ||
// auto path = spline.generate({ControlVector(Pose(sx, sy, syaw), sv, 0), | ||
// ControlVector(Pose(gx, gy, gyaw), gv, 0)}); | ||
// std::vector<GenerateOutput> out; | ||
// for (auto p : path) { | ||
// out.push_back(GenerateOutput({p.vector.pose.x, | ||
// p.vector.pose.y, | ||
// p.vector.pose.yaw, | ||
// p.vector.vel, | ||
// p.wheel_velocities[0], | ||
// p.wheel_velocities[1], | ||
// p.curvature})); | ||
// } | ||
// return out; | ||
// } | ||
|
||
EMSCRIPTEN_KEEPALIVE | ||
int generate(double sx, | ||
double sy, | ||
double syaw, | ||
double sv, | ||
double gx, | ||
double gy, | ||
double gyaw, | ||
double gv, | ||
double max_vel, | ||
double max_accel, | ||
double max_jerk, | ||
double track_width) { | ||
if (!sx) | ||
return 1; | ||
auto constraints = Constraints(max_vel, max_accel, max_jerk); | ||
auto model = std::make_shared<TankModel>(track_width, constraints); | ||
auto spline = SplineGenerator(constraints, model, 0.1); | ||
// we can't catch exceptions here for some reason, relying on the web client | ||
// to do that for us | ||
auto path = spline.generate({ControlVector(Pose(sx, sy, syaw), sv, 0), | ||
ControlVector(Pose(gx, gy, gyaw), gv, 0)}); | ||
// for (auto p: path) { | ||
// printf("%s\n", p.to_string().c_str()); | ||
// } | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.