pitch_controller.py - Vincent1334/ROS-Humble-BlueRov2-Driver GitHub Wiki
🎛️ Pitch Controller Node
Overview
The pitch_controller
Node is designed for controlling the pitch angle of a BlueROV2 underwater vehicle. This node uses a PID controller to adjust the vehicle's movement and maintain the desired pitch.
✅ Prerequisites
Before using the Pitch Controller Node, ensure the following:
- The BlueROV2 Controller Node is running.
👨🏼💻 Node Parameters
The Pitch Controller Node accepts the following parameters:
- pitch_desired: Desired pitch setpoint (default: 0 degrees)
- pwm_max: Maximum PWM value (default: 1900 pwm)
- pwm_neutral: Neutral PWM value (default: 1500 pwm)
- kp: Proportional gain constant (default: 600)
- kd: Derivative gain constant (default: 50)
- enable: Enable/disable the pitch controller (default: True)
These parameters can be adjusted by updating the corresponding values in the launch file or using dynamic reconfigure.
📜 Input Topics
The Pitch Controller Node subscribes to the following topics:
- /bluerov2/attitude: Attitude data (Roll, Pitch, Yaw) -
bluerov2_interfaces/Attitude
- /settings/pitch/set_pitch: Set the desired pitch -
std_msgs/UInt16
- /settings/pitch/set_pid: Set PID parameters -
bluerov2_interfaces/PID
- /settings/pitch/set_enable: Enable/disable the pitch controller -
std_msgs/Bool
📜 Output Topics
The Pitch Controller Node publishes the following topics:
- /bluerov2/rc/pitch: PWM signal for pitch control -
std_msgs/UInt16
- /settings/pitch/status: Pitch controller status -
std_msgs/String
/settings/pitch/status
Topic
Understanding the The /settings/pitch/status
topic provides real-time status information about the Pitch Controller Node. This information is published as a JSON-formatted string and includes key details about the current state of the pitch controller. Here's an example of the JSON structure:
{
"type": "pitch_controller",
"enable": true,
"kp": 600,
"kd": 50,
"pwm_max": 1900,
"pwm_neutral": 1500,
"pitch_desired": 0
}
[!WARNING]
This topic is read-only.
⚠️ Important Note
The Pitch Controller Node requires the BlueROV2 Controller Node to be running. Ensure that the BlueROV2 Controller Node is started before using the Pitch Controller Node.
⚒️ Example Usage
-
Set the desired pitch:
ros2 topic pub /settings/pitch/set_pitch std_msgs/UInt16 "data: 15"
-
Adjust PID parameters:
ros2 topic pub /settings/pitch/set_pid bluerov2_interfaces/PID "{kp: 700, kd: 60, pwm_max: 2000}"
-
Enable/disable the pitch controller:
ros2 topic pub /settings/pitch/set_enable std_msgs/Bool "data: true"
Feel free to experiment with different parameters to optimize pitch control for your BlueROV2 underwater vehicle! 🎛️🚤