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
13 changes: 13 additions & 0 deletions .LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Carologistics
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

3 changes: 0 additions & 3 deletions CONTRIBUTING.md

This file was deleted.

111 changes: 16 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,118 +1,39 @@
# FlexBE States and Behaviors for caro_skills
# Installing Flexbe

Generic template for a behaviors repository to be used for new projects
Follow the README in the [flexbe behavior engine repo](https://github.com/FlexBE/flexbe_behavior_engine) and the [flexbe webUI](https://github.com/FlexBE/flexbe_webui).

Modify this README as needed for your specific project details.
# Storing Behaviors

Below we provide basic details, but you are free to delete or modify this README as you wish.
Behaviors typically edited and generated by the FlexBE UI.
These generated files are stored in the
`install/caro_skills_flexbe_behaviors/lib/caro_skills_flexbe_behaviors/manifest` and
`install/caro_skills_flexbe_behaviors/python3.12/site-packages/caro_skills_flexbe_behaviors` folder.

----
To store it properly, save these files in the `src/caro_flexbe_behavior/manifest` and `src/caro_skills_flexbe_behaviors/caro_skills_flexbe_behaviors` folders.

This raw repository has several folders and files with the generic name `caro_skills`.


This repository is used by the FlexBE widget
[`create_repo`](https://github.com/FlexBE/flexbe_behavior_engine/blob/ros2-devel/flexbe_widget/bin/create_repo)
script to create an example project that you can build off of to add your own states and behaviors.

Using `ros2 run flexbe_widget create_repo <my_new_project_name>` will clone this repository,
and change the relevant `caro_skills` text to `my_new_project_name` as needed.

It sets up the `package.xml` files with proper FlexBE export tags.
It is maintained at version `0.0.1` as the starting point for your work.

We have provided a license file to conform to ROS guidelines; however, you are free to replace the
`LICENSE` file, and apply whatever license you choose to states and behaviors that you create.

This repository contains an example behavior and examples for writing your own state implementations.

## Example States in `caro_skills_flexbe_states`

Packages providing FlexBE states are identified by an export tag in the `package.xml`:

```xml
<export>
<flexbe_states />
<build_type>ament_cmake</build_type>
</export>
```

* `example_state.py `
* Example state implementation with extra console logging to show the state life cycle.

* `example_action_state.py`

> Note: These example states are defined with extra console logging that is useful when learning FlexBE,
> but you will typically not include so much of the `Logger.info` commands as in these examples.

> Note: You are free to copy and modify these files to create your own files and publish under your own license terms.
> As per the existing licenses, no warranty is implied.

## Example Behaviors in `caro_skills_flexbe_behaviors`

Packages providing FlexBE behaviors are identified by an export tag in the `package.xml`:

```xml
<export>
<flexbe_behaviors />
<build_type>ament_cmake</build_type>
</export>
```

* `example_behavior_sm.py`
* Most basic example state machine

* `example_action_behavior_sm.py`
* Uses the `ExampleActionState` with the standard action tutorials

[Understanding ROS2 Actions](https://docs.ros.org/en/iron/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.html)

[Introducing Turtlesim](https://docs.ros.org/en/iron/Tutorials/Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim.html)

To execute the associated behavior in FlexBE, you need to first run the turtlesim node that provdes the action server

`ros2 run turtlesim turtlesim_node`

To display the available actions:

`ros2 action list`

The action is defined by:

`/turtle1/rotate_absolute:` [`turtlesim/action/RotateAbsolute`](https://docs.ros2.org/latest/api/turtlesim/action/RotateAbsolute.html)

Behaviors typically edited and generated by the FlexBE UI.
These generated files are stored in the root workspace `install` folder.
Presuming a `WORKSPACE_ROOT` environment variable exists, we provide a simple
[`copy_behavior`](caro_skills_flexbe_behaviors/bin/copy_behavior) script to copy a saved behavior
&mdash; both the Python implementation and manifest `.xml` file &mdash;
to the project source folder for long term storage.
Use `ros2 run caro_skills_flexbe_behavior copy_behavior` to see the usage guide.
The script should be run from this repository's base folder.

For a Quick-start and more comprehensive introduction to FlexBE,
see the [FlexBE Turtlesim Demonstrations](https://github.com/FlexBE/flexbe_turtlesim_demo).

# Our instructions:

### start WebUI:
# Start WebUI:

```ros2 launch flexbe_webui flexbe_ocs.launch.py headless:=True```

```ros2 run flexbe_webui webui_client```

```ros2 launch flexbe_onboard behavior_onboard.launch.py```

## start behavior without WebUI:
# Start behavior without WebUI:

requires flexbe_behavior_engine to be on carologistic's fork on branch [mtschesche/action_server_jazzy](https://github.com/carologistics/flexbe_behavior_engine/tree/mtschesche/action_server_jazzy)

```ros2 launch flexbe_onboard behavior_onboard.launch.py```

```ros2 run flexbe_widget be_action_server```

example:
## Examples for starting behaviors via action server:

MoveTo:
```
ros2 action send_goal /flexbe/execute_behavior flexbe_msgs/action/BehaviorExecution "{behavior_name: 'MoveTo', input_keys: ['frame_id','target_x','target_y','target_yaw'], input_values: ['map','3.0','4.5','1.0']}"
```
MotorMove:
```
ros2 action send_goal /flexbe/execute_behavior flexbe_msgs/action/BehaviorExecution "{behavior_name: 'MotorMove', input_keys: ['frame_id','target_x','target_y','target_yaw'], input_values: ['robotinobase1/base_link','0.0','-10.0','0.0']}"
```
2 changes: 1 addition & 1 deletion caro_flexbe_behavior/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Changelog for package caro_flexbe_behavior

0.0.1 (2023-07-21)
------------------
* Initial release of ROS 2 example FlexBE project
* Initial release of ROS 2 example FlexBE project
2 changes: 1 addition & 1 deletion caro_skills_flexbe_behaviors/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Changelog for package caro_skills_flexbe_behaviors

0.0.1 (2023-07-21)
------------------
* Initial release of ROS 2 example FlexBE behaviors
* Initial release of ROS 2 example FlexBE behaviors
4 changes: 2 additions & 2 deletions caro_skills_flexbe_behaviors/bin/copy_behavior
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fi

beh=$(echo "$1" | cut -f 1 -d '.') # include only the base file name is someone pastes .xml name
pack="caro_skills_flexbe_behaviors" # Default name uses this behaviors package
if [ $# -eq 2 ]; then
if [ $# -eq 2 ]; then
pack="$2"
echo "Using specified package '${pack}'!"
fi
Expand Down Expand Up @@ -97,4 +97,4 @@ else
echo ""
echo -e "\e[91m Failed to copy behavior '${beh}'!\033[0m"
exit
fi
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# # Copyright 2026 Carologistics
# #
# # Licensed under the Apache License, Version 2.0 (the "License");
# # you may not use this file except in compliance with the License.
# # You may obtain a copy of the License at
# #
# # http://www.apache.org/licenses/LICENSE-2.0
# #
# # Unless required by applicable law or agreed to in writing, software
# # distributed under the License is distributed on an "AS IS" BASIS,
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# # See the License for the specific language governing permissions and
# # limitations under the License.
112 changes: 63 additions & 49 deletions ..._skills_flexbe_behaviors/caro_skills_flexbe_behaviors/example_action_state_behavior_sm.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright 2023 David Conner
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# # Copyright 2026 Carologistics
# #
# # Licensed under the Apache License, Version 2.0 (the "License");
# # you may not use this file except in compliance with the License.
# # You may obtain a copy of the License at
# #
# # http://www.apache.org/licenses/LICENSE-2.0
# #
# # Unless required by applicable law or agreed to in writing, software
# # distributed under the License is distributed on an "AS IS" BASIS,
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# # See the License for the specific language governing permissions and
# # limitations under the License.
###########################################################
# WARNING: Generated code! #
# ************************** #
# Manual changes may get lost if file is generated again. #
# Only code inside the [MANUAL] tags will be kept. #
###########################################################

"""
Define Example Action State Behavior.

Created on July 21, 2023
@author: David Conner
"""


from flexbe_core import Autonomy
from flexbe_core import Behavior
from flexbe_core import ConcurrencyContainer
Expand Down Expand Up @@ -58,7 +52,7 @@ class ExampleActionStateBehaviorSM(Behavior):

def __init__(self, node):
super().__init__()
self.name = 'Example Action State Behavior'
self.name = "Example Action State Behavior"

# parameters of this behavior

Expand All @@ -80,7 +74,7 @@ def __init__(self, node):

def create(self):
# x:1096 y:62, x:1095 y:363
_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])
_state_machine = OperatableStateMachine(outcomes=["finished", "failed"])
_state_machine.userdata.angle_degrees = 90.0

# Additional creation code can be added inside the following tags
Expand All @@ -89,44 +83,64 @@ def create(self):
# [/MANUAL_CREATE]
with _state_machine:
# x:102 y:157
OperatableStateMachine.add('LogRequest',
LogKeyState(text="Request to rotate {} degrees", severity=2),
transitions={'done': 'Rotate Turtle State'},
autonomy={'done': Autonomy.Off},
remapping={'data': 'angle_degrees'})
OperatableStateMachine.add(
"LogRequest",
LogKeyState(text="Request to rotate {} degrees", severity=2),
transitions={"done": "Rotate Turtle State"},
autonomy={"done": Autonomy.Off},
remapping={"data": "angle_degrees"},
)

# x:659 y:190
OperatableStateMachine.add('Log Failed',
LogState(text="Failed", severity=Logger.REPORT_WARN),
transitions={'done': 'failed'},
autonomy={'done': Autonomy.Off})
OperatableStateMachine.add(
"Log Failed",
LogState(text="Failed", severity=Logger.REPORT_WARN),
transitions={"done": "failed"},
autonomy={"done": Autonomy.Off},
)

# x:658 y:57
OperatableStateMachine.add('Log Success',
LogState(text="Success", severity=Logger.REPORT_HINT),
transitions={'done': 'finished'},
autonomy={'done': Autonomy.Off})
OperatableStateMachine.add(
"Log Success",
LogState(text="Success", severity=Logger.REPORT_HINT),
transitions={"done": "finished"},
autonomy={"done": Autonomy.Off},
)

# x:657 y:480
OperatableStateMachine.add('Log Timeout',
LogState(text="Timeout", severity=Logger.REPORT_WARN),
transitions={'done': 'failed'},
autonomy={'done': Autonomy.Off})
OperatableStateMachine.add(
"Log Timeout",
LogState(text="Timeout", severity=Logger.REPORT_WARN),
transitions={"done": "failed"},
autonomy={"done": Autonomy.Off},
)

# x:244 y:294
OperatableStateMachine.add('Rotate Turtle State',
RotateTurtleState(timeout=10, action_topic="/turtle1/rotate_absolute"),
transitions={'rotation_complete': 'Log Success', 'failed': 'Log Failed',
'canceled': 'Log Canceled', 'timeout': 'Log Timeout'},
autonomy={'rotation_complete': Autonomy.Off, 'failed': Autonomy.Off,
'canceled': Autonomy.Off, 'timeout': Autonomy.Off},
remapping={'angle': 'angle_degrees', 'duration': 'duration'})
OperatableStateMachine.add(
"Rotate Turtle State",
RotateTurtleState(timeout=10, action_topic="/turtle1/rotate_absolute"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turtle? sounds like some tutorial stuff, this is generated but it should have been copied from somewhere

transitions={
"rotation_complete": "Log Success",
"failed": "Log Failed",
"canceled": "Log Canceled",
"timeout": "Log Timeout",
},
autonomy={
"rotation_complete": Autonomy.Off,
"failed": Autonomy.Off,
"canceled": Autonomy.Off,
"timeout": Autonomy.Off,
},
remapping={"angle": "angle_degrees", "duration": "duration"},
)

# x:656 y:337
OperatableStateMachine.add('Log Canceled',
LogState(text="Canceled", severity=Logger.REPORT_WARN),
transitions={'done': 'failed'},
autonomy={'done': Autonomy.Off})
OperatableStateMachine.add(
"Log Canceled",
LogState(text="Canceled", severity=Logger.REPORT_WARN),
transitions={"done": "failed"},
autonomy={"done": Autonomy.Off},
)

return _state_machine

Expand Down
Loading