{"id":671,"date":"2025-05-03T03:32:53","date_gmt":"2025-05-03T03:32:53","guid":{"rendered":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/?page_id=671"},"modified":"2025-05-04T05:25:55","modified_gmt":"2025-05-04T05:25:55","slug":"software","status":"publish","type":"page","link":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/documents\/software\/","title":{"rendered":"Software Instructions"},"content":{"rendered":"\n<h1 class=\"wp-block-heading has-x-large-font-size\">Drone Autonomy System with Integrated Gimbal<\/h1>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">Project Information<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Class:<\/strong> Robotic Systems Development<\/li>\n\n\n\n<li><strong>Team:<\/strong> Team B, MRSD 2024<\/li>\n\n\n\n<li><strong>Team Members:<\/strong> Yufan Liu, Gweneth Ge, Joshua Pen, Jet Situ, Yi Wu<\/li>\n\n\n\n<li><strong>Description:<\/strong> Autonomous drone system with integrated gimbal control for target tracking and monitoring tasks<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">Introduction<\/h2>\n\n\n\n<p>This software system provides a complete solution for drone autonomy with integrated gimbal control. The system leverages ROS2 for communication between components, computer vision for object detection, and a multi-threaded architecture for efficient processing. The system includes components for UI visualization (Foxglove), gimbal control, camera stream processing, and object detection.<\/p>\n\n\n\n<p>For detailed explanation of the software architecture, please refer to our <a href=\"https:\/\/github.com\/LifGorg\/TeamB_mrsd_24\">GitHub repository<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">Repository Structure<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>AirStack\/<\/strong>: Air stack components for drone control<\/li>\n\n\n\n<li><strong>AirStack_GCS\/<\/strong>: Ground control station components<\/li>\n\n\n\n<li><strong>humanflow\/<\/strong>: ROS2-based gimbal control system\n<ul class=\"wp-block-list\">\n<li><strong>ros2_ghadron_gimbal\/<\/strong>: Main gimbal control workspace<\/li>\n\n\n\n<li><strong>docker\/<\/strong>: Docker configurations for the workspace<\/li>\n\n\n\n<li><strong>mcap_data\/<\/strong>: Recorded data in MCAP format<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">Prerequisites and Installation<\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">System Requirements<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Docker and Docker Compose<\/li>\n\n\n\n<li>ROS2 Humble<\/li>\n\n\n\n<li>Ubuntu Linux (recommended)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-large-font-size\">Installing Docker and Docker Compose<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Install Docker\nsudo apt-get update\nsudo apt-get install apt-transport-https ca-certificates curl software-properties-common\ncurl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo apt-key add -\nsudo add-apt-repository \"deb &#091;arch=amd64] https:\/\/download.docker.com\/linux\/ubuntu $(lsb_release -cs) stable\"\nsudo apt-get update\nsudo apt-get install docker-ce docker-ce-cli containerd.io\nsudo usermod -aG docker $USER\n\n# Install Docker Compose\nsudo curl -L \"https:\/\/github.com\/docker\/compose\/releases\/download\/v2.18.1\/docker-compose-$(uname -s)-$(uname -m)\" -o \/usr\/local\/bin\/docker-compose\nsudo chmod +x \/usr\/local\/bin\/docker-compose\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-large-font-size\">Cloning the Repository<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/LifGorg\/TeamB_mrsd_24.git\ncd TeamB_mrsd_24\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">Network Configuration<\/h2>\n\n\n\n<p>Configure WIFI with the following IPv4 settings:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Manual address: <code>10.3.1.201<\/code><\/li>\n\n\n\n<li>Netmask: <code>255.255.255.0<\/code><\/li>\n\n\n\n<li>Gateway: <code>10.3.1.100<\/code><\/li>\n<\/ul>\n\n\n\n<p>Set ROS domain ID:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>export ROS_DOMAIN_ID=70\n<\/code><\/pre>\n\n\n\n<p>Verify connectivity:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ping 10.3.1.32\nros2 topic list\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">Docker Environment Setup<\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Robot Component<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cd AirStack\ndocker compose --profile hitl build\ndocker compose --profile hitl up -d\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Ground Control Station Component<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cd AirStack_GCS\ndocker compose --profile hitl build\ndocker compose --profile hitl up -d\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Gimbal Component<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cd humanflow\/ros2_ghadron_gimbal\/dockers\ndocker compose -f docker-compose.yaml down\ndocker compose -f docker-compose.yaml up -d\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Permission Settings<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown -R $USER:$USER \/home\/dtc\/humanflow\/ros2_ghadron_gimbal\nsudo chmod -R 755 \/home\/dtc\/humanflow\/ros2_ghadron_gimbal\/install\nsudo chmod -R 755 \/home\/dtc\/humanflow\/ros2_ghadron_gimbal\/install\/detect_and_track\/lib\/python3.10\/site-packages\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">System Usage<\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Foxglove UI Setup<\/h3>\n\n\n\n<p>Source ROS2 environment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source \/opt\/ros\/humble\/setup.bash\n<\/code><\/pre>\n\n\n\n<p>Run Foxglove bridge:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ros2 run foxglove_bridge foxglove_bridge\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-large-font-size\">Development Workflow<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>SSH into the remote machine:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh dtc@10.3.1.32\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>Check Docker containers:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>docker ps\n<\/code><\/pre>\n\n\n\n<p>Ensure that <code>[robot_l4t]<\/code> and <code>[gimbal]<\/code> containers are active.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Set up local editing environment:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sshfs dtc@10.3.1.32:\/home\/dtc\/humanflow &#091;path to your desired working directory]\/mount\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li>Connect to the Gimbal:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ~\/mount\/humanflow\/ros2_ghadron_gimbal\/src\/inted_gimbal\/\nbash e_gim&lt;Tab&gt;  # to enter Docker\nros2 launch gim&lt;tab&gt;b&lt;tab&gt; g&lt;tab&gt;  # launches gimbal connection\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Build after editing:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code># Remove existing build, install, log\n.\/r_gimbal.sh\n# Rebuild the selected packages\n.\/b_gimbal.sh\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-large-font-size\">Visualizing the Camera Stream<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>export ROS_DOMAIN_ID=70\ncd Desktop\/DroneSystem\/\nsource install\/setup.bash\npython3 ros2_image.py\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">Gimbal Control Commands<\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Basic Control<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Send control commands (pitch=0, roll=0, yaw=90)\nros2 topic pub \/gimbal_angles geometry_msgs\/msg\/Vector3 \"{x: 0.0, y: 0.0, z: 90.0}\"\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Mode Control<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># EO mode (Electro-Optical mode)\n.\/eo_mode.sh\n# IR mode (Infrared mode)\n.\/ir_mode.sh\n# Lock the gimbal\n.\/lock.sh\n# Point the gimbal downward\n.\/pointdown.sh\n# Return to home position\n.\/homing.sh\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">System Architecture<\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Integrated-Gimbal Node Thread Layout<\/h3>\n\n\n\n<p><strong>Stream Thread:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Uses GStreamer to receive frames through RTSP + TCP protocol at ~15 Hz<\/li>\n\n\n\n<li>Provides frames for detection threads<\/li>\n<\/ul>\n\n\n\n<p><strong>Detection Thread:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Retrieves frames from the stream at 10 fps (reducing compute resource requirements)<\/li>\n\n\n\n<li>Runs YOLO detection model<\/li>\n\n\n\n<li>Estimates and publishes GPS coordinates<\/li>\n\n\n\n<li>Publishes compressed images<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-large-font-size\">Performance Optimizations<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Frame Acquisition:<\/strong> Only the most recent decoded frame is kept in memory; earlier frames are discarded to prevent queue build-up<\/li>\n\n\n\n<li><strong>Parallel, Non-blocking Inference:<\/strong> Detection thread polls the latest frame, runs detection, then hands control back<\/li>\n\n\n\n<li><strong>Sensor Synchronization:<\/strong> Uses bounded search (max_sync_time_diff \u2248 0.3s) to attach fresh GPS\/IMU samples to each frame<\/li>\n\n\n\n<li><strong>Publishing Strategy:<\/strong> Results are published with BEST_EFFORT reliability and queue depth 1<\/li>\n\n\n\n<li><strong>Profiling:<\/strong> Lightweight profiler records per-function timing, CPU usage, memory usage, and thread count<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">Troubleshooting<\/h2>\n\n\n\n<p>If you encounter issues with the gimbal connection, verify that:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The radio ethernet is correctly configured<\/li>\n\n\n\n<li>All containers are running (<code>docker ps<\/code>)<\/li>\n\n\n\n<li>The ROS domain ID is set correctly (<code>export ROS_DOMAIN_ID=70<\/code>)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\">Additional Notes<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The pitch range of the gimbal is -90 (pointing down) to 90 (pointing up)<\/li>\n\n\n\n<li>The yaw range of the gimbal is -120 (left) to 120 (right)<\/li>\n\n\n\n<li>It&#8217;s recommended to change directions incrementally (e.g., by 10 degrees each time) to avoid gimbal lock<\/li>\n\n\n\n<li>Main gimbal control path: <code>\/home\/dtc\/humanflow\/ros2_ghadron_gimbal\/src\/inted_gimbal\/<\/code><\/li>\n\n\n\n<li>The <code>robot_l4t<\/code> container uses NVIDIA runtime for GPU acceleration<\/li>\n\n\n\n<li>Both the <code>robot_l4t<\/code> and ground control station containers use host network mode for direct communication<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Drone Autonomy System with Integrated Gimbal Project Information Introduction This software system provides a complete solution for drone autonomy with integrated gimbal control. The system leverages ROS2 for communication between components, computer vision for object detection, and a multi-threaded architecture for efficient processing. The system includes components for UI visualization (Foxglove), gimbal control, camera stream<br \/><a class=\"moretag\" href=\"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/documents\/software\/\">+ Read More<\/a><\/p>\n","protected":false},"author":396,"featured_media":0,"parent":22,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-671","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/wp-json\/wp\/v2\/pages\/671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/wp-json\/wp\/v2\/users\/396"}],"replies":[{"embeddable":true,"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/wp-json\/wp\/v2\/comments?post=671"}],"version-history":[{"count":20,"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/wp-json\/wp\/v2\/pages\/671\/revisions"}],"predecessor-version":[{"id":816,"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/wp-json\/wp\/v2\/pages\/671\/revisions\/816"}],"up":[{"embeddable":true,"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/wp-json\/wp\/v2\/pages\/22"}],"wp:attachment":[{"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2025teamb\/wp-json\/wp\/v2\/media?parent=671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}