Skip to content
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
30 changes: 15 additions & 15 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,55 +68,55 @@ jobs:
chmod +rwx ./helper-scripts/project-impl/*.sh && chmod +rwx ./helper-scripts/ci-cd/*.sh

- name: Compiling electrostatic-core Native Binaries
run: sudo ./helper-scripts/ci-cd/compile-electrostatic.sh "-primer"
run: ./helper-scripts/ci-cd/compile-electrostatic.sh "-primer"

- name: Testing electrostatic-core Native Binaries
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "hello_comm.c" "hello-comm"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "hello_comm.c" "hello-comm"

# - name: Testing "hello_vector2d.c"
# run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "hello_vector2d.c" "hello-vec2d"

- name: Testing "hello_contiguous_buffer.c"
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "hello_lists.c" "hello-listadt"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "hello_lists.c" "hello-listadt"

- name: Testing "hello_unittest.c"
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "hello_unittest.c" "hello-unittest"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "hello_unittest.c" "hello-unittest"

- name: Testing "hello_switching_mux.c"
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "hello_switching_mux.c" "hello-switching-mux"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "hello_switching_mux.c" "hello-switching-mux"

- name: Testing Arithmos Calculus (2D Vector Rotation)
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_vec2d_rotation.c" "test_2d_rotation"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_vec2d_rotation.c" "test_2d_rotation"

- name: Testing Arithmos Calculus (3D Gimbal Rotation Sequence)
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_vec3d_rotation.c" "test_3d_rotation"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_vec3d_rotation.c" "test_3d_rotation"

- name: Testing Arithmos Calculus (3D Gimbal Rotation around X-axis)
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_3d_x_gimbal_rotation.c" "test_3d_x_gimbal_rotation"

- name: Testing Arithmos Calculus (3D Gimbal Rotation around Y-axis)
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_3d_y_gimbal_rotation.c" "test_3d_y_gimbal_rotation"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_3d_y_gimbal_rotation.c" "test_3d_y_gimbal_rotation"

- name: Testing Arithmos Calculus (3D Gimbal Rotation around Z-axis)
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_3d_z_gimbal_rotation.c" "test_3d_z_gimbal_rotation"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_3d_z_gimbal_rotation.c" "test_3d_z_gimbal_rotation"

- name: Testing Arithmos Matrix Rotation API
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_3d_mat_gimbal_rotation.c" "test_3d_mat_gimbal_rotation"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_3d_mat_gimbal_rotation.c" "test_3d_mat_gimbal_rotation"

- name: Testing Arithmos Calculus (Matrix Algebra Operations -- mat_product)
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_mat_product.c" "test_mat_product"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_mat_product.c" "test_mat_product"

- name: Testing Arithmos Calculus (Matrix Algebra Operations -- mat_add)
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_matrix_addition.c" "test_mat_addition"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_matrix_addition.c" "test_mat_addition"

- name: Testing Arithmos Calculus (Matrix Algebra Operations -- mat_iterate_elements)
run: sudo ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_matrix_iteration.c" "test_mat_traversal"
run: ./helper-scripts/ci-cd/test-electrostatic.sh "calculus/test_matrix_iteration.c" "test_mat_traversal"

- name: Compiling electrostatic4j Java Binding API
run: sudo ./helper-scripts/ci-cd/compile-e4j.sh
run: ./helper-scripts/ci-cd/compile-e4j.sh

- name: Testing electrostatic4j Java Binding API
run: sudo ./helper-scripts/ci-cd/test-e4j.sh
run: ./helper-scripts/ci-cd/test-e4j.sh

- name: Building Serial4j Framework
run: sudo ./helper-scripts/ci-cd/compile-serial4j.sh
8 changes: 4 additions & 4 deletions helper-scripts/project-impl/compile-all-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ util_module="${electronetsoft}/util/"

./helper-scripts/project-impl/compile-electrostatic.sh \
"${COMMISSION_LIB}" "${CLANG_BIN}" "${CLANGPP_BIN}" "ON" "ON" "OFF" "-O3 -fPIC" \
"--target=${ARM_64}" \
"--target=${ARM_64} -D_ELECTRO_ANDROID" \
"${electrostatic_core_headers}" "${platform_module} ${comm_module} \
${algorithm_module} ${util_module}" "${NULL}" "m;c;dl" "${source_dir}" "android" "${ARM_64}" "${POST_COMPILE_TRUE}"

./helper-scripts/project-impl/compile-electrostatic.sh \
"${COMMISSION_LIB}" "${CLANG_BIN}" "${CLANGPP_BIN}" "ON" "ON" "OFF" "-O3 -fPIC" \
"--target=${ARM_32}" \
"--target=${ARM_32} -D_ELECTRO_ANDROID" \
"${electrostatic_core_headers}" "${platform_module} ${comm_module} \
${algorithm_module} ${util_module}" "${NULL}" "m;c;dl" "${source_dir}" "android" "${ARM_32}" "${POST_COMPILE_TRUE}"

./helper-scripts/project-impl/compile-electrostatic.sh \
"${COMMISSION_LIB}" "${CLANG_BIN}" "${CLANGPP_BIN}" "ON" "ON" "OFF" "-O3 -fPIC" \
"--target=${ANDROID_x86}" \
"--target=${ANDROID_x86} -D_ELECTRO_ANDROID" \
"${electrostatic_core_headers}" "${platform_module} ${comm_module} \
${algorithm_module} ${util_module}" "${NULL}" "m;c;dl" "${source_dir}" "android" "${ANDROID_x86}" "${POST_COMPILE_TRUE}"

./helper-scripts/project-impl/compile-electrostatic.sh \
"${COMMISSION_LIB}" "${CLANG_BIN}" "${CLANGPP_BIN}" "ON" "ON" "OFF" "-O3 -fPIC" \
"--target=${ANDROID_x86_64}" \
"--target=${ANDROID_x86_64} -D_ELECTRO_ANDROID" \
"${electrostatic_core_headers}" "${platform_module} ${comm_module} \
${algorithm_module} ${util_module}" "${NULL}" "m;c;dl" "${source_dir}" "android" "${ANDROID_x86_64}" "${POST_COMPILE_TRUE}"
6 changes: 3 additions & 3 deletions helper-scripts/project-impl/compile-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ electrokio_module="${electrokio}"

./helper-scripts/project-impl/compile-electrostatic.sh \
"${COMMISSION_LIB}" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "ON" "ON" "OFF" "-O3 -fPIC" \
"${TARGET_x86_64}" "${TOOLCHAIN_INCLUDES_x86};${electrostatic_core_headers}" "${platform_module} \
${comm_module} ${algorithm_module} ${util_module} ${electrokio_module}" "${NULL}" "m;pthread;dl" "${source_dir}" \
"${TARGET_x86_64} -D__LINUX_x86_64" "${TOOLCHAIN_INCLUDES_x86};${electrostatic_core_headers}" "${platform_module} \
${comm_module} ${algorithm_module} ${util_module} ${electrokio_module}" "${NULL}" "m;pthread;dl;glfw;GL" "${source_dir}" \
"linux" "${x86_64}" "${POST_COMPILE_TRUE}"

./helper-scripts/project-impl/compile-electrostatic.sh \
"${COMMISSION_LIB}" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "ON" "ON" "OFF" "-O3 -fPIC" \
"${TARGET_x86}" "${TOOLCHAIN_INCLUDES_x86};${electrostatic_core_headers}" "${platform_module} \
"${TARGET_x86} -D__LINUX_x86" "${TOOLCHAIN_INCLUDES_x86};${electrostatic_core_headers}" "${platform_module} \
${comm_module} ${algorithm_module} ${util_module}" "${NULL}" "m;pthread;dl" "${source_dir}" \
"linux" "${x86}" "${POST_COMPILE_TRUE}"
2 changes: 1 addition & 1 deletion helper-scripts/project-impl/compile-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies="$(pwd)/${examples_dir}/dependencies/libs/${SYSTEM_DIR}/${BUILD_DIR
compile "${EXECUTABLE}" "${GCC_BIN_x86}" "${GPP_BIN_x86}" \
"OFF" "OFF" "ON" "${INPUT_COMPILER_OPTIONS}" \
"${TARGET_MACHINE}" "${TOOLCHAIN_INCLUDES_x86};${electrostatic_core_headers}" \
"${examples_dir}" "${sources}" "${dependencies};m;pthread;dl" \
"${examples_dir}" "${sources}" "${dependencies};m;pthread;dl;glfw;GL" \
"${SYSTEM_DIR}/${BUILD_DIR}" "."

cd "${project_root}" || exit $?
15 changes: 14 additions & 1 deletion helper-scripts/setup-environment/setup-sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ source "${setup_avr_toolchains_script}"
# Downloading prerequisite binaries
##
echo "Downloading missing binaries"

sudo apt update
# typically for WSL machines
sudo apt-get install make
sudo apt-get install usbutils
Expand All @@ -24,6 +26,17 @@ sudo apt-get install pulseaudio
sudo apt-get install gcc
sudo apt-get install g++

sudo apt install \
build-essential \
pkg-config \
libgl1-mesa-dev \
libglu1-mesa-dev \
freeglut3-dev \
libglfw3-dev \
libglew-dev

sudo apt update

##
# Prepare the sandbox workspace
##
Expand Down Expand Up @@ -90,4 +103,4 @@ cleanup_ndk
# create_ide_symbol

source "$(pwd)/helper-scripts/setup-environment/create-symbols.sh"
source "$(pwd)/helper-scripts/setup-environment/add-user-to-serial-groups.sh"
source "$(pwd)/helper-scripts/setup-environment/add-user-to-serial-groups.sh"
1 change: 0 additions & 1 deletion sdk/core/src/include/electronetsoft/arithmos/ecs/info.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@ struct rotation_metadata {
matrix *out_orientation;
};

void preprocess_orientator(vector3d *v, vector3d *axis);
status_code init_rotator_gimbal(vector3d axis, matrix orientation,
matrix *__rotator,
vec_component angle);

status_code preprocess_mat3_orientator(vec3d_gimbal, vector3d *);

status_code init_rotator_gimbal(vector3d axis, matrix *__rotator,
vec_component angle,
vec_component *angle1,
vec3d_gimbal *gimbal);

status_code rotate_gimbal(vector3d axis, vec_component angle1,
matrix *__rotator,
status_code rotate_gimbal(vector3d axis, matrix __rotator,
vec3d_gimbal *in_gimbal,
vec3d_gimbal *out_gimbal,
vec3d_processors *procs);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// dissociate this file from the ElectroMIO Library
#if !(defined GIMBAL_VISUALIZER_H && (defined __LINUX_x86 || defined _ELECTRO_MIO || defined _ELECTRO_ANDROID))

#define GIMBAL_VISUALIZER_H

#include <GLFW/glfw3.h>
#include <GL/gl.h>
#include <electronetsoft/arithmos_calculus.h>
#include <electronetsoft/arithmos/vectorspaces/matrix/matrix.h>

typedef struct {
GLFWwindow *window;
int width;
int height;
float rotation_x;
float rotation_y;
float rotation_z;
vec3d_gimbal gimbal;
} gimbal_visualizer;

/* Initialize the OpenGL window and visualizer */
gimbal_visualizer* gimbal_visualizer_init(int width, int height, vec3d_gimbal *gimbal);

/* Update and Render the gimbal visualization */
void gimbal_visualizer_render(gimbal_visualizer *viz, mat3_gimbal *gimbal);
void gimbal_visualizer_update(gimbal_visualizer *viz, mat3_gimbal *mat_gimbal);

/* Check if the visualizer window should close */
int gimbal_visualizer_should_close(gimbal_visualizer *viz);

/* Cleanup and destroy the visualizer */
void gimbal_visualizer_destroy(gimbal_visualizer *viz);

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <math.h>
#include <electronetsoft/arithmos/vectorspaces/matrix/matrix.h>
#include <electronetsoft/util/utilities.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -17,13 +18,16 @@ struct mat3_processors {
mat_processors processors;
void (*on_gimbal_lock_trap)(mat3_gimbal rotated,
vector_gimbal gimbal,
vec_component angle);
vec_component angle,
mat_processors);
};

status_code mat3_translate(matrix, matrix, matrix *, mat_processors);
status_code mat3_rotate(mat3_gimbal m, vector3d axis,
mat3_gimbal *out, vec_component angle,
mat3_processors proc);
status_code mat3_get_axis_orientation(mat3_gimbal m, vector3d axis, vector3d *out);
status_code mat3_get_vector(mat3_gimbal m, vector3d axis, vector3d *out);
#ifdef __cplusplus
};
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ struct vec3d_gimbal {
vec_component y_gimbal;
vec_component z_gimbal;

vec_component delta_x;
vec_component delta_y;
vec_component delta_z;

matrix *orientation;
};

Expand Down Expand Up @@ -102,18 +106,18 @@ extern vector3d VEC3_Z_COMPONENT;

static inline vector_gimbal get_vec_gimbal(vector3d axis) {
if ((axis.x > ___ROTATION_MIN_THRESHOLD) &&
((axis.y >= 0) && (axis.y < 1)) &&
((axis.z >= 0) && (axis.z < 1))) {
((axis.y >= 0) && (axis.y < axis.x)) &&
((axis.z >= 0) && (axis.z < axis.x))) {

return GIMBAL_X;
} else if ((axis.y > ___ROTATION_MIN_THRESHOLD) &&
((axis.x >= 0) && (axis.x < 1)) &&
((axis.z >= 0) && (axis.z < 1))) {
((axis.x >= 0) && (axis.x < axis.y)) &&
((axis.z >= 0) && (axis.z < axis.y))) {

return GIMBAL_Y;
} else if ((axis.z > ___ROTATION_MIN_THRESHOLD) &&
((axis.y >= 0) && (axis.y < 1)) &&
((axis.x >= 0) && (axis.x < 1))) {
((axis.y >= 0) && (axis.y < axis.z)) &&
((axis.x >= 0) && (axis.x < axis.z))) {

return GIMBAL_Z;
}
Expand Down
41 changes: 41 additions & 0 deletions sdk/core/src/include/electronetsoft/util/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <electronetsoft/arithmos/vectorspaces/vector2d/vector2d.h>
#include <electronetsoft/util/types.h>

#define ___DELTA ((float) 1 * vector2d_pow(10.0f, -10.0f))

#ifdef __cplusplus
extern "C" { // disable C++ name mangling by declaring function prototypes
// a C externally linked space
Expand Down Expand Up @@ -100,6 +104,43 @@ static inline typed_pointer get_typed_pointer(void *address, pointer_type type)
return pointer;
}

/**
* @brief Improved spreading: uses a 64-bit Mixer (MurmurHash3 style)
* to distribute entropy across the entire 64-bit range.
*/
static inline status_code spread_64(uint64_t in, uint64_t *out) {
if (rvalue(out) == NULL) {
return EUNDEFINEDBUFFER;
}

in = (in ^ (in >> 30)) * 0xbf58476d1ce4e5b9ULL;
in = (in ^ (in >> 27)) * 0x94d049bb133111ebULL;
in = in ^ (in >> 31);
*out = in;

return PASS;
}

static inline status_code hash_key(const char *key, uint64_t *hash) {
if (rvalue((void *) key) == NULL || rvalue(hash) == NULL) {
return EUNDEFINEDBUFFER;
}

// Use a large prime constant to initialize (FNV-1a style)
uint64_t h = 0xcbf29ce484222325ULL;

// Process every character
for (const char *address = key; *address != '\0'; address++) {
// 1. XOR the character into the hash
h ^= (uint8_t) (*address);
// 2. Multiply by a large prime (this spreads the bits)
h *= 0x100000001b3ULL;
}

// Apply your spread_64 as a finalizer to ensure high entropy
return spread_64(h, hash);
}

#ifdef __cplusplus
};
#endif
Expand Down
Loading
Loading