mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-03 16:47:47 +08:00
Implemented wifi_mapping example on Mac OS X
This commit is contained in:
+9
-1
@@ -138,7 +138,7 @@ ENDIF()
|
||||
|
||||
####### OSX BUNDLE CMAKE_INSTALL_PREFIX #######
|
||||
IF(APPLE AND BUILD_AS_BUNDLE)
|
||||
IF(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND)
|
||||
IF(Qt5_FOUND OR (QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND))
|
||||
|
||||
# Required when packaging, and set CMAKE_INSTALL_PREFIX to "/".
|
||||
SET(CMAKE_INSTALL_PREFIX "/")
|
||||
@@ -341,4 +341,12 @@ ELSE()
|
||||
MESSAGE(STATUS " With g2o = NO (g2o not found)")
|
||||
ENDIF()
|
||||
|
||||
IF(QT4_FOUND)
|
||||
MESSAGE(STATUS " With Qt = YES (version 4)")
|
||||
ELSEIF(Qt5_FOUND)
|
||||
MESSAGE(STATUS " With Qt = YES (version 5)")
|
||||
ELSE()
|
||||
MESSAGE(STATUS " With Qt = NO (Qt not found, to use Qt5 you should set -DRTABMAP_QT_VERSION=5)")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "--------------------------------------------")
|
||||
|
||||
@@ -3,12 +3,7 @@ ADD_SUBDIRECTORY( BOWMapping )
|
||||
|
||||
IF(TARGET rtabmap_gui)
|
||||
ADD_SUBDIRECTORY( RGBDMapping )
|
||||
|
||||
# Only on Linux and Windows
|
||||
IF(NOT APPLE)
|
||||
ADD_SUBDIRECTORY( WifiMapping )
|
||||
ENDIF(NOT APPLE)
|
||||
|
||||
ELSE()
|
||||
MESSAGE(STATUS "RTAB-Map GUI lib is not built, the RGBDMapping and WifiMapping examples will not be built...")
|
||||
ENDIF()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
|
||||
SET(srcs
|
||||
main.cpp)
|
||||
|
||||
SET(INCLUDE_DIRS
|
||||
${PROJECT_SOURCE_DIR}/utilite/include
|
||||
${PROJECT_SOURCE_DIR}/corelib/include
|
||||
@@ -25,8 +28,20 @@ ELSE()
|
||||
QT5_WRAP_CPP(moc_srcs ../RGBDMapping/MapBuilder.h MapBuilderWifi.h)
|
||||
ENDIF()
|
||||
|
||||
ADD_EXECUTABLE(wifi_mapping main.cpp ${moc_srcs})
|
||||
IF(APPLE)
|
||||
FIND_LIBRARY(CoreWLAN_LIBRARY CoreWLAN)
|
||||
MARK_AS_ADVANCED(CoreWLAN_LIBRARY)
|
||||
SET(LIBRARIES
|
||||
${LIBRARIES}
|
||||
${CoreWLAN_LIBRARY}
|
||||
)
|
||||
SET(srcs
|
||||
${srcs}
|
||||
WifiOSX.mm
|
||||
)
|
||||
ENDIF(APPLE)
|
||||
|
||||
ADD_EXECUTABLE(wifi_mapping ${srcs} ${moc_srcs})
|
||||
TARGET_LINK_LIBRARIES(wifi_mapping rtabmap_core rtabmap_gui rtabmap_utilite ${LIBRARIES})
|
||||
|
||||
SET_TARGET_PROPERTIES( wifi_mapping
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* WifiOSX.h
|
||||
*
|
||||
* Created on: Mar 26, 2015
|
||||
* Author: mathieu
|
||||
*/
|
||||
|
||||
#ifndef WIFIOSX_H_
|
||||
#define WIFIOSX_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct AccessPoint
|
||||
{
|
||||
std::string ssid;
|
||||
std::string bssid;
|
||||
int rssi;
|
||||
};
|
||||
|
||||
int getRssi(const std::string& interfaceName);
|
||||
std::vector<AccessPoint> scanAir(const std::string& interfaceName);
|
||||
|
||||
|
||||
#endif /* WIFIOSX_H_ */
|
||||
@@ -0,0 +1,34 @@
|
||||
#import <CoreWLAN/CoreWLAN.h>
|
||||
#include "WifiOSX.h"
|
||||
|
||||
int getRssi(const std::string& interfaceName)
|
||||
{
|
||||
NSString* ifName = [NSString stringWithUTF8String:interfaceName.c_str()];
|
||||
CWInterface* interface = [CWInterface interfaceWithName:ifName];
|
||||
return interface.rssiValue;
|
||||
}
|
||||
|
||||
std::vector<AccessPoint> scanAir(const std::string& interfaceName)
|
||||
{
|
||||
NSString* ifName = [NSString stringWithUTF8String:interfaceName.c_str()];
|
||||
CWInterface* interface = [CWInterface interfaceWithName:ifName];
|
||||
|
||||
NSError* error = nil;
|
||||
NSArray* scanResult = [[interface scanForNetworksWithSSID:nil error:&error] allObjects];
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"%@ (%ld)", [error localizedDescription], [error code]);
|
||||
}
|
||||
|
||||
std::vector<AccessPoint> result;
|
||||
for (CWNetwork* network in scanResult)
|
||||
{
|
||||
AccessPoint ap;
|
||||
ap.ssid = std::string([[network ssid] UTF8String]);
|
||||
ap.bssid = std::string([[network bssid] UTF8String]);
|
||||
ap.rssi = [network rssiValue];
|
||||
result.push_back(ap);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -45,6 +45,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// Need to link with Wlanapi.lib and Ole32.lib
|
||||
#pragma comment(lib, "wlanapi.lib")
|
||||
#pragma comment(lib, "ole32.lib")
|
||||
#elif __APPLE__
|
||||
#include "WifiOSX.h"
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <linux/wireless.h>
|
||||
@@ -159,6 +161,8 @@ private:
|
||||
WlanFreeMemory(pIfList);
|
||||
pIfList = NULL;
|
||||
}
|
||||
#elif __APPLE__
|
||||
dBm = getRssi(interfaceName_);
|
||||
#else
|
||||
// Code inspired from http://blog.ajhodges.com/2011/10/using-ioctl-to-gather-wifi-information.html
|
||||
|
||||
|
||||
Reference in New Issue
Block a user