00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #define GLM_FORCE_RADIANS
00029
00030 #include <jni.h>
00031 #include <RTABMapApp.h>
00032 #include <scene.h>
00033
00034 static RTABMapApp app;
00035
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039
00040 void GetJStringContent(JNIEnv *AEnv, jstring AStr, std::string &ARes) {
00041 if (!AStr) {
00042 ARes.clear();
00043 return;
00044 }
00045
00046 const char *s = AEnv->GetStringUTFChars(AStr,NULL);
00047 ARes=s;
00048 AEnv->ReleaseStringUTFChars(AStr,s);
00049 }
00050
00051 JNIEXPORT void JNICALL
00052 Java_com_introlab_rtabmap_RTABMapLib_onCreate(
00053 JNIEnv* env, jobject, jobject activity)
00054 {
00055 return app.onCreate(env, activity);
00056 }
00057
00058 JNIEXPORT void JNICALL
00059 Java_com_introlab_rtabmap_RTABMapLib_setScreenRotation(
00060 JNIEnv* env, jobject, int displayRotation, int cameraRotation)
00061 {
00062 return app.setScreenRotation(displayRotation, cameraRotation);
00063 }
00064
00065 JNIEXPORT int JNICALL
00066 Java_com_introlab_rtabmap_RTABMapLib_openDatabase(
00067 JNIEnv* env, jobject, jstring databasePath, bool databaseInMemory, bool optimize)
00068 {
00069 std::string databasePathC;
00070 GetJStringContent(env,databasePath,databasePathC);
00071 return app.openDatabase(databasePathC, databaseInMemory, optimize);
00072 }
00073
00074 JNIEXPORT int JNICALL
00075 Java_com_introlab_rtabmap_RTABMapLib_openDatabase2(
00076 JNIEnv* env, jobject, jstring databaseSource, jstring databasePath, bool databaseInMemory, bool optimize)
00077 {
00078 std::string databasePathC;
00079 GetJStringContent(env,databasePath,databasePathC);
00080 std::string databaseSourceC;
00081 GetJStringContent(env,databaseSource,databaseSourceC);
00082 return app.openDatabase(databasePathC, databaseInMemory, optimize, databaseSourceC);
00083 }
00084
00085 JNIEXPORT bool JNICALL
00086 Java_com_introlab_rtabmap_RTABMapLib_onTangoServiceConnected(
00087 JNIEnv* env, jobject, jobject iBinder) {
00088 return app.onTangoServiceConnected(env, iBinder);
00089 }
00090
00091 JNIEXPORT void JNICALL
00092 Java_com_introlab_rtabmap_RTABMapLib_initGlContent(
00093 JNIEnv*, jobject) {
00094 app.InitializeGLContent();
00095 }
00096
00097 JNIEXPORT void JNICALL
00098 Java_com_introlab_rtabmap_RTABMapLib_setupGraphic(
00099 JNIEnv*, jobject, jint width, jint height) {
00100 app.SetViewPort(width, height);
00101 }
00102
00103 JNIEXPORT int JNICALL
00104 Java_com_introlab_rtabmap_RTABMapLib_render(
00105 JNIEnv*, jobject) {
00106 return app.Render();
00107 }
00108
00109 JNIEXPORT void JNICALL
00110 Java_com_introlab_rtabmap_RTABMapLib_onPause(
00111 JNIEnv*, jobject) {
00112 app.onPause();
00113 }
00114
00115 JNIEXPORT void JNICALL
00116 Java_com_introlab_rtabmap_RTABMapLib_setCamera(
00117 JNIEnv*, jobject, int camera_index) {
00118 using namespace tango_gl;
00119 GestureCamera::CameraType cam_type =
00120 static_cast<GestureCamera::CameraType>(camera_index);
00121 app.SetCameraType(cam_type);
00122 }
00123
00124 JNIEXPORT void JNICALL
00125 Java_com_introlab_rtabmap_RTABMapLib_onTouchEvent(
00126 JNIEnv*, jobject, int touch_count, int event, float x0, float y0, float x1,
00127 float y1) {
00128 using namespace tango_gl;
00129 GestureCamera::TouchEvent touch_event =
00130 static_cast<GestureCamera::TouchEvent>(event);
00131 app.OnTouchEvent(touch_count, touch_event, x0, y0, x1, y1);
00132 }
00133
00134 JNIEXPORT void JNICALL
00135 Java_com_introlab_rtabmap_RTABMapLib_setPausedMapping(
00136 JNIEnv*, jobject, bool paused)
00137 {
00138 return app.setPausedMapping(paused);
00139 }
00140 JNIEXPORT void JNICALL
00141 Java_com_introlab_rtabmap_RTABMapLib_setOnlineBlending(
00142 JNIEnv*, jobject, bool enabled)
00143 {
00144 return app.setOnlineBlending(enabled);
00145 }
00146 JNIEXPORT void JNICALL
00147 Java_com_introlab_rtabmap_RTABMapLib_setMapCloudShown(
00148 JNIEnv*, jobject, bool shown)
00149 {
00150 return app.setMapCloudShown(shown);
00151 }
00152 JNIEXPORT void JNICALL
00153 Java_com_introlab_rtabmap_RTABMapLib_setOdomCloudShown(
00154 JNIEnv*, jobject, bool shown)
00155 {
00156 return app.setOdomCloudShown(shown);
00157 }
00158 JNIEXPORT void JNICALL
00159 Java_com_introlab_rtabmap_RTABMapLib_setMeshRendering(
00160 JNIEnv*, jobject, bool enabled, bool withTexture)
00161 {
00162 return app.setMeshRendering(enabled, withTexture);
00163 }
00164 JNIEXPORT void JNICALL
00165 Java_com_introlab_rtabmap_RTABMapLib_setPointSize(
00166 JNIEnv*, jobject, float value)
00167 {
00168 return app.setPointSize(value);
00169 }
00170 JNIEXPORT void JNICALL
00171 Java_com_introlab_rtabmap_RTABMapLib_setFOV(
00172 JNIEnv*, jobject, float fov)
00173 {
00174 return app.setFOV(fov);
00175 }
00176 JNIEXPORT void JNICALL
00177 Java_com_introlab_rtabmap_RTABMapLib_setOrthoCropFactor(
00178 JNIEnv*, jobject, float value)
00179 {
00180 return app.setOrthoCropFactor(value);
00181 }
00182 JNIEXPORT void JNICALL
00183 Java_com_introlab_rtabmap_RTABMapLib_setGridRotation(
00184 JNIEnv*, jobject, float value)
00185 {
00186 return app.setGridRotation(value);
00187 }
00188 JNIEXPORT void JNICALL
00189 Java_com_introlab_rtabmap_RTABMapLib_setLighting(
00190 JNIEnv*, jobject, bool enabled)
00191 {
00192 return app.setLighting(enabled);
00193 }
00194 JNIEXPORT void JNICALL
00195 Java_com_introlab_rtabmap_RTABMapLib_setBackfaceCulling(
00196 JNIEnv*, jobject, bool enabled)
00197 {
00198 return app.setBackfaceCulling(enabled);
00199 }
00200 JNIEXPORT void JNICALL
00201 Java_com_introlab_rtabmap_RTABMapLib_setWireframe(
00202 JNIEnv*, jobject, bool enabled)
00203 {
00204 return app.setWireframe(enabled);
00205 }
00206 JNIEXPORT void JNICALL
00207 Java_com_introlab_rtabmap_RTABMapLib_setLocalizationMode(
00208 JNIEnv*, jobject, bool enabled)
00209 {
00210 return app.setLocalizationMode(enabled);
00211 }
00212 JNIEXPORT void JNICALL
00213 Java_com_introlab_rtabmap_RTABMapLib_setTrajectoryMode(
00214 JNIEnv*, jobject, bool enabled)
00215 {
00216 return app.setTrajectoryMode(enabled);
00217 }
00218 JNIEXPORT void JNICALL
00219 Java_com_introlab_rtabmap_RTABMapLib_setGraphOptimization(
00220 JNIEnv*, jobject, bool enabled)
00221 {
00222 return app.setGraphOptimization(enabled);
00223 }
00224 JNIEXPORT void JNICALL
00225 Java_com_introlab_rtabmap_RTABMapLib_setNodesFiltering(
00226 JNIEnv*, jobject, bool enabled)
00227 {
00228 return app.setNodesFiltering(enabled);
00229 }
00230 JNIEXPORT void JNICALL
00231 Java_com_introlab_rtabmap_RTABMapLib_setGraphVisible(
00232 JNIEnv*, jobject, bool visible)
00233 {
00234 return app.setGraphVisible(visible);
00235 }
00236 JNIEXPORT void JNICALL
00237 Java_com_introlab_rtabmap_RTABMapLib_setGridVisible(
00238 JNIEnv*, jobject, bool visible)
00239 {
00240 return app.setGridVisible(visible);
00241 }
00242 JNIEXPORT void JNICALL
00243 Java_com_introlab_rtabmap_RTABMapLib_setRawScanSaved(
00244 JNIEnv*, jobject, bool enabled)
00245 {
00246 return app.setRawScanSaved(enabled);
00247 }
00248 JNIEXPORT void JNICALL
00249 Java_com_introlab_rtabmap_RTABMapLib_setFullResolution(
00250 JNIEnv*, jobject, bool enabled)
00251 {
00252 return app.setFullResolution(enabled);
00253 }
00254 JNIEXPORT void JNICALL
00255 Java_com_introlab_rtabmap_RTABMapLib_setSmoothing(
00256 JNIEnv*, jobject, bool enabled)
00257 {
00258 return app.setSmoothing(enabled);
00259 }
00260 JNIEXPORT void JNICALL
00261 Java_com_introlab_rtabmap_RTABMapLib_setCameraColor(
00262 JNIEnv*, jobject, bool enabled)
00263 {
00264 return app.setCameraColor(enabled);
00265 }
00266 JNIEXPORT void JNICALL
00267 Java_com_introlab_rtabmap_RTABMapLib_setAppendMode(
00268 JNIEnv*, jobject, bool enabled)
00269 {
00270 return app.setAppendMode(enabled);
00271 }
00272 JNIEXPORT void JNICALL
00273 Java_com_introlab_rtabmap_RTABMapLib_setDataRecorderMode(
00274 JNIEnv*, jobject, bool enabled)
00275 {
00276 return app.setDataRecorderMode(enabled);
00277 }
00278 JNIEXPORT void JNICALL
00279 Java_com_introlab_rtabmap_RTABMapLib_setMaxCloudDepth(
00280 JNIEnv*, jobject, float value)
00281 {
00282 return app.setMaxCloudDepth(value);
00283 }
00284 JNIEXPORT void JNICALL
00285 Java_com_introlab_rtabmap_RTABMapLib_setMinCloudDepth(
00286 JNIEnv*, jobject, float value)
00287 {
00288 return app.setMinCloudDepth(value);
00289 }
00290 JNIEXPORT void JNICALL
00291 Java_com_introlab_rtabmap_RTABMapLib_setCloudDensityLevel(
00292 JNIEnv*, jobject, int value)
00293 {
00294 return app.setCloudDensityLevel(value);
00295 }
00296 JNIEXPORT void JNICALL
00297 Java_com_introlab_rtabmap_RTABMapLib_setMeshAngleTolerance(
00298 JNIEnv*, jobject, float value)
00299 {
00300 return app.setMeshAngleTolerance(value);
00301 }
00302 JNIEXPORT void JNICALL
00303 Java_com_introlab_rtabmap_RTABMapLib_setMeshTriangleSize(
00304 JNIEnv*, jobject, int value)
00305 {
00306 return app.setMeshTriangleSize(value);
00307 }
00308 JNIEXPORT void JNICALL
00309 Java_com_introlab_rtabmap_RTABMapLib_setClusterRatio(
00310 JNIEnv*, jobject, float value)
00311 {
00312 return app.setClusterRatio(value);
00313 }
00314 JNIEXPORT void JNICALL
00315 Java_com_introlab_rtabmap_RTABMapLib_setMaxGainRadius(
00316 JNIEnv*, jobject, float value)
00317 {
00318 return app.setMaxGainRadius(value);
00319 }
00320 JNIEXPORT void JNICALL
00321 Java_com_introlab_rtabmap_RTABMapLib_setRenderingTextureDecimation(
00322 JNIEnv*, jobject, int value)
00323 {
00324 return app.setRenderingTextureDecimation(value);
00325 }
00326 JNIEXPORT void JNICALL
00327 Java_com_introlab_rtabmap_RTABMapLib_setBackgroundColor(
00328 JNIEnv*, jobject, float value)
00329 {
00330 return app.setBackgroundColor(value);
00331 }
00332 JNIEXPORT jint JNICALL
00333 Java_com_introlab_rtabmap_RTABMapLib_setMappingParameter(
00334 JNIEnv* env, jobject, jstring key, jstring value)
00335 {
00336 std::string keyC, valueC;
00337 GetJStringContent(env,key,keyC);
00338 GetJStringContent(env,value,valueC);
00339 return app.setMappingParameter(keyC, valueC);
00340 }
00341
00342 JNIEXPORT void JNICALL
00343 Java_com_introlab_rtabmap_RTABMapLib_setGPS(
00344 JNIEnv*, jobject,
00345 double stamp,
00346 double longitude,
00347 double latitude,
00348 double altitude,
00349 double accuracy,
00350 double bearing)
00351 {
00352 return app.setGPS(rtabmap::GPS(stamp,
00353 longitude,
00354 latitude,
00355 altitude,
00356 accuracy,
00357 bearing));
00358 }
00359
00360 JNIEXPORT void JNICALL
00361 Java_com_introlab_rtabmap_RTABMapLib_resetMapping(
00362 JNIEnv*, jobject)
00363 {
00364 return app.resetMapping();
00365 }
00366
00367 JNIEXPORT void JNICALL
00368 Java_com_introlab_rtabmap_RTABMapLib_save(
00369 JNIEnv* env, jobject, jstring databasePath)
00370 {
00371 std::string databasePathC;
00372 GetJStringContent(env,databasePath,databasePathC);
00373 return app.save(databasePathC);
00374 }
00375
00376 JNIEXPORT void JNICALL
00377 Java_com_introlab_rtabmap_RTABMapLib_cancelProcessing(
00378 JNIEnv* env, jobject)
00379 {
00380 return app.cancelProcessing();
00381 }
00382
00383 JNIEXPORT bool JNICALL
00384 Java_com_introlab_rtabmap_RTABMapLib_exportMesh(
00385 JNIEnv* env, jobject,
00386 float cloudVoxelSize,
00387 bool regenerateCloud,
00388 bool meshing,
00389 int textureSize,
00390 int textureCount,
00391 int normalK,
00392 bool optimized,
00393 float optimizedVoxelSize,
00394 int optimizedDepth,
00395 int optimizedMaxPolygons,
00396 float optimizedColorRadius,
00397 bool optimizedCleanWhitePolygons,
00398 int optimizedMinClusterSize,
00399 float optimizedMaxTextureDistance,
00400 int optimizedMinTextureClusterSize,
00401 bool blockRendering)
00402 {
00403 return app.exportMesh(
00404 cloudVoxelSize,
00405 regenerateCloud,
00406 meshing,
00407 textureSize,
00408 textureCount,
00409 normalK,
00410 optimized,
00411 optimizedVoxelSize,
00412 optimizedDepth,
00413 optimizedMaxPolygons,
00414 optimizedColorRadius,
00415 optimizedCleanWhitePolygons,
00416 optimizedMinClusterSize,
00417 optimizedMaxTextureDistance,
00418 optimizedMinTextureClusterSize,
00419 blockRendering);
00420 }
00421
00422 JNIEXPORT bool JNICALL
00423 Java_com_introlab_rtabmap_RTABMapLib_postExportation(
00424 JNIEnv* env, jobject, bool visualize)
00425 {
00426 return app.postExportation(visualize);
00427 }
00428
00429 JNIEXPORT bool JNICALL
00430 Java_com_introlab_rtabmap_RTABMapLib_writeExportedMesh(
00431 JNIEnv* env, jobject, jstring directory, jstring name)
00432 {
00433 std::string directoryC;
00434 GetJStringContent(env,directory,directoryC);
00435 std::string nameC;
00436 GetJStringContent(env,name,nameC);
00437 return app.writeExportedMesh(directoryC, nameC);
00438 }
00439
00440
00441 JNIEXPORT int JNICALL
00442 Java_com_introlab_rtabmap_RTABMapLib_postProcessing(
00443 JNIEnv* env, jobject, int approach)
00444 {
00445 return app.postProcessing(approach);
00446 }
00447
00448
00449
00450 #ifdef __cplusplus
00451 }
00452 #endif