|
2 | 2 | <WorkflowBuilder Version="2.8.5" |
3 | 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
4 | 4 | xmlns:p1="clr-namespace:OpenEphys.Miniscope;assembly=OpenEphys.Miniscope" |
5 | | - xmlns:wie="clr-namespace:Bonsai.Windows.Input;assembly=Bonsai.Windows.Input" |
6 | | - xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" |
7 | | - xmlns:ipy="clr-namespace:Bonsai.Scripting.IronPython;assembly=Bonsai.Scripting.IronPython" |
8 | | - xmlns:port="clr-namespace:Bonsai.IO.Ports;assembly=Bonsai.System" |
9 | 5 | xmlns="https://bonsai-rx.org/2018/workflow"> |
10 | 6 | <Workflow> |
11 | 7 | <Nodes> |
|
22 | 18 | <Expression xsi:type="MemberSelector"> |
23 | 19 | <Selector>Quaternion</Selector> |
24 | 20 | </Expression> |
25 | | - <Expression xsi:type="GroupWorkflow"> |
26 | | - <Name>Commutator</Name> |
27 | | - <Description>Automates commutation (using an Open Ephys Commutator) using BNO055 Quaternion data. |
28 | | -Allows manual commutation by pressing the Alt+Right/Alt+Left keys.</Description> |
29 | | - <Workflow> |
30 | | - <Nodes> |
31 | | - <Expression xsi:type="Combinator"> |
32 | | - <Combinator xsi:type="wie:KeyDown"> |
33 | | - <wie:Filter>LButton RButton Cancel MButton XButton1 XButton2 Space Prior PageUp Next PageDown End Home Left Up Right Alt</wie:Filter> |
34 | | - <wie:SuppressRepetitions>false</wie:SuppressRepetitions> |
35 | | - </Combinator> |
36 | | - </Expression> |
37 | | - <Expression xsi:type="Combinator"> |
38 | | - <Combinator xsi:type="StringProperty"> |
39 | | - <Value>"{turn : 0.1}"</Value> |
40 | | - </Combinator> |
41 | | - </Expression> |
42 | | - <Expression xsi:type="Combinator"> |
43 | | - <Combinator xsi:type="wie:KeyDown"> |
44 | | - <wie:Filter>LButton MButton XButton1 Space Prior PageUp Home Left Alt</wie:Filter> |
45 | | - <wie:SuppressRepetitions>false</wie:SuppressRepetitions> |
46 | | - </Combinator> |
47 | | - </Expression> |
48 | | - <Expression xsi:type="Combinator"> |
49 | | - <Combinator xsi:type="StringProperty"> |
50 | | - <Value>"{turn : -0.1}"</Value> |
51 | | - </Combinator> |
52 | | - </Expression> |
53 | | - <Expression xsi:type="WorkflowInput"> |
54 | | - <Name>Source1</Name> |
55 | | - </Expression> |
56 | | - <Expression xsi:type="Combinator"> |
57 | | - <Combinator xsi:type="rx:Timer"> |
58 | | - <rx:DueTime>PT0S</rx:DueTime> |
59 | | - <rx:Period>PT0.1S</rx:Period> |
60 | | - </Combinator> |
61 | | - </Expression> |
62 | | - <Expression xsi:type="Combinator"> |
63 | | - <Combinator xsi:type="rx:Sample" /> |
64 | | - </Expression> |
65 | | - <Expression xsi:type="ipy:PythonTransform"> |
66 | | - <ipy:Name>Heading</ipy:Name> |
67 | | - <ipy:Description>Transform the UCLA Miniscope v4's quarternion data to heading data.</ipy:Description> |
68 | | - <ipy:Script>from math import atan2 |
69 | | -@returns(float) |
70 | | -def process(value): |
71 | | - |
72 | | - siny_cosp = 2 * (value.W * value.Z + value.x * value.y); |
73 | | - cosy_cosp = 1 - 2 * (value.y * value.y + value.z * value.z); |
74 | | - |
75 | | - return atan2(siny_cosp, cosy_cosp)</ipy:Script> |
76 | | - </Expression> |
77 | | - <Expression xsi:type="Combinator"> |
78 | | - <Combinator xsi:type="rx:Skip"> |
79 | | - <rx:Count>1</rx:Count> |
80 | | - </Combinator> |
81 | | - </Expression> |
82 | | - <Expression xsi:type="Combinator"> |
83 | | - <Combinator xsi:type="rx:Zip" /> |
84 | | - </Expression> |
85 | | - <Expression xsi:type="ipy:PythonTransform"> |
86 | | - <ipy:Name>AutomatedCommutatorCommand</ipy:Name> |
87 | | - <ipy:Description>Transform current and previous heading data to a commutator command</ipy:Description> |
88 | | - <ipy:Script>from math import pi |
89 | | - |
90 | | -@returns(str) |
91 | | -def process(value): |
92 | | - |
93 | | - |
94 | | - last = value.Item2 |
95 | | - |
96 | | - curr = value.Item1 |
97 | | - a1 = curr + 2 * pi |
98 | | - a2 = curr - 2 * pi |
99 | | - pos = [curr, a1, a2] |
100 | | - |
101 | | - delta = [abs(x - last) for x in pos] |
102 | | - |
103 | | - p = pos[delta.index(min(delta))] |
104 | | - |
105 | | - turn = (p - last) / (2 * pi) |
106 | | - |
107 | | - return "{turn : %s}" % turn</ipy:Script> |
108 | | - </Expression> |
109 | | - <Expression xsi:type="Combinator"> |
110 | | - <Combinator xsi:type="rx:Merge" /> |
111 | | - </Expression> |
112 | | - <Expression xsi:type="ExternalizedMapping"> |
113 | | - <Property Name="PortName" /> |
114 | | - </Expression> |
115 | | - <Expression xsi:type="Combinator"> |
116 | | - <Combinator xsi:type="port:SerialWriteLine"> |
117 | | - <port:PortName>COM4</port:PortName> |
118 | | - <port:NewLine>\r\n</port:NewLine> |
119 | | - </Combinator> |
120 | | - </Expression> |
121 | | - <Expression xsi:type="WorkflowOutput" /> |
122 | | - </Nodes> |
123 | | - <Edges> |
124 | | - <Edge From="0" To="1" Label="Source1" /> |
125 | | - <Edge From="1" To="11" Label="Source1" /> |
126 | | - <Edge From="2" To="3" Label="Source1" /> |
127 | | - <Edge From="3" To="11" Label="Source2" /> |
128 | | - <Edge From="4" To="6" Label="Source1" /> |
129 | | - <Edge From="5" To="6" Label="Source2" /> |
130 | | - <Edge From="6" To="7" Label="Source1" /> |
131 | | - <Edge From="7" To="8" Label="Source1" /> |
132 | | - <Edge From="7" To="9" Label="Source1" /> |
133 | | - <Edge From="8" To="9" Label="Source2" /> |
134 | | - <Edge From="9" To="10" Label="Source1" /> |
135 | | - <Edge From="10" To="11" Label="Source3" /> |
136 | | - <Edge From="11" To="13" Label="Source1" /> |
137 | | - <Edge From="12" To="13" Label="Source2" /> |
138 | | - <Edge From="13" To="14" Label="Source1" /> |
139 | | - </Edges> |
140 | | - </Workflow> |
| 21 | + <Expression xsi:type="IncludeWorkflow" Path="OpenEphys.Commutator:AutoCommutator.bonsai"> |
| 22 | + <PortName xsi:nil="true" /> |
| 23 | + <Enable>true</Enable> |
| 24 | + <EnableLed>true</EnableLed> |
141 | 25 | </Expression> |
142 | 26 | </Nodes> |
143 | 27 | <Edges> |
|
0 commit comments