Skip to content

Commit 93db27c

Browse files
committed
fixed no transition when sensor state is the same for two states. Added fastslow example under the testing folder
1 parent e461615 commit 93db27c

File tree

5 files changed

+291
-8
lines changed

5 files changed

+291
-8
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This is a configuration definition file in folder "/home/catherine/Dropbox/ASL/ltlMultiRobot/configs".
2+
# Format details are described at the beginning of each section below.
3+
4+
5+
======== General Config ========
6+
7+
Actuator_Proposition_Mapping: # Mapping between actuator propositions and actuator handler functions
8+
camera = share.DummyActuatorHandler.setActuator(name="camera")
9+
10+
Initial_Truths: # Initially true propositions
11+
12+
Main_Robot: # The name of the robot used for moving in this config
13+
Basic_Simulated_Robot
14+
15+
Name: # Configuration name
16+
twoRegions
17+
18+
Region_Tags: # Mapping from tag names to region groups, for quantification
19+
{}
20+
21+
Sensor_Proposition_Mapping: # Mapping between sensor propositions and sensor handler functions
22+
r1_rc = share.DummySensorHandler.inRegion(regionName="r1")
23+
r2_rc = share.DummySensorHandler.inRegion(regionName="r2")
24+
camera_ac = share.DummySensorHandler.buttonPress(button_name="camera_ac",init_value=False)
25+
person = share.DummySensorHandler.buttonPress(button_name="person",init_value=False)
26+
27+
28+
======== Robot1 Config ========
29+
30+
CalibrationMatrix: # 3x3 matrix for converting coordinates, stored as lab->map
31+
array([[1, 0, 0],
32+
[0, 1, 0],
33+
[0, 0, 1]])
34+
35+
DriveHandler: # Input value for robot drive handler, refer to file inside the handlers/drive folder
36+
share.Drive.HolonomicDriveHandler(multiplier=50.0,maxspeed=999.0)
37+
38+
InitHandler: # Input value for robot init handler, refer to the init file inside the handlers/robots/Type folder
39+
basicSim.BasicSimInitHandler(init_region="r1")
40+
41+
LocomotionCommandHandler: # Input value for robot locomotion command handler, refer to file inside the handlers/robots/Type folder
42+
basicSim.BasicSimLocomotionCommandHandler(speed=0.5)
43+
44+
MotionControlHandler: # Input value for robot motion control handler, refer to file inside the handlers/motionControl folder
45+
share.MotionControl.VectorControllerHandler()
46+
47+
PoseHandler: # Input value for robot pose handler, refer to file inside the handlers/pose folder
48+
basicSim.BasicSimPoseHandler()
49+
50+
RobotName: # Robot Name
51+
Basic_Simulated_Robot
52+
53+
Type: # Robot type
54+
basicSim
55+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[INPUT]
2+
person
3+
camera_ac
4+
sbit0
5+
6+
[OUTPUT]
7+
camera
8+
bit0
9+
10+
[ENV_TRANS]
11+
| & ! ! sbit0' ! ! sbit0' & ! sbit0' ! sbit0'
12+
| ! sbit0' sbit0'
13+
| ! & ! sbit0 ! bit0 ! sbit0'
14+
| ! & sbit0 bit0 sbit0'
15+
| ! & camera_ac camera camera_ac'
16+
| ! & ! camera_ac ! camera ! camera_ac'
17+
18+
[ENV_LIVENESS]
19+
| ! ! bit0 ! sbit0'
20+
| ! bit0 sbit0'
21+
22+
[ENV_INIT]
23+
! sbit0
24+
! camera_ac
25+
26+
[SYS_TRANS]
27+
| ! person' camera'
28+
| ! camera_ac camera'
29+
30+
[SYS_LIVENESS]
31+
! sbit0'
32+
sbit0'
33+
34+
[SYS_INIT]
35+
bit0
36+
| ! bit0 bit0
37+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This is a specification definition file for the LTLMoP toolkit.
2+
# Format details are described at the beginning of each section below.
3+
4+
5+
======== SETTINGS ========
6+
7+
Actions: # List of action propositions and their state (enabled = 1, disabled = 0)
8+
camera, 1
9+
10+
CompileOptions:
11+
convexify: True
12+
parser: ltl
13+
symbolic: False
14+
use_region_bit_encoding: True
15+
synthesizer: slugs
16+
fastslow: True
17+
decompose: True
18+
19+
CurrentConfigName:
20+
twoRegions
21+
22+
Customs: # List of custom propositions
23+
24+
RegionFile: # Relative path of region description file
25+
twoRegions.regions
26+
27+
Sensors: # List of sensor propositions and their state (enabled = 1, disabled = 0)
28+
person, 1
29+
30+
31+
======== SPECIFICATION ========
32+
33+
RegionMapping: # Mapping between region names and their decomposed counterparts
34+
r1 = p2
35+
r2 = p1
36+
others =
37+
38+
Spec: # Specification in structured English
39+
# SPEC
40+
# visit r1 and r2 infinitely often
41+
# camera stays on once it is turned on
42+
# camera is triggered when sensing a person
43+
(e.r1_rc & ! e.camera_ac)
44+
45+
[](next(e.r1_rc) <-> !next(e.r2_rc))
46+
47+
[](next(e.r1_rc) | next(e.r2_rc))
48+
49+
[]((e.r1_rc & s.r1)-> next(e.r1_rc))
50+
[]((e.r2_rc & s.r2)-> next(e.r2_rc))
51+
52+
[]<>(s.r1 -> next(e.r1_rc))
53+
[]<>(s.r2 -> next(e.r2_rc))
54+
55+
56+
[]((e.camera_ac & s.camera) -> next(e.camera_ac))
57+
[]((!e.camera_ac & !s.camera) -> !next(e.camera_ac))
58+
59+
--
60+
s.r2
61+
62+
[] (next(e.person) -> next(s.camera))
63+
[] (e.camera_ac -> next(s.camera))
64+
65+
[]<> (e.r1_rc)
66+
[]<> (e.r2_rc)
67+
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# This is a region definition file for the LTLMoP toolkit.
2+
# Format details are described at the beginning of each section below.
3+
# Note that all values are separated by *tabs*.
4+
5+
Background: # Relative path of background image file
6+
None
7+
8+
CalibrationPoints: # Vertices to use for map calibration: (vertex_region_name, vertex_index)
9+
10+
Obstacles: # Names of regions to treat as obstacles
11+
12+
Regions: # Stored as JSON string
13+
[
14+
{
15+
"name": "boundary",
16+
"color": [
17+
0,
18+
255,
19+
0
20+
],
21+
"holeList": [],
22+
"height": 0.0,
23+
"points": [
24+
[
25+
0.0,
26+
3.0
27+
],
28+
[
29+
283.0,
30+
3.0
31+
],
32+
[
33+
287,
34+
2
35+
],
36+
[
37+
580.0,
38+
0.0
39+
],
40+
[
41+
576.0,
42+
290.0
43+
],
44+
[
45+
283.0,
46+
260.0
47+
],
48+
[
49+
0.0,
50+
260.0
51+
]
52+
],
53+
"position": [
54+
111.0,
55+
218.0
56+
],
57+
"type": "poly",
58+
"size": [
59+
580.0,
60+
290.0
61+
]
62+
},
63+
{
64+
"name": "r2",
65+
"color": [
66+
0,
67+
0,
68+
255
69+
],
70+
"holeList": [],
71+
"height": 0,
72+
"points": [
73+
[
74+
0.0,
75+
3.0
76+
],
77+
[
78+
4.0,
79+
2.0
80+
],
81+
[
82+
297,
83+
0
84+
],
85+
[
86+
293,
87+
290
88+
],
89+
[
90+
0.0,
91+
260.0
92+
]
93+
],
94+
"position": [
95+
394.0,
96+
218.0
97+
],
98+
"type": "poly",
99+
"size": [
100+
297.0,
101+
290.0
102+
]
103+
},
104+
{
105+
"name": "r1",
106+
"color": [
107+
255,
108+
255,
109+
0
110+
],
111+
"height": 0,
112+
"position": [
113+
111.0,
114+
221.0
115+
],
116+
"type": "rect",
117+
"size": [
118+
283.0,
119+
257.0
120+
]
121+
}
122+
]
123+
124+
Transitions: # Region 1 Name, Region 2 Name, Bidirectional transition faces (face1_x1, face1_y1, face1_x2, face1_y2, face2_x1, ...)
125+
boundary r2 398.0 220.0 394.0 221.0 687.0 508.0 394.0 478.0 398.0 220.0 691.0 218.0 687.0 508.0 691.0 218.0
126+
boundary r1 394.0 221.0 111.0 221.0 111.0 478.0 394.0 478.0 111.0 478.0 111.0 221.0
127+
r2 r1 394.0 221.0 394.0 478.0
128+

src/lib/executeStrategy.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,15 @@ def runStrategyIterationInstanteousAction(self):
162162
# Run actuators before motion
163163
self.updateOutputs(self.next_state)
164164

165-
# check if we have changes in sensor values
166-
if self.last_sensor_state != sensor_state and self.strategy.current_state.getPropValue('regionCompleted') == self.next_state.getPropValue('regionCompleted'):
167-
self.arrived = True
168-
else:
169-
self.arrived = False
165+
# save current sensor state for next iteration
170166
self.last_sensor_state = sensor_state
171167

172-
if not self.arrived:
168+
if self.strategy.current_state == self.next_state:
173169
# Move one step towards the next region (or stay in the same region)
174-
self.arrived = self.hsub.gotoRegion(self.current_region, self.next_region)
170+
self.hsub.gotoRegion(self.current_region, self.next_region)
175171

176172
# Check for completion of motion
177-
if self.arrived and self.next_state != self.strategy.current_state:
173+
if self.next_state != self.strategy.current_state:
178174
if self.transition_contains_motion:
179175
self.postEvent("INFO", "Crossed border from %s to %s!" % (self.current_region.name, self.next_state.getPropValue('regionCompleted').name))
180176
self.postEvent("INFO", "Heading to region %s..." % self.next_region.name)

0 commit comments

Comments
 (0)