-- L0 Closed-loop control of UABotet L0UI = {} L0UI.xml = [[ <ui title="L0 User…
- User
-- L0 Closed-loop control of UABotet
L0_UI = {} L0_UI.xml = [[ <ui title="L0 User Interface" resizable="true" style="background-color:lightBlue"
<group layout="hbox" flat="true"><group layout="vbox" flat="true"> <group layout="hbox" flat="true"> <label text="Angle" /> <edit id="110" value="0" on-editing-finished="L0_UI.updateAtext" style="background-color:white" /> <label text="deg" /> </group> <hslider id="115" minimum="-90" maximum="90" value="0" tick-interval="10" tick-position="below" on-change="L0_UI.updateAslider" /> <group layout="hbox" flat="true"> <label text="Distance" /> <edit id="120" value="0" on-editing-finished="L0_UI.updateDtext" style="background-color:white" /> <label text="cm" /> </group> <hslider id="125" minimum="0" maximum="255" value="0" tick-interval="10" tick-position="below" on-change="L0_UI.updateDslider" /> <group layout="hbox" flat="true"> <button id="1" text="GO" style="background-color:lightGreen" on-click="L0_UI.GO" /> <button id="4" text="HALT" style="background-color:red" on-click="L0_UI.HALT" /> </group> <group layout="hbox" flat="true"> <button id="2" text="LIDAR" style="background-color:lightGreen" on-click="L0_UI.LIDAR" /> <button id="3" text="RESUME" style="background-color:lightGreen" on-click="L0_UI.RESUME" /> </group> </group> <group layout="vbox" flat="true"> <label text="From L0: "/> <text-browser id="40" text="..." html="false" read-only="true" style="align:left" /> <!--tree id="40" show-header="false" style="align:left"> <row> <item> ... </item> </row> </tree--> </group> </group>-- L0 CONTROLLER
init = function() rW = 17 -- Radius of wheels = 17mm dW = 105 -- wheel distance [mm] CPR = 1440 -- Counts per revolution eticks2mm = rW2math.pi/CPR I = {0, 0, 0} -- Instruction table state = {}; state.next = "LISTEN" B = {}; B.next = 0 -- Begin time A = {}; A.next = nil -- Absolute angle rotation S = {}; S.next = nil -- Space/distance to move ahead L = {}; L.next = 0 -- DC value for left motor R = {}; R.next = 0 -- DC value for right motor M = {}; M.next = nil -- Message to user/upper-level controllers if sim then eL = sim.getInt32Signal("enc_left") or 0 -- as they depend on order of execution of eR = sim.getInt32Signal("enc_right") or 0 -- init()'s, default init values are given else eL = 0 eR = 0 end -- if dA = 0 dS = 0 end -- init()
forward = function() -- Current state update -- ************************ -- * TO COMPLETE !!!! * -- ************************ end -- forward()
read_inputs = function() local C = L0_UI:getC() if sim then local cL = sim.getInt32Signal("enc_left") - self.eL local cR = sim.getInt32Signal("enc_right") - self.eR eL = eL + cL; eR = eR + cR; local dL = eticks2mmcL local dR = eticks2mmcR dA = (dR-dL)/dW -- dA = 0.5*(dAL+dAR) = 0.5*(2dR/dW-2dL/dW) dA = math.abs(dA180/math.pi) dS = 0.5(dL+dR) dS = self.dS/10.0 -- mm into cm else -- console input io.write(string.format("> dA [deg] = ")) local x = tonumber(io.read()) if x then dA = x end io.write(string.format("> dS [cm] = ")) local x = tonumber(io.read()) if x then dS = x end io.write(string.format("> I = ")) C = io.read() end -- if if C and #C>0 then local words = {} for w in string.gmatch(C, "-?%d+") do table.insert(words, w) end I[1] = tonumber(words[1]) if I[1] then if I[1]==1 then -- GO if #words>1 then I[2] = tonumber(words[2]) end if #words>2 then I[3] = tonumber(words[3]) end else I[2] = 0; I[3] = 0 end -- if end -- if else I[1] = 0 -- no command received end -- if end -- read_inputs()
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.