Base Station ROS Network - Weber-State-UAV-Program/Documentation-2024-2025 GitHub Wiki

RQT Graph

The following graph illustrates the connections between ROS topics and nodes controlled by the base station computer. rqt_graph

Nodes

Three nodes run upon booting up the LattePanda as seen in the RQT graph above. The code listing for each node is listed in the Code page.

base_exec

This node communicates the door status to the drone and calculates the distance from the drone to the base station.

Parameters

These are the parameters that are defined in the parameters.yaml file in the code listing for arg_basestation_pkg.

Parameter Name Type Default Value Description
central_tags_light_level int 10 % brightness for inner tags
outer_tags_light_level int 20 % brightness for outer tags
central_tags_visible_height float 3.0 Height (m) below which IR lights are dimmed for easier visibility
light_threshold int 75 Ambient light threshold (%)
XY_distance_threshold float 20.0 Drone proximity threshold (m) below which IR lights are turned on
precision_landing_mode string "CMODE(218365952)" MAVROS mode name for custom precision landing

Publishers

Topic Name Message Type Description
relay_control std_msgs/Bool Relay control signal
to_ir_control std_msgs/UInt8 PWM percentage to IR controller
/base_exec/heartbeat std_msgs/Bool Heartbeat signal to drone
/door_cmd custom_msgs/DoorCmd Door command to I/O controller
/base_exec/door_status custom_msgs/DoorStatus Door status published to drone

Subscribers

Topic Name Message Type Description
/base_exec/door_cmd custom_msgs/DoorCmd Command from drone to control door
/door_status custom_msgs/DoorStatus Door status from I/O controller
solar_to_baseExec custom_msgs/SolarInfo Solar panel telemetry (V, A, W)
/mavros/state mavros_msgs/State Drone state (armed, flight mode)
from_ir_control std_msgs/Float32 Ambient light level from IR control node
/mavros/home_position/home mavros_msgs/HomePosition Drone’s home pose
/mavros/local_position/pose geometry_msgs/PoseStamped Current local position of drone

Timers

Timer Name Interval Purpose
heartbeat_timer 1.0 sec Sends periodic heartbeat signal
test_timer 1.0 sec Test logic for IR/door control (optional)

io_controller

This node controls all the pins on the LattePanda. It contains the state machine that dictates the doors opening and closing, controls the relay pins, and determines when it is too dark outside for the AprilTags to be seen by the drone camera based on the data from the Ambient Light Processing PCB.

Publishers

Topic Type Purpose
/door_cmd DoorCmd Receives command to open or close doors
relay_control std_msgs/String Controls relay banks by string command
to_ir_control std_msgs/UInt8 Controls IR system (implementation TBD)

Subscribers

Topic Type Purpose
/door_status DoorStatus Publishes current door state (OPEN/CLOSED)
from_ir_control std_msgs/Float32 Publishes processed light intensity from IR sensor

Timers

Timer Interval Callback
door_status_timer 0.1s Publishes door status
motor_timer 0.01s Manages motor state transitions (IDLE, OPENING, CLOSING)
ir_timer 1s Reads from IR sensor and publishes data

solar_node

This node spits out a bunch of information from the solar charge controller inside the base station. It will not work unless the RS232 cable is connected to both the LattePanda and the charge controller. No data will display from the node if the solar panel is not connected to the corresponding connectors on the base station.

Publishers

Topic Type Purpose
solar_to_baseExec SolarInfo Publishes solar system status including battery, PV, temperature, load, etc.

Timers

Timer Interval Callback
solar_timer 60 seconds timer_callback() — Reads from RS232 and publishes SolarInfo

basestation_adc_node

This node does not work currently. It requires a raspberrypi inside the base station. We did not have an extra and since this node was not pertinent to our continuation project, we did not bother buying a new raspberrypi. For this reason, it is not included in the launch file we are using.

Starting the ROS Nodes

Startup Service

The LattePanda runs a service on boot that starts the nodes automatically with the following terminal conmands:

cd ARG-Drone-2024-2025/arg_workspace_2024
ros2 launch arg_basestation_pkg launch.py

Note that the service doesn't actually build the package before launching the nodes, so the service will use whatever build is in the build directory. If you need to use the latest changes, you will need to stop the service, rebuild the package, then start the service again:

sudo systemctl stop ros_nodes_startup.service
colcon build
source install/setup.bash
sudo systemctl start ros_nodes_startup.service

The launch file runs io_controller.py, base_exec.py, and solar_node.py.

The service is located in the following folder: /etc/systemd/system/ros_nodes_startup.service

INFO: There is no way to view the logs of the individual nodes running while running the service. If you want to see the logs live in the terminal, you need to stop the service and run the nodes manually.

Manually Running Nodes

You can manually run all three nodes by running the launch file in /ARG-Drone-2024-2025/arg_workspace_2024:

ros2 launch arg_basestation_pkg launch.py

Opening and closing the doors

From the Base Station

  1. Make sure the io_controller node is running.
  2. Open a new terminal and navigate to /ARG-Drone-2024-2025/arg_workspace_2024.
  3. Run this command to open the doors: ros2 topic pub /base_exec/door_cmd arg_interfaces/DoorCmd "{cmd: 0}"
  4. To close the doors: ros2 topic pub /base_exec/door_cmd arg_interfaces/DoorCmd "{cmd: 1}"

From the Drone

The Drone can command the doors to open or close through QGroundControl. Go here for more details.

Opening/Closing Doors Logic

A complete rewrite of the logical flow for how the base station doors open/close was completed for this year's project. Originally, two analog pins were being used as digital pins to determine when one of each pair of limit switches was being tripped. This was how they determined when the doors were open or closed and when to stop the motor. These two pins no longer work as they did before. We are suspicious that the pins are fried. We had to switch to using a single digital pin because there were no remaining analog pins that worked and this was the last available digital pin that worked. We routed all four limit switches to the same digital pin on the LattePanda (see LattePanda Page for the full pinout of the used pins). This required a change in determining when the doors were open and which direction to set the motor when we wanted to open or close the doors. The following state machine was implemented in io_controller.py to open and close the doors: doors_SM drawio

Determining whether the doors are open or closed

A file called "doors_open.txt" is created in /ARG-Drone-2024-2025/arg_workspace_2024 on the LattePanda when the doors are opened that is then deleted when the doors are closed. Since this is non-volatile memory, upon starting the io_controller node, we simply check if that exact file name exists in a specific path. If it does, we know the doors are open, otherwise the doors must be closed. Even if we got stuck halfway through opening or closing the doors, the next command to open or close the doors should still work because the file is created or deleted only after a limit switch is triggered which only happens when the doors have been completely opened or closed.