Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ jobs:
run: ./build.sh
- name: Test
run: ctest --test-dir build --output-on-failure --no-tests=error
- name: Build and test without yaml-cpp
if: matrix.ubuntu == '24.04' && matrix.arch == 'amd64'
run: |
BUILD_DIR=build-noyaml ./build.sh -Denable_yaml=OFF
ctest --test-dir build-noyaml --output-on-failure --no-tests=error \
-R '^(helm|behavior_file|bhv_schema|closed_loop_s1_alpha_inline)$'
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ elseif(GOBY_moos_FOUND)
find_package(MOOS 10 QUIET)
endif()

# YAML behavior files (.bhv.yml); without it, behaviors come from .bhv files or the helm config
find_package(yaml-cpp QUIET)
option(enable_yaml "Read YAML behavior files (.bhv.yml)" ${yaml-cpp_FOUND})
if(enable_yaml AND NOT yaml-cpp_FOUND)
message(FATAL_ERROR "enable_yaml is ON but yaml-cpp wasn't found (apt install libyaml-cpp-dev)")
endif()
message(STATUS "YAML behavior files (enable_yaml): ${enable_yaml}")

include(CTest)

add_subdirectory(src)
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ One way to think of this project is as a generator for the equivalent of the MOO
- src: Source code
- lib: Library source
- interface: Interface messages (Protobuf)
- helm: The helm, pHelmIvP without MOOS (`ivpico::helm::Helm`)
- helm: The helm, pHelmIvP without MOOS (`ivpico::helm::Helm`), and behavior files
- bin: Binary source
- bhv: `ivpico_bhv`, for behavior files (`.bhv`, `.bhv.yml`)
- goby: Goby middleware app (`goby_helm_ivp`)
- ros: ROS middleware node
- test: Tests, including replays of MOOS-IvP missions (`test/missions`)
- launch: Example missions
- share/ivpico: The JSON Schema of `.bhv.yml` files (`bhv.schema.json`)

## Building

Expand All @@ -30,6 +32,8 @@ One way to think of this project is as a generator for the equivalent of the MOO

All of these come from [Open Ocean Software](https://github.com/openocean-software/openocean-build)'s continuous builds, with its releases for what they depend on (DCCL, MOOS, ...), at apt.oceansoft.org. `init.sh` adds both if apt can't install the packages already.

yaml-cpp (`libyaml-cpp-dev`) is optional: without it, behaviors come only from `.bhv` files or the helm configuration (`-Denable_yaml=OFF` leaves it out).

`build.sh` then builds IvPico in `build/` and installs it into `build/usr`.

```
Expand All @@ -49,6 +53,19 @@ ctest --test-dir build
- Field levels (CORE, ADVANCED, DEVELOPER) and what each adds to `Status` and `HelmConfig`.
- Differences from pHelmIvP: the MOOSDB echo, rejournal, standby helm.

## Behavior files

*Outline, to be written:*

- Three ways to give the helm its behaviors (`HelmConfig`):
- `.bhv` files, MOOS-IvP's own format and the reference;
- `.bhv.yml` files: the same content as YAML, checked against `share/ivpico/bhv.schema.json`;
- `behaviors`: the same structure inline in the helm configuration.
- How each is read: everything is converted to `.bhv` text for MOOS-IvP's Populator; with any YAML or inline behaviors, files are read in the order given, not sorted.
- The `.bhv.yml` format: `initialize`, `initialize_deferred`, `modes`, `behaviors`; common parameters as keys, the behavior's own under `params`; a list where a parameter repeats; `x-` keys and merges (`<<: *name`) for shared settings (merges are shallow, so a behavior's `params` replaces a merged `params`). Example: `launch/goby/alpha/config/alpha.bhv.yml`.
- `ivpico_bhv`: `convert` (YAML to `.bhv`), `import` (`.bhv` to YAML), `check` (builds the behaviors and reports problems at their YAML line), `schema`.
- Editor setup: the `# yaml-language-server: $schema=...` line `import` writes.

## Goby app

*This section was written by Claude.*
Expand Down
2 changes: 2 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ apt_install() {

# xz-utils: the replay tests' recorded missions are compressed
packages=(cmake ninja-build g++ git ca-certificates protobuf-compiler libprotobuf-dev xz-utils)
# optional: YAML behavior files (.bhv.yml), and the test that validates them against the schema
packages+=(libyaml-cpp-dev python3-jsonschema python3-yaml)
$SUDO apt-get update
apt_install "${packages[@]}"

Expand Down
91 changes: 0 additions & 91 deletions launch/goby/alpha/config/alpha.bhv

This file was deleted.

84 changes: 84 additions & 0 deletions launch/goby/alpha/config/alpha.bhv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/GobySoft/IvPico/main/share/ivpico/bhv.schema.json
# MOOS-IvP's alpha mission: a survey, then a return to 0,-20, as alpha.bhv in
# ivp/missions/s1_alpha. ivpico_bhv convert writes it as a .bhv file.

initialize:
DEPLOY: false
RETURN: false

behaviors:
- type: BHV_Waypoint
name: waypt_survey
pwt: 100
condition:
- RETURN = false
- DEPLOY = true
updates: WPT_UPDATE
perpetual: true
endflag:
- RETURN = true
- SUMMARY=speed=$[SPEED],time=$[DUR_RUN_TIME]
activeflag:
- INFO=$[OWNSHIP]
- INFO=$[BHVNAME]
- INFO=$[BHVTYPE]
configflag: CRUISE_SPD = $[SPEED]
params:
cycleflag: CINFO=$[OSX],$[OSY]
wptflag:
- PREV=$(PX),$(PY)
- NEXT=$(NX),$(NY)
- TEST=$(X),$(Y)
- OSPOS=$(OSX),$(OSY)
wptflag_on_start: true
speed_alt: 1.2
use_alt_speed: true
lead: 8
lead_damper: 1
lead_to_start: true
speed: 3
capture_line: true
capture_radius: 5.0
slip_radius: 15.0
efficiency_measure: all
polygon: 60,-40:60,-160:150,-160:180,-100:150,-40
order: normal
repeat: 0
visual_hints:
- nextpt_color=yellow
- nextpt_vertex_size=8
- nextpt_lcolor=gray70
- vertex_color=dodger_blue, edge_color=white
- vertex_size=5, edge_size=1

- type: BHV_Waypoint
name: waypt_return
pwt: 100
condition:
- RETURN = true
- DEPLOY = true
updates: RETURN_UPDATE
perpetual: true
endflag:
- RETURN = false
- DEPLOY = false
- MISSION = complete
params:
speed: 2.0
capture_radius: 2.0
slip_radius: 8.0
points: 0,-20

- type: BHV_ConstantSpeed
name: const_speed
pwt: 200
condition:
- SPD=true
- DEPLOY = true
updates: SPEED_UPDATE
duration: 10
duration_reset: CONST_SPD_RESET=true
perpetual: true
endflag: SPD = false
params:
speed: 0.5
2 changes: 1 addition & 1 deletion launch/goby/alpha/config/helm_ivp.pb.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interprocess {
}

helm {
behavior_file: "config/alpha.bhv"
behavior_file: "config/alpha.bhv.yml"
domain { name: "course" low: 0 high: 359 points: 360 }
domain { name: "speed" low: 0 high: 4 points: 41 }
}
Expand Down
89 changes: 89 additions & 0 deletions share/ivpico/bhv.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/GobySoft/IvPico/blob/main/share/ivpico/bhv.schema.json",
"title": "IvPico behavior file (.bhv.yml)",
"description": "MOOS-IvP behaviors, modes and initial variables, as a .bhv file holds them",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^x-": { "description": "Ignored: a place for anchors to merge elsewhere" }
},
"properties": {
"initialize": {
"description": "Variables posted when the helm starts (initialize)",
"$ref": "#/$defs/variables"
},
"initialize_deferred": {
"description": "Variables posted unless another app has set them (initialize_)",
"$ref": "#/$defs/variables"
},
"modes": {
"description": "Hierarchical modes (set), in order",
"type": "array",
"items": { "$ref": "#/$defs/mode" }
},
"behaviors": {
"type": "array",
"items": { "$ref": "#/$defs/behavior" }
}
},
"$defs": {
"value": { "type": ["string", "number", "boolean"] },
"values": {
"oneOf": [
{ "$ref": "#/$defs/value" },
{ "type": "array", "items": { "$ref": "#/$defs/value" } }
]
},
"variables": {
"type": "object",
"propertyNames": { "pattern": "^[^\\s=,{}]+$" },
"additionalProperties": { "$ref": "#/$defs/value" }
},
"mode": {
"type": "object",
"additionalProperties": false,
"required": ["set"],
"properties": {
"set": { "description": "MODE_VAR = value", "type": "string", "pattern": "\\S\\s*=\\s*\\S" },
"condition": { "$ref": "#/$defs/values" },
"else": { "$ref": "#/$defs/value" }
}
},
"behavior": {
"type": "object",
"additionalProperties": false,
"required": ["type"],
"properties": {
"type": { "type": "string", "pattern": "^\\S+$" },
"name": { "$ref": "#/$defs/value" },
"pwt": { "$ref": "#/$defs/value" },
"condition": { "$ref": "#/$defs/values" },
"updates": { "$ref": "#/$defs/value" },
"templating": { "$ref": "#/$defs/value" },
"duration": { "$ref": "#/$defs/value" },
"duration_status": { "$ref": "#/$defs/value" },
"duration_reset": { "$ref": "#/$defs/value" },
"duration_idle_decay": { "$ref": "#/$defs/value" },
"perpetual": { "$ref": "#/$defs/value" },
"nostarve": { "$ref": "#/$defs/values" },
"post_mapping": { "$ref": "#/$defs/values" },
"comms_policy": { "$ref": "#/$defs/value" },
"endflag": { "$ref": "#/$defs/values" },
"runflag": { "$ref": "#/$defs/values" },
"runxflag": { "$ref": "#/$defs/values" },
"activeflag": { "$ref": "#/$defs/values" },
"inactiveflag": { "$ref": "#/$defs/values" },
"idleflag": { "$ref": "#/$defs/values" },
"spawnflag": { "$ref": "#/$defs/values" },
"spawnxflag": { "$ref": "#/$defs/values" },
"configflag": { "$ref": "#/$defs/values" },
"params": {
"description": "The behavior's own parameters, in order; a list for a parameter given more than once",
"type": "object",
"additionalProperties": { "$ref": "#/$defs/values" }
}
}
}
}
}
2 changes: 2 additions & 0 deletions src/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_subdirectory(bhv)

if(GOBY_FOUND)
add_subdirectory(goby)
endif()
Expand Down
6 changes: 6 additions & 0 deletions src/bin/bhv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
add_executable(ivpico_bhv ivpico_bhv.cpp)
target_include_directories(ivpico_bhv PRIVATE ${PROJECT_SOURCE_DIR}/src/lib)
target_link_libraries(ivpico_bhv PRIVATE ivpico_helm)
install(TARGETS ivpico_bhv RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${PROJECT_SOURCE_DIR}/share/ivpico/bhv.schema.json
DESTINATION ${CMAKE_INSTALL_DATADIR}/ivpico)
Loading