Skip to content
Draft
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
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files.associations": {
"*.cs": "csharp",
"cstdlib": "cpp"
},
"cmake.sourceDirectory": "C:/Users/aidan/dev/MarsRover/mono-rover/lidar/src"
}
4 changes: 3 additions & 1 deletion lidar/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ include_directories("sick_scan_xd/include/sick_scan_xd_api")
if (NOT WIN32)
add_executable(lidar udp.cpp image.cpp lidar.cpp main.cpp)
target_link_libraries(lidar sick_scan_xd_lib)
elseif(WIN32)
add_executable(lidar image.cpp lidar.cpp main.cpp)
endif()

add_library(lidar_ffi SHARED lidar.cpp image.cpp )
add_library(lidar_ffi SHARED lidar.cpp image.cpp)
target_link_libraries(lidar_ffi sick_scan_xd_lib)
19 changes: 17 additions & 2 deletions lidar/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#include <cstdlib>
#include <unistd.h>
#ifdef __linux__
#include <unistd.h>
#elif _WIN32
#include <windows.h>
#else
#endif


#include <iostream>

#include "lidar.h"
Expand All @@ -17,7 +24,11 @@ int main() {
// Open the lidar
auto lidar = new Lidar;
init(lidar);
#if __linux__
sleep(5); // init is actually async. TODO: better error-handling
#elseif(WIN32)
Sleep(5000);
#endif

while (true) {
// Check for errors and quit if there are any (the lidar has disconnected)
Expand All @@ -38,6 +49,10 @@ int main() {
}
}

sleep(sleepDelay);
#if __linux__
sleep(sleepDelay); // init is actually async. TODO: better error-handling
#elseif(WIN32)
Sleep(sleepDelay);
#endif
}
}
23 changes: 15 additions & 8 deletions lidar/src/udp.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#include <errno.h>
#include <iostream>
#include <netinet/in.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>

#include "udp.hpp"
#include <errno.h>
#include <iostream>

#ifdef __linux__
#include <netinet/in.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#elif _WIN32
#include <windows.h>
#else
#endif



UdpSocket::UdpSocket(int destPort) : destPort(destPort) { }

Expand Down
8 changes: 7 additions & 1 deletion lidar/src/udp.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#include <netinet/in.h>
#ifdef __linux__
#include <netinet/in.h>
#elif _WIN32
#include <winsock2.h>
#else
#endif


class UdpSocket {
private:
Expand Down