Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python bindings: add collision_avoidance #914

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions bindings/cffirmware.i
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#include "pptraj.h"
#include "planner.h"
#include "stabilizer_types.h"
#include "collision_avoidance.h"
%}

%include "math3d.h"
%include "pptraj.h"
%include "planner.h"
%include "stabilizer_types.h"
%include "collision_avoidance.h"

%inline %{
struct poly4d* piecewise_get(struct piecewise_traj *pp, int i)
Expand All @@ -37,6 +39,41 @@ void poly4d_free(struct poly4d *p)
{
free(p);
}

struct vec vec2svec(struct vec3_s v)
{
return mkvec(v.x, v.y, v.z);
}

struct vec3_s svec2vec(struct vec v)
{
struct vec3_s vv = {
.x = v.x,
.y = v.y,
.z = v.z,
};
return vv;
}

void collisionAvoidanceUpdateSetpointWrap(
collision_avoidance_params_t const *params,
collision_avoidance_state_t *collisionState,
int nOthers,
float const *otherPositions,
setpoint_t *setpoint, sensorData_t const *sensorData, state_t const *state)
{
nOthers /= 3;
float *workspace = malloc(sizeof(float) * 7 * (nOthers + 6));
collisionAvoidanceUpdateSetpointCore(
params,
collisionState,
nOthers,
otherPositions,
workspace,
setpoint, sensorData, state);
free(workspace);
}

%}

%pythoncode %{
Expand Down Expand Up @@ -94,3 +131,7 @@ structname(struct structname const *x) { \
return _cffirmware.vsub(self, other)
%}
};

%extend traj_eval {
COPY_CTOR(traj_eval)
};
3 changes: 2 additions & 1 deletion bindings/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
modules = [
"pptraj.c",
"pptraj_compressed.c",
"planner.c"
"planner.c",
"collision_avoidance.c"
]
fw_sources = [os.path.join(fw_dir, "src/modules/src", mod) for mod in modules]

Expand Down