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
45 changes: 45 additions & 0 deletions .github/workflows/ci_pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI Pipeline

on:
push:
branches:
- main
- googletest-framework
- sensor-logging-feature
pull_request:
branches:
- main
- googletest-framework
- sensor-logging-feature
jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive

# Set up CMake
- name: Set up CMake
run: |
sudo apt-get update
sudo apt-get install -y cmake g++

# Configure the build
- name: Configure CMake
run: |
cmake -S . -B build

# Build the project
- name: Build
run: |
cmake --build build

# Run the tests
- name: Run Tests
run: |
cd build
ctest --output-on-failure
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "googletest"]
path = googletest
url = https://github.com/google/googletest.git
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.14)
project(MyProject)

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)

# Add source files
# add_library(MyLibrary src/my_library.cpp)

# Include GoogleTest
add_subdirectory(googletest)

# Enable testing
enable_testing()

# Add unit tests
add_executable(sampleTest tests/sample_test.cpp)
target_link_libraries(sampleTest PRIVATE gtest gtest_main)

# Register the test with CTest
add_test(NAME sampleTest COMMAND sampleTest)
113 changes: 113 additions & 0 deletions docs/test-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# How to Add and Run Tests via CLI

This guide explains how to add new tests to the project and run them via the command line.

---

## Adding Tests

### 1. Create a New Test File
- Navigate to the `tests/` directory.
- Create a new test file with a `.cpp` extension, such as `example_test.cpp`.

### 2. Include the GoogleTest Framework
- At the top of your test file, include the GoogleTest header:

```cpp
#include <gtest/gtest.h>
```

### 3. Write Your Test Cases
- Use the `TEST` macro to define test cases:

```cpp
int Add(int a, int b) {
return a + b;
}

TEST(ExampleTest, Addition) {
EXPECT_EQ(Add(2, 3), 5); // Test that 2 + 3 = 5
EXPECT_EQ(Add(-1, 1), 0); // Test that -1 + 1 = 0
}
```

### 4. Add Your Test File to CMake
- Open the project's `CMakeLists.txt`.
- Add the new test file to the test executable:

```cmake
add_executable(ExampleTest tests/example_test.cpp) # this builds your test executable
target_link_libraries(ExampleTest PRIVATE gtest gtest_main) # this links necessary libraries to your test
add_test(NAME ExampleTest COMMAND ExampleTest) # this adds your test to CTest
```

---

## Building the Tests

### 1. Navigate to the Project Root
- Open a terminal and navigate to the project root directory:

```bash
cd /path/to/project
```

### 2. Create and Enter the `build` Directory
- Run the following commands:

```bash
mkdir -p build
cd build
```

### 3. Run CMake to Configure the Build System
- Configure the project:

```bash
cmake ..
```

### 4. Build the Project
- Build the project, including all tests:

```bash
cmake --build .
```

---

## Running Tests

### 1. Run All Tests
- From the `build/` directory, use `ctest` to run all tests:

```bash
ctest --output-on-failure
```

### 2. Run a Specific Test
- Execute a specific test binary directly:

```bash
./ExampleTest
```

### 3. Debugging Test Failures
- If a test fails, you’ll see detailed output with the failure reason and the file/line number where it occurred.

---

## Example Workflow

### Example Test File (`tests/example_test.cpp`)
```cpp
#include <gtest/gtest.h>

int Multiply(int a, int b) {
return a * b;
}

TEST(MultiplyTest, Basic) {
EXPECT_EQ(Multiply(2, 3), 6);
EXPECT_EQ(Multiply(-1, 5), -5);
}
1 change: 1 addition & 0 deletions googletest
Submodule googletest added at 2b6b04
35 changes: 33 additions & 2 deletions sensors/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
# Sensor
Submodule of McMaster Exoskeleton responsible for receving and sanitizing various sensor input
# Electrical
McMaster Exoskeleton Electrical Repo

**Instructions for setting up and programming a raspberry pi with an IMU sensor:**

Follow the link below (you may need to copy and paste the url into a new tab) for detailed instructions on:
- Connecting the sensors to the raspberry pi
- Connecting your raspberrypi to your laptop or monitor set up with a wired keyboard and mouse peripherals (anything with a USB connection).
- Transferring code to the raspberry pi

https://docs.google.com/document/d/1bPw8EsmMWdXL3RPsF8rNoQGg5wTfWrAu-fDAF66zfOI/edit?usp=sharing

Once you complete all the steps in the document above you are ready to start coding. To start, you're going to want to download the necessary files and running the driver file. The easiest way to access what you need is by logging on to Github using the browser on the pi and downloading `bno055.h`, `bno055.c`(containing the api) and the `driver.cpp` file if they're not already on the pi. Make sure that they are all in the same folder, and you can open them in the Geany editor which should already be on the pi if you want to make changes to the files.

The driver file in this repo, is configured to read values from one sensor (as of January 29 2025). This will be updated in the future. To run the file you will need to open up the terminal and run the command:

`g++ -o drivertest driver.cpp bno055.c -lwiringPi`

This should compile the driver file with the API. Then use the command `./drivertest` in the terminal to run the program.

Note: You may encounter warnings when compiling the driver file but they don't affect the output of the program, so it's still fine to run the program.

Now the program should run, which will continuously print all 8 types of measurements with a short delay.

If there are any other sensor-specific function you need to access to, or if you want to see how the functions called in the driver file are defined. You will have to search for them in the API.
However, it is almost 20,000 lines so you will need to know the names of the functions your looking for and use Ctrl+f to find them.


Happy sensing lol




Loading