Skip to content

Commit 3e63c7a

Browse files
committed
feat: add new flexbe states and behaviors
Add new states: - estimate_pose: pose estimation state - find_tf: TF lookup state - generic_service_toggle_state: toggle generic services - mapper_state: mapping functionality Update existing states and behaviors for improved functionality. Fix pre-commit issues and update configuration files.
1 parent 6514304 commit 3e63c7a

33 files changed

+1390
-421
lines changed

.LICENSE

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

.flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 16 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,39 @@
1-
# FlexBE States and Behaviors for caro_skills
1+
# Installing Flexbe
22

3-
Generic template for a behaviors repository to be used for new projects
3+
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).
44

5-
Modify this README as needed for your specific project details.
5+
# Storing Behaviors
66

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

9-
----
12+
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.
1013

11-
This raw repository has several folders and files with the generic name `caro_skills`.
12-
13-
14-
This repository is used by the FlexBE widget
15-
[`create_repo`](https://github.com/FlexBE/flexbe_behavior_engine/blob/ros2-devel/flexbe_widget/bin/create_repo)
16-
script to create an example project that you can build off of to add your own states and behaviors.
17-
18-
Using `ros2 run flexbe_widget create_repo <my_new_project_name>` will clone this repository,
19-
and change the relevant `caro_skills` text to `my_new_project_name` as needed.
20-
21-
It sets up the `package.xml` files with proper FlexBE export tags.
22-
It is maintained at version `0.0.1` as the starting point for your work.
23-
24-
We have provided a license file to conform to ROS guidelines; however, you are free to replace the
25-
`LICENSE` file, and apply whatever license you choose to states and behaviors that you create.
26-
27-
This repository contains an example behavior and examples for writing your own state implementations.
28-
29-
## Example States in `caro_skills_flexbe_states`
30-
31-
Packages providing FlexBE states are identified by an export tag in the `package.xml`:
32-
33-
```xml
34-
<export>
35-
<flexbe_states />
36-
<build_type>ament_cmake</build_type>
37-
</export>
38-
```
39-
40-
* `example_state.py `
41-
* Example state implementation with extra console logging to show the state life cycle.
42-
43-
* `example_action_state.py`
44-
45-
> Note: These example states are defined with extra console logging that is useful when learning FlexBE,
46-
> but you will typically not include so much of the `Logger.info` commands as in these examples.
47-
48-
> Note: You are free to copy and modify these files to create your own files and publish under your own license terms.
49-
> As per the existing licenses, no warranty is implied.
50-
51-
## Example Behaviors in `caro_skills_flexbe_behaviors`
52-
53-
Packages providing FlexBE behaviors are identified by an export tag in the `package.xml`:
54-
55-
```xml
56-
<export>
57-
<flexbe_behaviors />
58-
<build_type>ament_cmake</build_type>
59-
</export>
60-
```
61-
62-
* `example_behavior_sm.py`
63-
* Most basic example state machine
64-
65-
* `example_action_behavior_sm.py`
66-
* Uses the `ExampleActionState` with the standard action tutorials
67-
68-
[Understanding ROS2 Actions](https://docs.ros.org/en/iron/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.html)
69-
70-
[Introducing Turtlesim](https://docs.ros.org/en/iron/Tutorials/Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim.html)
71-
72-
To execute the associated behavior in FlexBE, you need to first run the turtlesim node that provdes the action server
73-
74-
`ros2 run turtlesim turtlesim_node`
75-
76-
To display the available actions:
77-
78-
`ros2 action list`
79-
80-
The action is defined by:
81-
82-
`/turtle1/rotate_absolute:` [`turtlesim/action/RotateAbsolute`](https://docs.ros2.org/latest/api/turtlesim/action/RotateAbsolute.html)
83-
84-
Behaviors typically edited and generated by the FlexBE UI.
85-
These generated files are stored in the root workspace `install` folder.
86-
Presuming a `WORKSPACE_ROOT` environment variable exists, we provide a simple
87-
[`copy_behavior`](caro_skills_flexbe_behaviors/bin/copy_behavior) script to copy a saved behavior
88-
&mdash; both the Python implementation and manifest `.xml` file &mdash;
89-
to the project source folder for long term storage.
90-
Use `ros2 run caro_skills_flexbe_behavior copy_behavior` to see the usage guide.
91-
The script should be run from this repository's base folder.
92-
93-
For a Quick-start and more comprehensive introduction to FlexBE,
94-
see the [FlexBE Turtlesim Demonstrations](https://github.com/FlexBE/flexbe_turtlesim_demo).
95-
96-
# Our instructions:
97-
98-
### start WebUI:
14+
# Start WebUI:
9915

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

10218
```ros2 run flexbe_webui webui_client```
10319

10420
```ros2 launch flexbe_onboard behavior_onboard.launch.py```
10521

106-
## start behavior without WebUI:
22+
# Start behavior without WebUI:
10723

10824
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)
10925

11026
```ros2 launch flexbe_onboard behavior_onboard.launch.py```
11127

11228
```ros2 run flexbe_widget be_action_server```
11329

114-
example:
30+
## Examples for starting behaviors via action server:
11531

32+
MoveTo:
11633
```
11734
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']}"
11835
```
36+
MotorMove:
37+
```
38+
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']}"
39+
```

caro_flexbe_behavior/CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Changelog for package caro_flexbe_behavior
44

55
0.0.1 (2023-07-21)
66
------------------
7-
* Initial release of ROS 2 example FlexBE project
7+
* Initial release of ROS 2 example FlexBE project

caro_skills_flexbe_behaviors/CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Changelog for package caro_skills_flexbe_behaviors
44

55
0.0.1 (2023-07-21)
66
------------------
7-
* Initial release of ROS 2 example FlexBE behaviors
7+
* Initial release of ROS 2 example FlexBE behaviors

caro_skills_flexbe_behaviors/bin/copy_behavior

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fi
3939

4040
beh=$(echo "$1" | cut -f 1 -d '.') # include only the base file name is someone pastes .xml name
4141
pack="caro_skills_flexbe_behaviors" # Default name uses this behaviors package
42-
if [ $# -eq 2 ]; then
42+
if [ $# -eq 2 ]; then
4343
pack="$2"
4444
echo "Using specified package '${pack}'!"
4545
fi
@@ -97,4 +97,4 @@ else
9797
echo ""
9898
echo -e "\e[91m Failed to copy behavior '${beh}'!\033[0m"
9999
exit
100-
fi
100+
fi
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# # Copyright 2026 Carologistics
2+
# #
3+
# # Licensed under the Apache License, Version 2.0 (the "License");
4+
# # you may not use this file except in compliance with the License.
5+
# # You may obtain a copy of the License at
6+
# #
7+
# # http://www.apache.org/licenses/LICENSE-2.0
8+
# #
9+
# # Unless required by applicable law or agreed to in writing, software
10+
# # distributed under the License is distributed on an "AS IS" BASIS,
11+
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# # See the License for the specific language governing permissions and
13+
# # limitations under the License.

caro_skills_flexbe_behaviors/caro_skills_flexbe_behaviors/example_action_state_behavior_sm.py

100644100755
Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,29 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
4-
# Copyright 2023 David Conner
5-
#
6-
# Licensed under the Apache License, Version 2.0 (the "License");
7-
# you may not use this file except in compliance with the License.
8-
# You may obtain a copy of the License at
9-
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
12-
# Unless required by applicable law or agreed to in writing, software
13-
# distributed under the License is distributed on an "AS IS" BASIS,
14-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
# See the License for the specific language governing permissions and
16-
# limitations under the License.
17-
2+
# # Copyright 2026 Carologistics
3+
# #
4+
# # Licensed under the Apache License, Version 2.0 (the "License");
5+
# # you may not use this file except in compliance with the License.
6+
# # You may obtain a copy of the License at
7+
# #
8+
# # http://www.apache.org/licenses/LICENSE-2.0
9+
# #
10+
# # Unless required by applicable law or agreed to in writing, software
11+
# # distributed under the License is distributed on an "AS IS" BASIS,
12+
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# # See the License for the specific language governing permissions and
14+
# # limitations under the License.
1815
###########################################################
1916
# WARNING: Generated code! #
2017
# ************************** #
2118
# Manual changes may get lost if file is generated again. #
2219
# Only code inside the [MANUAL] tags will be kept. #
2320
###########################################################
24-
2521
"""
2622
Define Example Action State Behavior.
2723
2824
Created on July 21, 2023
2925
@author: David Conner
3026
"""
31-
32-
3327
from flexbe_core import Autonomy
3428
from flexbe_core import Behavior
3529
from flexbe_core import ConcurrencyContainer
@@ -58,7 +52,7 @@ class ExampleActionStateBehaviorSM(Behavior):
5852

5953
def __init__(self, node):
6054
super().__init__()
61-
self.name = 'Example Action State Behavior'
55+
self.name = "Example Action State Behavior"
6256

6357
# parameters of this behavior
6458

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

8175
def create(self):
8276
# x:1096 y:62, x:1095 y:363
83-
_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])
77+
_state_machine = OperatableStateMachine(outcomes=["finished", "failed"])
8478
_state_machine.userdata.angle_degrees = 90.0
8579

8680
# Additional creation code can be added inside the following tags
@@ -89,44 +83,64 @@ def create(self):
8983
# [/MANUAL_CREATE]
9084
with _state_machine:
9185
# x:102 y:157
92-
OperatableStateMachine.add('LogRequest',
93-
LogKeyState(text="Request to rotate {} degrees", severity=2),
94-
transitions={'done': 'Rotate Turtle State'},
95-
autonomy={'done': Autonomy.Off},
96-
remapping={'data': 'angle_degrees'})
86+
OperatableStateMachine.add(
87+
"LogRequest",
88+
LogKeyState(text="Request to rotate {} degrees", severity=2),
89+
transitions={"done": "Rotate Turtle State"},
90+
autonomy={"done": Autonomy.Off},
91+
remapping={"data": "angle_degrees"},
92+
)
9793

9894
# x:659 y:190
99-
OperatableStateMachine.add('Log Failed',
100-
LogState(text="Failed", severity=Logger.REPORT_WARN),
101-
transitions={'done': 'failed'},
102-
autonomy={'done': Autonomy.Off})
95+
OperatableStateMachine.add(
96+
"Log Failed",
97+
LogState(text="Failed", severity=Logger.REPORT_WARN),
98+
transitions={"done": "failed"},
99+
autonomy={"done": Autonomy.Off},
100+
)
103101

104102
# x:658 y:57
105-
OperatableStateMachine.add('Log Success',
106-
LogState(text="Success", severity=Logger.REPORT_HINT),
107-
transitions={'done': 'finished'},
108-
autonomy={'done': Autonomy.Off})
103+
OperatableStateMachine.add(
104+
"Log Success",
105+
LogState(text="Success", severity=Logger.REPORT_HINT),
106+
transitions={"done": "finished"},
107+
autonomy={"done": Autonomy.Off},
108+
)
109109

110110
# x:657 y:480
111-
OperatableStateMachine.add('Log Timeout',
112-
LogState(text="Timeout", severity=Logger.REPORT_WARN),
113-
transitions={'done': 'failed'},
114-
autonomy={'done': Autonomy.Off})
111+
OperatableStateMachine.add(
112+
"Log Timeout",
113+
LogState(text="Timeout", severity=Logger.REPORT_WARN),
114+
transitions={"done": "failed"},
115+
autonomy={"done": Autonomy.Off},
116+
)
115117

116118
# x:244 y:294
117-
OperatableStateMachine.add('Rotate Turtle State',
118-
RotateTurtleState(timeout=10, action_topic="/turtle1/rotate_absolute"),
119-
transitions={'rotation_complete': 'Log Success', 'failed': 'Log Failed',
120-
'canceled': 'Log Canceled', 'timeout': 'Log Timeout'},
121-
autonomy={'rotation_complete': Autonomy.Off, 'failed': Autonomy.Off,
122-
'canceled': Autonomy.Off, 'timeout': Autonomy.Off},
123-
remapping={'angle': 'angle_degrees', 'duration': 'duration'})
119+
OperatableStateMachine.add(
120+
"Rotate Turtle State",
121+
RotateTurtleState(timeout=10, action_topic="/turtle1/rotate_absolute"),
122+
transitions={
123+
"rotation_complete": "Log Success",
124+
"failed": "Log Failed",
125+
"canceled": "Log Canceled",
126+
"timeout": "Log Timeout",
127+
},
128+
autonomy={
129+
"rotation_complete": Autonomy.Off,
130+
"failed": Autonomy.Off,
131+
"canceled": Autonomy.Off,
132+
"timeout": Autonomy.Off,
133+
},
134+
remapping={"angle": "angle_degrees", "duration": "duration"},
135+
)
124136

125137
# x:656 y:337
126-
OperatableStateMachine.add('Log Canceled',
127-
LogState(text="Canceled", severity=Logger.REPORT_WARN),
128-
transitions={'done': 'failed'},
129-
autonomy={'done': Autonomy.Off})
138+
OperatableStateMachine.add(
139+
"Log Canceled",
140+
LogState(text="Canceled", severity=Logger.REPORT_WARN),
141+
transitions={"done": "failed"},
142+
autonomy={"done": Autonomy.Off},
143+
)
130144

131145
return _state_machine
132146

0 commit comments

Comments
 (0)