Skip to content

Commit

Permalink
Finish 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Georg Wiedebach committed Dec 4, 2018
2 parents bfb5aac + 44b8fd2 commit 8dbab62
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 40 deletions.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

## Compiling Native Code (Compile for Mac and Win!)
## Compiling Native Code

To speed up the estimation the filter uses some native c++ code to perform the EKF specific matrix operations faster using Eigen. If it becomes necessary to modify / recompile these libraries follow the instructions here. To compile the c++ library on Ubuntu (assuming you are inside the ekf repository folder):
To speed up the estimation the filter uses some native c++ code to perform the EKF specific matrix operations faster using Eigen. If it becomes necessary to modify / recompile these libraries follow the instructions here.

### Ubuntu

To compile the c++ library on Ubuntu (assuming you are inside the ekf repository folder):

`cd nativeEKF`
`mkdir build`
Expand All @@ -66,10 +70,29 @@ The dependencies for compiling are
- Java
- Eigen3

### Changing the Native Code under Ubuntu

If you need to modify or extend the functionality of the native libraries and you need to modify the java class `NativeFilterMatrixOpsWrapper` you will need to regenerate the header file by running the command

`javac -h nativeEKF/ src/main/java/us/ihmc/ekf/filter/NativeFilterMatrixOpsWrapper.java`

Then modify the c++ source files to reflect your changes and recompile.

### Windows

This tutorial assumes a fresh Windows 10 install and was tested in a virtual machine.

Install [Visual Studio 2017 Community](https://visualstudio.microsoft.com/downloads/) and in the installer select "Desktop development with C++".

Install [Java](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html), then open the Advanced System Settings and
select the button "Environment Variables...". In the new Window create a new System variable `JAVA_HOME` and select the jdk directory e.g.
`C:\Program Files\Java\jdk1.8.0_191`.

Download [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page#Download) and extract the folder. Rename the folder containing the sub-folder
"cmake" and move it to `C:\Program Files`. Inside the folder (next to the folder "cmake" and others) create a folder "build".
Run the "x64 Native Tools Command Prompt for VS 2017" and navigate into the build folder you created. The run the command `cmake ..`. This will
configure Eigen so it can be found later and can be used to link against.

Finally, in the project folder create a directory called "build". Run the "x64 Native Tools Command Prompt for VS 2017" to compile the project and
navigate into the build folder you created.
Then run the command `cmake -G "Visual Studio 15 2017 Win64" ..` followed by `cmake --build . --target install --config Release`.
28 changes: 8 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.15.1"
classpath "us.ihmc:ihmc-ci-plugin:0.18.0"
}
plugins {
id("us.ihmc.ihmc-build") version "0.15.4"
}
apply plugin: "us.ihmc.ihmc-build"
apply plugin: "us.ihmc.ihmc-ci-plugin"

sourceCompatibility = 1.8

ihmc {
group = "us.ihmc"
version = "0.1.0"
version = "0.2.0"
openSource = true

configureDependencyResolution()
configurePublications()
}

mainDependencies {
compile group: "com.google.guava", name: "guava", version: "18.0"

compile group: "org.ejml", name: "dense64", version: "0.30"
compile group: "org.ejml", name: "core", version: "0.30"

compile group: "us.ihmc", name: "euclid", version: "0.8.2"
compile group: "us.ihmc", name: "mecano", version: "0.0.11"
compile group: "us.ihmc", name: "euclid", version: "0.10.0"
compile group: "us.ihmc", name: "mecano", version: "0.0.13"
compile group: "us.ihmc", name: "ihmc-commons", version: "0.24.0"
compile group: "us.ihmc", name: "IHMCNativeLibraryLoader", version: "1.0"
compile group: "us.ihmc", name: "ihmc-yovariables", version: "0.3.5"
compile group: "us.ihmc", name: "ihmc-yovariables", version: "0.3.6"
}

testDependencies {
Expand All @@ -43,5 +31,5 @@ testDependencies {
visualizersDependencies {
compile ihmc.sourceSetProject("main")

compile group: "us.ihmc", name: "simulation-construction-set", version: "0.12.6"
compile group: "us.ihmc", name: "simulation-construction-set", version: "0.12.7"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ kebabCasedName = ekf
pascalCasedName = EKF
extraSourceSets = ["test", "visualizers"]
publishUrl = local
compositeSearchHeight = 1
compositeSearchHeight = 0
excludeFromCompositeBuild = false
6 changes: 4 additions & 2 deletions nativeEKF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8)
project(NativeFilterMatrixOps)

find_package(JNI REQUIRED)
find_package(Eigen3 3.3 REQUIRED)
find_package(Eigen3 3.3 REQUIRED NO_MODULE)

include_directories(${JNI_INCLUDE_DIRS})

Expand All @@ -14,4 +14,6 @@ set(SOURCE_FILES NativeFilterMatrixOps.cpp)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../src/main/resources)

add_library(NativeFilterMatrixOps SHARED ${SOURCE_FILES})
target_link_libraries (NativeFilterMatrixOps Eigen3::Eigen)
target_link_libraries (NativeFilterMatrixOps Eigen3::Eigen)

install(TARGETS NativeFilterMatrixOps RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}/../src/main/resources LIBRARY DESTINATION ${PROJECT_SOURCE_DIR}/../src/main/resources)
28 changes: 14 additions & 14 deletions nativeEKF/NativeFilterMatrixOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ JNIEXPORT void JNICALL Java_us_ihmc_ekf_filter_NativeFilterMatrixOpsWrapper_comp
Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(resultDataArray, n, n) = ABAt;
env->SetDoubleArrayRegion(result, 0, n * n, resultDataArray);

delete aDataArray;
delete bDataArray;
env->ReleaseDoubleArrayElements(aData, aDataArray, 0);
env->ReleaseDoubleArrayElements(bData, bDataArray, 0);
delete resultDataArray;
}

Expand All @@ -47,9 +47,9 @@ JNIEXPORT void JNICALL Java_us_ihmc_ekf_filter_NativeFilterMatrixOpsWrapper_pred
Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(resultDataArray, n, n) = errorCovariance;
env->SetDoubleArrayRegion(result, 0, n * n, resultDataArray);

delete fDataArray;
delete pDataArray;
delete qDataArray;
env->ReleaseDoubleArrayElements(fData, fDataArray, 0);
env->ReleaseDoubleArrayElements(pData, pDataArray, 0);
env->ReleaseDoubleArrayElements(qData, qDataArray, 0);
delete resultDataArray;
}

Expand All @@ -69,9 +69,9 @@ JNIEXPORT void JNICALL Java_us_ihmc_ekf_filter_NativeFilterMatrixOpsWrapper_upda
Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(resultDataArray, m, m) = errorCovariance;
env->SetDoubleArrayRegion(result, 0, m * m, resultDataArray);

delete kDataArray;
delete hDataArray;
delete pDataArray;
env->ReleaseDoubleArrayElements(kData, kDataArray, 0);
env->ReleaseDoubleArrayElements(hData, hDataArray, 0);
env->ReleaseDoubleArrayElements(pData, pDataArray, 0);
delete resultDataArray;
}

Expand All @@ -94,9 +94,9 @@ JNIEXPORT void JNICALL Java_us_ihmc_ekf_filter_NativeFilterMatrixOpsWrapper_comp
Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(resultDataArray, m, n) = kalmanGain;
env->SetDoubleArrayRegion(result, 0, m * n, resultDataArray);

delete pDataArray;
delete hDataArray;
delete rDataArray;
env->ReleaseDoubleArrayElements(pData, pDataArray, 0);
env->ReleaseDoubleArrayElements(hData, hDataArray, 0);
env->ReleaseDoubleArrayElements(rData, rDataArray, 0);
delete resultDataArray;
}

Expand All @@ -116,8 +116,8 @@ JNIEXPORT void JNICALL Java_us_ihmc_ekf_filter_NativeFilterMatrixOpsWrapper_upda
Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(resultDataArray, n, 1) = state;
env->SetDoubleArrayRegion(result, 0, n, resultDataArray);

delete xDataArray;
delete kDataArray;
delete rDataArray;
env->ReleaseDoubleArrayElements(xData, xDataArray, 0);
env->ReleaseDoubleArrayElements(kData, kDataArray, 0);
env->ReleaseDoubleArrayElements(rData, rDataArray, 0);
delete resultDataArray;
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.15.1"
classpath "us.ihmc:ihmc-build:0.15.4"
}
}

Expand Down
Binary file added src/main/resources/NativeFilterMatrixOps.dll
Binary file not shown.
Binary file modified src/main/resources/libNativeFilterMatrixOps.so
Binary file not shown.

0 comments on commit 8dbab62

Please sign in to comment.