Skip to content

Latest commit

 

History

History
198 lines (152 loc) · 4.61 KB

File metadata and controls

198 lines (152 loc) · 4.61 KB

SRFV Usage Notes

This file keeps the detailed commands out of the main README.

PX4 Model Setup

Install the custom model into PX4:

cd ~/ros2_ws/src/srfv_controller
./scripts/install_px4_model.sh

Build the ROS 2 package the first time, and rebuild after code changes:

cd ~/ros2_ws
colcon build --packages-select srfv_controller --symlink-install
source install/setup.bash

The build installs the custom Gazebo plugin libRollingResistance.so. Source the workspace in every terminal that starts PX4, Gazebo, or ROS 2 nodes.

Startup Sequence

Use one terminal for each step.

1. PX4 SITL

source ~/ros2_ws/install/setup.bash
cd ~/PX4-Autopilot
make px4_sitl gz_x500_custom

2. DDS Agent

cd ~/Micro-XRCE-DDS-Agent/build
MicroXRCEAgent udp4 -p 8888

3. Gazebo Bridge

cd ~/ros2_ws
source install/setup.bash
ros2 launch srfv_controller srfv_universal_bridge.launch.py

The bridge publishes /clock, /joint_states, /model/x500_custom_0/pose, /ground_truth/drone_odometry, and /ground_truth/cage_odometry.

Trajectory Commands

Hold

cd ~/ros2_ws
source install/setup.bash
ros2 run srfv_controller trajectory_reference_node --ros-args \
  -p pattern:=hold \
  -p hold_x:=0.01 \
  -p hold_y:=0.01

Square

cd ~/ros2_ws
source install/setup.bash
ros2 run srfv_controller trajectory_reference_node --ros-args \
  -p pattern:=square \
  -p center_x:=0.0 \
  -p center_y:=0.0 \
  -p square_side:=0.03 \
  -p square_leg_duration:=15.0

Circle

cd ~/ros2_ws
source install/setup.bash
ros2 run srfv_controller trajectory_reference_node --ros-args \
  -p pattern:=circle \
  -p center_x:=0.0 \
  -p center_y:=0.0 \
  -p radius:=0.03 \
  -p period:=60.0 \
  -p ramp_time:=15.0

Figure Eight

cd ~/ros2_ws
source install/setup.bash
ros2 run srfv_controller trajectory_reference_node --ros-args \
  -p pattern:=figure_eight \
  -p center_x:=0.0 \
  -p center_y:=0.0 \
  -p radius:=0.025 \
  -p period:=180.0 \
  -p ramp_time:=45.0

Controller Command

Run the controller after PX4 SITL, the DDS agent, and the Gazebo bridge are running:

cd ~/ros2_ws
mkdir -p ~/ros2_ws/logs
source install/setup.bash

ros2 run srfv_controller rpn_position_controller --ros-args \
  -p arm_enabled:=true \
  -p external_trajectory_enabled:=true \
  -p external_trajectory_relative:=true \
  -p position_feedback_source:=estimated \
  -p paper_actuation_enabled:=true \
  -p paper_dry_run_enabled:=false \
  -p kp:=0.20 \
  -p kd:=0.04 \
  -p moment_limit:=0.008 \
  -p collective_command:=0.150 \
  -p paper_collective_command:=0.150 \
  -p cage_radius:=0.55 \
  -p odometry_frame_yaw_offset:=0.28 \
  -p position_kp_x:=0.11 \
  -p position_kd_x:=0.70 \
  -p position_ki_x:=0.0 \
  -p position_kp_y:=0.11 \
  -p position_kd_y:=0.70 \
  -p position_ki_y:=0.0 \
  -p paper_position_ki_x:=0.0 \
  -p paper_position_ki_y:=0.0 \
  -p max_lateral_force:=0.005 \
  -p max_lateral_force_rate:=0.010 \
  -p max_command_angle:=0.014 \
  -p lateral_rpn_sign:=1.0 \
  -p lateral_rpn_sign_x:=1.0 \
  -p lateral_rpn_sign_y:=1.0 \
  -p outer_loop_start_delay:=0.0 \
  -p roll_mixer_sign:=1.0 \
  -p pitch_mixer_sign:=1.0 \
  -p rod_fixed_roll_offset:=0.0 \
  -p project_force_to_rolling_axis:=false \
  -p yaw_damping_gain:=0.0 \
  2>&1 | tee ~/ros2_ws/logs/paper_run_$(date +%Y%m%d_%H%M%S).log

The tee command is used to save the controller output to a log file while still showing it in the terminal.

Restart the controller after any safety abort.

RViz Validation

Start RViz after the trajectory and controller nodes:

rviz2

Set Fixed Frame to world, then add these Path topics:

  • Green: /srfv/path/desired
  • Blue: /srfv/path/estimated
  • Red: /srfv/path/ground_truth

Use the red Gazebo cage path only for validation. The final controller run should use position_feedback_source:=estimated.

MATLAB Connection

MATLAB ROS Toolbox can connect directly to the ROS 2 DDS graph:

setenv("ROS_DOMAIN_ID", "0");
node = ros2node("/matlab_srfv");
topics = ros2("topic", "list");

desired = ros2subscriber(node, "/srfv/path/desired");
estimated = ros2subscriber(node, "/srfv/path/estimated");
truth = ros2subscriber(node, "/ground_truth/cage_odometry");

PX4 topics still require the Micro XRCE-DDS Agent.

Validation Checklist

For final results, run each trajectory at least three times from a fresh PX4 SITL and controller restart. Record:

  • Estimated versus cage-ground-truth RMS error
  • Maximum position error
  • Motor command range
  • Whether a safety abort occurred

Do not report internal drone odometry as cage-center ground truth.