Browse Source

hybrid model running (not fully tested yet)

Cláudio Gomes 9 years ago
parent
commit
610eb1ab77

+ 15 - 1
debugging_fsa_cbd_composition/fsa_cbd_simulator/CBDMultipleOutput/Source/CBD.py

@@ -179,6 +179,20 @@ class AdderBlock(BaseBlock):
     def	compute(self, curIteration):
         self.appendToSignal(self.getInputSignal(curIteration, "IN1").value + self.getInputSignal(curIteration, "IN2").value)
 
+class DecisionBlock(BaseBlock):
+    """
+    A block that has three inputs (T, F, C) and one output. If C > 0, then T is the output,  otherwise F is the output.
+    """
+    def __init__(self, blockname):
+        BaseBlock.__init__(self, blockname, ["T", "F", "C"], ["OUT1"])
+
+    def compute(self, curIteration):
+        if self.getInputSignal(curIteration, "C").value > 0:
+            self.appendToSignal(self.getInputSignal(curIteration, "T").value, "OUT1")
+        if self.getInputSignal(curIteration, "C").value <= 0:
+            self.appendToSignal(self.getInputSignal(curIteration, "F").value, "OUT1")
+
+
 class ProductBlock(BaseBlock):
     """
     The product block will multiply the two inputs
@@ -481,7 +495,7 @@ class CBD(BaseBlock):
             self.__blocks.append(block)
             self.__blocksDict[block.getBlockName()] = block
         else:
-            print("Warning: did not add this block as it has the same name %s as an existing block" % block.getBlockName())
+            raise RuntimeError("Error: block with same name %s as an existing block in CBD %s" % block.getBlockName(), block._parent.getBlockName())
 
     def removeBlock(self, block):
         assert isinstance(block, BaseBlock), "Can only delete BaseBlock (subclass) instances to a CBD"

+ 5 - 5
debugging_fsa_cbd_composition/fsa_cbd_simulator/HierarchicalSimulator/run_debug.py

@@ -31,12 +31,12 @@ def buildModel():
     transitiondf = fsaclasses.Transition("d2f",stated,statef)
     transitiondf.trigger = fsaclasses.After(fsaclasses.Float(5.0))
 
-    fsamodel = fsaclasses.FSAModel(
+    cbdmodel = fsaclasses.FSAModel(
                         [statea,stateb,statec,stated],
                         [transitionab,transitionbc,transitioncd,transitiondf]
                         )
-    fsamodel.initialState = statea
-    return fsamodel
+    cbdmodel.initialState = statea
+    return cbdmodel
 
 if __name__ == '__main__':    
     if os.path.exists(FSACBDLib.OUTPUT_EVENTS):
@@ -46,11 +46,11 @@ if __name__ == '__main__':
     
     options = Options(delta = CBD_DELTA)
     options.setMaxIterations(10000);
-    fsamodel = BouncingBallFSA()
+    cbdmodel = BouncingBallFSA()
     events = fsaclasses.Events([fsaclasses.RunTimeEvent('kick',4.0), fsaclasses.RunTimeEvent('enough',5.0)])
     # events = fsaclasses.Events([fsaclasses.RunTimeEvent('kick',13.0), fsaclasses.RunTimeEvent('kick',23.0), fsaclasses.RunTimeEvent('kick',37.0) ,fsaclasses.RunTimeEvent('enough',60.0)])
     #events = Events([RunTimeEvent('enough',25.0)])
-    controller = target.Controller(fsamodel, events, options, keep_running=True)
+    controller = target.Controller(cbdmodel, events, options, keep_running=True)
     
     def set_defaults(inp, defaultlist):
         for i, v in enumerate(defaultlist):

+ 2 - 0
debugging_fsa_cbd_composition/fsa_cbd_simulator/events.csv

@@ -0,0 +1,2 @@
+fsatime,Event

+1.0,end


+ 215 - 92
debugging_fsa_cbd_composition/fsa_cbd_simulator/models/power_window.py

@@ -1,127 +1,250 @@
 from CBDMultipleOutput.Source.CBD import ConstantBlock, NegatorBlock, \
-    IntegratorBlock, CBD, ProductBlock, AdderBlock
+    IntegratorBlock, CBD, ProductBlock, AdderBlock, InverterBlock, DecisionBlock
 from fsa_cbd_woven_classes import InputConstantBlock, CBDState, WhenCrossesZeroTrigger
-from fsaclasses import FSAModel, Transition, Event, State
+from fsaclasses import FSAModel, Transition, Event, State, After, Float
 
 
 class PowerWindow(FSAModel):
     def __init__(self):
         Started = CBDState("Started", PowerWindowStarted("Started"))
         Neutral = State("Neutral")
-        Pass_up = CBDState("Pass_up", PowerWindowUp("Pass_up"))
+        Pass_Up = CBDState("Pass_up", PowerWindowUp("Pass_up"))
         Driver_Up = CBDState("Driver_Up", PowerWindowUp("Driver_Up"))
         Pass_Down = CBDState("Pass_Down", PowerWindowDown("Pass_Down"))
         Driver_Down = CBDState("Driver_Down", PowerWindowDown("Driver_Down"))
         Obj_Detected = CBDState("Obj_Detected", PowerWindowDown("Obj_Detected"))
+        End = State("Obj_Detected", final=True)
         
         start = Transition("start", Started, Neutral)
         
-        p_up = Transition("p_up", Neutral, Pass_Up)
-        p_down = Transition("p_down", Neutral, Pass_Down)
-        d_up = Transition("d_up", Neutral, Driver_Up)
-        d_down = Transition("d_down", Neutral, Driver_Down)
-        
-        
-        initial2Freefall = Transition("Initial2Freefall", initial, freeFall)
-        freefall2Collision = Transition("Freefall2Collision", freeFall, collision)
-        freefall2Collision.trigger = WhenCrossesZeroTrigger("x", up_direction=False);
-        collision2Freefall = Transition("Collision2Freefall", collision, freeFall)
-        freefall2Kicked = Transition("Freefall2Kicked", freeFall, kicked)
-        freefall2Kicked.trigger = Event("kick");
-        kicked2Freefall = Transition("kicked2Freefall", kicked, freeFall)
-        freefall2End = Transition("Freefall2End", freeFall, end)
-        freefall2End.trigger = Event("enough");
+        p_up_Neutral = Transition("p_up", Neutral, Pass_Up)
+        p_up_Neutral.trigger = Event("p_up");
+        p_down_Neutral = Transition("p_down", Neutral, Pass_Down)
+        p_down_Neutral.trigger = Event("p_down");
+        d_up_Neutral = Transition("d_up", Neutral, Driver_Up)
+        d_up_Neutral.trigger = Event("d_up");
+        d_down_Neutral = Transition("d_down", Neutral, Driver_Down)
+        d_down_Neutral.trigger = Event("d_down");
+        end_Neutral = Transition("end", Neutral, End)
+        end_Neutral.trigger = Event("end");
+        
+        
+        stop_Pass_up = Transition("stop", Pass_Up, Neutral)
+        stop_Pass_up.trigger = Event("stop");
+        d_down_Pass_up = Transition("d_down", Pass_Up, Driver_Down)
+        d_down_Pass_up.trigger = Event("d_down");
+        d_up_Pass_up = Transition("d_up", Pass_Up, Driver_Up)
+        d_up_Pass_up.trigger = Event("d_up");
+        when_obj_detected_Pass_up = Transition("when_obj_detected", Pass_Up, Obj_Detected)
+        when_obj_detected_Pass_up.trigger = WhenCrossesZeroTrigger("Fo100", up_direction=True)
+        
+        stop_Driver_Up = Transition("stop", Driver_Up, Neutral)
+        stop_Driver_Up.trigger = Event("stop");
+        when_obj_detected_Driver_Up = Transition("when_obj_detected", Driver_Up, Obj_Detected)
+        when_obj_detected_Driver_Up.trigger = WhenCrossesZeroTrigger("Fo100", up_direction=True)
+        
+        stop_Pass_Down = Transition("stop", Pass_Down, Neutral)
+        stop_Pass_Down.trigger = Event("stop");
+        d_down_Pass_Down = Transition("d_down", Pass_Down, Driver_Down)
+        d_down_Pass_Down.trigger = Event("d_down");
+        d_up_Pass_Down = Transition("d_up", Pass_Down, Driver_Up)
+        d_up_Pass_Down.trigger = Event("d_up");
+        
+        stop_Driver_Down = Transition("stop", Driver_Down, Neutral)
+        stop_Driver_Down.trigger = Event("stop");
+        
+        stop_Obj_Detected = Transition("after", Obj_Detected, Neutral)
+        stop_Obj_Detected.trigger = After(Float(1000.0)); # ms
         
         self.states = [
-                       initial,
-                       freeFall,
-                       collision,
-                       kicked,
-                       end
+                       Started,
+                       Neutral,
+                       Pass_Up,
+                       Driver_Up,
+                       Pass_Down,
+                       Driver_Down,
+                       Obj_Detected,
+                       End
                        ]
         
-        self.initialState = initial
+        self.initialState = Started
         
         self.transitions = [
-                            initial2Freefall,
-                            freefall2Collision,
-                            collision2Freefall,
-                            freefall2Kicked,
-                            kicked2Freefall,
-                            freefall2End
+                            start,
+                            p_up_Neutral,
+                            p_down_Neutral,
+                            d_up_Neutral,
+                            d_down_Neutral,
+                            end_Neutral,
+                            stop_Pass_up,
+                            d_down_Pass_up,
+                            d_up_Pass_up,
+                            when_obj_detected_Pass_up,
+                            stop_Driver_Up,
+                            when_obj_detected_Driver_Up,
+                            stop_Pass_Down,
+                            d_down_Pass_Down,
+                            d_up_Pass_Down,
+                            stop_Driver_Down,
+                            stop_Obj_Detected
                             ]
+
+class PowerWindowStarted(CBD):
+    def __init__(self, blockName, delta_t = 0.01):
+        CBD.__init__(self,blockName, input_ports=[], output_ports=["out_w0","out_v0"])
+        
+        self.addBlock(ConstantBlock("0", value=delta_t))
         
-       
-    
+        self.addConnection("0", "out_w0")
+        self.addConnection("0", "out_v0")
+      
+class PowerWindowDown(CBD):
+    def __init__(self, blockName, delta_t = 0.01):
+        CBD.__init__(self,blockName, input_ports=[], output_ports=["out_w0","out_v0"])
         
+        self.addBlock(ConstantBlock("delta_t", value=delta_t))
+        self.addBlock(ConstantBlock("torque", value=-2.0))
+        self.addBlock(ConstantBlock("0", value=0.0))
+        self.addBlock(ConstantBlock("100", value=100.0))
         
+        self.addBlock(InputConstantBlock("in_w0", value=0.0))
+        self.addBlock(InputConstantBlock("in_v0", value=0.0))
+        
+        self.addBlock(PowerWindowPlant("plant"))
+        
+        self.addConnection("delta_t", "plant", input_port_name="delta_t")
+        self.addConnection("torque", "plant", input_port_name="motor")
+        self.addConnection("0", "plant", input_port_name="object_detect")
+        self.addConnection("100", "plant", input_port_name="object_position")
+        
+        self.addConnection("in_w0", "plant", input_port_name="init_position")
+        self.addConnection("in_v0", "plant", input_port_name="init_velocity")
+        
+        self.addConnection("plant", "out_w0", output_port_name="position_out")
+        self.addConnection("plant", "out_v0", output_port_name="velocity_out")
 
-class BouncingBallFreefall(CBD):
+class PowerWindowUp(CBD):
     def __init__(self, blockName, delta_t = 0.01):
-        CBD.__init__(self,blockName, input_ports=[], output_ports=["out_v", "out_x"])
-        
-        self.addBlock(InputConstantBlock(block_name="in_x"))
-        self.addBlock(InputConstantBlock(block_name="in_v"))
-        
-        self.addBlock(ConstantBlock(block_name="gravity", value=-9.81))
-        self.addBlock(ConstantBlock(block_name="delta", value=delta_t))
-        
-        self.addBlock(IntegratorBlock(block_name="intgv"))
-        self.addBlock(IntegratorBlock(block_name="intvx"))
-        
-        self.addConnection("delta", "intgv",  input_port_name="delta_t")
-        self.addConnection("delta", "intvx",  input_port_name="delta_t")
-        self.addConnection("in_v", "intgv",  input_port_name="IC")
-        self.addConnection("in_x", "intvx",  input_port_name="IC")
-        
-        self.addConnection("gravity", "intgv")
-        self.addConnection("intgv", "intvx")
-        self.addConnection("intgv", "out_v")
-        self.addConnection("intvx", "out_x")
-    
-    def setDeltaT(self, deltaT):
-        CBD.setDeltaT(self, deltaT)
-        self.getBlockByName("delta").setValue(deltaT);
-    
-    
-
-class BouncingBallInitial(CBD):
-    def __init__(self, blockName, delta_t=0.01):
-        CBD.__init__(self,blockName, input_ports=[], output_ports=["out_v", "out_x"])
+        CBD.__init__(self,blockName, input_ports=[], output_ports=["out_w0","out_v0", "out_Fo100"])
         
-        self.addBlock(ConstantBlock(block_name="init_velocity", value=15.0))
-        self.addBlock(ConstantBlock(block_name="init_position", value=10.0))
+        self.addBlock(ConstantBlock("delta_t", value=delta_t))
+        self.addBlock(ConstantBlock("torque", value=2.0))
+        self.addBlock(ConstantBlock("1", value=1.0))
+        self.addBlock(ConstantBlock("0.4", value=0.4))
+        self.addBlock(ConstantBlock("force_threshold", value=-100))
         
-        self.addConnection("init_velocity", "out_v")
-        self.addConnection("init_position", "out_x")
-    
-
-
-class BouncingBallCollision(CBD):
-    def __init__(self, blockName, delta_t=0.01):
-        CBD.__init__(self,blockName, input_ports=[], output_ports=["out_v"])
+        self.addBlock(InputConstantBlock("in_w0", value=0.0))
+        self.addBlock(InputConstantBlock("in_v0", value=0.0))
         
-        self.addBlock(InputConstantBlock(block_name="in_v"))
+        self.addBlock(AdderBlock("compare_force"))
+        
+        self.addBlock(PowerWindowPlant("plant"))
+        
+        
+        self.addConnection("delta_t", "plant", input_port_name="delta_t")
+        self.addConnection("torque", "plant", input_port_name="motor")
+        self.addConnection("1", "plant", input_port_name="object_detect")
+        self.addConnection("0.4", "plant", input_port_name="object_position")
+        self.addConnection("force_threshold", "compare_force")
+        
+        self.addConnection("in_w0", "plant", input_port_name="init_position")
+        self.addConnection("in_v0", "plant", input_port_name="init_velocity")
+        
+        self.addConnection("compare_force", "out_Fo100")
+        
+        self.addConnection("plant", "out_w0", output_port_name="position_out")
+        self.addConnection("plant", "out_v0", output_port_name="velocity_out")
+        self.addConnection("plant", "compare_force", output_port_name="force_out")
+        
+        
+        
+class PowerWindowPlant(CBD):
+    def __init__(self, blockName, delta_t = 0.01):
+        CBD.__init__(self,blockName, input_ports=[
+                                    "object_detect",
+                                    "object_position",
+                                    "motor", 
+                                    "init_position",
+                                    "init_velocity",
+                                    "delta_t"
+                        ], output_ports=["position_out","velocity_out","force_out"])
+        
+        # See power_window_object.pdf
+        
+        self.addBlock(ConstantBlock("m", value=10.0))
+        self.addBlock(ConstantBlock("cw",value=10.0))
+        self.addBlock(ConstantBlock("0",value=0.0))
+        self.addBlock(ConstantBlock("k0",value=1000.0))
+        self.addBlock(ConstantBlock("c0",value=1000.0))
+        
+        self.addBlock(InverterBlock("1/m"))
+        
+        self.addBlock(NegatorBlock("-cw"))
+        self.addBlock(NegatorBlock("-k0"))
+        self.addBlock(NegatorBlock("-c0"))
+        self.addBlock(NegatorBlock("-position"))
+        
+        self.addBlock(ProductBlock("-cw_p"))
+        self.addBlock(ProductBlock("1/m_p"))
+        self.addBlock(ProductBlock("-c0_p"))
+        self.addBlock(ProductBlock("-k0_p"))
+        self.addBlock(ProductBlock("object_detect_enable"))
+        
+        self.addBlock(AdderBlock("acceleration"))
+        self.addBlock(AdderBlock("objectF+acceleration"))
+        self.addBlock(AdderBlock("object_compare"))
+        self.addBlock(AdderBlock("object_compression"))
+        
+        self.addBlock(IntegratorBlock("velocity"))
+        self.addBlock(IntegratorBlock("position"))
+        
+        self.addBlock(DecisionBlock("obj_detected"))
+        
+        
+        self.addConnection("object_detect", "object_detect_enable")
+        self.addConnection("object_position", "object_compare")
+        self.addConnection("motor", "1/m_p")
+        self.addConnection("init_position", "position", input_port_name="IC")
+        self.addConnection("init_velocity", "velocity", input_port_name="IC")
+        self.addConnection("delta_t", "position", input_port_name="delta_t")
+        self.addConnection("delta_t", "velocity", input_port_name="delta_t")
+        
+        self.addConnection("m", "1/m")
+        self.addConnection("cw", "-cw")
+        self.addConnection("0", "obj_detected", input_port_name="F")
+        self.addConnection("k0", "-k0")
+        self.addConnection("c0", "-c0")
+        
+        self.addConnection("1/m", "1/m_p")
+        
+        self.addConnection("-cw", "-cw_p")
+        self.addConnection("-k0", "-k0_p")
+        self.addConnection("-c0", "-c0_p")
+        self.addConnection("-position", "object_compare")
+        
+        self.addConnection("-cw_p", "acceleration")
+        self.addConnection("1/m_p", "acceleration")
+        self.addConnection("-c0_p", "object_compression")
+        self.addConnection("-k0_p", "object_compression")
+        self.addConnection("object_detect_enable", "objectF+acceleration")
+        self.addConnection("object_detect_enable", "force_out")
+        
+        self.addConnection("acceleration", "objectF+acceleration")
+        self.addConnection("objectF+acceleration", "velocity")
+        self.addConnection("object_compare", "obj_detected", input_port_name="C")
+        self.addConnection("object_compression", "obj_detected", input_port_name="T")
+        
+        self.addConnection("velocity", "position")
+        self.addConnection("velocity", "-cw_p")
+        self.addConnection("velocity", "-c0_p")
+        self.addConnection("velocity", "velocity_out")
+        self.addConnection("position", "-k0_p")
+        self.addConnection("position", "position_out")
+        self.addConnection("position", "-position")
+        
+        self.addConnection("obj_detected", "object_detect_enable")
         
-        self.addBlock(ConstantBlock(block_name="coeficient", value=-0.8))
-        self.addBlock(ProductBlock(block_name="mult"))
         
-        self.addConnection("in_v", "mult")
-        self.addConnection("coeficient", "mult")
-        self.addConnection("mult", "out_v")
-
-
-class BouncingBallKicked(CBD):
-    def __init__(self, blockName, delta_t=0.01):
-        CBD.__init__(self,blockName, input_ports=[], output_ports=["out_v"])
         
-        self.addBlock(InputConstantBlock(block_name="in_v"))
         
-        self.addBlock(ConstantBlock(block_name="kick_impact", value=20))
-        self.addBlock(AdderBlock(block_name="sum"))
         
-        self.addConnection("in_v", "sum")
-        self.addConnection("kick_impact", "sum")
-        self.addConnection("sum", "out_v")
-
-

BIN
debugging_fsa_cbd_composition/fsa_cbd_simulator/models/power_window_fsa_model.pdf


File diff suppressed because it is too large
+ 5873 - 293
debugging_fsa_cbd_composition/fsa_cbd_simulator/models/power_window_fsa_model.svg


BIN
debugging_fsa_cbd_composition/fsa_cbd_simulator/models/power_window_hybrid_model.pdf


+ 25 - 13
debugging_fsa_cbd_composition/fsa_cbd_simulator/models/power_window_hybrid_model.svg

@@ -5647,9 +5647,9 @@
      borderopacity="1.0"
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
-     inkscape:zoom="4.0000002"
-     inkscape:cx="431.74214"
-     inkscape:cy="451.39745"
+     inkscape:zoom="2.8284273"
+     inkscape:cx="383.05565"
+     inkscape:cy="522.09708"
      inkscape:document-units="px"
      inkscape:current-layer="layer1"
      showgrid="false"
@@ -7160,7 +7160,7 @@
        sodipodi:nodetypes="csc"
        inkscape:connector-curvature="0"
        id="path30178"
-       d="m 257.53935,583.12043 c 0,0 -2.26915,-12.19444 18.43919,-12.38572 27.91801,-0.25788 123.82567,15.88572 123.82567,15.88572"
+       d="m 323.78935,583.12043 c 0,0 3.98085,-4.44444 24.68919,-4.63572 27.91801,-0.25788 51.32567,8.13572 51.32567,8.13572"
        style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker30180)" />
     <g
        transform="matrix(1.25,0,0,1.25,536.95422,565.26673)"
@@ -7244,7 +7244,7 @@
     </g>
     <g
        id="surface1-04"
-       transform="matrix(1.25,0,0,1.25,203.46461,564.76673)">
+       transform="matrix(1.25,0,0,1.25,291.71461,565.51673)">
       <g
          id="g32244"
          style="fill:#000000;fill-opacity:1">
@@ -7475,16 +7475,16 @@
     <text
        xml:space="preserve"
        style="font-style:normal;font-weight:normal;font-size:11.25px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-       x="245.03046"
-       y="568.78442"
+       x="333.28046"
+       y="569.53442"
        id="text34143"
        sodipodi:linespacing="125%"><tspan
          sodipodi:role="line"
          id="tspan34145"
-         x="245.03046"
-         y="568.78442"
+         x="333.28046"
+         y="569.53442"
          style="font-size:11.25px;text-align:center;text-anchor:middle">stop <tspan
-   style="-inkscape-font-specification:'sans-serif Italic';font-family:sans-serif;font-weight:normal;font-style:italic;font-stretch:normal;font-variant:normal"
+   style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:'sans-serif Italic'"
    id="tspan41477">or</tspan></tspan></text>
     <text
        sodipodi:linespacing="125%"
@@ -7543,13 +7543,13 @@
        style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker34217)" />
     <path
        style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker35768)"
-       d="m 205.18806,695.988 c 0,0 -192.891281,-5.29233 -166.101981,-105.27135 26.7893,-99.97901 334.682571,-100.46379 334.682571,-100.46379"
+       d="m 264.68806,583.48801 c 0,0 -2.91264,-17.31478 1.99153,-35.60276 m 1.9349,-6.452 c 2.39617,-6.44502 5.78588,-13.0836 10.72011,-18.7514 m 5.0851,-4.37176 c 25.33516,-21.56788 88.7454,-20.96564 88.7454,-20.96564"
        id="path35766"
        inkscape:connector-curvature="0"
-       sodipodi:nodetypes="czc" />
+       sodipodi:nodetypes="cccccc" />
     <g
        id="surface1-84"
-       transform="matrix(1.25,0,0,1.25,181.2051,479.26673)">
+       transform="matrix(1.25,0,0,1.25,258.63329,479.26673)">
       <g
          id="g39068"
          style="fill:#000000;fill-opacity:1">
@@ -8004,5 +8004,17 @@
          x="480.19583"
          y="539.25995"
          style="font-style:italic;font-size:11.25px;text-align:center;text-anchor:middle">or</tspan></text>
+    <path
+       style="opacity:0.98699999;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       d="m 279.27186,522.78232 c -0.80935,-0.9549 -1.04779,-2.26905 -0.6255,-3.4474 0.42229,-1.17836 1.44115,-2.04192 2.67278,-2.26539 1.23164,-0.22346 2.48894,0.22711 3.29829,1.18201"
+       id="path6458"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cssc" />
+    <path
+       sodipodi:nodetypes="cssc"
+       inkscape:connector-curvature="0"
+       id="path6461"
+       d="m 266.73808,548.10373 c -1.199,-0.35955 -2.11508,-1.33147 -2.40318,-2.54961 -0.28815,-1.21811 0.0956,-2.49743 1.00643,-3.35601 0.91089,-0.85857 2.21063,-1.16598 3.40962,-0.80643"
+       style="opacity:0.98699999;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
   </g>
 </svg>

BIN
debugging_fsa_cbd_composition/fsa_cbd_simulator/models/power_window_object.pdf


+ 126 - 39
debugging_fsa_cbd_composition/fsa_cbd_simulator/models/power_window_object.svg

@@ -19,6 +19,36 @@
    sodipodi:docname="power_window_object.svg">
   <defs
      id="defs4">
+    <marker
+       inkscape:stockid="Arrow1Mend"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker6933"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         inkscape:connector-curvature="0"
+         id="path6935"
+         d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+         transform="matrix(-0.4,0,0,-0.4,-4,0)" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow1Mend"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker6088"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         inkscape:connector-curvature="0"
+         id="path6090"
+         d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+         transform="matrix(-0.4,0,0,-0.4,-4,0)" />
+    </marker>
     <marker
        inkscape:isstock="true"
        style="overflow:visible"
@@ -286,7 +316,8 @@
        refX="0"
        refY="0"
        orient="auto"
-       inkscape:stockid="Arrow1Mend">
+       inkscape:stockid="Arrow1Mend"
+       inkscape:collect="always">
       <path
          transform="matrix(-0.4,0,0,-0.4,-4,0)"
          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
@@ -4338,8 +4369,8 @@
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
      inkscape:zoom="2.8284271"
-     inkscape:cx="190.90341"
-     inkscape:cy="709.08489"
+     inkscape:cx="279.28872"
+     inkscape:cy="701.61783"
      inkscape:document-units="px"
      inkscape:current-layer="layer1"
      showgrid="false"
@@ -4545,18 +4576,18 @@
        sodipodi:nodetypes="cc"
        inkscape:connector-curvature="0"
        id="path5215"
-       d="m 243.52903,353.11403 61.13716,0"
+       d="m 243.52903,353.11403 84.47168,0"
        style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker12459)" />
     <rect
        style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
        id="rect5217"
        width="33.597561"
        height="33.763054"
-       x="306.30554"
+       x="330.30554"
        y="335.75952" />
     <g
        id="g5219"
-       transform="matrix(1.25,0,0,1.25,311.07018,331.59217)">
+       transform="matrix(1.25,0,0,1.25,335.07018,331.59217)">
       <g
          id="g5221"
          style="fill:#000000;fill-opacity:1">
@@ -4704,7 +4735,7 @@
        d="m 220.69685,271.01958 34.32722,-0.0304 0.0268,15.48957"
        style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker12479)" />
     <path
-       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker12519)"
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker6933)"
        d="m 243.03408,304.01958 -66.82722,-0.0304 -0.0268,30.98957"
        id="path7280"
        inkscape:connector-curvature="0"
@@ -5055,7 +5086,7 @@
     </g>
     <path
        style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker15402)"
-       d="m 339.78996,353.11403 149.63716,0"
+       d="m 364.18514,353.11403 125.24198,0"
        id="path11166"
        inkscape:connector-curvature="0"
        sodipodi:nodetypes="cc" />
@@ -5076,32 +5107,6 @@
        d="m 514.38743,352.89742 -23.40287,13.41934 0.0799,-26.97716 z"
        inkscape:transform-center-x="-0.30791903"
        inkscape:transform-center-y="-1.522764" />
-    <g
-       id="surface1-6"
-       transform="matrix(1.25,0,0,1.25,486.91663,341.68683)">
-      <g
-         id="g11730"
-         style="fill:#000000;fill-opacity:1">
-        <use
-           id="use11732"
-           y="9.7200003"
-           x="4.9569998"
-           xlink:href="#glyph0-0-418"
-           width="100%"
-           height="100%" />
-      </g>
-      <g
-         id="g11734"
-         style="fill:#000000;fill-opacity:1">
-        <use
-           id="use11736"
-           y="11.214"
-           x="9.842"
-           xlink:href="#glyph1-0-56"
-           width="100%"
-           height="100%" />
-      </g>
-    </g>
     <path
        style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker14244)"
        d="m 382.52401,353.04942 0,39.63716"
@@ -5513,10 +5518,10 @@
        d="m 350.08345,264.286 -23.40288,13.41934 0.0799,-26.97716 z"
        inkscape:transform-center-x="-1.5227628"
        inkscape:transform-center-y="0.30791916"
-       transform="matrix(0,1,-1,0,587.1966,-69.859693)" />
+       transform="matrix(0,1,-1,0,611.1966,-69.859693)" />
     <path
        style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker16063)"
-       d="m 322.9234,279.53176 0,54.94351"
+       d="m 346.9234,279.53176 0,54.94351"
        id="path16061"
        inkscape:connector-curvature="0"
        sodipodi:nodetypes="cc" />
@@ -5581,7 +5586,7 @@
        sodipodi:type="star" />
     <g
        id="surface1-02"
-       transform="matrix(1.25,0,0,1.25,485.09728,369.39044)">
+       transform="matrix(1.25,0,0,1.25,485.45083,368.68334)">
       <g
          id="g7770"
          style="fill:#000000;fill-opacity:1">
@@ -5718,7 +5723,7 @@
     </g>
     <g
        id="surface1-3"
-       transform="matrix(1.25,0,0,1.25,351.90138,334.90415)">
+       transform="matrix(1.25,0,0,1.25,395.03489,334.90415)">
       <g
          id="g6649"
          style="fill:#000000;fill-opacity:1">
@@ -5807,7 +5812,7 @@
     </g>
     <g
        id="surface1-53"
-       transform="matrix(1.25,0,0,1.25,309.5228,253.16686)">
+       transform="matrix(1.25,0,0,1.25,333.5228,253.16686)">
       <g
          id="g6740"
          style="fill:#000000;fill-opacity:1">
@@ -5879,5 +5884,87 @@
            height="100%" />
       </g>
     </g>
+    <g
+       transform="matrix(1.25,0,0,1.25,487.45676,342.00467)"
+       id="g5912">
+      <g
+         style="fill:#000000;fill-opacity:1"
+         id="g5914">
+        <use
+           height="100%"
+           width="100%"
+           xlink:href="#glyph0-0-49"
+           x="4.9660001"
+           y="9.7200003"
+           id="use5916" />
+      </g>
+      <g
+         style="fill:#000000;fill-opacity:1"
+         id="g5918">
+        <use
+           height="100%"
+           width="100%"
+           xlink:href="#glyph1-0-09"
+           x="9.8509998"
+           y="11.214"
+           id="use5920" />
+      </g>
+    </g>
+    <circle
+       r="2.4748733"
+       cy="353.28363"
+       cx="301.80954"
+       id="circle6066"
+       style="opacity:0.98699999;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <path
+       inkscape:transform-center-y="-0.30792158"
+       inkscape:transform-center-x="1.522764"
+       d="m 315.33686,296.68242 -23.40287,13.41934 0.0799,-26.97716 z"
+       inkscape:randomized="0"
+       inkscape:rounded="0"
+       inkscape:flatsided="true"
+       sodipodi:arg2="1.0501611"
+       sodipodi:arg1="0.0029636118"
+       sodipodi:r2="0.26186919"
+       sodipodi:r1="15.575336"
+       sodipodi:cy="296.63626"
+       sodipodi:cx="299.7616"
+       sodipodi:sides="3"
+       id="path6068"
+       style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       sodipodi:type="star"
+       transform="matrix(0,-1,1,0,5.191562,573.17919)" />
+    <path
+       sodipodi:nodetypes="cc"
+       inkscape:connector-curvature="0"
+       id="path6086"
+       d="m 302.0423,353.50661 0,-71.17448"
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker6088)" />
+    <g
+       transform="matrix(1.25,0,0,1.25,290.26608,263.37144)"
+       id="g6923">
+      <g
+         style="fill:#000000;fill-opacity:1"
+         id="g6925">
+        <use
+           height="100%"
+           width="100%"
+           xlink:href="#glyph0-0-290"
+           x="4.9749999"
+           y="9.7200003"
+           id="use6927" />
+      </g>
+      <g
+         style="fill:#000000;fill-opacity:1"
+         id="g6929">
+        <use
+           height="100%"
+           width="100%"
+           xlink:href="#glyph1-0-30"
+           x="9.8039999"
+           y="11.214"
+           id="use6931" />
+      </g>
+    </g>
   </g>
 </svg>

+ 11 - 36
debugging_fsa_cbd_composition/fsa_cbd_simulator/run_debug.py

@@ -1,41 +1,16 @@
-import target
-from sccd.runtime.statecharts_core import Event
-import threading
-import fsaclasses
-from fsa_cbd_woven_classes import CBDState
-from CBDMultipleOutput.models.HarmonicOscilator import CircleCBDDerivative
-from Options import Options
-from models.bouncingball import BouncingBallFSA
 import os
-from woven_cbd_fsa_lib import FSACBDLib
+import threading
 
-CBD_DELTA = 0.01
+from sccd.runtime.statecharts_core import Event
 
-def buildModel():
-    statea = fsaclasses.State("a")
-    stateb = fsaclasses.State("b")
-    statec = CBDState("c", CircleCBDDerivative("Harmonic Oscilator", CBD_DELTA))
-    stated = fsaclasses.State("d")
-    statef = State("f", True)
-    
-    transitionab = fsaclasses.Transition("a2b",statea,stateb)
-    transitionab.trigger = fsaclasses.After(fsaclasses.Float(5.0))
-    
-    transitionbc = fsaclasses.Transition("b2c",stateb,statec)
-    transitionbc.trigger = fsaclasses.After(fsaclasses.Float(2.0))
-    
-    transitioncd = fsaclasses.Transition("c2d",statec,stated)
-    transitioncd.trigger = fsaclasses.Event("c")
+from Options import Options
+import fsaclasses
+from models.power_window import PowerWindow
+import target
+from woven_cbd_fsa_lib import FSACBDLib
 
-    transitiondf = fsaclasses.Transition("d2f",stated,statef)
-    transitiondf.trigger = fsaclasses.After(fsaclasses.Float(5.0))
 
-    fsamodel = fsaclasses.FSAModel(
-                        [statea,stateb,statec,stated,statef],
-                        [transitionab,transitionbc,transitioncd,transitiondf]
-                        )
-    fsamodel.initialState = statea
-    return fsamodel
+CBD_DELTA = 0.01
 
 if __name__ == '__main__':    
     if os.path.exists(FSACBDLib.OUTPUT_EVENTS):
@@ -45,9 +20,9 @@ if __name__ == '__main__':
         
     options = Options(delta = CBD_DELTA)
     options.setMaxIterations(10000);
-    fsamodel = BouncingBallFSA()
-    events = fsaclasses.Events([fsaclasses.RunTimeEvent('kick',13.0), fsaclasses.RunTimeEvent('kick',23.0), fsaclasses.RunTimeEvent('kick',37.0) ,fsaclasses.RunTimeEvent('enough',60.0)])
-    controller = target.Controller(options, fsamodel, events, keep_running=True)
+    cbdmodel = PowerWindow()
+    events = fsaclasses.Events([fsaclasses.RunTimeEvent("end",1.0)])
+    controller = target.Controller(options, cbdmodel, events, keep_running=True)
     
     def set_defaults(inp, defaultlist):
         for i, v in enumerate(defaultlist):

+ 4 - 4
debugging_fsa_cbd_composition/fsa_cbd_simulator/signals.csv

@@ -1,4 +1,4 @@
-x,fsatime,current_cbdtime,fsastate,v

-10.0,0.0,0.0,Initial,15.0

-10.0,0.0,-1.0,FreeFall,15.0

-10.0,0.0,0.0,FreeFall,15.0

+current_cbdtime,v0,fsastate,fsatime,Fo100,w0

+0.0,0.01,Started,0.0,,0.01

+-1.0,0.01,Neutral,0.0,,0.01

+-1.0,0.01,Obj_Detected,1.0,,0.01


+ 6 - 6
debugging_fsa_cbd_composition/fsa_cbd_simulator/woven_runner.py

@@ -35,12 +35,12 @@ def buildModel():
     transitiondf = Transition("d2f",stated,statef)
     transitiondf.trigger = After(Float(5.0))
 
-    fsamodel = FSAModel(
+    cbdmodel = FSAModel(
                         [statea,stateb,statec,stated],
                         [transitionab,transitionbc,transitioncd,transitiondf]
                         )
-    fsamodel.initialState = statea
-    return fsamodel
+    cbdmodel.initialState = statea
+    return cbdmodel
 
 if __name__ == '__main__':
     
@@ -51,14 +51,14 @@ if __name__ == '__main__':
     
     options = Options(delta = CBD_DELTA)
     options.setMaxIterations(10000);
-    fsamodel = BouncingBallFSA()
+    cbdmodel = BouncingBallFSA()
     events = Events([RunTimeEvent('kick',13.0), RunTimeEvent('kick',23.0), RunTimeEvent('kick',37.0) ,RunTimeEvent('enough',60.0)])
     #events = Events([RunTimeEvent('enough',25.0)])
-    controller = Controller(options, fsamodel, events, keep_running=False)
+    controller = Controller(options, cbdmodel, events, keep_running=False)
     controller.start()
     
     '''
-    cbdModel = fsamodel.states[2].cbd;
+    cbdModel = cbdmodel.states[2].cbd;
     
     times = []
     values = []

+ 5 - 5
fsa_cbd_composition/fsasimulator/runner.py

@@ -20,16 +20,16 @@ def buildModel():
     
     transitiontc = Transition("t2c",statet,statec)
 
-    fsamodel = FSAModel(
+    cbdmodel = FSAModel(
                         [statea,stateb,statec],
                         [transitionab,transitionbt, transitiontc]
                         )
-    fsamodel.initialState = statea
-    return fsamodel
+    cbdmodel.initialState = statea
+    return cbdmodel
 
 if __name__ == '__main__':
     
-    fsamodel = buildModel()
+    cbdmodel = buildModel()
     events = Events([RunTimeEvent('a',3.0)])
-    controller = fsasimulator.Controller(fsamodel, events, [])
+    controller = fsasimulator.Controller(cbdmodel, events, [])
     controller.start()