|
@@ -1,5 +1,6 @@
|
|
|
from CBDMultipleOutput.Source.CBD import ConstantBlock, NegatorBlock, \
|
|
from CBDMultipleOutput.Source.CBD import ConstantBlock, NegatorBlock, \
|
|
|
- IntegratorBlock, CBD, ProductBlock, AdderBlock, InverterBlock, DecisionBlock
|
|
|
|
|
|
|
+ IntegratorBlock, CBD, ProductBlock, AdderBlock, InverterBlock, DecisionBlock, \
|
|
|
|
|
+ GenericBlock, AbsBlock
|
|
|
from fsa_cbd_woven_classes import InputConstantBlock, CBDState, WhenCrossesZeroTrigger
|
|
from fsa_cbd_woven_classes import InputConstantBlock, CBDState, WhenCrossesZeroTrigger
|
|
|
from fsaclasses import FSAModel, Transition, Event, State, After, Float
|
|
from fsaclasses import FSAModel, Transition, Event, State, After, Float
|
|
|
|
|
|
|
@@ -13,7 +14,7 @@ class PowerWindow(FSAModel):
|
|
|
Pass_Down = CBDState("Pass_Down", PowerWindowDown("Pass_Down"))
|
|
Pass_Down = CBDState("Pass_Down", PowerWindowDown("Pass_Down"))
|
|
|
Driver_Down = CBDState("Driver_Down", PowerWindowDown("Driver_Down"))
|
|
Driver_Down = CBDState("Driver_Down", PowerWindowDown("Driver_Down"))
|
|
|
Obj_Detected = CBDState("Obj_Detected", PowerWindowDown("Obj_Detected"))
|
|
Obj_Detected = CBDState("Obj_Detected", PowerWindowDown("Obj_Detected"))
|
|
|
- End = State("Obj_Detected", final=True)
|
|
|
|
|
|
|
+ End = State("End", final=True)
|
|
|
|
|
|
|
|
start = Transition("start", Started, Neutral)
|
|
start = Transition("start", Started, Neutral)
|
|
|
|
|
|
|
@@ -28,7 +29,6 @@ class PowerWindow(FSAModel):
|
|
|
end_Neutral = Transition("end", Neutral, End)
|
|
end_Neutral = Transition("end", Neutral, End)
|
|
|
end_Neutral.trigger = Event("end");
|
|
end_Neutral.trigger = Event("end");
|
|
|
|
|
|
|
|
-
|
|
|
|
|
stop_Pass_up = Transition("stop", Pass_Up, Neutral)
|
|
stop_Pass_up = Transition("stop", Pass_Up, Neutral)
|
|
|
stop_Pass_up.trigger = Event("stop");
|
|
stop_Pass_up.trigger = Event("stop");
|
|
|
d_down_Pass_up = Transition("d_down", Pass_Up, Driver_Down)
|
|
d_down_Pass_up = Transition("d_down", Pass_Up, Driver_Down)
|
|
@@ -54,7 +54,7 @@ class PowerWindow(FSAModel):
|
|
|
stop_Driver_Down.trigger = Event("stop");
|
|
stop_Driver_Down.trigger = Event("stop");
|
|
|
|
|
|
|
|
stop_Obj_Detected = Transition("after", Obj_Detected, Neutral)
|
|
stop_Obj_Detected = Transition("after", Obj_Detected, Neutral)
|
|
|
- stop_Obj_Detected.trigger = After(Float(1000.0)); # ms
|
|
|
|
|
|
|
+ stop_Obj_Detected.trigger = After(Float(10.0)); # s
|
|
|
|
|
|
|
|
self.states = [
|
|
self.states = [
|
|
|
Started,
|
|
Started,
|
|
@@ -93,7 +93,7 @@ class PowerWindowStarted(CBD):
|
|
|
def __init__(self, blockName, delta_t = 0.01):
|
|
def __init__(self, blockName, delta_t = 0.01):
|
|
|
CBD.__init__(self,blockName, input_ports=[], output_ports=["out_w0","out_v0"])
|
|
CBD.__init__(self,blockName, input_ports=[], output_ports=["out_w0","out_v0"])
|
|
|
|
|
|
|
|
- self.addBlock(ConstantBlock("0", value=delta_t))
|
|
|
|
|
|
|
+ self.addBlock(ConstantBlock("0", value=0.0))
|
|
|
|
|
|
|
|
self.addConnection("0", "out_w0")
|
|
self.addConnection("0", "out_w0")
|
|
|
self.addConnection("0", "out_v0")
|
|
self.addConnection("0", "out_v0")
|
|
@@ -125,7 +125,7 @@ class PowerWindowDown(CBD):
|
|
|
|
|
|
|
|
class PowerWindowUp(CBD):
|
|
class PowerWindowUp(CBD):
|
|
|
def __init__(self, blockName, delta_t = 0.01):
|
|
def __init__(self, blockName, delta_t = 0.01):
|
|
|
- CBD.__init__(self,blockName, input_ports=[], output_ports=["out_w0","out_v0", "out_Fo100"])
|
|
|
|
|
|
|
+ CBD.__init__(self,blockName, input_ports=[], output_ports=["out_w0","out_v0", "out_Fo100","out_Fo","out_total_force","out_friction_force"])
|
|
|
|
|
|
|
|
self.addBlock(ConstantBlock("delta_t", value=delta_t))
|
|
self.addBlock(ConstantBlock("delta_t", value=delta_t))
|
|
|
self.addBlock(ConstantBlock("torque", value=2.0))
|
|
self.addBlock(ConstantBlock("torque", value=2.0))
|
|
@@ -140,7 +140,6 @@ class PowerWindowUp(CBD):
|
|
|
|
|
|
|
|
self.addBlock(PowerWindowPlant("plant"))
|
|
self.addBlock(PowerWindowPlant("plant"))
|
|
|
|
|
|
|
|
-
|
|
|
|
|
self.addConnection("delta_t", "plant", input_port_name="delta_t")
|
|
self.addConnection("delta_t", "plant", input_port_name="delta_t")
|
|
|
self.addConnection("torque", "plant", input_port_name="motor")
|
|
self.addConnection("torque", "plant", input_port_name="motor")
|
|
|
self.addConnection("1", "plant", input_port_name="object_detect")
|
|
self.addConnection("1", "plant", input_port_name="object_detect")
|
|
@@ -155,7 +154,9 @@ class PowerWindowUp(CBD):
|
|
|
self.addConnection("plant", "out_w0", output_port_name="position_out")
|
|
self.addConnection("plant", "out_w0", output_port_name="position_out")
|
|
|
self.addConnection("plant", "out_v0", output_port_name="velocity_out")
|
|
self.addConnection("plant", "out_v0", output_port_name="velocity_out")
|
|
|
self.addConnection("plant", "compare_force", output_port_name="force_out")
|
|
self.addConnection("plant", "compare_force", output_port_name="force_out")
|
|
|
-
|
|
|
|
|
|
|
+ self.addConnection("plant", "out_Fo", output_port_name="force_out")
|
|
|
|
|
+ self.addConnection("plant", "out_total_force", output_port_name="total_force_out")
|
|
|
|
|
+ self.addConnection("plant", "out_friction_force", output_port_name="friction_force_out")
|
|
|
|
|
|
|
|
|
|
|
|
|
class PowerWindowPlant(CBD):
|
|
class PowerWindowPlant(CBD):
|
|
@@ -167,84 +168,82 @@ class PowerWindowPlant(CBD):
|
|
|
"init_position",
|
|
"init_position",
|
|
|
"init_velocity",
|
|
"init_velocity",
|
|
|
"delta_t"
|
|
"delta_t"
|
|
|
- ], output_ports=["position_out","velocity_out","force_out"])
|
|
|
|
|
|
|
+ ], output_ports=["position_out","velocity_out","force_out","total_force_out","friction_force_out"])
|
|
|
|
|
|
|
|
# See power_window_object.pdf
|
|
# See power_window_object.pdf
|
|
|
|
|
|
|
|
self.addBlock(ConstantBlock("m", value=10.0))
|
|
self.addBlock(ConstantBlock("m", value=10.0))
|
|
|
- self.addBlock(ConstantBlock("cw",value=10.0))
|
|
|
|
|
- self.addBlock(ConstantBlock("0",value=0.0))
|
|
|
|
|
|
|
+ self.addBlock(ConstantBlock("cw",value=-10.0))
|
|
|
|
|
+ self.addBlock(ConstantBlock("zero",value=0.0))
|
|
|
self.addBlock(ConstantBlock("k0",value=1000.0))
|
|
self.addBlock(ConstantBlock("k0",value=1000.0))
|
|
|
- self.addBlock(ConstantBlock("c0",value=1000.0))
|
|
|
|
|
|
|
+ self.addBlock(ConstantBlock("c0",value=-1000.0))
|
|
|
|
|
|
|
|
- self.addBlock(InverterBlock("1/m"))
|
|
|
|
|
|
|
+ self.addBlock(InverterBlock("invert_mass"))
|
|
|
|
|
|
|
|
- self.addBlock(NegatorBlock("-cw"))
|
|
|
|
|
- self.addBlock(NegatorBlock("-k0"))
|
|
|
|
|
- self.addBlock(NegatorBlock("-c0"))
|
|
|
|
|
- self.addBlock(NegatorBlock("-position"))
|
|
|
|
|
|
|
+ self.addBlock(NegatorBlock("position_object_neg"))
|
|
|
|
|
|
|
|
- self.addBlock(ProductBlock("-cw_p"))
|
|
|
|
|
- self.addBlock(ProductBlock("1/m_p"))
|
|
|
|
|
- self.addBlock(ProductBlock("-c0_p"))
|
|
|
|
|
- self.addBlock(ProductBlock("-k0_p"))
|
|
|
|
|
|
|
+ self.addBlock(ProductBlock("cw_p"))
|
|
|
|
|
+ self.addBlock(ProductBlock("divide_m"))
|
|
|
|
|
+ self.addBlock(ProductBlock("c0_p"))
|
|
|
|
|
+ self.addBlock(ProductBlock("k0_p"))
|
|
|
self.addBlock(ProductBlock("object_detect_enable"))
|
|
self.addBlock(ProductBlock("object_detect_enable"))
|
|
|
|
|
|
|
|
- self.addBlock(AdderBlock("acceleration"))
|
|
|
|
|
- self.addBlock(AdderBlock("objectF+acceleration"))
|
|
|
|
|
|
|
+ self.addBlock(AdderBlock("torque_friction"))
|
|
|
|
|
+ self.addBlock(AdderBlock("total_forces"))
|
|
|
self.addBlock(AdderBlock("object_compare"))
|
|
self.addBlock(AdderBlock("object_compare"))
|
|
|
self.addBlock(AdderBlock("object_compression"))
|
|
self.addBlock(AdderBlock("object_compression"))
|
|
|
|
|
+ self.addBlock(AdderBlock("object_displacement"))
|
|
|
|
|
|
|
|
self.addBlock(IntegratorBlock("velocity"))
|
|
self.addBlock(IntegratorBlock("velocity"))
|
|
|
self.addBlock(IntegratorBlock("position"))
|
|
self.addBlock(IntegratorBlock("position"))
|
|
|
|
|
|
|
|
self.addBlock(DecisionBlock("obj_detected"))
|
|
self.addBlock(DecisionBlock("obj_detected"))
|
|
|
|
|
|
|
|
|
|
+ self.addBlock(AbsBlock("abs"))
|
|
|
|
|
|
|
|
self.addConnection("object_detect", "object_detect_enable")
|
|
self.addConnection("object_detect", "object_detect_enable")
|
|
|
- self.addConnection("object_position", "object_compare")
|
|
|
|
|
- self.addConnection("motor", "1/m_p")
|
|
|
|
|
|
|
+ self.addConnection("object_position", "position_object_neg")
|
|
|
|
|
+ self.addConnection("motor", "torque_friction")
|
|
|
self.addConnection("init_position", "position", input_port_name="IC")
|
|
self.addConnection("init_position", "position", input_port_name="IC")
|
|
|
self.addConnection("init_velocity", "velocity", 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", "position", input_port_name="delta_t")
|
|
|
self.addConnection("delta_t", "velocity", 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("m", "invert_mass")
|
|
|
|
|
+ self.addConnection("zero", "obj_detected", input_port_name="F")
|
|
|
|
|
+
|
|
|
|
|
+ self.addConnection("invert_mass", "divide_m")
|
|
|
|
|
|
|
|
- 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_neg", "object_compare")
|
|
|
|
|
+ self.addConnection("position_object_neg", "object_displacement")
|
|
|
|
|
|
|
|
- self.addConnection("-cw", "-cw_p")
|
|
|
|
|
- self.addConnection("-k0", "-k0_p")
|
|
|
|
|
- self.addConnection("-c0", "-c0_p")
|
|
|
|
|
- self.addConnection("-position", "object_compare")
|
|
|
|
|
|
|
+ self.addConnection("cw_p", "torque_friction")
|
|
|
|
|
+ self.addConnection("divide_m", "velocity")
|
|
|
|
|
+ self.addConnection("c0_p", "object_compression")
|
|
|
|
|
+ self.addConnection("k0_p", "object_compression")
|
|
|
|
|
+ self.addConnection("object_detect_enable", "total_forces")
|
|
|
|
|
+ self.addConnection("object_detect_enable", "abs")
|
|
|
|
|
|
|
|
- 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("abs", "force_out")
|
|
|
|
|
|
|
|
- self.addConnection("acceleration", "objectF+acceleration")
|
|
|
|
|
- self.addConnection("objectF+acceleration", "velocity")
|
|
|
|
|
|
|
+ self.addConnection("torque_friction", "total_forces")
|
|
|
|
|
+ self.addConnection("torque_friction", "friction_force_out")
|
|
|
|
|
+ self.addConnection("total_forces", "divide_m")
|
|
|
|
|
+ self.addConnection("total_forces", "total_force_out")
|
|
|
self.addConnection("object_compare", "obj_detected", input_port_name="C")
|
|
self.addConnection("object_compare", "obj_detected", input_port_name="C")
|
|
|
self.addConnection("object_compression", "obj_detected", input_port_name="T")
|
|
self.addConnection("object_compression", "obj_detected", input_port_name="T")
|
|
|
|
|
+ self.addConnection("object_displacement", "k0_p")
|
|
|
|
|
|
|
|
self.addConnection("velocity", "position")
|
|
self.addConnection("velocity", "position")
|
|
|
- self.addConnection("velocity", "-cw_p")
|
|
|
|
|
- self.addConnection("velocity", "-c0_p")
|
|
|
|
|
|
|
+ self.addConnection("velocity", "cw_p")
|
|
|
|
|
+ self.addConnection("velocity", "c0_p")
|
|
|
self.addConnection("velocity", "velocity_out")
|
|
self.addConnection("velocity", "velocity_out")
|
|
|
- self.addConnection("position", "-k0_p")
|
|
|
|
|
|
|
+ self.addConnection("position", "object_displacement")
|
|
|
self.addConnection("position", "position_out")
|
|
self.addConnection("position", "position_out")
|
|
|
- self.addConnection("position", "-position")
|
|
|
|
|
|
|
+ self.addConnection("position", "object_compare")
|
|
|
|
|
|
|
|
self.addConnection("obj_detected", "object_detect_enable")
|
|
self.addConnection("obj_detected", "object_detect_enable")
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|