Skip to content

Commit

Permalink
added rc remote test
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Jan 6, 2024
1 parent ef7ab2c commit 35da01a
Show file tree
Hide file tree
Showing 9 changed files with 912 additions and 4 deletions.
2 changes: 2 additions & 0 deletions test/control_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ add_subdirectory(eland_service)
add_subdirectory(escalating_failsafe_service)

add_subdirectory(escalating_failsafe_rc)

add_subdirectory(rc_remote_control)
8 changes: 4 additions & 4 deletions test/control_manager/escalating_failsafe_rc/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ Tester::Tester() {

ph_rc_channels_ = mrs_lib::PublisherHandler<mrs_msgs::HwApiRcChannels>(nh_, "/" + _uav_name_ + "/hw_api/rc_channels");

rc_.channels.push_back(0.0);
rc_.channels.push_back(0.0);
rc_.channels.push_back(0.0);
rc_.channels.push_back(0.0);
rc_.channels.push_back(0.5);
rc_.channels.push_back(0.5);
rc_.channels.push_back(0.5);
rc_.channels.push_back(0.5);
rc_.channels.push_back(0.0);
rc_.channels.push_back(0.0);
rc_.channels.push_back(0.0);
Expand Down
16 changes: 16 additions & 0 deletions test/control_manager/rc_remote_control/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
get_filename_component(TEST_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME)

catkin_add_executable_with_gtest(test_${TEST_NAME}
test.cpp
)

target_link_libraries(test_${TEST_NAME}
${catkin_LIBRARIES}
)

add_dependencies(test_${TEST_NAME}
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

add_rostest(${TEST_NAME}.test)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mrs_uav_managers:

constraint_manager:

default_constraints:
gps_garmin: "medium"
gps_baro: "medium"
34 changes: 34 additions & 0 deletions test/control_manager/rc_remote_control/config/world_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
world_origin:

units: "LATLON" # {"UTM, "LATLON"}

origin_x: 47.397743
origin_y: 8.545594

safety_area:

enabled: false

horizontal:

# the frame of reference in which the points are expressed
frame_name: "world_origin"

# polygon
#
# x, y [m] for any frame_name except latlon_origin
# x = latitude, y = longitude [deg] for frame_name=="latlon_origin"
points: [
-50, -50,
50, -50,
50, 50,
-50, 50,
]

vertical:

# the frame of reference in which the max&min z is expressed
frame_name: "world_origin"

max_z: 15.0
min_z: 0.5
66 changes: 66 additions & 0 deletions test/control_manager/rc_remote_control/launch/hw_api.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<launch>

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

<!-- other args -->
<arg name="debug" default="false" />
<arg name="bond" default="$(optenv BOND true)" />
<arg name="nodelet_manager_name" default="$(optenv NODELET_MANAGER)" />
<arg name="custom_config" default="" />

<arg if="$(eval arg('nodelet_manager_name') != '')" name="standalone" value="false" />
<arg if="$(eval arg('nodelet_manager_name') == '')" name="standalone" value="true" />

<env name="ROSCONSOLE_CONFIG_FILE" if="$(eval arg('LOGGER_DEBUG'))" value="$(find mrs_uav_hw_api)/config/debug_verbosity.yaml" />

<arg if="$(arg bond)" name="bond_suffix" value="" />
<arg unless="$(arg bond)" name="bond_suffix" value="--no-bond" />

<arg if="$(eval arg('standalone') or arg('debug'))" name="nodelet" value="standalone" />
<arg unless="$(eval arg('standalone') or arg('debug'))" name="nodelet" value="load" />
<arg if="$(eval arg('standalone') or arg('debug'))" name="nodelet_manager" value="" />
<arg unless="$(eval arg('standalone') or arg('debug'))" name="nodelet_manager" value="$(arg nodelet_manager_name)" />

<arg if="$(arg debug)" name="launch_prefix" value="debug_roslaunch" />
<arg unless="$(arg debug)" name="launch_prefix" value="" />

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

<node pkg="nodelet" type="nodelet" name="hw_api" args="$(arg nodelet) mrs_uav_hw_api/HwApiManager $(arg nodelet_manager) $(arg bond_suffix)" output="screen" launch-prefix="$(arg launch_prefix)">

<rosparam file="$(find mrs_uav_hw_api)/config/hw_api.yaml" />
<rosparam file="$(find mrs_multirotor_simulator)/config/hw_api.yaml" />

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

<!-- Parameters -->
<param name="topic_prefix" type="string" value="/$(arg UAV_NAME)/" />
<param name="uav_name" type="string" value="$(arg UAV_NAME)" />
<param name="simulation" type="bool" value="$(eval arg('RUN_TYPE') == 'simulation')" />

<!-- custom remaps -->
<remap from="~simulator_imu_in" to="/multirotor_simulator/$(arg UAV_NAME)/imu" />
<remap from="~simulator_odom_in" to="/multirotor_simulator/$(arg UAV_NAME)/odom" />
<remap from="~simulator_rangefinder_in" to="/multirotor_simulator/$(arg UAV_NAME)/rangefinder" />
<remap from="~simulator_actuators_cmd_out" to="/multirotor_simulator/$(arg UAV_NAME)/actuators_cmd" />
<remap from="~simulator_control_group_cmd_out" to="/multirotor_simulator/$(arg UAV_NAME)/control_group_cmd" />
<remap from="~simulator_attitude_rate_cmd_out" to="/multirotor_simulator/$(arg UAV_NAME)/attitude_rate_cmd" />
<remap from="~simulator_attitude_cmd_out" to="/multirotor_simulator/$(arg UAV_NAME)/attitude_cmd" />
<remap from="~simulator_acceleration_hdg_rate_cmd_out" to="/multirotor_simulator/$(arg UAV_NAME)/acceleration_hdg_rate_cmd" />
<remap from="~simulator_acceleration_hdg_cmd_out" to="/multirotor_simulator/$(arg UAV_NAME)/acceleration_hdg_cmd" />
<remap from="~simulator_velocity_hdg_rate_cmd_out" to="/multirotor_simulator/$(arg UAV_NAME)/velocity_hdg_rate_cmd" />
<remap from="~simulator_velocity_hdg_cmd_out" to="/multirotor_simulator/$(arg UAV_NAME)/velocity_hdg_cmd" />
<remap from="~simulator_position_cmd_out" to="/multirotor_simulator/$(arg UAV_NAME)/position_cmd" />
<remap from="~simulator_tracker_cmd_out" to="/multirotor_simulator/$(arg UAV_NAME)/tracker_cmd" />

<remap from="~rc_channels" to="~rc_channels_unused" />

</node>

</group>

</launch>
37 changes: 37 additions & 0 deletions test/control_manager/rc_remote_control/rc_remote_control.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<launch>

<arg name="this_path" default="$(dirname)" />

<arg name="UAV_NAME" default="uav1" />
<arg name="UAV_TYPE" default="x500" />

<!-- automatically deduce the test name -->
<arg name="test_name" default="$(eval arg('this_path').split('/')[-1])" />

<!-- automatically deduce the package name -->
<arg name="import_eval" default="eval('_' + '_import_' + '_')"/>
<arg name="package_eval" default="eval(arg('import_eval') + '(\'rospkg\')').get_package_name(arg('this_path'))" />
<arg name="package" default="$(eval eval(arg('package_eval')))" />

<include file="$(find mrs_uav_testing)/launch/mrs_simulator.launch">
<arg name="UAV_NAME" default="$(arg UAV_NAME)" />
</include>

<include file="$(dirname)/launch/hw_api.launch">
<arg name="UAV_NAME" default="$(arg UAV_NAME)" />
</include>

<include file="$(find mrs_uav_testing)/launch/mrs_uav_system.launch">
<arg name="automatic_start" default="false" />
<arg name="platform_config" default="$(find mrs_multirotor_simulator)/config/mrs_uav_system/$(arg UAV_TYPE).yaml" />
<arg name="custom_config" default="$(dirname)/config/custom_config.yaml" />
<arg name="world_config" default="$(dirname)/config/world_config.yaml" />
<arg name="UAV_NAME" default="$(arg UAV_NAME)" />
</include>

<test pkg="$(arg package)" type="test_$(arg test_name)" test-name="$(arg test_name)" time-limit="60.0">
<param name="test" value="$(arg test_name)" />
<param name="uav_name" value="$(arg UAV_NAME)" />
</test>

</launch>
Loading

0 comments on commit 35da01a

Please sign in to comment.