Skip to content

Commit 3edd23e

Browse files
authored
Merge branch 'master' into AM-677/culvert_alt
2 parents d3c7067 + e321900 commit 3edd23e

50 files changed

Lines changed: 978 additions & 168 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/nightly.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,3 @@ jobs:
1212
uses: AutoModality/action-package-debian-ros@v5-ros
1313
with:
1414
release-repo-entitlement: ${{ secrets.CLOUDSMITH_READ_RELEASE_ENTITLEMENT }}
15-
- name: Repo Name
16-
if: always()
17-
run: echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")" >> $GITHUB_ENV
18-
- name: Test Results
19-
if: always()
20-
id: xunit-viewer
21-
uses: AutoModality/action-xunit-viewer@v1
22-
with:
23-
results: catkin_ws/build/${{env.REPOSITORY_NAME}}/test_results/${{env.REPOSITORY_NAME}}
24-
- name: Attach Test Reports
25-
if: always()
26-
uses: actions/upload-artifact@v1
27-
with:
28-
name: ${{ steps.xunit-viewer.outputs.report-name }}
29-
path: ${{ steps.xunit-viewer.outputs.report-dir }}
30-
- uses: codecov/codecov-action@v1
31-
with:
32-
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
33-

.github/workflows/package.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,13 @@ jobs:
1515
- uses: AutoModality/action-clean@v1.1.0
1616
- uses: actions/checkout@v2
1717
- uses: rlespinasse/github-slug-action@3.1.0 # for GITHUB_REF_SLUG
18-
# - name: Restore Cache
19-
# uses: actions/cache@v2
20-
# with:
21-
# path: |
22-
# catkin_ws
23-
# # different caches for different architectures and control files
24-
# # first element in matrix.os is the architecture, by convention
25-
# key: ${{ matrix.os[0] }}-${{ env.GITHUB_REF_SLUG }}-${{ hashFiles('debian/control') }}
2618
- name: Package
2719
id: package
2820
uses: AutoModality/action-package-debian-ros@v5-amros
2921
with:
3022
branch: ${{ env.GITHUB_REF_SLUG }}
3123
build-number: ${{ github.run_number }}
3224
release-repo-entitlement: ${{ secrets.CLOUDSMITH_READ_RELEASE_ENTITLEMENT }}
33-
- name: The generated package
34-
run: echo "The artifact is ${{ steps.package.outputs.artifact-path }}"
3525
- name: Deploy
3626
id: deploy
3727
uses: AutoModality/action-cloudsmith@0.2.0
@@ -44,21 +34,6 @@ jobs:
4434
distro: 'ubuntu'
4535
release: 'bionic'
4636
file: '${{ steps.package.outputs.artifact-path }}'
47-
- name: Repo Name
48-
if: contains( matrix.os, 'x64' )
49-
run: echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")" >> $GITHUB_ENV
50-
- name: Test Results
51-
if: contains( matrix.os, 'x64' )
52-
id: xunit-viewer
53-
uses: AutoModality/action-xunit-viewer@v1
54-
with:
55-
results: catkin_ws/build/${{env.REPOSITORY_NAME}}/test_results/${{env.REPOSITORY_NAME}}
56-
- name: Attach Test Reports
57-
if: contains( matrix.os, 'x64' )
58-
uses: actions/upload-artifact@v1
59-
with:
60-
name: ${{ steps.xunit-viewer.outputs.report-name }}
61-
path: ${{ steps.xunit-viewer.outputs.report-dir }}
6237
draft-pr:
6338
runs-on: ubuntu-18.04
6439
needs: package

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Test
2+
on:
3+
push:
4+
schedule:
5+
- cron: '20 05 * * *'
6+
jobs:
7+
test:
8+
runs-on: [x64, self-hosted,linux,build]
9+
steps:
10+
- uses: AutoModality/action-clean@v1.1.0
11+
- uses: actions/checkout@v2
12+
- name: Test
13+
run: amros dev docker run --test
14+
- name: Attach Test Reports
15+
uses: actions/upload-artifact@v1
16+
if: always() #test failures report an error code, but good to attach results
17+
with:
18+
name: test_results
19+
path: test_results.tar.gz
20+
21+
22+
23+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ build
4141
.catkin_tools
4242
*.deb
4343
*.ddeb
44+
test_results.tar.gz

CMakeLists.txt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,23 +221,22 @@ if (CATKIN_ENABLE_TESTING)
221221
error_forced
222222
error_status
223223
error_status_without_stats
224+
error_terminal_before_config
225+
error_tolerant_before_config
226+
hz_config
224227
manual_to_disarming
225228
param
229+
platform_app_required_fail
230+
platform_app_required_pass
231+
platform_required_fail
232+
platform_required_pass
226233
primary
227234
ready_to_shutdown
228235
semi_auto_to_manual
229236
)
230237
foreach(TEST_NAME ${TEST_NAMES})
231-
add_rostest_gtest(${TEST_NAME}_rostest rostest/${TEST_NAME}/${TEST_NAME}_rostest.test rostest/${TEST_NAME}/${TEST_NAME}_rostest.cpp)
232-
target_link_libraries(${TEST_NAME}_rostest ${catkin_LIBRARIES} super_lib)
238+
set(PROJECT_TEST_NAME ${TEST_NAME}_${PROJECT_NAME}_rostest)
239+
add_rostest_gtest(${PROJECT_TEST_NAME} rostest/${TEST_NAME}/${TEST_NAME}_rostest.test rostest/${TEST_NAME}/${TEST_NAME}_rostest.cpp)
240+
target_link_libraries(${PROJECT_TEST_NAME} ${catkin_LIBRARIES} super_lib)
233241
endforeach()
234-
235-
# Create a target ${PROJECT_NAME}_coverage_report
236-
if(ENABLE_COVERAGE_TESTING)
237-
set(COVERAGE_EXCLUDES "*/${PROJECT_NAME}/test*" )
238-
add_code_coverage(
239-
NAME ${PROJECT_NAME}_coverage_report
240-
DEPENDENCIES tests
241-
)
242-
endif()
243242
endif()

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ SHELL := /bin/bash
22

33
BUILD_COMMAND := source /opt/ros/melodic/setup.bash && cd catkin_ws && catkin build -j8
44

5-
# Test only if on AMD, not ARM, which is already too slow and underpowered and redundant
6-
ARCH := $(shell arch)
7-
ifeq ($(ARCH),x86_64)
8-
BUILD_COMMAND := $(BUILD_COMMAND) && catkin build -j8 --catkin-make-args run_tests
9-
endif
10-
115
default:
126
$(BUILD_COMMAND)
137
rm -f catkin_ws/install/lib/pkgconfig/catkin_tools_prebuild.pc

include/am_super/super_node_mediator.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ class SuperNodeMediator
4747
ros::Time last_contact; // last time a message was received from the node
4848
};
4949

50+
/**
51+
* Describes the platform configuration for the hardware running AMROS.
52+
* maker-model-app
53+
* Some variants are just the maker, some maker-model.
54+
* Sometimes a variant may provide just the app, indiciating the app could be flown on different platforms.
55+
*/
56+
struct PlatformVariant
57+
{
58+
/** the manufacture of the drone (DJI, ACSL)*/
59+
std::string maker;
60+
/** The product name of the drone specific to the maker (m210,m300,mini,pf2)*/
61+
std::string model;
62+
/** The application configuration for the mission (bridge, subt, etc). */
63+
std::string app;
64+
65+
};
66+
5067
struct Supervisor
5168
{
5269
/** map of all nodes in the system*/
@@ -288,6 +305,31 @@ class SuperNodeMediator
288305
*/
289306
bool forceTransition(const SuperState& to_state);
290307

308+
/**
309+
* Validates the actual platform matches the required.
310+
* Empty required platform will always return true.
311+
* App provided by itself will ensure the app is correct without concern for the maker/model.
312+
* dji_m300_bridge and acsl_pf2_bridge will both pass required app=bridge
313+
*
314+
* @returns true if the running platform has matching components for that required
315+
*/
316+
bool isCorrectPlatform(const PlatformVariant &required, const PlatformVariant &actual);
317+
318+
/** Given the string in the configurations, the variant given
319+
* is populated with the components parsed from the config
320+
* dji_m300 -> maker=dji,model=m300,app=""
321+
* dji_m300_bridge -> ...,app=bridge
322+
* */
323+
void platformConfigToVariant(const std::string config, PlatformVariant &variant);
324+
325+
/**
326+
* Converts the platform struct into a single string, separated by underscores
327+
* {maker}
328+
* {maker}_{model}
329+
* {maker}_{model}_{app}
330+
*/
331+
std::string platformVariantToConfig(const PlatformVariant &variant);
332+
291333
private:
292334
/** name of supervisor node */
293335
const std::string SUPER_NODE_NAME;

include/super_lib/am_life_cycle.h

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <diagnostic_msgs/DiagnosticStatus.h>
99

1010
#include <super_lib/am_stat_list.h>
11+
#include <super_lib/am_stat_reset.h>
1112
#include <super_lib/am_life_cycle_types.h>
1213
#include <super_lib/am_life_cycle_mediator.h>
1314

@@ -30,6 +31,18 @@ class AMLifeCycle
3031
{
3132
public:
3233
static constexpr std::string_view BROADCAST_NODE_NAME = "";
34+
35+
/**Specific parts of the lifecycle where nodes have responsibilities.*/
36+
LifeCycleState getState() const;
37+
38+
/**Simple indication of health */
39+
LifeCycleStatus getStatus() const;
40+
41+
/** @brief string represenation of LifeCycleState*/
42+
const std::string_view& getStateName();
43+
44+
/** @brief string representation of LifeCycleStatus*/
45+
const std::string_view& getStatusName();
3346

3447
private:
3548
/* Variables to help seperate business logic from AMLifeCycle ROS */
@@ -60,6 +73,7 @@ class AMLifeCycle
6073
void destroy();
6174
void cleanup();
6275
void sendNodeUpdate();
76+
void error(std::string message, std::string error_code, bool forced = false);
6377

6478
protected:
6579
std::string node_name_;
@@ -139,8 +153,15 @@ class AMLifeCycle
139153
* @param error_code provides a reference for the developer to correlate log output to the originating error.
140154
* @param forced terminal error that will not allow any tolerance
141155
*/
156+
[[deprecated("use errorTolerant or errorTerminal with message")]]
142157
void error(std::string error_code="NNLW",bool forced = false);
143158

159+
/** Reports an error for immediate shutdown without any tolerance. */
160+
void errorTerminal(std::string message, std::string error_code);
161+
162+
/** Reports an error, but may not shutdown the system if tolerance is allowed.*/
163+
void errorTolerant(std::string message, std::string error_code);
164+
144165
/**
145166
* @brief Function to be defined by the user.
146167
* Called at any time and transitions to UNCONFIGURED or FINALIZED.
@@ -155,19 +176,43 @@ class AMLifeCycle
155176
virtual void onShutdown();
156177
void doShutdown(bool success);
157178

179+
/**Initialize statistics by adding to the list*/
158180
virtual void addStatistics(diagnostic_updater::DiagnosticStatusWrapper& dsw);
181+
182+
/** Initialize the stats that reset once per second providing the equivalent of rostopic hz to ensure frequency of
183+
* publishing. Allows for overriding values in roslaunch configurations.
184+
* Provide the target, which is the approximate value you expect to receive. The warnings and errors will be
185+
* provided with tolerance on both sides of the target.
186+
*
187+
* Configurations key use the stats short name.
188+
*
189+
* setting a target will also set a min/max 5% warn and 10% error
190+
* no target allows for just min or just max or both.
191+
*
192+
* stats_target_sets_min_max:
193+
* hz:
194+
* target: 100 # sets min_error=90,min_warn=95,max_warn=105,max_error=110
195+
*
196+
* stats_only_min:
197+
* hz:
198+
* error:
199+
* min: 50
200+
* warn:
201+
* min: 60
202+
*
203+
*
204+
* @param stats to be configured
205+
* */
206+
AMStatReset& configureHzStats(AMStatReset& stats);
207+
208+
/** Called periodically by a timer defaulting to 1 second.
209+
* Useful for checking health regularly, but not during
210+
* callbacks which can affect performance and be too granular
211+
*/
159212
virtual void heartbeatCB(const ros::TimerEvent& event);
160213

161214
void lifecycleCB(const brain_box_msgs::LifeCycleCommand::ConstPtr msg);
162215

163-
/**Specific parts of the lifecycle where nodes have responsibilities.*/
164-
LifeCycleState getState() const;
165-
/**Simple indication of health */
166-
LifeCycleStatus getStatus() const;
167-
/** @brief string represenation of LifeCycleState*/
168-
const std::string_view& getStateName();
169-
/** @brief string representation of LifeCycleStatus*/
170-
const std::string_view& getStatusName();
171216

172217
double getThrottleS() const;
173218
void setThrottleS(const double throttleS);

include/super_lib/am_life_cycle_mediator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,12 @@ class AMLifeCycleMediator
193193

194194
bool redundantShutdown(const AMLifeCycleMediator::LifeCycleInfo& info);
195195

196+
/** @brief return true if already in error state */
196197
bool redundantError(const AMLifeCycleMediator::LifeCycleInfo& info);
197198

199+
/** @brief return true if in UNCONFIGURED or CONFIGURING */
200+
bool unconfigured(const AMLifeCycleMediator::LifeCycleInfo& info);
201+
198202
bool illegalDestroy(const AMLifeCycleMediator::LifeCycleInfo& info);
199203

200204
private:

launch/am_super.launch

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?xml version="1.0" ?>
22
<launch>
3+
<arg name="platform" value="$(eval optenv('AM_PLATFORM'))" if="$(eval optenv('AM_PLATFORM') != '')" />
4+
<arg name="platform" value="dev" if="$(eval optenv('AM_PLATFORM') == '')" />
35
<node pkg="am_super" type="am_super" name="am_super" output="screen">
4-
<rosparam command="load" file="$(find am_super)/launch/am_super.yaml"/>
6+
<rosparam command="load" file="$(find am_super)/launch/am_super.yaml" subst_value="true">
7+
<arg name="platform" value="$(arg platform)" />
8+
</rosparam>
59
</node>
610
</launch>

0 commit comments

Comments
 (0)