.. rubric:: Installation Robot

- Enable Internet by connecting it to a switch with internet

.. code-block:: bash

    sudo ip link set eth0 down && sudo ip link set eth0 up
    sudo dhclient eth0


- Switch H1 id with ctrl+h

.. code-block:: bash

    h1_unit_238


- Switch username

.. code-block:: bash

    sudo hostnamectl set-hostname h1-unit-284-pc-4


- Disable redundant B2 slam

.. code-block:: bash

    sudo systemctl stop unitree_slam.service
    sudo systemctl disable unitree_slam.service
    sudo rm /lib/systemd/system/unitree_slam.service


- Update date and time, ensure you have internet in the robot. The quickest way is using the USB WiFi stick

.. code-block:: bash
    
    sudo timedatectl set-timezone Europe/Berlin
    sudo date -s "$(wget --method=HEAD -qSO- --max-redirect=0 google.com 2>&1 | sed -n 's/^ *Date: *//p')"


- Install ROS2 Humble dev tools

.. code-block:: bash
    
    sudo apt update && sudo apt install curl -y
    export ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F\" '{print $4}')
    curl -L -o /tmp/ros2-apt-source.deb "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.$(. /etc/os-release && echo $VERSION_CODENAME)_all.deb" # If using Ubuntu derivates use $UBUNTU_CODENAME
    sudo dpkg -i /tmp/ros2-apt-source.deb
    sudo apt install ros-dev-tools


- Create directory for h1 Workspace

.. code-block:: bash
    
    sudo mkdir /opt/mybotshop

.. code-block:: bash
    
    sudo chown -R unitree:unitree /opt/mybotshop


- Clone the repository, copy over to the h1's PC and run the installer script
  - Press Y when installing Livox Mid360
  - Select gdm3 when prompted in webserver installation

.. code-block:: bash
    
    cd /opt/mybotshop/src/mybotshop/ && sudo chmod +x h1_install.sh && ./h1_install.sh



.. code-block:: bash
    
    cd /opt/mybotshop/src/mybotshop/h1_webserver && sudo chmod +x webserver_installer.sh && ./webserver_installer.sh


- Build unitree sdk

.. code-block:: bash
    
    cp -r /opt/mybotshop/src/third_party/unitree/04Aug2025_unitree_sdk2/ /opt/mybotshop
    cd /opt/mybotshop/04Aug2025_unitree_sdk2/build
    cmake .. && make && sudo make install

- Build Kiss ICP

.. code-block:: bash
    
    python3 -m pip install --user --upgrade "cmake>=3.24"
    export PATH="$HOME/.local/bin:$PATH"
    cd /opt/mybotshop && colcon build --symlink-install --packages-select kiss_icp --cmake-args -DCMAKE_POLICY_VERSION_MINIMUM=3.24

- Build ros2 workspace

.. code-block:: bash

    cd /opt/mybotshop && colcon build --symlink-install && source install/setup.bash

- Add the following to `.bashrc`

.. code-block:: bash
    
    # MYBOTSHOP
    source /opt/mybotshop/install/setup.bash
    alias h1_build='cd /opt/mybotshop && colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release && source install/setup.bash'

- Increase cyclone kernel

.. code-block:: bash

    printf "net.core.rmem_max=33554432\nnet.core.rmem_default=33554432\nnet.core.wmem_max=33554432\nnet.core.wmem_default=33554432\nnet.ipv4.udp_rmem_min=16384\nnet.ipv4.udp_wmem_min=16384\n" | sudo tee /etc/sysctl.d/90-ros2-dds.conf

.. code-block:: bash
    
    sudo sysctl --system 


- Run the startup installer
  - Ensure H1/H1-2 for **description** in the `/opt/mybotshopt/src/mybotshop/h1_bringup/scripts/startup_installer.py`

.. code-block:: bash
    
    ros2 run h1_bringup startup_installer.py

.. rubric:: Installation External

- Clone the repository into a ros2_ws and build essential items only via:

.. code-block:: bash
    
    colcon build --symlink-install --packages-select h1_description h1_viz && source install/setup.bash 

- Source and run rviz2

.. code-block:: bash
    
    export H1_NS="h1_unit_238"
    ros2 launch h1_viz view_robot.launch.py