Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Aug 10, 2023
1 parent 5385db1 commit 04290a7
Show file tree
Hide file tree
Showing 8 changed files with 1,292 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ros_package_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: ros_package_build

on:

push:
branches: [ master ]

pull_request:
branches: [ master ]

workflow_dispatch:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:

build:
uses: ctu-mrs/ci_scripts/.github/workflows/ros_package_build.yml@master
secrets:
PUSH_TOKEN: ${{ secrets.PUSH_TOKEN }}
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# ignore temp files
*~

# ignore vim temp files
*.swp
*.swo
*.swn

# Runtime-python
*.pyc
80 changes: 80 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
cmake_minimum_required(VERSION 3.1.2)
project(mrs_uav_autostart)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CATKIN_DEPENDENCIES
cmake_modules
roscpp
rospy
std_srvs
mrs_msgs
mrs_lib
nodelet
std_msgs
topic_tools
)

find_package(catkin REQUIRED COMPONENTS
${CATKIN_DEPENDENCIES}
)

set(LIBRARIES
MrsAutomaticStart
)

catkin_package(
LIBRARIES ${LIBRARIES}
CATKIN_DEPENDS ${CATKIN_DEPENDENCIES}
)

include_directories(
${catkin_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)

add_library(MrsAutomaticStart
src/automatic_start.cpp
)

add_dependencies(MrsAutomaticStart
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

target_link_libraries(MrsAutomaticStart
${catkin_LIBRARIES}
)

## --------------------------------------------------------------
## | Install |
## --------------------------------------------------------------

install(TARGETS ${LIBRARIES}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)

install(TARGETS ${EXECUTABLES}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(DIRECTORY launch config
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(DIRECTORY scripts/
USE_SOURCE_PERMISSIONS
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(DIRECTORY scripts
USE_SOURCE_PERMISSIONS
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(FILES plugins.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
24 changes: 24 additions & 0 deletions config/automatic_start.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
safety_timeout: 5.0 # [s]

main_timer_rate: 30 # [Hz]

# how many times it will try to call the start/stop services if the call fails
call_n_attempts: 10

handle_takeoff: true
handle_landing: false
action_duration: 12.0 # [min]
land_mode: "eland" # {land_home, land, eland}
pre_takeoff_sleep: 0 # [s]

topic_check:

enabled: true
timeout: 5.0 # [s], a window for the last accepted message

# if "/" is provided at the beginning of topic_name, the topic name is considered as written,
# if there is no "/" at the beginning, UAV_NAME is automatically added in from of the topic name (/uav1/topic_name)
topics: [
"estimation_manager/uav_state",
"control_manager/diagnostics",
]
57 changes: 57 additions & 0 deletions launch/automatic_start.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<launch>

<!-- args corresponding to environment variables -->
<arg name="UAV_NAME" default="$(optenv UAV_NAME)" />
<arg name="RUN_TYPE" default="$(optenv RUN_TYPE)" />

<arg name="custom_config" default="" />

<arg if="$(eval arg('RUN_TYPE') == 'simulation')" name="simulation" default="true" />
<arg if="$(eval arg('RUN_TYPE') == 'realworld')" name="simulation" default="false" />

<!-- other args -->
<arg name="standalone" default="true" />

<arg if="$(arg standalone)" name="nodelet" value="standalone" />
<arg unless="$(arg standalone)" name="nodelet" value="load" />
<arg if="$(arg standalone)" name="nodelet_manager" value="" />
<arg unless="$(arg standalone)" name="nodelet_manager" value="$(arg UAV_NAME)_vision_nodelet_manager" />

<group ns="$(arg UAV_NAME)">

<node name="automatic_start" pkg="nodelet" type="nodelet" args="$(arg nodelet) mrs_uav_autostart/AutomaticStart $(arg nodelet_manager)" output="screen">

<rosparam file="$(find mrs_uav_autostart)/config/automatic_start.yaml" />

<!-- Load a user param file -->
<rosparam if="$(eval not arg('custom_config') == '')" file="$(arg custom_config)" />

<param name="uav_name" value="$(arg UAV_NAME)" />
<param name="simulation" value="$(arg simulation)" />

<!-- Subscribers -->
<remap from="~hw_api_status_in" to="hw_api/status" />
<remap from="~control_manager_diagnostics_in" to="control_manager/diagnostics" />
<remap from="~uav_manager_diagnostics_in" to="uav_manager/diagnostics" />
<remap from="~gazebo_spawner_diagnostics_in" to="/mrs_drone_spawner/diagnostics" />

<!-- Publishers -->
<remap from="~can_takeoff_out" to="~can_takeoff" />

<!-- services -->
<remap from="~takeoff_out" to="uav_manager/takeoff" />
<remap from="~land_home_out" to="uav_manager/land_home" />
<remap from="~land_out" to="uav_manager/land" />
<remap from="~eland_out" to="control_manager/eland" />
<remap from="~toggle_control_output_out" to="control_manager/toggle_output" />
<remap from="~arm_out" to="hw_api/arming" />
<remap from="~validate_reference_out" to="control_manager/validate_reference_2d" />

<remap from="~start_out" to="~start" />
<remap from="~stop_out" to="~stop" />

</node>

</group>

</launch>
29 changes: 29 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<package format="2">

<name>mrs_uav_autostart</name>
<version>1.0.4</version>
<description>The mrs_uav_autostart package</description>

<author email="[email protected]">Tomas Baca</author>
<maintainer email="[email protected]">Tomas Baca</maintainer>

<license>BSD 3-Clause</license>

<buildtool_depend>catkin</buildtool_depend>

<depend>cmake_modules</depend>
<depend>roscpp</depend>
<depend>rospy</depend>
<depend>std_srvs</depend>
<depend>mrs_msgs</depend>
<depend>mrs_lib</depend>
<depend>nodelet</depend>
<depend>std_msgs</depend>
<depend>topic_tools</depend>

<export>
<nodelet plugin="${prefix}/plugins.xml" />
</export>

</package>
5 changes: 5 additions & 0 deletions plugins.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library path="lib/libMrsAutomaticStart">
<class name="mrs_uav_autostart/AutomaticStart" type="mrs_uav_autostart::automatic_start::AutomaticStart" base_class_type="nodelet::Nodelet">
<description>AutomaticStart nodelet</description>
</class>
</library>
Loading

0 comments on commit 04290a7

Please sign in to comment.