Skip to content

Commit 9802798

Browse files
committed
Rename proto to xyz
1 parent c4e9cab commit 9802798

File tree

290 files changed

+278
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+278
-175
lines changed

Makefile

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ MKFILE_PATH=$(abspath $(lastword $(MAKEFILE_LIST)))
22
PROJ_PATH=$(patsubst %/,%,$(dir $(MKFILE_PATH)))
33
CATKIN_WS=~/catkin_ws
44

5-
.PHONY: third_party docs build install tests ci run_test_proto clean
5+
.PHONY: third_party docs build install tests ci run_test_xyz clean
66

77
help:
88
@echo "\033[1;34m[make targets]:\033[0m"
@@ -22,17 +22,17 @@ docs: ## Build docs
2222
@rm -rf docs/build
2323
@sphinx-autobuild docs/source docs/build/html
2424

25-
build: ## Build libproto
26-
@cd proto && make -s libproto
25+
build: ## Build libxyz
26+
@cd xyz && make -s libxyz
2727

28-
install: build ## Install libproto
29-
@cd proto && make -s install
28+
install: build ## Install libxyz
29+
@cd xyz && make -s install
3030

3131
tests: ## Run unittests
32-
@cd proto && make -s tests
32+
@cd xyz && make -s tests
3333

3434
ci: ## Run CI tests
35-
@cd proto && make -s ci
35+
@cd xyz && make -s ci
3636

3737
clean: ## Clean
38-
@cd proto && make -s clean
38+
@cd xyz && make -s clean

proto/Makefile xyz/Makefile

+28-28
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CUR_DIR := $(shell pwd)
33
BLD_DIR := build
44
INC_DIR := $(realpath $(PWD))
55
DEPS_DIR := $(realpath ../third_party)
6-
PREFIX := /opt/proto
6+
PREFIX := /opt/xyz
77
PYTHON3_PATH := $(shell python3 -c "import site; print(site.getsitepackages()[0])")
88

99

@@ -34,7 +34,7 @@ ASSIMP_LDFLAGS := -lassimp
3434

3535
APRILTAG_LDFLAGS := -L$(DEPS_DIR)/lib -lapriltag
3636
YAML_LDFLAGS := -lyaml
37-
PROTO_LDFLAGS := -L$(BLD_DIR) -lproto
37+
XYZ_LDFLAGS := -L$(BLD_DIR) -lxyz
3838

3939

4040
# CFLAGS
@@ -67,7 +67,7 @@ CFLAGS += \
6767
RPATH := -Wl,-rpath,$(DEPS_DIR)/lib
6868
LDFLAGS= \
6969
$(RPATH) \
70-
$(PROTO_LDFLAGS) \
70+
$(XYZ_LDFLAGS) \
7171
$(CERES_LDFLAGS) \
7272
$(APRILTAG_LDFLAGS) \
7373
$(OPENGL_LDFLAGS) \
@@ -88,17 +88,17 @@ ARFLAGS = rvs
8888

8989

9090
# TARGETS
91-
LIBPROTO := $(BLD_DIR)/libproto.a
92-
LIBPROTO_OBJS := \
93-
$(BLD_DIR)/proto.o \
91+
LIBXYZ := $(BLD_DIR)/libxyz.a
92+
LIBXYZ_OBJS := \
93+
$(BLD_DIR)/xyz.o \
9494
$(BLD_DIR)/aprilgrid.o \
9595
$(BLD_DIR)/euroc.o \
9696
$(BLD_DIR)/gui.o \
9797
$(BLD_DIR)/sbgc.o \
9898
$(BLD_DIR)/ceres_bridge.o
9999

100100
TESTS := \
101-
test_proto \
101+
test_xyz \
102102
test_aprilgrid \
103103
test_sbgc \
104104
test_ubx
@@ -120,11 +120,11 @@ $(BLD_DIR)/ceres_bridge.o: ceres_bridge.cpp Makefile
120120
@echo "CXX [ceres_bridge.c]"
121121
@g++ -Wall -O3 -c ceres_bridge.cpp -o $(BLD_DIR)/ceres_bridge.o -I/usr/include/eigen3
122122

123-
$(BLD_DIR)/libproto.a: $(LIBPROTO_OBJS)
124-
@echo "AR [libproto.a]"
123+
$(BLD_DIR)/libxyz.a: $(LIBXYZ_OBJS)
124+
@echo "AR [libxyz.a]"
125125
@$(AR) $(ARFLAGS) \
126-
$(BLD_DIR)/libproto.a \
127-
$(LIBPROTO_OBJS) \
126+
$(BLD_DIR)/libxyz.a \
127+
$(LIBXYZ_OBJS) \
128128
> /dev/null 2>&1
129129

130130
setup:
@@ -135,35 +135,35 @@ setup:
135135
clean: ## Clean build directory
136136
@rm -rf $(BLD_DIR)
137137

138-
libproto: setup $(BLD_DIR)/libproto.a ## Compile libproto
138+
libxyz: setup $(BLD_DIR)/libxyz.a ## Compile libxyz
139139

140-
install: ## Install libproto
140+
install: ## Install libxyz
141141
mkdir -p $(PREFIX)
142142
mkdir -p $(PREFIX)/lib
143143
mkdir -p $(PREFIX)/include
144-
ln -sf $(CUR_DIR)/build/libproto.a $(PREFIX)/lib/libproto.a
144+
ln -sf $(CUR_DIR)/build/libxyz.a $(PREFIX)/lib/libxyz.a
145145
ln -sf $(CUR_DIR)/aprilgrid.h $(PREFIX)/include/aprilgrid.h
146146
ln -sf $(CUR_DIR)/ceres_bridge.h $(PREFIX)/include/ceres_bridge.h
147147
ln -sf $(CUR_DIR)/euroc.h $(PREFIX)/include/euroc.h
148148
ln -sf $(CUR_DIR)/gui.h $(PREFIX)/include/gui.h
149149
ln -sf $(CUR_DIR)/http.h $(PREFIX)/include/http.h
150-
ln -sf $(CUR_DIR)/proto.h $(PREFIX)/include/proto.h
150+
ln -sf $(CUR_DIR)/xyz.h $(PREFIX)/include/xyz.h
151151
ln -sf $(CUR_DIR)/sbgc.h $(PREFIX)/include/sbgc.h
152152
ln -sf $(CUR_DIR)/stb_image.h $(PREFIX)/include/stb_image.h
153-
ln -sf $(CUR_DIR)/proto.py $(PYTHON3_PATH)/proto.py
153+
ln -sf $(CUR_DIR)/xyz.py $(PYTHON3_PATH)/xyz.py
154154

155-
uninstall: ## Uninstall libproto
156-
rm $(PREFIX)/lib/libproto.a
155+
uninstall: ## Uninstall libxyz
156+
rm $(PREFIX)/lib/libxyz.a
157157
rm $(PREFIX)/include/aprilgrid.h
158158
rm $(PREFIX)/include/euroc.h
159159
rm $(PREFIX)/include/gui.h
160160
rm $(PREFIX)/include/http.h
161-
rm $(PREFIX)/include/proto.h
161+
rm $(PREFIX)/include/xyz.h
162162
rm $(PREFIX)/include/sbgc.h
163163
rm $(PREFIX)/include/stb_image.h
164-
rm $(PYTHON3_PATH)/proto.py
164+
rm $(PYTHON3_PATH)/xyz.py
165165

166-
avs: $(BLD_DIR)/libproto.a
166+
avs: $(BLD_DIR)/libxyz.a
167167
@g++ \
168168
-std=c++17 \
169169
-fsanitize=address -static-libasan \
@@ -175,13 +175,13 @@ avs: $(BLD_DIR)/libproto.a
175175
avs.cpp \
176176
-o $(BLD_DIR)/avs \
177177
$(LDFLAGS) \
178-
-lproto \
178+
-lxyz \
179179
$(shell pkg-config opencv4 --libs)
180180

181-
test_proto: libproto ## Compile test_proto
181+
test_xyz: libxyz ## Compile test_xyz
182182
@echo "CC [$@]"
183-
@$(CC) $(CFLAGS) test_proto.c -o $(BLD_DIR)/test_proto $(LDFLAGS)
184-
./build/test_proto --target $(TEST_TARGET)
183+
@$(CC) $(CFLAGS) test_xyz.c -o $(BLD_DIR)/test_xyz $(LDFLAGS)
184+
./build/test_xyz --target $(TEST_TARGET)
185185

186186
test_aprilgrid: ## Compile test_aprilgrid
187187
@echo "CC [$@]"
@@ -212,8 +212,8 @@ test_http: ## Compile test_http
212212
@$(CC) $(CFLAGS) test_http.c -o $(BLD_DIR)/test_http $(LDFLAGS)
213213
@./build/test_http
214214

215-
tests: test_proto test_aprilgrid test_sbgc test_ubx
215+
tests: test_xyz test_aprilgrid test_sbgc test_ubx
216216

217217
ci:
218-
@$(CC) $(CFLAGS) -DMU_REDIRECT_STREAMS=1 test_proto.c -o $(BLD_DIR)/test_proto $(LDFLAGS)
219-
@./build/test_proto
218+
@$(CC) $(CFLAGS) -DMU_REDIRECT_STREAMS=1 test_xyz.c -o $(BLD_DIR)/test_xyz $(LDFLAGS)
219+
@./build/test_xyz

proto/aprilgrid.c xyz/aprilgrid.c

File renamed without changes.

proto/aprilgrid.h xyz/aprilgrid.h

File renamed without changes.

proto/avs.cpp xyz/avs.cpp

File renamed without changes.

proto/avs.hpp xyz/avs.hpp

File renamed without changes.
File renamed without changes.
File renamed without changes.

proto/euroc.c xyz/euroc.c

File renamed without changes.

proto/euroc.h xyz/euroc.h

File renamed without changes.

proto/gui.c xyz/gui.c

File renamed without changes.

proto/gui.h xyz/gui.h

+63-4
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void gl_camera_zoom(gl_camera_t *camera,
264264
* GL-PRIMITIVES
265265
*****************************************************************************/
266266

267-
void gl_triangle_setup(gl_entity_t *entity, GLfloat pos[3]);
267+
void gl_triangle_setup(gl_entity_t *entity);
268268
void gl_triangle_cleanup(const gl_entity_t *entity);
269269
void gl_triangle_draw(const gl_entity_t *entity, const gl_camera_t *camera);
270270

@@ -398,9 +398,6 @@ void gui_loop(gui_t *gui);
398398
#include "stb_image_write.h"
399399
#endif
400400

401-
// #define GLAD_GL_IMPLEMENTATION
402-
// #include "glad.h"
403-
404401
// /**
405402
// * Tic, start timer.
406403
// * @returns A timespec encapsulating the time instance when tic() is called
@@ -1132,6 +1129,64 @@ void gl_camera_zoom(gl_camera_t *camera,
11321129
* GL-PRIMITIVES
11331130
*****************************************************************************/
11341131

1132+
void gl_triangle_setup(gl_entity_t *entity) {
1133+
// Entity transform
1134+
gl_eye(entity->T, 4, 4);
1135+
1136+
// Shader program
1137+
char *vs = load_file("./shaders/triangle.vert");
1138+
char *fs = load_file("./shaders/triangle.frag");
1139+
entity->program_id = gl_prog_setup(vs, fs, NULL);
1140+
free(vs);
1141+
free(fs);
1142+
if (entity->program_id == GL_FALSE) {
1143+
FATAL("Failed to create shaders to draw cube!");
1144+
}
1145+
1146+
// Vertices
1147+
const float vertices[] = {-0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f, 0.0f, 0.5f, 0.0f};
1148+
const int num_vertices = 3;
1149+
const size_t vertex_buffer_size = sizeof(float) * 3 * num_vertices;
1150+
1151+
// VAO
1152+
glGenVertexArrays(1, &entity->vao);
1153+
glBindVertexArray(entity->vao);
1154+
1155+
// VBO
1156+
glGenBuffers(1, &entity->vbo);
1157+
glBindBuffer(GL_ARRAY_BUFFER, entity->vbo);
1158+
glBufferData(GL_ARRAY_BUFFER, vertex_buffer_size, vertices, GL_STATIC_DRAW);
1159+
// -- Position attribute
1160+
size_t vertex_size = 3 * sizeof(float);
1161+
void *pos_offset = (void *) 0;
1162+
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, vertex_size, pos_offset);
1163+
glEnableVertexAttribArray(0);
1164+
// -- Color attribute
1165+
// void *color_offset = (void *) (3 * sizeof(float));
1166+
// glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, vertex_size, color_offset);
1167+
// glEnableVertexAttribArray(1);
1168+
1169+
// Clean up
1170+
glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind VBO
1171+
glBindVertexArray(0); // Unbind VAO
1172+
}
1173+
1174+
void gl_triangle_cleanup(const gl_entity_t *entity) {
1175+
glDeleteVertexArrays(1, &entity->vao);
1176+
glDeleteBuffers(1, &entity->vbo);
1177+
}
1178+
1179+
void gl_triangle_draw(const gl_entity_t *entity, const gl_camera_t *camera) {
1180+
glUseProgram(entity->program_id);
1181+
// gl_prog_set_mat4f(entity->program_id, "projection", camera->P);
1182+
// gl_prog_set_mat4f(entity->program_id, "view", camera->V);
1183+
// gl_prog_set_mat4f(entity->program_id, "model", entity->T);
1184+
1185+
glBindVertexArray(entity->vao);
1186+
glDrawArrays(GL_TRIANGLES, 0, 3);
1187+
glBindVertexArray(0);
1188+
}
1189+
11351190
void gl_cube_setup(gl_entity_t *entity, GLfloat pos[3]) {
11361191
// Entity transform
11371192
gl_eye(entity->T, 4, 4);
@@ -2206,6 +2261,9 @@ void gui_loop(gui_t *gui) {
22062261
gl_entity_t cf;
22072262
gl_camera_frame_setup(&cf);
22082263

2264+
gl_entity_t triangle;
2265+
gl_triangle_setup(&triangle);
2266+
22092267
// gl_entity_t frame;
22102268
// gl_axis_frame_setup(&frame);
22112269

@@ -2229,6 +2287,7 @@ void gui_loop(gui_t *gui) {
22292287
// gl_camera_frame_draw(&cf, &gui->camera);
22302288
// gl_axis_frame_draw(&frame, &gui->camera);
22312289
gl_grid_draw(&grid, &gui->camera);
2290+
gl_triangle_draw(&triangle, &gui->camera);
22322291
// gl_model_draw(model, &gui->camera);
22332292

22342293
glBegin(GL_QUADS);

proto/http.h xyz/http.h

File renamed without changes.

proto/munit.h xyz/munit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static char *test_target_name = NULL;
3131
#endif
3232

3333
#ifndef MU_ENABLE_PRINT
34-
#define MU_ENABLE_PRINT 0
34+
#define MU_ENABLE_PRINT 1
3535
#endif
3636

3737
/* TERMINAL COLORS */

proto/sbgc.c xyz/sbgc.c

File renamed without changes.

proto/sbgc.h xyz/sbgc.h

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

proto/stb_image.h xyz/stb_image.h

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

proto/test_gui.c xyz/test_gui.c

File renamed without changes.

proto/test_http.c xyz/test_http.c

File renamed without changes.

proto/test_sbgc.c xyz/test_sbgc.c

File renamed without changes.

proto/test_tis.c xyz/test_tis.c

File renamed without changes.

proto/test_ubx.c xyz/test_ubx.c

File renamed without changes.

proto/test_proto.c xyz/test_xyz.c

+31-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "proto.h"
1+
#include "xyz.h"
22
#include "munit.h"
33
#include "stb_ds.h"
44

@@ -4506,7 +4506,7 @@ static void free_imu_test_data(imu_test_data_t *test_data) {
45064506
int test_imu_propagate() {
45074507
// Setup test data
45084508
imu_test_data_t test_data;
4509-
setup_imu_test_data(&test_data, 5.0, 1.0);
4509+
setup_imu_test_data(&test_data, 1.0, 0.1);
45104510

45114511
// Setup IMU buffer
45124512
const int n = 100;
@@ -4717,7 +4717,7 @@ int test_imu_factor() {
47174717
setup_imu_test_data(&test_data, circle_r, circle_v);
47184718

47194719
// Setup IMU buffer
4720-
int buf_size = 20;
4720+
int buf_size = 100;
47214721
imu_buffer_t imu_buf;
47224722
imu_buffer_setup(&imu_buf);
47234723
for (int k = 0; k < buf_size; k++) {
@@ -4760,6 +4760,10 @@ int test_imu_factor() {
47604760
imu_params.sigma_gw = 2.0e-6;
47614761
imu_params.g = 9.81;
47624762

4763+
pose_j.data[0] += 0.01;
4764+
pose_j.data[1] += 0.02;
4765+
pose_j.data[2] += 0.03;
4766+
47634767
imu_factor_t factor;
47644768
imu_factor_setup(&factor,
47654769
&imu_params,
@@ -4774,13 +4778,25 @@ int test_imu_factor() {
47744778

47754779
// print_vector("pose_i", pose_i.data, 7);
47764780
// print_vector("pose_j", pose_j.data, 7);
4781+
// print_vector("vel_i", vel_i.data, 3);
4782+
// print_vector("vel_j", vel_j.data, 3);
47774783
// print_vector("dr", factor.dr, 3);
47784784
// print_vector("dv", factor.dv, 3);
47794785
// print_vector("dq", factor.dq, 4);
47804786
// printf("dt: %f\n", factor.Dt);
47814787
// print_vector("r", factor.r, 15);
4782-
mat_save("/tmp/F_.csv", factor.F, 15, 15);
4783-
// mat_save("/tmp/P_.csv", factor.P, 15, 15);
4788+
mat_save("/tmp/F.csv", factor.F, 15, 15);
4789+
mat_save("/tmp/P.csv", factor.P, 15, 15);
4790+
mat_save("/tmp/r.csv", factor.r, 15, 1);
4791+
mat_save("/tmp/pose_i.csv", factor.params[0], 7, 1);
4792+
mat_save("/tmp/vel_i.csv", factor.params[1], 3, 1);
4793+
mat_save("/tmp/pose_j.csv", factor.params[3], 7, 1);
4794+
mat_save("/tmp/vel_j.csv", factor.params[4], 3, 1);
4795+
4796+
for (int i =0; i < 15; i++) {
4797+
printf("%.4e\n", factor.r[i]);
4798+
}
4799+
printf("\n");
47844800

47854801
/*
47864802
const char *cmd = "\
@@ -4810,14 +4826,14 @@ ginput();\
48104826
system(syscmd);
48114827
*/
48124828

4813-
MU_ASSERT(factor.pose_i == &pose_i);
4814-
MU_ASSERT(factor.vel_i == &vel_i);
4815-
MU_ASSERT(factor.biases_i == &biases_i);
4816-
MU_ASSERT(factor.pose_i == &pose_i);
4817-
MU_ASSERT(factor.vel_j == &vel_j);
4818-
MU_ASSERT(factor.biases_j == &biases_j);
4819-
4820-
// Check Jacobians
4829+
// MU_ASSERT(factor.pose_i == &pose_i);
4830+
// MU_ASSERT(factor.vel_i == &vel_i);
4831+
// MU_ASSERT(factor.biases_i == &biases_i);
4832+
// MU_ASSERT(factor.pose_i == &pose_i);
4833+
// MU_ASSERT(factor.vel_j == &vel_j);
4834+
// MU_ASSERT(factor.biases_j == &biases_j);
4835+
//
4836+
// // Check Jacobians
48214837
// const double tol = 1e-4;
48224838
// const double step_size = 1e-8;
48234839
// eye(factor.sqrt_info, 15, 15);
@@ -5587,7 +5603,7 @@ int test_visual_odometry_batch() {
55875603
int test_inertial_odometry_batch() {
55885604
// Setup test data
55895605
imu_test_data_t test_data;
5590-
setup_imu_test_data(&test_data, 1.0, 1.0);
5606+
setup_imu_test_data(&test_data, 1.0, 0.1);
55915607

55925608
// Inertial Odometry
55935609
const int num_partitions = test_data.num_measurements / 20.0;
@@ -8372,7 +8388,7 @@ void test_suite() {
83728388
MU_ADD_TEST(test_calib_gimbal_factor);
83738389
MU_ADD_TEST(test_marg);
83748390
// MU_ADD_TEST(test_visual_odometry_batch);
8375-
// MU_ADD_TEST(test_inertial_odometry_batch);
8391+
MU_ADD_TEST(test_inertial_odometry_batch);
83768392
// MU_ADD_TEST(test_visual_inertial_odometry_batch);
83778393
// MU_ADD_TEST(test_tsf);
83788394
#ifdef USE_CERES

proto/tis.c xyz/tis.c

File renamed without changes.

proto/tis.h xyz/tis.h

File renamed without changes.

proto/ubx.c xyz/ubx.c

File renamed without changes.

proto/ubx.h xyz/ubx.h

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)