Skip to content

Commit 9b0b65d

Browse files
committed
(roseus_bt) Update t08_multimaster
1 parent 29ae622 commit 9b0b65d

3 files changed

Lines changed: 45 additions & 14 deletions

File tree

roseus_bt/include/roseus_bt/tutorial_parser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ std::string TutorialParser::format_node_body(const XMLElement* node, int padding
3939
// Conditions
4040
if (id == "CheckTrue") return std::string("(send value :data)").insert(0, padding, ' ');
4141
if (id == "atTable") return std::string("(at-spot \"table-front\")").insert(0, padding, ' ');
42-
if (id == "atSpot") return fmt::format("{}(at-spot {})", pad, param_list.at(0));
42+
if (id == "atSpot" || id == "atTableSpot" || id == "atBroomSpot")
43+
return fmt::format("{}(at-spot {})", pad, param_list.at(0));
4344
if (id == "CheckCoords") return fmt::format(
4445
"{}(not (equal (instance geometry_msgs::Pose :init) {}))", pad, param_list.at(0));
4546

roseus_bt/sample/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ The `{var}` notation also works.
234234
This example shows how to use the rosbridge interface to assign different hosts to each action in a multimaster application.
235235
https://github.com/Affonso-Gui/jsk_roseus/blob/roseus_bt/roseus_bt/sample/models/t08_multimaster.xml
236236

237-
To do this we declare the actions with the `<RemoteAction/>` tag in the `<TreeNodesModel/>`, and add a `host_name` and `host_port` field to it. As a normal action, it also requires to have the `server_name` field set.
238-
The `host_name` and `host_port` can be set either statically (in the `TreeNodesModel` definition) or dynamically (within the `BehaviorTree` node instance), although we recommend to set it statically to avoid possible runtime errors.
237+
To do this we declare the actions with the `<RemoteAction/>` and conditions with the `<RemoteCondition/>` tag in the `<TreeNodesModel/>`, and add a `host_name` and `host_port` field to them.
239238

240239
#### Run the code
241240

@@ -247,7 +246,7 @@ roslaunch rosbridge_server rosbridge_websocket.launch
247246
Run the first roseus server:
248247
```bash
249248
roscd roseus_bt_tutorials/euslisp
250-
roseus t08_multimaster-action-server.l
249+
roseus t08_multimaster_localhost9090-action-server.l
251250
```
252251

253252
Run the second rosbridge_server:
@@ -260,7 +259,7 @@ Run the second roseus server:
260259
```bash
261260
export ROS_MASTER_URI=http://localhost:11312
262261
roscd roseus_bt_tutorials/euslisp
263-
roseus t08_multimaster-action-server.l
262+
roseus t08_multimaster_localhost9091-action-server.l
264263
```
265264

266265
Run the cpp client

roseus_bt/sample/models/t08_multimaster.xml

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,56 @@
55
<Parallel failure_threshold="1" success_threshold="2">
66
<Sequence name="Robot1">
77
<Action ID="Init"/>
8-
<Action ID="MoveToTable"/>
8+
<Fallback>
9+
<Condition ID="atTableSpot" spot="table-front"/>
10+
<Action ID="MoveToTable"/>
11+
</Fallback>
12+
<Action ID="PickBottle"/>
13+
<Action ID="PourBottle"/>
14+
<Action ID="PlaceBottle"/>
915
</Sequence>
1016
<Sequence name="Robot2">
11-
<Action ID="InitWithBroom"
12-
host_name="localhost" host_port="9091"/>
13-
<Action ID="MoveToBroom"
14-
host_name="localhost" host_port="9091"/>
17+
<Action ID="InitWithBroom"/>
18+
<Fallback>
19+
<Condition ID="atBroomSpot" spot="broom-front"/>
20+
<Action ID="MoveToBroom"/>
21+
</Fallback>
22+
<Timeout msec="5000">
23+
<Action ID="SweepFloor"/>
24+
</Timeout>
1525
</Sequence>
1626
</Parallel>
1727
</BehaviorTree>
1828
<!-- ////////// -->
1929
<TreeNodesModel>
20-
<RemoteAction ID="Init" server_name="/robot1/init"
30+
<!-- Robot1 -->
31+
<RemoteAction ID="Init" server_name="/t08_multimaster/robot1/init"
2132
host_name="localhost" host_port="9090"/>
22-
<RemoteAction ID="MoveToTable" server_name="/robot1/move"
33+
<RemoteAction ID="MoveToTable" server_name="/t08_multimaster/robot1/move"
2334
host_name="localhost" host_port="9090"/>
35+
<RemoteAction ID="PickBottle" server_name="/t08_multimaster/robot1/pick"
36+
host_name="localhost" host_port="9090"/>
37+
<RemoteAction ID="PourBottle" server_name="/t08_multimaster/robot1/pour"
38+
host_name="localhost" host_port="9090"/>
39+
<RemoteAction ID="PlaceBottle" server_name="/t08_multimaster/robot1/place"
40+
host_name="localhost" host_port="9090"/>
41+
<RemoteCondition ID="atTableSpot" service_name="/t08_multimaster/robot1/atspot"
42+
host_name="localhost" host_port="9090">
43+
<input_port name="spot" type="string"/>
44+
</RemoteCondition>
45+
46+
<!-- Robot2 -->
47+
<RemoteAction ID="InitWithBroom" server_name="/t08_multimaster/robot2/init"
48+
host_name="localhost" host_port="9091"/>
49+
<RemoteAction ID="MoveToBroom" server_name="/t08_multimaster/robot2/move"
50+
host_name="localhost" host_port="9091"/>
51+
<RemoteAction ID="SweepFloor" server_name="/t08_multimaster/robot2/sweep"
52+
host_name="localhost" host_port="9091"/>
53+
<RemoteCondition ID="atBroomSpot" service_name="/t08_multimaster/robot2/atspot"
54+
host_name="localhost" host_port="9091">
55+
<input_port name="spot" type="string"/>
56+
</RemoteCondition>
2457

25-
<RemoteAction ID="InitWithBroom" server_name="/robot2/init"/>
26-
<RemoteAction ID="MoveToBroom" server_name="/robot2/move"/>
2758
</TreeNodesModel>
2859
<!-- ////////// -->
2960
</root>

0 commit comments

Comments
 (0)