Skip to content

Commit d0f64d7

Browse files
authored
Merge pull request #52 from ihsrobotics/refactor
Refactor
2 parents 870367d + 5d3702d commit d0f64d7

File tree

115 files changed

+662
-343
lines changed

Some content is hidden

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

115 files changed

+662
-343
lines changed

.github/workflows/cmake.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,20 @@ jobs:
1818
uses: myrotvorets/[email protected]
1919
with:
2020
token: ${{ secrets.GITHUB_TOKEN }}
21-
# Commit status (one of "error", "failure", "pending", "success")
2221
status: pending
23-
# A short description of the status.
2422
description: awaiting building
2523
context: build-status
24+
2625
- name: set-test-status
2726
uses: myrotvorets/[email protected]
2827
with:
2928
token: ${{ secrets.GITHUB_TOKEN }}
30-
# Commit status (one of "error", "failure", "pending", "success")
3129
status: pending
32-
# A short description of the status.
3330
description: awaiting testing
3431
context: test-status
3532

3633
build-and-test:
3734
needs: setup-status # wait for pending status before starting
38-
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
39-
# You can convert this to a matrix build if you need cross-platform coverage.
40-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
4135
runs-on: ubuntu-latest
4236
steps:
4337
- uses: actions/checkout@v3
@@ -76,9 +70,7 @@ jobs:
7670
uses: myrotvorets/[email protected]
7771
with:
7872
token: ${{ secrets.GITHUB_TOKEN }}
79-
# Commit status (one of "error", "failure", "pending", "success")
8073
status: success
81-
# A short description of the status.
8274
description: build successful
8375
context: build-status
8476

@@ -91,9 +83,7 @@ jobs:
9183
uses: myrotvorets/[email protected]
9284
with:
9385
token: ${{ secrets.GITHUB_TOKEN }}
94-
# Commit status (one of "error", "failure", "pending", "success")
9586
status: success
96-
# A short description of the status.
9787
description: all tests passed
9888
context: test-status
9989

.github/workflows/doxygen.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ jobs:
1919
- name: Install Doxygen
2020
run: sudo apt-get install doxygen graphviz doxygen-latex -y
2121
shell: bash
22+
2223
- name: Configure Doxygen Python
23-
run: cp ./bindings/include/ihs_bindings.pyi ./bindings/include/ihs_bindings.py
24+
run: cp ./modules/bindings/include/ihs_bindings.pyi ./modules/bindings/include/ihs_bindings.py
2425

2526
# ========== Build Doxygen ==========
2627
- name: Configure
27-
run: cmake -Dwith_documentation=ON -Dbuild_library=OFF -Dbuild_python=OFF .
28+
run: cmake -Dwith_documentation=ON -Dbuild_library=OFF .
2829

2930
- name: Build
3031
run: make

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ bin/
1212
ihs_bindings.py
1313

1414
# configure output
15-
config.hpp
15+
config.hpp
16+
modules.hpp

CMakeLists.txt

Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,25 @@
11
cmake_minimum_required(VERSION 3.0)
22
project(ihs_boost VERSION 1.5.0)
33

4-
# global includes
5-
include(CTest)
6-
74
# options
8-
option(roomba "Whether to build for the roomba or not" ON)
9-
option(build_library "build_library" ON)
105
option(build_tests "build_tests" OFF)
11-
option(build_python "build_python" ON)
126
option(with_documentation "with_documentation" OFF)
137

14-
# setup
15-
set(LIBRARY_DIRS communicate controllers create_extra
16-
movement servos threading util
17-
)
18-
19-
# configure config.hpp
20-
if (${roomba})
21-
set(robot_config_name "roomba_config.json")
22-
set(robot_config_hpp "roomba_config.hpp")
23-
else()
24-
set(robot_config_name "small_bot_config.json")
25-
set(robot_config_hpp "small_bot_config.hpp")
26-
endif()
27-
configure_file(${CMAKE_SOURCE_DIR}/util/include/config.hpp.in ${CMAKE_SOURCE_DIR}/util/include/config.hpp)
28-
29-
# main .so file
30-
if (${build_library})
31-
# add compile options
32-
add_compile_options("-std=c++11")
33-
add_compile_options("-fPIC")
34-
add_compile_options("-Wall")
35-
add_compile_options("-Wconversion")
36-
37-
# find required libs
38-
find_library(json_libs jsoncpp REQUIRED)
39-
find_library(bluetooth_libs bluetooth REQUIRED)
40-
41-
# install path configuration, defaults to /usr/local/
42-
message("installing to " ${CMAKE_INSTALL_PREFIX})
43-
define_property(GLOBAL PROPERTY install_path BRIEF_DOCS "where to install" FULL_DOCS "where to install files")
44-
set_property(GLOBAL PROPERTY install_path ${CMAKE_INSTALL_PREFIX}/include/ihsboost)
45-
get_property(local_install_path GLOBAL PROPERTY install_path)
46-
message("include install_path has been set to " ${local_install_path})
47-
48-
# add subdirectories
49-
foreach(subdir IN LISTS LIBRARY_DIRS)
50-
add_subdirectory(${CMAKE_SOURCE_DIR}/${subdir})
51-
endforeach()
52-
53-
# link
54-
add_library(ihsboost SHARED empty.cpp)
55-
target_link_libraries(ihsboost PUBLIC kipr pthread rt ${bluetooth_libs} ${json_libs})
56-
foreach(subdir IN LISTS LIBRARY_DIRS)
57-
target_link_libraries(ihsboost PUBLIC ihs_${subdir})
58-
endforeach()
59-
60-
# install
61-
install(TARGETS ihsboost DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
62-
install(FILES all.hpp DESTINATION ${local_install_path})
63-
endif()
8+
# add modules
9+
add_subdirectory(modules)
6410

65-
# python bindings
66-
if (${build_python})
67-
add_subdirectory(bindings)
11+
# tests for ctest
12+
if (${build_tests})
13+
include(CTest)
14+
add_subdirectory(tests)
6815
endif()
6916

7017
# doxygen/documentation
7118
if (${with_documentation})
7219
find_package(Doxygen REQUIRED)
7320

7421
# include the extra files
75-
set(DOXYGEN_SOURCES ${LIBRARY_DIRS} ${CMAKE_SOURCE_DIR}/README.md ${CMAKE_SOURCE_DIR}/all.hpp ${CMAKE_SOURCE_DIR}/bindings/)
22+
set(DOXYGEN_SOURCES ${CMAKE_SOURCE_DIR}/README.md ${CMAKE_SOURCE_DIR}/modules/)
7623
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_SOURCE_DIR}/examples)
7724
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${CMAKE_SOURCE_DIR}/README.md)
7825

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
The ihs library of robot functions, from steady acceleration to servo movement
55
## Installing
66
### Dependencies
7-
ihsboost depends on the following libraries:
8-
* libwallaby - please use [this branch](https://github.com/chrehall68/libwallaby/tree/refactor) to install libwallaby
9-
* libjsoncpp - on linux, run `sudo apt-get install libjsoncpp-dev` to install
10-
* libbluetooth - on linux, run `sudo apt-get install libbluetooth-dev` to install
7+
Some ihsboost modules have dependencies. The format below is dependency - modules - installation instructions
8+
* libwallaby - servos, movement, create_extra - please use [this branch](https://github.com/chrehall68/libwallaby/tree/refactor) to install libwallaby
9+
* libjsoncpp - util - on linux, run `sudo apt-get install libjsoncpp-dev` to install
10+
* libbluetooth - communicate - on linux, run `sudo apt-get install libbluetooth-dev` to install
11+
* libboost_python - bindings - on linux, run `sudo apt-get install libboost-python-dev` to install
1112
### Getting the Source files
1213
To get the source files on a wombat, the best way to do that is to start on your local
1314
computer. Run `git clone https://github.com/ihsrobotics/ihsboost.git` to get the github
@@ -41,21 +42,32 @@ Note: you will need to use either the `main` branch or the
4142
`older-wombat` branch depending on whether you are using a
4243
new wombat or an old (original OS) wombat (see `Getting the Source files`)
4344
### Cross Compile Build
44-
Currently, Cross compile build is unsupported.
45+
Currently, cross compile build is unsupported.
4546
### Other Build Options
4647
The following are options that can be appended to the `cmake` command
4748
when configuring the project.
4849

49-
* `-Dwith_documentation=OFF/ON` - build documentation files for the project, defaults to `OFF`
5050
* `-Dbuild_library=ON/OFF` - build ihsboost, defaults to `ON`
51-
* `-Dbuild_python=ON/OFF`- build python bindings, defaults to `ON`
52-
* `-Dpython_version=XXX` - use a specific version of python (for example, 3.9 or 3.10), defaults to 3.9
51+
* `-Dbuild_tests=OFF/ON` - build tests to assure that ihsboost built successfully, defaults to `OFF`
52+
* `-Dwith_documentation=OFF/ON` - build documentation files for the project, defaults to `OFF`
5353
* `-Droomba=ON/OFF` - use roomba configs or not, defaults to `ON`
54+
* `-Dpython_version=XXX` - use a specific version of python (for example, 3.9 or 3.10), defaults to 3.9,
55+
only relevant if building python bindings
56+
57+
The following are options to configure which ihsboost modules to build
58+
* `-Dbuild_bindings=ON/OFF`- build python bindings, defaults to `ON`
59+
* `-Dbuild_communicate=ON/OFF` - build communicate, defaults to `ON`
60+
* `-Dbuild_controllers=ON/OFF` - build controllers, defaults to `ON`
61+
* `-Dbuild_create_extra=ON/OFF` - build extra create functionality (vacuum and brushes), defaults to `ON`
62+
* `-Dbuild_movement=ON/OFF` - build movement functions, defaults to `ON`
63+
* `-Dbuild_servos=ON/OFF` - build servo movement functions, defaults to `ON`
64+
* `-Dbuild_thread=ON/OFF` - build threading classes, defaults to `ON`
65+
* `-Dbuild_util=ON/OFF` - build util, defaults to `ON`
5466

5567
For example,
5668
`cmake .. -DCMAKE_BUILD_TYPE=Release -Dwith_documentation=ON -Dpython_version=3.10`
5769
will configure cmake to build the library and python bindings
58-
(since `build_library` and `build_python` default to `ON`) but
70+
(since `build_library` and `build_bindings` default to `ON`) but
5971
will also make the documentation (since `with_documentation` was specified to `ON`)
6072
and use python 3.10 instean of python 3.9
6173
## Compiling programs with it

bindings/CMakeLists.txt

Lines changed: 0 additions & 59 deletions
This file was deleted.

communicate/CMakeLists.txt

Lines changed: 0 additions & 57 deletions
This file was deleted.

controllers/CMakeLists.txt

Lines changed: 0 additions & 29 deletions
This file was deleted.

create_extra/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/bindings/listener.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/**
2+
* @file listener.cpp
3+
* @author Eliot Hall
4+
* @brief FIle to listen on the c++ side for messages sent by python
5+
* @version 0.1
6+
* @date 2023-03-31
7+
*
8+
* @copyright Copyright (c) 2023
9+
*
10+
*/
111
#include <ihsboost/all.hpp>
212
#include <iostream>
313
using namespace std;

0 commit comments

Comments
 (0)