Skip to content

Commit

Permalink
Merge pull request FlexBE#11 from benmaidel/sync
Browse files Browse the repository at this point in the history
sync with upstream
  • Loading branch information
fmessmer authored Jan 13, 2021
2 parents 6220e30 + 222d5e0 commit 1d86941
Show file tree
Hide file tree
Showing 18 changed files with 224 additions and 94 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/flexbe_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This is a basic workflow to help you get started with Actions
name: FlexBE CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
strategy:
matrix:
ros: [kinetic, melodic, noetic]
include:
- os: ubuntu-16.04
ros: kinetic
- os: ubuntu-18.04
ros: melodic
- os: ubuntu-20.04
ros: noetic
python: python3

runs-on: ${{ matrix.os }}
env:
ROS_DISTRO: ${{ matrix.ros }}
PYTHON: ${{ matrix.python }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Prepare CI
run: |
git clone https://github.com/FlexBE/flexbe_ci.git ~/flexbe_ci
source ~/flexbe_ci/setup.bash $ROS_DISTRO
- name: Install ROS
run: ~/flexbe_ci/ci_scripts/install_ros.bash
- name: Setup Workspace
run: ~/flexbe_ci/ci_scripts/setup_workspace.bash
- name: Clone FlexBE Repos
run: ~/flexbe_ci/ci_scripts/run_rosinstall.bash
- name: Test Create Repo
run: ~/flexbe_ci/ci_scripts/test_create_repo.bash
- name: Test Devel Workspace
run: ~/flexbe_ci/ci_scripts/run_devel_tests.bash
- name: Test Install Workspace
run: ~/flexbe_ci/ci_scripts/run_install_tests.bash
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nwjs/
.*/**
.vscode/**
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

49 changes: 49 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,55 @@
Changelog for package flexbe_app
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2.3.0 (2020-11-19)
------------------
* Merge remote-tracking branch 'origin/feature/python3_support' into develop
* Add support for python3
* Use correct state prefix in autocompletion
(fix `#65 <https://github.com/FlexBE/flexbe_app/issues/65>`_)
* Prevent module caching in Python parser to fix state reloading
(see `#61 <https://github.com/FlexBE/flexbe_app/issues/61>`_)
* Sort input-dependent elements for more deterministic code generation
(see #`team-vigir/flexbe_behavior_engine#111 <https://github.com/team-vigir/flexbe_behavior_engine/issues/111>`_)
* Contributors: Philipp Schillinger

2.2.4 (2020-03-25)
------------------
* Revert nwjs version increment because of Travis failure due to Chromium bug
(see https://crbug.com/1025266)
* Increment nwjs version after file chooser fix
* Use HTML file chooser instead of Chrome file API for settings import and export
(see `#52 <https://github.com/FlexBE/flexbe_app/issues/52>`_)
* Improve cache for workspace switching and allow to disable it
* Fix detection of new packages
* Merge branch 'benmaidel-feature/cmd_option_checkbehaviors' into develop
* Always run all behavior check tests and print error message
* Robustify behavior loading for generating behavior check reports
* Close window-related sub-processes also when only closing the window
(see `team-vigir/flexbe_behavior_engine#105 <https://github.com/team-vigir/flexbe_behavior_engine/issues/105>`_)
* Merge remote-tracking branch 'origin/fix/handle_closed_window' into develop
* add --check-behavior command line option
* Fix support for symbolic references in Python parser
* Robustify Python parser against instantiation failures
(see `team-vigir/flexbe_behavior_engine#99 <https://github.com/team-vigir/flexbe_behavior_engine/issues/99>`_)
* Close window-related sub-processes also when only closing the window
(see `team-vigir/flexbe_behavior_engine#105 <https://github.com/team-vigir/flexbe_behavior_engine/issues/105>`_)
* Merge branch 'cheffe112-bugfix-import-config' into develop
* Fix mixed indentation
* reverting nw.js to last known-to-work version
From nw.js 0.42.4, the import/export configuration functionality throws an "Invalid calling page. This function can't be called from a background page." error. This has been reported for nw.js already on https://github.com/nwjs/nw.js/issues/7349.
Hence, the import/export functionality is currently unusable with nw.js >0.42.3 as integrated in b93078fd6705445bf6183af40598619243800b1e.
* throw error if importing/exporting configuration crashes
* Explicitly spawn window on center position because default changed
* Allow comment after super-call in regex state parser
(see `team-vigir/flexbe_behavior_engine#98 <https://github.com/team-vigir/flexbe_behavior_engine/issues/98>`_)
* Check for undefined transition label (fix `team-vigir/flexbe_behavior_engine#100 <https://github.com/team-vigir/flexbe_behavior_engine/issues/100>`_)
* Merge branch 'cheffe112-bugfix-python-parsing' into develop
* Fix mixed indentation
* bugfix: avoid crash during Python state parsing on empty documentation string
The Python state parsing feature introduced in 4f20227ef900ca32e78414c190fb464d964666e5 used to crash when no docstring is provided in a state definition, hence stalling the parsing procedure. This commit returns the default label "[no documentation]" on a missing docstring.
* Contributors: Benjamin Maidel, Philipp Schillinger, Tobias Doernbach

2.2.3 (2020-01-15)
------------------
* Increment nwjs version
Expand Down
11 changes: 9 additions & 2 deletions bin/test_report
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/usr/bin/env python
#!/bin/bash
if "true" : '''\'
then
python${ROS_PYTHON_VERSION:-} "${BASH_SOURCE[0]}" $*
exit
fi
'''
# flake8: noqa
import yaml
import unittest
Expand All @@ -18,7 +25,7 @@ class TestReport(unittest.TestCase):
def test_report(self):
try:
with open("/tmp/flexbe_app_report.log", 'r') as f:
report = yaml.load(f)
report = yaml.safe_load(f)
except IOError:
return # skip test since there is no report to evaluate
for test_type, tests in report.items():
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FlexBE App",
"version": "2.2.3",
"version": "2.3.0",
"main": "src/main.js",
"window": {
"icon": "src/img/icon-128.png",
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<package format="2">
<name>flexbe_app</name>
<version>2.2.3</version>
<version>2.3.0</version>
<description>
flexbe_app provides a user interface (editor + runtime control) for the FlexBE behavior engine.
</description>
Expand Down
1 change: 1 addition & 0 deletions src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ document.addEventListener('DOMContentLoaded', function() {
document.getElementById('button_ros_connect').addEventListener('click', UI.Settings.rosConnectClicked);

document.getElementById('select_state_parser').addEventListener('change', UI.Settings.stateParserChanged);
document.getElementById('cb_pkg_cache_enabled').addEventListener('change', UI.Settings.pkgCacheEnabledClicked);
document.getElementById('button_force_discover').addEventListener('click', UI.Settings.forceDiscoverClicked);

document.getElementById('cb_synthesis_enabled').addEventListener('change', UI.Settings.synthesisEnabledClicked);
Expand Down
19 changes: 18 additions & 1 deletion src/io/io_codegenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ IO.CodeGenerator = new (function() {
}
// put together
code += "from flexbe_core import Behavior, Autonomy, OperatableStateMachine, ConcurrencyContainer, PriorityContainer, Logger\n";
code += import_list.join("\n");
code += import_list.sort().join("\n");
code += "\n";
// add manual imports
code += "# Additional imports can be added inside the following tags\n";
Expand Down Expand Up @@ -104,6 +104,7 @@ IO.CodeGenerator = new (function() {

contained_behaviors.push(states[i]);
}
contained_behaviors.sort(compareKey(be => be.getStatePath()));
for (var i=0; i<contained_behaviors.length; ++i) {
code += ws+ws+"self.add_behavior(" + contained_behaviors[i].getStateClass() + ", '" + contained_behaviors[i].getStatePath().substr(1) + "')\n";
}
Expand All @@ -120,6 +121,7 @@ IO.CodeGenerator = new (function() {
code += "\n";
code += ws+ws+"# Behavior comments:\n\n";
var notes = Behavior.getCommentNotes();
notes.sort(compareKey(note => note.getContent()));
for (var i = 0; i < notes.length; i++) {
var n = notes[i];
code += ws+ws+"# " + (n.isImportant()? "!" : "O") + " " + Math.round(n.getPosition().x) + " " + Math.round(n.getPosition().y) + " " + n.getContainerPath() + "\n";
Expand Down Expand Up @@ -174,6 +176,7 @@ IO.CodeGenerator = new (function() {

// generate contained state machines
var sub_sms = helper_getAllSubSMs(Behavior.getStatemachine());
sub_sms.sort(compareKey(sm => sm.getStatePath()));
for (var i = sub_sms.length - 1; i >= 0; i--) {
code += generateStateMachine(sub_sms[i], true);
code += "\n";
Expand Down Expand Up @@ -249,6 +252,7 @@ IO.CodeGenerator = new (function() {

// smach needs to start with initial state
var states = sm.getStates();
states.sort(compareKey(s => s.getStateName()));
var init_trans = sm.getTransitions().findElement(function(element) {
return element.getFrom().getStateName() == "INIT";
});
Expand Down Expand Up @@ -457,4 +461,17 @@ IO.CodeGenerator = new (function() {
return states;
}

var compareKey = function(operation) {
return (a, b) => {
var a_key = operation(a);
var b_key = operation(b);
if (a_key < b_key)
return -1;
else if (a_key > b_key)
return 1;
else
return 0;
};
}

}) ();
14 changes: 10 additions & 4 deletions src/io/io_packageparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@ IO.PackageParser = new (function() {
var add_behaviors = [];

ROS.getPackageList((pkg_list) => {
pkg_list = pkg_list.filter(entry => pkg_cache.findElement(cached => cached['name'] == entry['name']) == undefined);
// remove missing packages from cache
pkg_cache = pkg_cache.filter(cached => pkg_list.findElement(entry => cached.name == entry.name) != undefined);
// remove cached packages from detected ones
pkg_list = pkg_list.filter(entry => pkg_cache.findElement(cached => cached.name == entry.name) == undefined);
// all remaining packages are new and should be parsed
var pkg_count = pkg_list.length;
if (pkg_count > 0) {
T.logInfo("Checking "+pkg_count+" ROS packages for states and behaviors ("+pkg_cache.length+" in cache)...");
} else {
T.logInfo("No new ROS packages detected ("+pkg_cache.length+" in cache).");
}
pkg_cache = pkg_cache.concat(pkg_list);

var processEntry = function(idx) {
var entry = pkg_list[idx];
if (idx >= pkg_count) {
callback(pkg_list, add_states, add_behaviors);
callback(pkg_cache, add_states, add_behaviors);
} else {
checkForRelevance(entry['path'], (has_states, has_behaviors) => {
if (has_states || has_behaviors) {
Expand Down Expand Up @@ -95,9 +101,9 @@ IO.PackageParser = new (function() {
if (state_def != undefined) {
state_def.setFilePath(entry);
WS.Statelib.updateDef(state_def);
T.logInfo("Updating changed definition for state: " + state_def.getStateClass());
T.logInfo("Updating changed definition for state: " + state_def.getStateType());
var update_states = Behavior.getStatemachine().traverseStates(function(state) {
return state.getStateClass() == state_def.getStateClass();
return state.getStateType() == state_def.getStateType();
});
update_states.forEach(function (state) {
state.updateStateDefinition(state_def);
Expand Down
4 changes: 3 additions & 1 deletion src/io/io_stateparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ IO.StateParser = new (function() {
var that = this;
var os = require('os');
var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');
var crypto = require('crypto');
var md5 = str => crypto.createHash('md5').update(str).digest('hex');

Expand All @@ -19,6 +20,7 @@ for data in iter(sys.stdin.readline, ""):
result = {'id': request['id'], 'state_defs': state_defs}
try:
pkg = __import__(request['import_path'], fromlist=[request['import_path']])
del sys.modules[pkg.__name__] # prevent module caching (to allow state reloading)
def is_state(member):
return (inspect.isclass(member) and
member.__module__ == pkg.__name__ and
Expand Down Expand Up @@ -69,7 +71,7 @@ for data in iter(sys.stdin.readline, ""):
var parseCallbacks = [];

var spawnLoader = function() {
loader = spawn('python', ['-c', impl]);
loader = spawn(python, ['-c', impl]);
loader.stdout.on('data', (data) => {
buffer += data;
var try_parse = true;
Expand Down
5 changes: 3 additions & 2 deletions src/ros/ros.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ROS = new (function() {
var os = require('os');
var sys = require('sys');
var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');

////////////////////////////////
// BEGIN Python implementation
Expand All @@ -25,7 +26,7 @@ rospy.spin()
var ros_proc = undefined;

that.init = function(callback) {
ros_proc = spawn('python', ['-c', init_impl]);
ros_proc = spawn(python, ['-c', init_impl]);
ros_proc.stdout.on('data', data => {
data = String(data);
if (data.endsWith("connected")) {
Expand Down Expand Up @@ -104,7 +105,7 @@ rospy.spin()
callback(python_path);
});
} else {
var proc = spawn('python', ['-c', `import importlib; print(importlib.import_module('` + package_name + `').__path__[-1])`]);
var proc = spawn(python, ['-c', `import importlib; print(importlib.import_module('` + package_name + `').__path__[-1])`]);
var path_data = '';
proc.stdout.on('data', data => {
path_data += data;
Expand Down
3 changes: 2 additions & 1 deletion src/ros/ros_actionclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ROS.ActionClient = function(topic, action_type) {
var os = require('os');
var sys = require('sys');
var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');

var feedback_cb = undefined;
var result_cb = undefined;
Expand Down Expand Up @@ -64,7 +65,7 @@ while not rospy.is_shutdown():
// END Python implementation
//////////////////////////////

var client = spawn('python', ['-c', impl, topic, action_type]);
var client = spawn(python, ['-c', impl, topic, action_type]);

var buffer = "";

Expand Down
3 changes: 2 additions & 1 deletion src/ros/ros_publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ROS.Publisher = function(topic, msg_type, latched=false) {
var os = require('os');
var sys = require('sys');
var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');

var LATCHED = "latched";
////////////////////////////////
Expand Down Expand Up @@ -43,7 +44,7 @@ while not rospy.is_shutdown():
// END Python implementation
//////////////////////////////

var pub = spawn('python', ['-c', impl, topic, msg_type, latched? LATCHED : "_"]);
var pub = spawn(python, ['-c', impl, topic, msg_type, latched? LATCHED : "_"]);

pub.stdout.on('data', (data) => {
T.logInfo('[PUB:'+topic+'] ' + data);
Expand Down
3 changes: 2 additions & 1 deletion src/ros/ros_subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ROS.Subscriber = function(topic, msg_type, callback) {
var that = this;
var sys = require('sys');
var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');

////////////////////////////////
// BEGIN Python implementation
Expand Down Expand Up @@ -35,7 +36,7 @@ rospy.spin()
// END Python implementation
//////////////////////////////

var sub = spawn('python', ['-c', impl, topic, msg_type]);
var sub = spawn(python, ['-c', impl, topic, msg_type]);

var buffer = "";

Expand Down
13 changes: 8 additions & 5 deletions src/ui/panels/ui_panels_stateproperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ UI.Panels.StateProperties = new (function() {
});
}

var addAutocomplete = function(el, state_class, mode, state, additional_keywords) {
var addAutocomplete = function(el, state_type, mode, state, additional_keywords) {
var additional_keywords = additional_keywords || [];
if (state_class != undefined) {
var class_vars = WS.Statelib.getFromLib(state_class).getClassVariables();
if (state_type != undefined) {
var state_def = WS.Statelib.getFromLib(state_type);
var state_prefix = (!UI.Settings.isExplicitStates() && WS.Statelib.isClassUnique(state_def.getStateClass()))?
state_def.getStateClass() : state_def.getStatePackage() + "__" + state_def.getStateClass();
var class_vars = state_def.getClassVariables();
for (var i = 0; i < class_vars.length; i++) {
var v = class_vars[i];
additional_keywords.push({text: v.name, hint: "", fill: state_class + "." + v.name});
additional_keywords.push({text: v.name, hint: "", fill: state_prefix + "." + v.name});
}
additional_keywords.push({text: state_class, hint: "", fill: state_class + "."});
additional_keywords.push({text: state_def.getStateClass(), hint: "", fill: state_prefix + "."});
}

el.addEventListener('keyup', function(evt) {
Expand Down
Loading

0 comments on commit 1d86941

Please sign in to comment.