Skip to content
Draft

CRA #69

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
35 changes: 8 additions & 27 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
FROM ubuntu:latest

# Set environment variables for non-interactive installation and set micromamba paths
ENV DEBIAN_FRONTEND=noninteractive \
MAMBA_ROOT_PREFIX=/opt/micromamba \
PATH=/opt/micromamba/bin:$PATH \
MAMBA_DOCKERFILE_ACTIVATE=1
# Set environment variables for non-interactive installation
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies and micromamba
RUN apt-get update && apt-get -y upgrade && \
apt-get install -y --no-install-recommends \
curl \
ca-certificates \
bzip2 && \
curl -L https://micromamba.snakepit.net/api/micromamba/linux-64/latest | \
tar -xvj -C /usr/local/bin --strip-components=1 bin/micromamba

# Initialize micromamba for all future shells (important)
RUN echo 'eval "$(micromamba shell hook --shell bash)"' >> /etc/bash.bashrc
# Install ca-certificates for HTTPS support in install.sh
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*

# Clean up micromamba install tools and continue with other packages
RUN apt-get purge -y curl bzip2 && \
apt-get autoremove -y && \
apt-get clean

# Copy the install script into the container
COPY install.sh /tmp/install.sh

# Run the script with loggin on and remove it in a single layer
RUN chmod +x /tmp/install.sh && /tmp/install.sh || (cat /tmp/install.log && exit 1) && \
rm -f /tmp/install.sh /tmp/install.log && \
rm -rf /var/lib/apt/lists/*

RUN chmod +x /tmp/install.sh && /tmp/install.sh && \
rm -f /tmp/install.sh
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"service": "dev",
"workspaceFolder": "/workspace",
"overrideCommand": true,
"postCreateCommand": "git config --global user.name \"${GIT_AUTHOR_NAME:-Your Name}\" && git config --global user.email \"${GIT_AUTHOR_EMAIL:-you@example.com}\" && /workspace/tools/setup-tools-envs.sh && /workspace/build.sh cmake",
"postCreateCommand": "git config --global user.name \"${GIT_AUTHOR_NAME:-Your Name}\" && git config --global user.email \"${GIT_AUTHOR_EMAIL:-you@example.com}\"",
"shutdownAction": "stopCompose"
}
3 changes: 0 additions & 3 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ services:
dockerfile: .devcontainer/Dockerfile
volumes:
- ..:/workspace:cached
- micromamba-data:/opt/micromamba
command: sleep infinity
volumes:
micromamba-data:
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,29 @@ add_library(${STB_IMAGE} STATIC ${STB_IMAGE_SRC})
target_compile_definitions(${STB_IMAGE} PRIVATE STB_IMAGE_IMPLEMENTATION)
target_include_directories(${STB_IMAGE} PUBLIC $<BUILD_INTERFACE:${CACHE_DIR}>)

##### Eigen #####

# Disable Eigen's own tests and docs to speed up configuration
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
set(EIGEN_BUILD_DOC OFF CACHE BOOL "" FORCE)
set(EIGEN_BUILD_PKGCONFIG OFF CACHE BOOL "" FORCE)

FetchContent_Declare(
eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.4.0
GIT_SHALLOW ON
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(eigen)

# Set the source libraries
set(SRC_LIBS ${STB_IMAGE})

##### FOUND Library #####

add_library(found_lib STATIC ${FILTERED_SRC})
target_link_libraries(found_lib PRIVATE ${STB_IMAGE})
target_link_libraries(found_lib PUBLIC Eigen3::Eigen PRIVATE ${STB_IMAGE})
target_include_directories(found_lib
PUBLIC
$<BUILD_INTERFACE:${SRC_DIR}>
Expand Down Expand Up @@ -220,6 +236,7 @@ add_executable(found-test EXCLUDE_FROM_ALL ${TEST} ${FILTERED_SRC})
target_compile_definitions(found-test PRIVATE ENABLE_LOGGING
LOGGING_LEVEL=INFO)
target_compile_options(found-test PRIVATE
-Wdouble-promotion -Werror
--coverage
-pthread
$<$<NOT:$<BOOL:${OMIT_ASAN}>>:-fsanitize=address>
Expand All @@ -228,6 +245,7 @@ target_compile_options(found-test PRIVATE
target_link_libraries(found-test PRIVATE
--coverage
${TEST_LIBS}
Eigen3::Eigen
$<$<NOT:$<BOOL:${OMIT_ASAN}>>:-fsanitize=address>
$<$<NOT:$<BOOL:${OMIT_ASAN}>>:-fomit-frame-pointer>)
set_target_properties(found-test PROPERTIES
Expand Down
25 changes: 20 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ DOXYGEN_AWESOME_URL := https://github.com/jothepro/$(DOXYGEN_AWESOME)/archive/re
DOXYGEN_AWESOME_ZIP := $(CACHE_DIR)/v$(DOXYGEN_AWESOME_VERSION).tar.gz
DOXYGEN_AWESOME_ARTIFACT := $(CACHE_DIR)/$(DOXYGEN_AWESOME)-$(DOXYGEN_AWESOME_VERSION)

# Define the Eigen library
EIGEN := eigen
EIGEN_VERSION := 3.4.0
EIGEN_URL := https://gitlab.com/libeigen/eigen/-/archive/$(EIGEN_VERSION)/eigen-$(EIGEN_VERSION).tar.gz
EIGEN_CACHE_ARTIFACT := $(CACHE_DIR)/eigen-$(EIGEN_VERSION).tar.gz
EIGEN_CACHE_DIR := $(CACHE_DIR)/eigen-$(EIGEN_VERSION)
EIGEN_DIR := $(BUILD_LIBRARY_SRC_DIR)/eigen-$(EIGEN_VERSION)


# Define all source and test code
SRC := $(shell find $(SRC_DIR) -name "*.cpp")
Expand Down Expand Up @@ -88,8 +96,8 @@ endif
LOGGING_MACROS_TEST := -DENABLE_LOGGING -DLOGGING_LEVEL=INFO

# Compiler flags
LIBS := $(SRC_LIBS) -I$(BUILD_LIBRARY_SRC_DIR)
LIBS_TEST := $(TEST_LIBS) -I$(GTEST_DIR)/$(GTEST)/include -I$(GTEST_DIR)/googlemock/include -pthread
LIBS := $(SRC_LIBS) -I$(BUILD_LIBRARY_SRC_DIR) -isystem $(EIGEN_DIR)
LIBS_TEST := $(TEST_LIBS) -isystem $(EIGEN_DIR) -I$(GTEST_DIR)/$(GTEST)/include -I$(GTEST_DIR)/googlemock/include -pthread
DEBUG_FLAGS := -ggdb -fno-omit-frame-pointer
COVERAGE_FLAGS := --coverage
CXXFLAGS := $(CXXFLAGS) -Wall -Wextra -Wno-missing-field-initializers -Werror -pedantic --std=gnu++17 -MMD $(LIBS) $(FOUND_FLOAT_MODE_MACRO)
Expand Down Expand Up @@ -154,7 +162,7 @@ all: $(COMPILE_SETUP_TARGET) \
$(DOXYGEN_TARGET) \

# The build setup target (sets up appropriate directories)
$(COMPILE_SETUP_TARGET): compile_setup_message $(BUILD_DIR) $(STB_IMAGE_DIR)
$(COMPILE_SETUP_TARGET): compile_setup_message $(BUILD_DIR) $(STB_IMAGE_DIR) $(EIGEN_DIR)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DOCUMENTATION_DIR)
Expand All @@ -173,11 +181,18 @@ $(STB_IMAGE_CACHE_ARTIFACT):
echo '#define STB_IMAGE_IMPLEMENTATION\n#include "stb_image/stb_image.h"' > $(STB_IMAGE_CACHE_ARTIFACT)
$(CXX) -I$(CACHE_DIR) -c $(STB_IMAGE_CACHE_ARTIFACT) -o $(STB_IMAGE_CACHE_DIR)/$(STB_IMAGE).o # Exclude CXXFLAGS because we know its fine

# Eigen header-only library (download and extract)
$(EIGEN_DIR): $(EIGEN_CACHE_ARTIFACT) $(BUILD_LIBRARY_SRC_DIR)
tar -xzf $(EIGEN_CACHE_ARTIFACT) -C $(BUILD_LIBRARY_SRC_DIR)
$(EIGEN_CACHE_ARTIFACT):
mkdir -p $(CACHE_DIR)
wget $(EIGEN_URL) -P $(CACHE_DIR)

# The compile target
$(COMPILE_TARGET): $(COMPILE_SETUP_TARGET) compile_message $(BIN)
$(BIN): $(SRC_OBJS) $(BIN_DIR) $(STB_IMAGE_DIR)
$(BIN): $(SRC_OBJS) $(BIN_DIR) $(STB_IMAGE_DIR) $(EIGEN_DIR)
$(CXX) $(OPTIMIZATION) $(CXXFLAGS) -o $(BIN) $(SRC_OBJS) $(LDFLAGS)
$(BUILD_SRC_DIR)/%.o: $(SRC_DIR)/%.cpp $(STB_IMAGE_DIR)
$(BUILD_SRC_DIR)/%.o: $(SRC_DIR)/%.cpp $(STB_IMAGE_DIR) $(EIGEN_DIR)
mkdir -p $(@D)
$(CXX) $(OPTIMIZATION) $(CXXFLAGS) -c $< -o $@
compile_message:
Expand Down
2 changes: 1 addition & 1 deletion src/calibrate/calibrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace found {

Quaternion LOSTCalibrationAlgorithm::Run(const std::pair<EulerAngles, EulerAngles> &orientations) {
return SphericalToQuaternion(orientations.first) * SphericalToQuaternion(orientations.second).Conjugate();
return SphericalToQuaternion(orientations.first) * SphericalToQuaternion(orientations.second).conjugate();
}

} // namespace found
30 changes: 15 additions & 15 deletions src/command-line/execution/executors.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "command-line/execution/executors.hpp"

#include <algorithm>
#include <memory>
#include <utility>
#include <cstring>

#include "common/logging.hpp"
#include "common/time/time.hpp"
Expand All @@ -26,10 +26,10 @@ void CalibrationPipelineExecutor::ExecutePipeline() {
void CalibrationPipelineExecutor::OutputResults() {
// Output the results of the calibration
Quaternion *&calibrationQuaternion = this->pipeline_.GetProduct();
LOG_INFO("Calibration Quaternion: (" << calibrationQuaternion->real << ", "
<< calibrationQuaternion->i << ", "
<< calibrationQuaternion->j << ", "
<< calibrationQuaternion->k << ")");
LOG_INFO("Calibration Quaternion: (" << calibrationQuaternion->w() << ", "
<< calibrationQuaternion->x() << ", "
<< calibrationQuaternion->y() << ", "
<< calibrationQuaternion->z() << ")");
DataFile outputDF{};
outputDF.relative_attitude = *calibrationQuaternion;
std::ofstream outputFile(this->options_.outputFile);
Expand Down Expand Up @@ -61,10 +61,10 @@ void DistancePipelineExecutor::ExecutePipeline() {

void DistancePipelineExecutor::OutputResults() {
PositionVector *&positionVector = this->pipeline_.GetProduct();
LOG_INFO("Calculated Position: (" << positionVector->x << ", "
<< positionVector->y << ", "
<< positionVector->z << ") m");
LOG_INFO("Distance from Earth: " << positionVector->Magnitude() << " m");
LOG_INFO("Calculated Position: (" << positionVector->x() << ", "
<< positionVector->y() << ", "
<< positionVector->z() << ") m");
LOG_INFO("Distance from Earth: " << positionVector->norm() << " m");
// TODO: Figure out a much more optimized way of doing this please, especially
// since we're saving it into the exact same file, there should be an easy way
// to simply modify the file directly instead of this mess.
Expand All @@ -73,9 +73,9 @@ void DistancePipelineExecutor::OutputResults() {
outputDF.header = this->options_.calibrationData.header;
outputDF.relative_attitude = this->options_.calibrationData.relative_attitude;
outputDF.positions = std::make_unique<LocationRecord[]>(outputDF.header.num_positions + 1);
std::memcpy(outputDF.positions.get(),
this->options_.calibrationData.positions.get(),
outputDF.header.num_positions);
std::copy(this->options_.calibrationData.positions.get(),
this->options_.calibrationData.positions.get() + outputDF.header.num_positions,
outputDF.positions.get());
} else {
outputDF.relative_attitude = SphericalToQuaternion(this->options_.relOrientation);
outputDF.positions = std::make_unique<LocationRecord[]>(1);
Expand Down Expand Up @@ -106,9 +106,9 @@ void OrbitPipelineExecutor::ExecutePipeline() {
void OrbitPipelineExecutor::OutputResults() {
// TODO: Output this somewhere
[[maybe_unused]] LocationRecord &futurePosition = this->pipeline_.GetProduct()->back();
LOG_INFO("Calculated Future Position: (" << futurePosition.position.x << ", "
<< futurePosition.position.y << ", "
<< futurePosition.position.z << ") m"
LOG_INFO("Calculated Future Position: (" << futurePosition.position.x() << ", "
<< futurePosition.position.y() << ", "
<< futurePosition.position.z() << ") m"
<< " at time "
<< futurePosition.timestamp << " s");
}
Expand Down
Loading
Loading