Files
pnkx_nav_core/examples/run_example.sh
duongtd d40051df27 pnkx_nav_core 1.0 — every package is a submodule at its own pinned commit
A single commit on an orphan branch, so this is the whole tree as it should
land on a robot, with no history from the branch it grew out of.

Every package is now a git submodule - 26 of them, 15 registered here for the
first time. They were sitting in the tree as plain clones, which looks right
locally and is empty on the robot: a clone of this repository would have
carried the directory names and none of the contents. That failure reports
itself as "works on my machine, not on the robot", and it is the reason this
conversion happened at all.

Newly registered:

  src/Navigations/Packages/move_base2
  src/Algorithms/Packages/actions/dock_pattern_action
  src/Algorithms/Packages/global_planners/sbpl_lattice_planner
  src/Algorithms/Packages/local_planners/{hybrid,mppi,priest}_local_planner
  src/Libraries/{action_core,angles,depth_image_proc,dock_pattern_detector}
  src/Libraries/{mission_adapters,recovery_core,robot_line_extraction}
  src/Libraries/{robot_sensor_ports,sbpl}

.gitignore had a rule - **/[Pp]ackages/* - that hid move_base2 and
dock_pattern_action from git status entirely, so they would have been left out
without anything being said. The exception is written for those two paths only
rather than by loosening the rule.

Every submodule points at the tip of the branch it was already pinned to, not
blindly at main. costmap_2d stays on dev_cam_intel; that branch exists for a
reason, and this tree carries field calibration that does not belong to main.
The other 25 are at the tip of main.

config/ is flattened into config/runtime/, matching the layout the nav core
reads. The .zip snapshots of old package states are gone - they were manual
backups, not build inputs.
2026-08-27 10:09:25 +07:00

124 lines
4.0 KiB
Bash
Executable File

#!/bin/bash
# Script để build và chạy C# example
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
BUILD_DIR="$PROJECT_ROOT/build"
LIB_DIR="$BUILD_DIR"
EXAMPLE_DIR="$SCRIPT_DIR"
echo "=========================================="
echo "Building and Running C# Navigation Example"
echo "=========================================="
echo ""
echo "📁 Paths:"
echo " SCRIPT_DIR: $SCRIPT_DIR"
echo " PROJECT_ROOT: $PROJECT_ROOT"
echo " BUILD_DIR: $BUILD_DIR"
echo " LIB_DIR: $LIB_DIR"
echo " EXAMPLE_DIR: $EXAMPLE_DIR"
echo ""
echo "Building C API library..."
cd "$BUILD_DIR"
cmake ..
make
sudo make install
echo "Library built successfully!"
# Kiểm tra dotnet có được cài đặt không
if ! command -v dotnet &> /dev/null; then
echo "=========================================="
echo "WARNING: .NET SDK not found!"
echo "=========================================="
echo "To run the C# example, please install .NET SDK:"
echo ""
echo " Ubuntu/Debian:"
echo " wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh"
echo " chmod +x dotnet-install.sh"
echo " ./dotnet-install.sh --channel 6.0"
echo " export PATH=\$PATH:\$HOME/.dotnet"
echo ""
echo " Or visit: https://dotnet.microsoft.com/download"
echo ""
echo "Skipping C# example. Library is available at:"
echo " $LIB_DIR/libnav_c_api.so"
echo "=========================================="
exit 0
fi
# Bước 2: Tạo C# project nếu chưa có
if [ ! -d "$EXAMPLE_DIR/NavigationExample" ]; then
echo "Creating C# project..."
cd "$EXAMPLE_DIR"
dotnet new console -n NavigationExample
cd NavigationExample
# Tạo .csproj file
cat > NavigationExample.csproj << 'EOF'
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<None Include="libnav_c_api.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
EOF
echo "C# project created!"
else
echo "C# project already exists"
fi
# Luôn copy source code mới nhất (cập nhật file nếu đã có)
cd "$EXAMPLE_DIR/NavigationExample"
# # Bước 3: Copy library
# echo "Copying library..."
# cp "$LIB_DIR/libnav_c_api.so" .
# Bước 4: Set LD_LIBRARY_PATH để tìm được tất cả dependencies
# Main build directory (contains libtf3.so, librobot_cpp.so, etc.)
export LD_LIBRARY_PATH="$BUILD_DIR:$LD_LIBRARY_PATH"
# Library directories for dependencies
export LD_LIBRARY_PATH="$BUILD_DIR/src/Libraries/robot_time:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$BUILD_DIR/src/Libraries/xmlrpcpp:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$BUILD_DIR/src/Libraries/robot_costmap_2d:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$BUILD_DIR/src/Libraries/geometry2/robot_tf3_geometry_msgs:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$BUILD_DIR/src/Libraries/geometry2/robot_tf3_sensor_msgs:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$BUILD_DIR/src/Navigations/Packages/move_base:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$BUILD_DIR/src/Navigations/Cores/move_base_core:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$BUILD_DIR/src/Navigations/Libraries/tf3:$LD_LIBRARY_PATH"
# Also add the example directory where the library is copied
export LD_LIBRARY_PATH="$EXAMPLE_DIR/NavigationExample:$LD_LIBRARY_PATH"
# Add the output directory where .NET places the library
export LD_LIBRARY_PATH="$EXAMPLE_DIR/NavigationExample/bin/Debug/net6.0/linux-x64:$LD_LIBRARY_PATH"
# Bước 5: Build và chạy
echo "Building C# project..."
dotnet build
echo ""
echo "Running example..."
echo "=========================================="
echo "LD_LIBRARY_PATH includes:"
echo "$LD_LIBRARY_PATH" | tr ':' '\n' | head -5
echo "..."
echo "=========================================="
dotnet run
echo "=========================================="
echo "Done!"