-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
135 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
float[12] cals | ||
uint8 sensor | ||
|
||
<enum types uint8_t | ||
accels = 1 | ||
gyros = 2 | ||
mags = 4 | ||
enum> |
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 @@ | ||
include vec | ||
|
||
<enum error uint32_t | ||
none = 0 | ||
accels = 1 | ||
gyros = 2 | ||
mags = 4 | ||
pressure = 8 | ||
temperature = 16 | ||
enum> | ||
|
||
vec accel | ||
vec gyro | ||
vec mag | ||
float pressure | ||
float temperature | ||
uint32 error | ||
uint32 timestamp |
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,26 @@ | ||
float w | ||
float x | ||
float y | ||
float z | ||
|
||
fru fru | ||
|
||
<c | ||
float magnitude() { | ||
return sqrtf(w*w + x*x + y*y + z*z); | ||
} | ||
|
||
vec_t normalize() { | ||
float mag = magnitude(); | ||
return quat_t{w/mag,x/mag,y/mag,z/mag}; | ||
} | ||
c> | ||
|
||
<p | ||
def magnitude(self): | ||
return sqrt(self.x*self.x + self.y*self.y + self.z*self.z) | ||
|
||
def normalize(self): | ||
mag = self.magnitude() | ||
return quat_t(self.w/mag, self.x/mag, self.y/mag, self.z/mag) | ||
p> |
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,19 @@ | ||
float x | ||
float y | ||
float z | ||
|
||
<c | ||
float magnitude() { | ||
return sqrtf(x*x + y*y + z*z); | ||
} | ||
|
||
vec_t normalize() { | ||
float mag = magnitude(); | ||
return vec_t{x/mag,y/mag,z/mag}; | ||
} | ||
c> | ||
|
||
<p | ||
def normalize(self): | ||
return sqrt(self.x*self.x + self.y*self.y + self.z*self.z) | ||
p> |
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,37 @@ | ||
from yivo import * | ||
from collections import namedtuple | ||
import pytest | ||
from numpy import pi, allclose | ||
|
||
from yivo.generator.yivo_gen import main | ||
|
||
def test_generator(): | ||
info = { | ||
"namespace": "foobar", | ||
"license": "MIT Kevin Walchko (c) 2023", | ||
"output": "tmp", | ||
1: "tests/messages/vec.yivo", | ||
2: "tests/messages/quat.yivo", | ||
4: "tests/messages/imu.yivo", | ||
5: "tests/messages/cal.yivo" | ||
} | ||
|
||
main(info) | ||
|
||
from tmp.python.vec_t import vec_t | ||
from tmp.python.base import fmt, cls, sizeof, id2str, msg_id | ||
|
||
v = vec_t(1,2,3) | ||
|
||
assert fmt(v) == "fff" | ||
assert sizeof(v) == 12 | ||
assert cls(v) == vec_t | ||
assert id2str(msg_id(v)) == "vec_t" | ||
|
||
from tmp.python.quat_t import quat_t | ||
|
||
q = quat_t(1,2,3,4) | ||
assert fmt(q) == "ffff" | ||
assert sizeof(q) == 16 | ||
assert cls(q) == quat_t | ||
assert id2str(msg_id(q)) == "quat_t" |
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
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
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