Skip to content
Open
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
30 changes: 28 additions & 2 deletions livox_ros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,38 @@

- Ubuntu 22.04 for ROS2 Humble

## Installation
## Alternative: automated build
The package provides a script that installs everything automatically for you. You first has to create a catkin workspace and place the _match_livox_ folder in __[your_workspace]/src/__. It should have this structure:
```
user/
└── your_workspace/
└── src/
└── match_livox
```
Then run the script within the _match_livox_ package, passing your ROS version as argument to it (ROS1|ROS2|humble). For example, if your ROS version is ROS1:
```
./auto_build.sh ROS1
```
In case the permission to run the script is denied, run:
```
chmod +x auto_build.sh
```
When the build is finished, the installed packages should have the following structure:
```
user/
├── Livox-SDK2
└── your_workspace/
└── src/
├── livox_ros_driver2
└── match_livox
```

## Alternative: Build from source

1. Follow the instruction for installing [Livox-SDK2](https://github.com/Livox-SDK/Livox-SDK2).

2. Follow the instruction for installing [Livox ROS Driver 2](https://github.com/Livox-SDK/livox_ros_driver2) . __Make sure to clone the repository in [your_workspace]/src/__.
3. Copy the match_livox folder to the same directory as livox_ros_driver2. Then from the root of your workspace folder, run `catkin_make`.
3. Copy the _match_livox_ folder to the same directory as _livox_ros_driver2_. Then from the root of your workspace folder, run `catkin_make`.


## Usage for match's mur620b robot
Expand Down
103 changes: 103 additions & 0 deletions livox_ros/match_livox/auto_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env bash
# Check if ROS version was passed
if [ $# -ne 1 ]; then
echo "Error: Incorrect number of arguments."
echo "Usage: $0 <ROS1|ROS2|humble>"
exit 1
fi

# Check if the argument is valid
if [ "$1" != "ROS1" ] && [ "$1" != "ROS2" ] && [ "$1" != "humble" ]; then
echo "Error: Invalid argument."
echo "Usage: $0 <ROS1|ROS2|humble>"
exit 1
fi

cd `dirname $0`
CURRENT_DIR=$(pwd)
echo "Running script from path: "$CURRENT_DIR

#build Livox-SDK2 at root folder (See https://github.com/Livox-SDK/Livox-SDK2)
cd ~
git clone https://github.com/Livox-SDK/Livox-SDK2.git
cd ./Livox-SDK2/
mkdir build
cd build
cmake .. && make -j
sudo make install
echo 'Finished building Livox-SDK2'

#build Livox ROS driver 2 (Modified build.sh, see https://github.com/Livox-SDK/livox_ros_driver2)
cd $CURRENT_DIR
cd ..
git clone https://github.com/Livox-SDK/livox_ros_driver2.git
cd livox_ros_driver2

source /opt/ros/noetic/setup.sh

readonly VERSION_ROS1="ROS1"
readonly VERSION_ROS2="ROS2"
readonly VERSION_HUMBLE="humble"

pushd `pwd` > /dev/null

ROS_VERSION=""
ROS_HUMBLE=""

# Set working ROS version
if [ "$1" = "ROS2" ]; then
ROS_VERSION=${VERSION_ROS2}
elif [ "$1" = "humble" ]; then
ROS_VERSION=${VERSION_ROS2}
ROS_HUMBLE=${VERSION_HUMBLE}
elif [ "$1" = "ROS1" ]; then
ROS_VERSION=${VERSION_ROS1}
else
echo "Invalid Argument"
exit
fi
echo "ROS version is: "$ROS_VERSION

# clear `build/` folder.
# TODO: Do not clear these folders, if the last build is based on the same ROS version.
rm -rf ../../build/
rm -rf ../../devel/
rm -rf ../../install/
# clear src/CMakeLists.txt if it exists.
if [ -f ../CMakeLists.txt ]; then
rm -f ../CMakeLists.txt
fi

# exit

# substitute the files/folders: CMakeList.txt, package.xml(s)
if [ ${ROS_VERSION} = ${VERSION_ROS1} ]; then
if [ -f package.xml ]; then
rm package.xml
fi
cp -f package_ROS1.xml package.xml
elif [ ${ROS_VERSION} = ${VERSION_ROS2} ]; then
if [ -f package.xml ]; then
rm package.xml
fi
cp -f package_ROS2.xml package.xml
cp -rf launch_ROS2/ launch/
fi

# build
pushd `pwd` > /dev/null
if [ $ROS_VERSION = ${VERSION_ROS1} ]; then
cd ../../
catkin_make -DROS_EDITION=${VERSION_ROS1}
elif [ $ROS_VERSION = ${VERSION_ROS2} ]; then
cd ../../
colcon build --cmake-args -DROS_EDITION=${VERSION_ROS2} -DHUMBLE_ROS=${ROS_HUMBLE}
fi
popd > /dev/null

# remove the substituted folders/files
if [ $ROS_VERSION = ${VERSION_ROS2} ]; then
rm -rf launch/
fi

popd > /dev/null
2 changes: 1 addition & 1 deletion livox_ros/match_livox/config/MID360_config_mur620b.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"lidar_configs" : [
{
"ip" : "192.168.1.185",
"ip" : "192.168.12.185",
"pcl_data_type" : 1,
"pattern_mode" : 0,
"extrinsic_parameter" : {
Expand Down