### Installation Source: https://aerostack2.github.io/_03_aerial_platforms/_multirotor_simulator/index.html Instructions for installing the Multirotor simulator platform. ```APIDOC ## Installation * For binary installation, install by running: ```bash sudo apt install ros-humble-as2-platform-multirotor-simulator ``` * For source installation, clone Aerostack2 repository into your workspace and build it. See it in Aerostack2 installation guide. ``` -------------------------------- ### Install Prerequisites Source: https://aerostack2.github.io/_02_examples/index.html Installs necessary tools like tmux, tmuxinator, and iputils-ping for organized execution and network testing. ```bash sudo apt install tmux tmuxinator iputils-ping -y ``` -------------------------------- ### Clone DJI PSDK Project Source: https://aerostack2.github.io/_02_examples/dji/project_dji_psdk/index.html Clone the PSDK project repository to your local machine. This is the first step to start using the examples. ```bash git clone https://github.com/aerostack2/project_dji_psdk ``` -------------------------------- ### Install DJI Tello Platform via Binary Source: https://aerostack2.github.io/_03_aerial_platforms/_ryze_tello/index.html Use this command for a standard binary installation on a ROS 2 Humble environment. ```bash sudo apt install ros-humble-as2-platform-tello ``` -------------------------------- ### Install DJI Tello Platform from Source Source: https://aerostack2.github.io/_03_aerial_platforms/_ryze_tello/index.html Clone the repository into a workspace and build it using colcon. Ensure rosdep dependencies are installed before building. ```bash # If you have installed Aerostack2 from sources we recommend to clone the package in the src folder of your workspace otherwise you can clone it in any ROS 2 workspace you want. cd ~/aerostack2_ws/src/aerostack2/as2_aerial_platforms git clone git@github.com:aerostack2/as2_platform_tello.git cd ~/aerostack2_ws rosdep install as2_platform_tello --from-paths src --ignore-src -r -y colcon build --packages-up-to as2_platform_tello ``` -------------------------------- ### Install Aerostack2 Gazebo Platform Source: https://aerostack2.github.io/_03_aerial_platforms/_gazebo_simulation/index.html Installs the binary package for the Aerostack2 Gazebo platform. ```bash sudo apt install ros-humble-as2-platform-gazebo ``` -------------------------------- ### Setup ArUco Detection Behavior Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Performs initial setup for the ArUco marker detection behavior. ```cpp void setup() ``` -------------------------------- ### Crazyflie Configuration YAML Example Source: https://aerostack2.github.io/_03_aerial_platforms/_crazyflie/index.html Example YAML configuration file for mapping Crazyflie URIs to namespaces, used for launching the platform. ```yaml cf0: uri: radio://0/80/2M/E7E7E7E700 cf1: uri: radio://0/80/2M/E7E7E7E701 ``` -------------------------------- ### Install Multirotor Simulator via Binary Source: https://aerostack2.github.io/_03_aerial_platforms/_multirotor_simulator/index.html Command to install the Multirotor Simulator platform package using the apt package manager. ```bash sudo apt install ros-humble-as2-platform-multirotor-simulator ``` -------------------------------- ### Geozones Setup Node Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Sets up the Geozones node. ```cpp void setupNode() ``` -------------------------------- ### Install Aerostack2 Gazebo Assets Source: https://aerostack2.github.io/_03_aerial_platforms/_gazebo_simulation/index.html Installs the binary package for Aerostack2 simulation assets. ```bash sudo apt install ros-humble-as2-gazebo-assets ``` -------------------------------- ### Install Required Development Tools Source: https://aerostack2.github.io/_09_development/_develop_guide/_develop_guide/_develop_new_pkg.html Install essential ROS 2 development tools and Python linters using apt-get. ```bash apt-get install python3-rosdep python3-pip python3-colcon-common-extensions python3-colcon-mixin ros-dev-tools -y apt-get install python3-flake8-builtins python3-flake8-comprehensions python3-flake8-docstrings python3-flake8-import-order python3-flake8-quotes -y ``` -------------------------------- ### Test device-mode setup Source: https://aerostack2.github.io/_03_aerial_platforms/_dji_psdk/index.html Manually executes the startup script to verify the configuration. ```bash cd /opt/nvidia/l4t-usb-device-mode/ ./nv-l4t-usb-device-mode-start.sh ``` -------------------------------- ### Start Simulated Mission Source: https://aerostack2.github.io/_02_examples/pixhawk/project_px4_vision/index.html Starts the mission execution for the simulated environment. Ensure you are in the project's root folder. ```python python3 mission.py -s ``` -------------------------------- ### Install Gazebo Harmonic ROS Package Source: https://aerostack2.github.io/_03_aerial_platforms/_gazebo_simulation/index.html Installs the required ROS package for Gazebo Harmonic integration. ```bash sudo apt install ros-humble-ros-gzharmonic ``` -------------------------------- ### Install all Aerostack2 packages Source: https://aerostack2.github.io/_00_getting_started/binary_install.html Installs the complete suite of Aerostack2 packages available for ROS2 Humble. ```bash sudo apt install ros-humble-aerostack2 ``` -------------------------------- ### Install platform package via apt Source: https://aerostack2.github.io/_03_aerial_platforms/_dji_psdk/index.html Installs the platform package using the system package manager. ```bash sudo apt install ros-humble-as2-platform-dji-psdk ``` -------------------------------- ### Install Aerostack2 DJI OSDK Package (Binary) Source: https://aerostack2.github.io/_03_aerial_platforms/_dji_osdk/index.html Installs the Aerostack2 DJI OSDK platform package using apt for binary installations. Ensure you have ROS Humble installed. ```bash sudo apt install ros-humble-as2-platform-dji-osdk ``` -------------------------------- ### Install PySimpleGUI Source: https://aerostack2.github.io/_06_user_interfaces/_keyboard_teleoperation/index.html Use this command to install the PySimpleGUI package, which is a dependency for the keyboard teleoperation interface. ```bash pip install PySimpleGUI-4-foss ``` -------------------------------- ### Install specific platform packages Source: https://aerostack2.github.io/_00_getting_started/binary_install.html Installs individual platform-specific packages for supported drone hardware. ```bash sudo apt install ros-humble-as2-platform-crazyflie sudo apt install ros-humble-as2-platform-tello sudo apt install ros-humble-as2-platform-mavlink sudo apt install ros-humble-as2-platform-pixhawk sudo apt install ros-humble-as2-platform-dji-osdk sudo apt install ros-humble-as2-platform-dji-psdk ``` -------------------------------- ### Start Mission Source: https://aerostack2.github.io/_02_examples/dji/project_dji_psdk/index.html Execute the mission script to start the mission. This command initiates the mission sequence. ```python python3 mission.py ``` -------------------------------- ### Clone configuration repository Source: https://aerostack2.github.io/_03_aerial_platforms/_dji_psdk/index.html Initial step to download the necessary configuration files for the PSDK setup. ```bash cd ~ git clone git@github.com:aerostack2/psdk_config_files.git cd psdk_config_files ``` -------------------------------- ### Launch the ground station Source: https://aerostack2.github.io/_02_examples/tello/project_tello/index.html Starts the ground station components. ```bash ./launch_ground_station.bash ``` -------------------------------- ### Start FollowPath Behavior Source: https://aerostack2.github.io/_modules/as2_python_api/behavior_actions/followpath_behavior.html Starts the FollowPath behavior with a given path, speed, and yaw control parameters. Handles GoalRejected exceptions by logging a warning. ```python def start(self, path: Union[list, tuple, Path, GeoPath, PoseWithID], speed: float, yaw_mode: int, yaw_angle: float, frame_id: str = 'earth', wait_result: bool = True) -> bool: """Start behavior.""" goal_msg = FollowPath.Goal() goal_msg.header.stamp = self.__drone.get_clock().now().to_msg() goal_msg.header.frame_id = frame_id goal_msg.path = self.__get_path(path) yaw_msg = YawMode() yaw_msg.angle = yaw_angle yaw_msg.mode = yaw_mode goal_msg.yaw = yaw_msg goal_msg.max_speed = speed try: return super().start(goal_msg, wait_result) except self.GoalRejected as err: self.__drone.get_logger().warn(str(err)) return False ``` -------------------------------- ### Replace system device-mode script Source: https://aerostack2.github.io/_03_aerial_platforms/_dji_psdk/index.html Installs a custom startup script and ensures it has execution permissions. ```bash sudo cp ./nv-l4t-usb-device-mode-start.sh \ /opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode-start.sh chmod +x ./nv-l4t-usb-device-mode-start.sh ``` -------------------------------- ### Start GoToWaypoint Behavior Source: https://aerostack2.github.io/_modules/as2_python_api/behavior_actions/go_to_behavior.html Starts the GoToWaypoint behavior, commanding the drone to navigate to a target pose. Handles 'GoalRejected' exceptions. ```python def start(self, pose: tuple[Pose, PoseStamped, GeoPose, GeoPoseStamped], speed: float, yaw_mode: int, yaw_angle: float, frame_id: str = 'earth', wait_result: bool = True) -> bool: """Start behavior.""" goal_msg = GoToWaypoint.Goal() pose_stamped = self.__get_pose(pose) goal_msg.target_pose.header.stamp = self.__drone.get_clock().now().to_msg() goal_msg.target_pose.header.frame_id = frame_id goal_msg.target_pose.point.x = pose_stamped.position.x goal_msg.target_pose.point.y = pose_stamped.position.y goal_msg.target_pose.point.z = pose_stamped.position.z goal_msg.max_speed = speed goal_msg.yaw.mode = yaw_mode if yaw_angle: goal_msg.yaw.angle = yaw_angle try: return super().start(goal_msg, wait_result) except self.GoalRejected as err: self.__drone.get_logger().warn(str(err)) return False ``` -------------------------------- ### Module Docstring and Header Example Source: https://aerostack2.github.io/_09_development/_develop_guide/_develop_guide/_develop_new_pkg.html Example of a standard Python module docstring and header, including author, copyright, license, and version information. ```python """Module docstring.""" __authors__ = 'Author' __copyright__ = 'Copyright (c) 2024 Universidad Politécnica de Madrid' __license__ = 'BSD-3-Clause' __version__ = '0.1.0' ``` -------------------------------- ### Plugin Setup Override Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Overrides the base class's on_setup method. This function is called during the plugin's setup phase and should contain initialization logic. ```cpp inline virtual void on_setup() override { } ``` -------------------------------- ### Source Installation of Crazyflie Platform Package Source: https://aerostack2.github.io/_03_aerial_platforms/_crazyflie/index.html Steps to clone, install dependencies, and build the as2-platform-crazyflie package from source within a ROS 2 workspace. ```bash # If you have installed Aerostack2 from sources we recommend to clone the package in the src folder of your workspace otherwise you can clone it in any ROS 2 workspace you want. cd ~/aerostack2_ws/src/aerostack2/as2_aerial_platforms git clone git@github.com:aerostack2/as2_platform_crazyflie.git cd ~/aerostack2_ws rosdep install as2_platform_crazyflie --from-paths src --ignore-src -r -y colcon build --packages-up-to as2_platform_crazyflie ``` -------------------------------- ### Start GoToBehavior Source: https://aerostack2.github.io/_modules/as2_python_api/behavior_actions/go_to_behavior.html Initiates the GoToBehavior to move the drone to a specified target pose. ```APIDOC ## POST /GoToBehavior/start ### Description Starts the navigation behavior to a target waypoint. ### Method POST ### Parameters #### Request Body - **pose** (tuple[Pose, PoseStamped, GeoPose, GeoPoseStamped]) - Required - The target destination. - **speed** (float) - Required - Maximum speed for the movement. - **yaw_mode** (int) - Required - Mode for yaw control. - **yaw_angle** (float) - Optional - Specific yaw angle. - **frame_id** (str) - Optional - Reference frame (default: 'earth'). - **wait_result** (bool) - Optional - Whether to wait for completion (default: True). ### Response #### Success Response (200) - **result** (bool) - Returns True if the behavior started successfully. ``` -------------------------------- ### Start Takeoff Behavior Source: https://aerostack2.github.io/_modules/as2_python_api/behavior_actions/takeoff_behavior.html Starts the takeoff behavior with a specified height and speed. Optionally waits for the result. Handles GoalRejected exceptions. ```python def start(self, height: float, speed: float, wait_result: bool = True) -> bool: """Start behavior.""" goal_msg = Takeoff.Goal() goal_msg.takeoff_height = float(height) goal_msg.takeoff_speed = float(speed) try: return super().start(goal_msg, wait_result) except self.GoalRejected as err: self.__drone.get_logger().warn(str(err)) return False ``` -------------------------------- ### Launch Aerostack2 components Source: https://aerostack2.github.io/_02_examples/tello/project_tello/index.html Starts the Aerostack2 instance in a tmux session. ```bash ./launch_as2.bash ``` -------------------------------- ### Manage Aerostack2 Projects Source: https://aerostack2.github.io/_09_development/_cli/index.html Commands to list available projects or install a specific project. ```bash as2 project list ``` ```bash as2 project as2_project ``` -------------------------------- ### Implement on_setup method for State Estimator Source: https://aerostack2.github.io/_09_development/_tutorials/_tutorials/estimator_plugin.html Overrides the on_setup method to initialize subscribers and publish static transforms. ```cpp void on_setup() override { mocap_pose_sub_ = node_ptr_->create_subscription( as2_names::topics::ground_truth::pose, as2_names::topics::ground_truth::qos, std::bind(&Plugin::mocap_pose_callback, this, std::placeholders::_1)); geometry_msgs::msg::TransformStamped map_to_odom = as2::tf::getTransformation(get_map_frame(), get_odom_frame(), 0, 0, 0, 0, 0, 0); publish_static_transform(map_to_odom); has_earth_to_map_ = false; } ``` -------------------------------- ### Source ROS 2 Environment Source: https://aerostack2.github.io/_00_getting_started/source_install.html Sources the ROS 2 environment setup script. This is necessary if ROS 2 was installed via Debian packages to ensure the environment variables are correctly set before building Aerostack2. ```bash source /opt/ros//setup.bash ``` -------------------------------- ### Export plugin description in CMakeLists.txt Source: https://aerostack2.github.io/_09_development/_tutorials/_tutorials/estimator_plugin.html Uses the pluginlib_export_plugin_description_file function to install the plugin description. ```cmake pluginlib_export_plugin_description_file(${PROJECT_NAME} plugins.xml) ``` -------------------------------- ### Install ROS 2 Package for Crazyflie Source: https://aerostack2.github.io/_03_aerial_platforms/_crazyflie/index.html Installs the Aerostack2 Crazyflie platform package using apt for binary installations. ```bash sudo apt install ros-humble-as2-platform-crazyflie ``` -------------------------------- ### Download bulk-mode reference package Source: https://aerostack2.github.io/_03_aerial_platforms/_dji_psdk/index.html Downloads and prepares the bulk-mode configuration files. ```bash wget https://terra-1-g.djicdn.com/71a7d383e71a4fb8887a310eb746b47f/psdk/e-port/usb-bulk-configuration-reference.zip \ && unzip usb-bulk-configuration-reference.zip -d startup_bulk \ && mv startup_bulk/ ~/Desktop/ \ && chmod +x ~/Desktop/startup_bulk/* ``` -------------------------------- ### Install ROS 2 Dependencies Source: https://aerostack2.github.io/_00_getting_started/source_install.html Installs essential packages required for ROS 2 development, including git, python3-rosdep, python3-pip, and colcon extensions. Run this command before proceeding with Aerostack2 installation. ```bash sudo apt install git python3-rosdep python3-pip python3-colcon-common-extensions -y ``` -------------------------------- ### Start Polynomial Trajectory Generation Source: https://aerostack2.github.io/_modules/as2_python_api/behavior_actions/trajectory_generation_behavior.html Starts the trajectory generation behavior. It constructs a goal message with path, speed, and yaw parameters, then calls the superclass start method. Catches GoalRejected exceptions and logs a warning. ```python def start(self, path: Union[list, tuple, Path, PoseWithID, PoseStampedWithID], speed: float, yaw_mode: int, yaw_angle: float, frame_id: str = 'earth', wait_result: bool = True) -> bool: """Start behavior.""" goal_msg = GeneratePolynomialTrajectory.Goal() goal_msg.stamp = self.__drone.get_clock().now().to_msg() goal_msg.path = self.__get_path(path, frame_id) yaw_msg = YawMode() yaw_msg.angle = yaw_angle yaw_msg.mode = yaw_mode goal_msg.yaw = yaw_msg goal_msg.max_speed = speed try: return super().start(goal_msg, wait_result) except self.GoalRejected as err: self.__drone.get_logger().warn(str(err)) return False ``` -------------------------------- ### Create Action Client Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Initializes the action client for the specified action name. ```cpp inline void createActionClient(const std::string &action_name) ``` -------------------------------- ### Start Mission Source: https://aerostack2.github.io/_modules/as2_python_api/mission_interpreter/mission_interpreter.html Starts a mission in a separate thread. Returns false if a mission is already in progress. ```python def start_mission(self, mid: int, idx: int) -> bool: """Start mission in different thread.""" if self.exec_thread: self._logger.warning('Mission being performed, start not allowed') return False self.mission = mid self.mission_stack.point_to_item(idx) self.exec_thread = Thread(target=self.__perform_mission) self.exec_thread.start() return True ``` -------------------------------- ### Launch Force Estimation Behavior (Autostart) Source: https://aerostack2.github.io/_04_robot_behaviors/param_estimation/force_estimation/index.html Launches the force estimation behavior node and automatically starts the estimation process immediately. ```bash ros2 launch as2_behaviors_param_estimation force_estimation_behavior_auto_launch.py ``` -------------------------------- ### Execute Mission Source: https://aerostack2.github.io/_modules/as2_python_api/mission_interpreter/ros2_adapter.html Loads and immediately starts a mission. This is a convenience function that combines loading and starting. ```python def execute_callback(self, mid: int, mission: Mission): """Load and start mission.""" self.interpreter.reset(mid, mission) self.start_callback(mid) ``` -------------------------------- ### Implement GazeboPlatform Constructor Source: https://aerostack2.github.io/_09_development/_tutorials/_tutorials/aerial_platform.html Initializes the platform by declaring ROS 2 parameters and creating publishers for velocity commands and arming state. ```cpp GazeboPlatform::GazeboPlatform() : as2::AerialPlatform() { this->declare_parameter("cmd_vel_topic"); // Reading topic from launch argument std::string cmd_vel_topic_param = this->get_parameter("cmd_vel_topic").as_string(); this->declare_parameter("arm_topic"); // Reading topic from launch argument std::string arm_topic_param = this->get_parameter("arm_topic").as_string(); twist_pub_ = this->create_publisher(cmd_vel_topic_param, rclcpp::QoS(1)); arm_pub_ = this->create_publisher(arm_topic_param, rclcpp::QoS(1)); } ``` -------------------------------- ### Go To Behavior File Includes Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Includes for the go to behavior file. ```cpp #include “ go_to_behavior/go_to_behavior.hpp” #include “rclcpp_components/register_node_macro.hpp” ``` -------------------------------- ### Install DJI PSDK Platform from Source Source: https://aerostack2.github.io/_03_aerial_platforms/_dji_psdk/index.html Commands to clone the repository into an existing Aerostack2 workspace, resolve dependencies, and build the package. ```bash cd ~/aerostack2_ws/src/aerostack2/as2_aerial_platforms git clone git@github.com:aerostack2/as2_platform_dji_psdk.git cd ~/aerostack2_ws rosdep install as2_platform_dji_psdk --from-paths src --ignore-src -r -y colcon build --packages-up-to as2_platform_dji_psdk ``` -------------------------------- ### Enable device-mode service Source: https://aerostack2.github.io/_03_aerial_platforms/_dji_psdk/index.html Enables the custom device-mode service to run on system startup. ```bash sudo systemctl enable /opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode.service ``` -------------------------------- ### Behavior Server Implementation Includes Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Includes for behavior server implementation and header files. ```cpp #include “ as2_behavior/__detail/behavior_server__class.hpp” ``` ```cpp #include “ as2_behavior/__impl/behavior_server__impl.hpp” ``` -------------------------------- ### Install cpplint using pip Source: https://aerostack2.github.io/_09_development/_develop_guide/_develop_guide/_setting_code.html Install the cpplint tool using pip for code analysis. This command should be run in the terminal. ```bash pip install --user cpplint ``` -------------------------------- ### Go To Behavior Implementation Includes Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Includes for the go to behavior trajectory plugin implementation. ```cpp #include “ as2_core/utils/frame_utils.hpp” #include “as2_msgs/action/generate_polynomial_trajectory.hpp” #include “as2_msgs/msg/pose_with_id.hpp” #include “as2_msgs/msg/yaw_mode.hpp” #include “ go_to_behavior/go_to_base.hpp” #include “rclcpp/rclcpp.hpp” #include “rclcpp_action/rclcpp_action.hpp” #include ``` -------------------------------- ### Get Origin Service Callback Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Callback function for the GetOrigin service. It is invoked when a request to get the current origin is received. ```cpp inline void getOriginCallback(const as2_msgs::srv::GetOrigin::Request::SharedPtr request, as2_msgs::srv::GetOrigin::Response::SharedPtr response) { } ``` -------------------------------- ### Behavior Client and Server Source Includes Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Source file includes for behavior client and server. ```cpp #include “behavior_client.hpp” ``` ```cpp #include “ behavior_server.hpp” ``` -------------------------------- ### Clone the project repository Source: https://aerostack2.github.io/_02_examples/tello/project_tello/index.html Initial step to download the project source code. ```bash git clone https://github.com/aerostack2/project_dji_tello ``` -------------------------------- ### Launch DJI Tello Platform Source: https://aerostack2.github.io/_03_aerial_platforms/_ryze_tello/index.html Start the platform node using the provided launch file, specifying the drone namespace. ```bash ros2 launch as2_platform_tello tello_platform.launch.py namespace:=drone0 ``` -------------------------------- ### Get Origin Service Server Member Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Shared pointer to the service server for getting the origin. This member manages the GetOrigin service. ```cpp rclcpp::Service::SharedPtr get_origin_srv_; ``` -------------------------------- ### Initialize DummyModule Source: https://aerostack2.github.io/_modules/as2_python_api/modules/dummy_module.html Initializes the DummyModule, setting up its alias and initial stopped state. ```python def __init__(self, drone: 'DroneInterface') -> None: super().__init__(drone, self.__alias__) self.stopped = False ``` -------------------------------- ### Install docformatter for PEP 257 Compliance Source: https://aerostack2.github.io/_09_development/_develop_guide/_develop_guide/_develop_new_pkg.html Install the docformatter tool using pip to help with PEP 257 docstring style checks. ```bash pip install --upgrade docformatter ``` -------------------------------- ### Start Mission Execution Source: https://aerostack2.github.io/_modules/as2_python_api/mission_interpreter/ros2_adapter.html Initiates a mission on the interpreter, ensuring the drone is armed and in offboard mode before starting. Handles cases where no mission is loaded. ```python def start_callback(self, mid: int, item_id: int = 0): """Start mission on interpreter.""" try: # TODO: where to arm and offboard? Avoid calling interpreter.drone property directly if not self.interpreter._drone.info['armed']: self.interpreter._drone.arm() if not self.interpreter._drone.info['offboard']: self.interpreter._drone.offboard() self.get_logger().info(f'Starting mission: {mid}') self.interpreter.start_mission(mid, item_id) except AttributeError: self.get_logger().error('Trying to start mission but no mission is loaded.') ``` -------------------------------- ### Setup Pose Transforms Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Sets up the necessary transforms for pose and odometry data based on device translation and rotation. ```cpp void setupPoseTransforms(const std::array &device_t, const std::array &device_r) ``` -------------------------------- ### Implement Takeoff Behavior Server Source: https://aerostack2.github.io/_09_development/_tutorials/_tutorials/behavior.html Example implementation of a Takeoff behavior inheriting from as2_behavior::BehaviorServer, demonstrating lifecycle method overrides. ```cpp TakeOffBehavior() : as2_behavior::BehaviorServer(as2_names::actions::behaviors::takeoff) { platform_takeoff_cli_ = node_ptr_->create_client(as2_names::services::platform::takeoff); platform_takeoff_request_ = std::make_shared(); platform_takeoff_request_->data = true; return; } bool on_activate(std::shared_ptr goal) override { platform_takeoff_future_ = platform_takeoff_cli_->async_send_request(platform_takeoff_request_); if (!platform_takeoff_future_.valid()) { RCLCPP_ERROR(node_ptr_->get_logger(), "Request could not be sent"); return false; } return true; } bool on_modify( std::shared_ptr goal) override; bool on_deactivate(const std::shared_ptr &message) override { RCLCPP_INFO(node_ptr_->get_logger(), "Takeoff can not be cancelled"); return false; } bool on_pause(const std::shared_ptr &message) override { RCLCPP_INFO(node_ptr_->get_logger(), "Takeoff can not be paused"); return false; } bool on_resume(const std::shared_ptr &message) override { RCLCPP_INFO(node_ptr_->get_logger(), "Takeoff can not be resumed"); return false; } as2_behavior::ExecutionStatus on_run(const std::shared_ptr &goal, std::shared_ptr &feedback_msg, std::shared_ptr &result_msg) override { if (platform_takeoff_future_.valid() && platform_takeoff_future_.wait_for(std::chrono::seconds(0)) == std::future_status::ready) { auto result = platform_takeoff_future_.get(); if (result->success) { result_.takeoff_success = true; return as2_behavior::ExecutionStatus::SUCCESS; } else { result_.takeoff_success = false; return as2_behavior::ExecutionStatus::FAILURE; } } return as2_behavior::ExecutionStatus::RUNNING; } void on_execution_end(const as2_behavior::ExecutionStatus &state) override { RCLCPP_INFO(node_ptr_->get_logger(), "Takeoff end"); return; } ``` -------------------------------- ### Set Origin on Start Flag Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Boolean flag indicating whether the origin should be set automatically upon starting the node. If true, the origin will be set using available data. ```cpp bool set_origin_on_start_ = false; ``` -------------------------------- ### GoTo Behavior Parameters and Action Node Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Structures for GoTo plugin parameters and the Behavior Tree action node implementation. ```cpp struct go_to_plugin_params ``` ```cpp double go_to_speed = 0.0 ``` ```cpp double go_to_threshold = 0.0 ``` ```cpp class GoToAction : public as2_behavior_tree::BtActionNode ``` ```cpp GoToAction(const std::string &xml_tag_name, const BT::NodeConfiguration &conf) ``` ```cpp virtual void on_tick() ``` ```cpp void on_wait_for_result(std::shared_ptr feedback) ``` ```cpp static inline BT::PortsList providedPorts() ``` -------------------------------- ### Install Aerostack2 DJI OSDK Package (Source) Source: https://aerostack2.github.io/_03_aerial_platforms/_dji_osdk/index.html Installs the Aerostack2 DJI OSDK platform package from source. This involves cloning the repository, resolving dependencies, and building the package within your ROS 2 workspace. ```bash # If you have installed Aerostack2 from sources we recommend to clone the package in the src folder of your workspace otherwise you can clone it in any ROS 2 workspace you want. cd ~/aerostack2_ws/src/aerostack2/as2_aerial_platforms git clone git@github.com:aerostack2/as2_platform_dji_osdk.git cd ~/aerostack2_ws rosdep install as2_platform_dji_osdk --from-paths src --ignore-src -r -y colcon build --packages-up-to as2_platform_dji_osdk ``` -------------------------------- ### Clone Aerostack2 and Install Dependencies Source: https://aerostack2.github.io/_00_getting_started/source_install.html Creates a new workspace, clones the Aerostack2 repository into the 'src' directory, and then uses rosdep to install binary dependencies for the Aerostack2 packages. Ensure your ROS 2 environment is sourced before running. ```bash mkdir -p ~/aerostack2_ws/src/ && cd ~/aerostack2_ws/src/ git clone https://github.com/aerostack2/aerostack2.git cd ~/aerostack2_ws sudo rosdep init rosdep update rosdep install -y -r -q --from-paths src --ignore-src ``` -------------------------------- ### POST /mission/start Source: https://aerostack2.github.io/_modules/as2_python_api/mission_interpreter/mission_interpreter.html Starts a mission in a separate thread. ```APIDOC ## POST /mission/start ### Description Starts the execution of a mission identified by its ID starting at a specific index. ### Method POST ### Parameters #### Request Body - **mid** (int) - Required - Mission ID - **idx** (int) - Required - Starting index ### Response #### Success Response (200) - **result** (bool) - Returns True if the mission started successfully, False otherwise. ``` -------------------------------- ### Initialize GoToBehavior Source: https://aerostack2.github.io/_modules/as2_python_api/behavior_actions/go_to_behavior.html Initializes the GoToBehavior with a drone interface. Handles potential 'BehaviorNotAvailable' exceptions. ```python def __init__(self, drone: 'DroneInterfaceBase') -> None: self.__drone = drone try: super().__init__(drone, GoToWaypoint, 'GoToBehavior') except self.BehaviorNotAvailable as err: self.__drone.get_logger().warn(str(err)) ``` -------------------------------- ### Launch DJI PSDK Platform and Wrapper Source: https://aerostack2.github.io/_03_aerial_platforms/_dji_psdk/index.html Commands to launch the platform and the required ROS 2 PSDK wrapper. ```bash ros2 launch as2_platform_dji_psdk as2_platform_dji_psdk.launch.py ``` ```bash ros2 launch as2_platform_dji_psdk psdk_wrapper.launch.py ``` -------------------------------- ### Launch Ground Station Source: https://aerostack2.github.io/_02_examples/multirotor_simulator/project_multirotor_simulator/index.html Execute this command from the root of the project to launch the ground station. Use the -h flag for available customization options. ```bash ./launch_ground_station.bash ``` -------------------------------- ### Get Desired Torque Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Retrieves the desired torque vector. ```APIDOC ## const Vector3 &get_desired_torque ### Description Get the desired torque. ### Method Not applicable (inline function) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **Desired torque** (const Vector3&) - Desired torque (N m) ### Response Example ```json { "desired_torque": [0.0, 0.0, 0.0] } ``` ``` -------------------------------- ### Get Desired Thrust Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Retrieves the desired thrust vector. ```APIDOC ## const Vector3 &get_desired_thrust ### Description Get the desired thrust. ### Method Not applicable (inline function) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **Desired thrust** (const Vector3&) - Desired thrust (N) ### Response Example ```json { "desired_thrust": [0.0, 0.0, 0.0] } ``` ``` -------------------------------- ### Get Inertia Matrix Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Retrieves the inertia matrix of the system. ```APIDOC ## const Matrix3 &get_inertia ### Description Get the inertia. ### Method Not applicable (inline function) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **Inertia matrix** (Matrix3) - Inertia matrix (kg m^2) ### Response Example ```json { "inertia": [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] } ``` ``` -------------------------------- ### Main Function for Adapter Node Source: https://aerostack2.github.io/_modules/as2_python_api/mission_interpreter/ros2_adapter.html Sets up argument parsing for the adapter node, allowing configuration of the namespace. ```python def main(): """Run node.""" parser = argparse.ArgumentParser() parser.add_argument('--n', type=str, default='drone0', help='Namespace') ``` -------------------------------- ### GET /as2_msgs/srv/GetGeozone Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Service callback to retrieve geozone information. ```APIDOC ## GET /as2_msgs/srv/GetGeozone ### Description Callback function to handle requests for retrieving geozone data. ### Method GET ### Request Body - **request** (as2_msgs::srv::GetGeozone::Request) - Required - The service request object. ### Response - **response** (as2_msgs::srv::GetGeozone::Response) - The service response object containing geozone details. ``` -------------------------------- ### as2_python_api.tools.utils.get_module_call_signature Source: https://aerostack2.github.io/_09_development/_api_documentation/temp_ws/src/as2_python_api/docs/source/as2_python_api.tools.html Gets the call signature of a given module name. ```APIDOC ## get_module_call_signature ### Description Get call method signature from given module name. ### Method N/A (Python function) ### Parameters - **_module_name** (str) - The name of the module to inspect. ### Return Value Signature - The call signature of the module. ``` -------------------------------- ### List Aerostack2 Packages Source: https://aerostack2.github.io/_09_development/_cli/index.html Command to display all installed Aerostack2 packages. ```bash as2 list ``` -------------------------------- ### Setup Camera Configuration Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Configures a specific camera sensor with stream type, encoding, and camera model information. ```cpp void setupCamera(const std::shared_ptr &_camera, const rs2_stream _rs2_stream, const std::string _encoding, const std::string _camera_model) ``` -------------------------------- ### GET /get_platform_status Source: https://aerostack2.github.io/_09_development/_api_documentation/aerostack2/aerostack2/docs/index.html Retrieves the current status of the platform state machine. ```APIDOC ## GET /get_platform_status ### Description Returns the current state of the platform state machine. ### Method GET ### Endpoint /get_platform_status ### Response #### Success Response (200) - **state** (as2_msgs::msg::PlatformStatus) - The current status of the platform. ```