RTS master installation - norlab-ulaval/Norlab_wiki GitHub Wiki

The master used to control to request the measurements from the clients is a Waveshare SX126X LoRa Hat module for LoRa communication.


LoRa Module Setup

  • Plug the LoRa module in your USB port
  • Launch RF Settings Software > Select COM port > Open > Get
  • Use the following settings > Set Params > Close
  • Unplug the LoRa module and put back the M1 jumper

Installation

Serial

cd ~/repos/
git clone [email protected]:norlab-ulaval/cpp_serial.git
cd cpp_serial/
cmake -S . -B build
cmake --build build -j
sudo cmake --install build --prefix /usr/local

Theodolite Master & Theodolite Pose

cd ~/ros2_ws/src
git clone [email protected]:norlab-ulaval/theodolite_master.git
git clone [email protected]:norlab-ulaval/theodolite_node_msgs.git
git clone [email protected]:norlab-ulaval/theodolite_pose.git
cd ~/ros2_ws && cb

Service

sudo micro /etc/systemd/system/launch_theodolite.service
[Unit]
Description="Theodolite Master Service"
Requires=launch_zenoh.service
After=launch_zenoh.service
Wants=launch_zenoh.service

[Service]
Type=forking
WorkingDirectory=/home/robot/
ExecStart=/home/robot/launch_theodolite.sh
KillMode=mixed
KillSignal=SIGINT
RestartKillSignal=SIGINT
Restart=on-failure
RestartSec=2
User=robot

[Install]
WantedBy=default.target

Startup script

sudo micro ~/ros2_ws/src/norlab_robot/scripts/startup/launch_theodolite.sh
eval "$(cat /home/robot/.bashrc | tail -n +10)"
sleep 2

name=master
screen -r -S $name -X quit
echo "Starting $name..."
screen -dmS $name -L -Logfile /home/robot/.screen/$name.log \
    bash -c "ros2 launch norlab_robot theodolite.launch.py"

sleep 1
if screen -list | grep -q $name; then
    echo "Theodolite master started successfully in screen '$name.'"
else
    echo "ERROR! Failed to start $name."
    exit 1
fi

Launch script

sudo micro ~/ros2_ws/src/norlab_robot/launch/theodolite.launch.py
import os
from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():
    share_folder = get_package_share_directory('norlab_robot')
    config_file = os.path.join(share_folder, 'config', '_theodolite.yaml')

    theodolite_master_launch = Node(
        package="theodolite_master",
        executable="theodolite_master",
        name="theodolite_master",
        output="screen",
        parameters=[config_file],
    )
    
    theodolite_pose_node = Node(
        package='theodolite_pose',
        executable='theodolite_pose_node',
        name='theodolite_pose_node',
        output='screen',
        parameters=[
            config_file,
            {'use_sim_time': True}
        ]
    )

    return LaunchDescription([
        theodolite_master_launch,
        theodolite_pose_node
    ])

Config file

sudo micro ~/ros2_ws/src/norlab_robot/config/_theodolite.yaml
/**:
  theodolite_master:
    ros__parameters:
      number_of_theodolite: 1
      polling_rate: 2.5
      time_sync_rate: 0.1
      alpha: 0.1
      debug: False
      port: "/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0"
      baudrate: 115200
      timeout_ms: 30

  theodolite_pose:
    ros__parameters:
      input_topic: "/theodolite_data"
      output_topic: "/theodolite_pose"
      reference_frame: "trajectory"
      robot_frame: "prism3"
      min_measurements: 3

Enable service

sudo systemctl daemon-reload
sudo systemctl enable launch_theodolite.sh