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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ __pycache__/
.env
venv/
*.venv
.vizflyt
61 changes: 40 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,29 @@ This guide will walk you through setting up **VizFlyt**, installing dependencies
Ensure you have the following dependencies installed before proceeding:

- ✅ **[Ubuntu 22.04](https://releases.ubuntu.com/jammy/)**
- ✅ **[NVIDIA Drivers](https://www.nvidia.com/en-us/drivers/)** (For GPU acceleration)
- ✅ **[NVIDIA Drivers (CUDA 11.8)](https://www.nvidia.com/en-us/drivers/)** (For GPU acceleration)
- ✅ **[ROS2 Humble](https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debs.html)** (Required for ROS-based workflows)
- ✅ **[Miniconda3](https://www.anaconda.com/docs/getting-started/miniconda/install#macos-linux-installation)** (For managing Python environments)
- ✅ **[ROS2 Vicon Reciever Package](https://github.com/OPT4SMART/ros2-vicon-receiver)** (For publishing vicon data to ROS)

➕ *Note: sometimes requires `pip install "empy<4.0" catkin_pkg lark` to satisfy build dependencies.*
---

### **1.2 Setting Up the VizFlyt Environment**
#### **Step 1: Create and Activate the Conda Environment**
Run the following commands to set up a dedicated Conda environment for VizFlyt:
#### **Step 1: Create and Activate the Venv Environment**
Run the following commands to set up a dedicated Venv environment for VizFlyt:

```bash
# Create a Conda environment with Python 3.10
conda create --name vizflyt -y python=3.10.14
# Clone the repository
git clone https://github.com/pearwpi/VizFlyt.git && cd VizFlyt

# Create a python venv environment with Python 3.10
python3 -m venv .vizflyt

# Activate the environment
conda activate vizflyt
source .vizflyt/bin/activate

# Upgrade pip
python -m pip install --upgrade pip
python3 -m pip install --upgrade pip
```

---
Expand All @@ -100,11 +104,18 @@ Install **PyTorch** and CUDA dependencies for GPU acceleration:
```bash
pip install torch==2.1.2+cu118 torchvision==0.16.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118

# Install CUDA Toolkit (Ensure compatibility with PyTorch version)
conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit
pip install --upgrade "numpy<2"

# Install tiny-cuda-nn (for optimized CUDA operations)
pip install ninja git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
pip install wheel ninja
pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
```
📌 Note: Ensure that CUDA 11.8 is installed and activated in the current terminal with nvcc --version.
If it is not, you can run the following (before installing the above).
```bash
export CUDA_HOME=/usr/local/cuda-11.8
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
```

---
Expand All @@ -113,10 +124,7 @@ pip install ninja git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindi
Clone the VizFlyt repository and install the modified **Nerfstudio** framework:

```bash
# Clone the repository
git clone https://github.com/pearwpi/VizFlyt.git

cd VizFlyt/nerfstudio
cd nerfstudio

# Upgrade pip and setuptools before installing dependencies
pip install --upgrade pip setuptools
Expand All @@ -131,16 +139,22 @@ pip install -e .
Once your environment is set up, build the ROS2 workspace:

```bash
pip install --upgrade "numpy<2"
cd ..

pip install transforms3d gdown pyquaternion

# edit the vizflyt package setup.cfg to use the venv
source setup_cfg.sh

cd vizflyt_ws/

colcon build --symlink-install
colcon build
```
📌 *Note: sometimes requires `pip install "empy<4.0" catkin_pkg lark` to satisfy build dependencies.*

This ensures all necessary dependencies are installed and the workspace is properly compiled.

*If you haven't already, add the vicon_reciever package under 'src' in `vizflyt_ws`*
---

## **3. Making Your Workflow Easier**
Expand All @@ -152,15 +166,20 @@ To simplify your workflow, you can define **aliases** in your `~/.bashrc` file f
Append the following lines to your `~/.bashrc` or `~/.bash_profile`:

```bash
alias viz='conda activate vizflyt'
alias viz='source $HOME/VizFlyt/.vizflyt/bin/activate'
alias viz_ws='cd $HOME/VizFlyt/vizflyt_ws'
alias source_ws='source install/setup.bash'
alias source_ws2='source install/local_setup.bash'
alias build_ws='colcon build --symlink-install'
alias set_env='export PYTHON_EXECUTABLE="$HOME/miniconda3/envs/vizflyt/bin/python" && export PYTHONPATH="$HOME/miniconda3/envs/vizflyt/lib/python3.10/site-packages:$PYTHONPATH" && export PYTHONPATH=$PYTHONPATH:$HOME/VizFlyt/nerfstudio'
alias build_ws='colcon build'
alias init_vizflyt='viz && viz_ws && source_ws && source_ws2 && set_env && cd src'
```

Alternatively, we provide a script to run these commands for you. Simply append the following lines to your `~/.bashrc` or `~/.bash_profile`:
```bash
export VIZFLYT_PATH="$HOME/VizFlyt/"
alias init_vizflyt="source $VIZFLYT_PATH/setup_vizflyt_venv.sh"
```

#### **Step 2: Apply the Changes**
To make the aliases available immediately, run:

Expand All @@ -178,7 +197,7 @@ init_vizflyt
```

This command will:
✔️ Activate the **vizflyt** Conda environment
✔️ Activate the **vizflyt** Venv environment
✔️ Navigate to the **VizFlyt workspace**
✔️ Source the required ROS2 setup files
✔️ Set up the necessary **Python environment variables**
Expand Down
23 changes: 23 additions & 0 deletions setup_cfg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Check if VIZFLYT_PATH is set
if [ -z "$VIZFLYT_PATH" ]; then
echo "❌ Error: VIZFLYT_PATH is not set."
exit 1
fi

# Define the full Python path
PYTHON_EXEC="$VIZFLYT_PATH/.vizflyt/bin/python"

# Generate setup.cfg
cat > $VIZFLYT_PATH/vizflyt_ws/src/vizflyt/setup.cfg <<EOF
[develop]
script_dir=\$base/lib/vizflyt
[install]
install_scripts=\$base/lib/vizflyt
[build_scripts]
executable = $PYTHON_EXEC
EOF

echo "✅ setup.cfg generated with:"
echo "executable = $PYTHON_EXEC"
9 changes: 9 additions & 0 deletions setup_vizflyt_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
conda activate vizflyt
cd $VIZFLYT_PATH/vizflyt_ws
colcon build --symlink-install
source install/setup.sh
source install/local_setup.sh
export PYTHON_EXECUTABLE="$HOME/miniconda3/envs/vizflyt/bin/python"
export PYTHONPATH="$HOME/miniconda3/envs/vizflyt/lib/python3.10/site-packages:$PYTHONPATH"
export PYTHONPATH=$PYTHONPATH:$HOME/VizFlyt/nerfstudio
cd src
18 changes: 18 additions & 0 deletions setup_vizflyt_venv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# load cuda 11.8 for nerfstudio
export CUDA_HOME=/usr/local/cuda-11.8
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH

# setup env
source $VIZFLYT_PATH/.vizflyt/bin/activate
cd $VIZFLYT_PATH/vizflyt_ws

# add the venv python interpreter to the setup.cfg in vizflyt
source $VIZFLYT_PATH/setup_cfg.sh

# build and source
colcon build
source install/setup.sh
source install/local_setup.sh

cd src
57 changes: 57 additions & 0 deletions vizflyt_ws/src/vicon_receiver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
cmake_minimum_required(VERSION 3.5)
project(vicon_receiver)

# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -g)
endif()

include_directories(
include
${Boost_INCLUDE_DIRS}
)

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(rclcpp REQUIRED)
find_package(Boost REQUIRED COMPONENTS thread)

rosidl_generate_interfaces(${PROJECT_NAME}
"msg/Position.msg"
)

ament_export_dependencies(rosidl_default_runtime)

add_executable(vicon_client src/vicon_receiver/communicator.cpp src/vicon_receiver/publisher.cpp)
target_link_libraries(vicon_client ViconDataStreamSDK_CPP ${Boost_LIBRARIES})
ament_target_dependencies(vicon_client "rclcpp")

get_default_rmw_implementation(rmw_implementation)
find_package("${rmw_implementation}" REQUIRED)
get_rmw_typesupport(typesupport_impls "${rmw_implementation}" LANGUAGE "cpp")

foreach(typesupport_impl ${typesupport_impls})
rosidl_target_interfaces(vicon_client
${PROJECT_NAME} "rosidl_typesupport_cpp"
)
endforeach()

install(TARGETS vicon_client DESTINATION lib/${PROJECT_NAME})

# Install launch file
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)

ament_package()
Loading