Skip to content

Commit

Permalink
Add LiDAR type definition. (#40)
Browse files Browse the repository at this point in the history
* Add LiDAR type definition.

* Add CLI configuration example.

* Fix formating and linting

* Fix build error.

* Update documentations.

* Update LiDAR setting documentation

* Fix version selector to have descending order.

---------

Co-authored-by: Jongkuk Lim <limjk@jmarple.ai>
  • Loading branch information
JeiKeiLim and Jongkuk Lim authored Jan 16, 2024
1 parent 411e4fb commit 65d61f4
Show file tree
Hide file tree
Showing 18 changed files with 666 additions and 29 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "examples/config_cli/libs/cli"]
path = examples/config_cli/libs/cli
url = https://github.com/daniele77/cli.git
branch = v2.1.0
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.0.2)
project(slambox_sdk
VERSION 0.1.0
VERSION 0.2.0
LANGUAGES CXX
)

Expand Down Expand Up @@ -111,6 +111,7 @@ endif()
if (BUILD_EXAMPLES)
add_subdirectory(examples/serial_communication)
add_subdirectory(examples/udp_communication)
add_subdirectory(examples/config_cli)
endif()

# Unit test
Expand Down
4 changes: 2 additions & 2 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = "SLAMBOX"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.1.0a
PROJECT_NUMBER = 0.2.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down Expand Up @@ -1371,7 +1371,7 @@ HTML_EXTRA_FILES = docs/doxygen-awesome-css/doxygen-awesome-darkmode-toggl
docs/doxygen-awesome-css/doxygen-awesome-interactive-toc.js \
docs/doxygen-awesome-css/doxygen-awesome-paragraph-link.js \
docs/doxygen-awesome-css/doxygen-awesome-tabs.js \
docs/SLAMBOX_Protocol_v0.1.0_R2.pdf
docs/SLAMBOX_Protocol.pdf

# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output
# should be rendered with a dark or light theme.
Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion docs/custom_style/custom_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
<select id="version-selector" onchange="window.location.href = this.value">
<option value="" disabled selected style="display:none;">Version</option>
<option value="/">Latest</option>
<option value="/v0.1.0">v0.1.0</option>
<option value="/v0.2.0">v0.2.0</option>
<option value="/v0.1.0a">v0.1.0a</option>
<option value="/v0.1.0">v0.1.0</option>
</select>
<!-- END VERSION SELECTOR -->
<!--BEGIN PROJECT_NUMBER-->
Expand Down
15 changes: 10 additions & 5 deletions docs/getting_started/lidar_setting.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Please follow instructions on your LiDAR sensor.
1. Livox [MID-360](#LiDARSetting-MID360)
2. Livox [AVIA](#LiDARSetting-AVIA)
3. Ouster [OS0 Family (OS0-32, OS0-64, and OS0-128)](#LIDARSetting-OusterOS0)
4. Velodyne [Puck (Lite)](#LIDARSetting-VelodynePuck)
4. Unitree L1 [Unitree L1](#LIDARSetting-Unitree-L1)
5. Velodyne [Puck (Lite)](#LIDARSetting-VelodynePuck)


[TOC]
Expand Down Expand Up @@ -167,17 +168,21 @@ Make sure LiDAR data is visible in Ouster Studio.

Now OS0 is ready to connect with SLAMBOX device. Connect OS0 SLAMBOX device via ethernet cable.

# 4. Velodyne Puck (VLP family) {#LIDARSetting-VelodynePuck}
# 4. Unitree L1 {#LIDARSetting-Unitree-L1}

## 4.1. Preparing for LiDAR setup
There is nothing to configure Unitree L1 LiDAR, however, OTG port of the SLAMBOX will be disabled. Please use ethernet port to communicate with SLAMBOX for this case. The documentation of communicating via ethernet cable can be found on [here](#Tutorial-CommunicationSetting-Ethernet).

# 5. Velodyne Puck (VLP family) {#LIDARSetting-VelodynePuck}

## 5.1. Preparing for LiDAR setup

Before starting the setup process, make sure you have following:

* Compudate with Ethernet ports (Ubuntu, MacOS, or Windows)

## 4.2. Velodyne Configuration Steps
## 5.2. Velodyne Configuration Steps

### 4.2.1. Setting Computer IP Address
### 5.2.1. Setting Computer IP Address

Set the computer's IP Address to `192.168.1.50`

Expand Down
18 changes: 12 additions & 6 deletions docs/getting_started/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,21 @@ sudo usermod -a -G dialout $USER
newgrp dialout
```

## 1.2. Ethernet (OTG) {#Tutorial-CommunicationSetting-Ethernet}
## 1.2. OTG {#Tutorial-CommunicationSetting-OTG}

To get data from *SLAMBOX* through etherent, set your host PC's host IP like below. You set this up either via [CLI](#Tutorial-CommunicationSetting-Ethernet-SetStaticIPwithTerminal) or [GUI](#Tutorial-CommunicationSetting-Ethernet-SetStaticIPwithUbuntuGUI).
Once you plug in OTG cable into your host computer, the IP address is automatically assigned via DHCP server built in SLAMBOX. Please check if the IP address has been acquired. If IP address is assigned, the host computer is ready to communicate via OTG cable.

## 1.3. Ethernet {#Tutorial-CommunicationSetting-Ethernet}

Some LiDARs, such as Unitree L1, requires to connect with USB. The OTG cable of the SLAMBOX will be disabled if you use such LiDARs. In that case, you can connect SLAMBOX via serial or ethernet communication.

To get data from *SLAMBOX* through etherent, set your host computer IP as below. You set this up either via [CLI](#Tutorial-CommunicationSetting-Ethernet-SetStaticIPwithTerminal) or [GUI](#Tutorial-CommunicationSetting-Ethernet-SetStaticIPwithUbuntuGUI).

### 1.2.1. Set Static IP with CLI {#Tutorial-CommunicationSetting-Ethernet-SetStaticIPwithTerminal}

To set static ip to your host PC, please follow the commands below

**NOTE**: The default IP address of OTG port of *SLAMBOX* is `192.168.101.101`. You need to avoid using this IP address.
**NOTE**: The default IP address of *SLAMBOX* is `192.168.101.101`. You need to avoid using this IP address.

```bash
# check the ethernet device
Expand All @@ -59,8 +65,6 @@ enx5ad1753eff84: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
```

The device name `enx5ad1753eff84` is the OTG ethernet connection of SLAMBOX.

Then set the device's IP.

In this example, we set the static IP to `192.168.101.5`
Expand Down Expand Up @@ -108,7 +112,9 @@ Then, set the device IP like the screen shot below

- Mapping results are saved periodically in the SLAMBOX device. The saved mapping file(.PCD) can be downloaded by visiting web URL (http://192.168.101.101:8080).

**NOTE** USB-C (OTG) cable must be plugged into your computer in order to access the URL.
- The default user ID and password are `user` / `user`

**NOTE** USB-C (OTG) or ethernet cable must be plugged into your computer in order to access the URL.

# 5. Advanced {#Tutorial-Advanced}

Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Connect LiDAR to SLAMBOX using provided cables.
You're now ready to dive into your project with seamless SLAM processing.

## Getting started on ROS1
Please follow instructions on https://github.com/j-marple-dev/slambox_ros_driver
Please follow instructions on https://github.com/j-marple-dev/slambox-ros

## Getting started on ROS2
Comming Soon
Expand All @@ -20,7 +20,7 @@ Comming Soon
Please look at [examples](https://github.com/j-marple-dev/SLAMBOX-SDK/tree/main/examples) on https://github.com/j-marple-dev/SLAMBOX-SDK for C++ development.

## Getting started on your own
Please look at [SLAMBOX protocol documentation](SLAMBOX_Protocol_v0.1.0_R2.pdf) to implement on your own environment.
Please look at [SLAMBOX protocol documentation](SLAMBOX_Protocol.pdf) to implement on your own environment.


# Key Features
Expand Down
2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ This directory includes C++ example codes using [slambox-sdk](https://github.com
# 2. UDP Communication
* [udp_communication](udp_communication) directory includes SLAMBOX UDP communication using [slambox-sdk](https://github.com/j-marple-dev/slambox-sdk) with `class` inheritance.

# 3. CLI Configuration
* [config_cli](config_cli) directory includes SLAMBOX configuration using [slambox-sdk](https://github.com/j-marple-dev/slambox-sdk).
23 changes: 23 additions & 0 deletions examples/config_cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.0.2)
project(slambox_serial_config_cli_example)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")

find_package(glog 0.6.0 REQUIRED)

add_executable(slambox_serial_config_cli_example config_cli.cpp config_cli_app.cpp)

if (NOT DEFINED slambox_sdk_LIBRARIES)
find_package(slambox_sdk 0.2.0 REQUIRED)
else()
set(slambox_sdk_LIBRARIES ${slambox_sdk_LIBRARIES};slambox_sdk_static)
endif()

target_link_libraries(slambox_serial_config_cli_example
glog::glog
cli::cli
${slambox_sdk_LIBRARIES}
)

add_subdirectory("libs/cli")

13 changes: 13 additions & 0 deletions examples/config_cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Config CLI

This example demonstrates how to create CLI application for SLAMBOX setting with SLAMBOX Protocol.

## Dependency

- This example requires [cli](https://github.com/daniele77/cli.git) library. Since [cli](https://github.com/daniele77/cli.git) library is included as submodule of this repository, you may need to update the submodules.

```
git submodule update --init --recursive
```


117 changes: 117 additions & 0 deletions examples/config_cli/config_cli.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/// @file
/// @author Jongkuk Lim <limjk@jmarple.ai>
/// @copyright 2023 J.Marple
/// @brief SLAMBOX CLI configurator application

#include <cli/cli.h>
#include <cli/clilocalsession.h>
#include <cli/filehistorystorage.h>
#include <cli/loopscheduler.h>
#include <glog/logging.h>

#include "include/config_cli_app.hpp"

/// @brief Print application usage
/// @param argv arguments
void print_usage(const std::string &binary_name) {
std::cout << "Usage: " << binary_name << " <serial_port> <baudrate>"
<< std::endl;
std::cout << " ex) " << binary_name << " /dev/ttyUSB0 1500000"
<< std::endl;
}

/// @brief Process arguments and set port name and baudrate
/// @param argc argument count
/// @param argv argument values
/// @param port_name port name to be set
/// @param baudrate baudrate to be set
/// @return 0 if success, otherwise 1
/// @note If argc is 2, then argv[1] is config file path
/// @note If argc is 3, then argv[1] is serial port name and argv[2] is baudrate
/// @note `port_name` and `baudrate` are inplace modified
int handle_arguments(int argc, char **argv, std::string *port_name,
int *baudrate) {
if (argc == 3) {
*port_name = argv[1];
try {
*baudrate = std::stoi(argv[2]);
} catch (const std::invalid_argument &e) {
std::cout << "Error parsing baudrate " << argv[2] << std::endl;
std::cout << "Reason: " << e.what() << std::endl;

print_usage(argv[0]);
return 1;
}
}

return 0;
}

int main(int argc, char **argv) {
// Handle arguments exception
if (argc < 2 || argc > 3) {
print_usage(argv[0]);
return 1;
}

// Parse arguments
std::string port_name = "/dev/ttyUSB0";
int baudrate = -1;

if (handle_arguments(argc, argv, &port_name, &baudrate) != 0) {
return 1;
}

FLAGS_stderrthreshold = google::INFO;
FLAGS_colorlogtostderr = true;
google::InitGoogleLogging(argv[0]);

LOG(INFO) << "port_name: " << port_name << ", baud_rate: " << baudrate;

try {
sbox::ConfigCLIApp config_cli_app(port_name, baudrate);
std::unique_ptr<cli::Menu> root_menu = config_cli_app.create_root_menu();
cli::Cli cli(
std::move(root_menu),
std::make_unique<cli::FileHistoryStorage>(".config_cli_history"));

cli.EnterAction([](std::ostream &out) { out << "Welcome" << std::endl; });
cli.ExitAction([](std::ostream &out) { out << "Bye" << std::endl; });

cli.StdExceptionHandler(
[](std::ostream &out, const std::string &cmd, const std::exception &e) {
out << "Exception caught in cli handler: " << e.what()
<< " handling command: " << cmd << ".\n";
});

cli::SetColor();
cli::LoopScheduler scheduler;
cli::CliLocalTerminalSession local_session(cli, scheduler, std::cout, 200);
local_session.ExitAction([&scheduler, &config_cli_app](auto &out) {
out << "Closing App...\n";
scheduler.Stop();
config_cli_app.stop();
});

config_cli_app.set_session(&local_session);
config_cli_app.set_loop_scheduler(&scheduler);
config_cli_app.run();

if (!config_cli_app.is_running()) {
std::cerr << "Error: Failed to open serial communication" << std::endl;
return 1;
}

scheduler.Run();

return 0;
} catch (const std::exception &e) {
std::cerr << "Error: " << e.what() << std::endl;
return 1;
} catch (...) {
std::cerr << "Error: Unknown exception" << std::endl;
return 1;
}

return 1;
}
Loading

0 comments on commit 65d61f4

Please sign in to comment.