Update Programme
This commit is contained in:
parent
7298c8642d
commit
2f7d6e2847
5 changed files with 116 additions and 7 deletions
14
README.md
14
README.md
|
|
@ -51,10 +51,16 @@ Via le reseau filaire (wired modems):
|
|||
ASCII (qwerty), le mappage est integre par defaut (0..9,
|
||||
Entree = valider, Backspace = effacer, + / - = consigne +-1).
|
||||
Ne calibrer que si le clavier a un mappage exotique.
|
||||
- `rsc` (mode INACTIF, drone pose): impulsion sur chaque RSC
|
||||
inconnu; l'effet d'assiette designe le coin; sans effet =
|
||||
propulseur. prop_l / prop_r arbitraires: si un virage gauche
|
||||
part a droite, les echanger dans drone.etat.
|
||||
- `rsc` (drone pose): impulsion sur chaque RSC; l'effet
|
||||
d'assiette designe le coin; sans effet = propulseur. prop_l /
|
||||
prop_r arbitraires: si un virage gauche part a droite, les
|
||||
echanger dans drone.etat. Pour un DRONE TROP LOURD (impulsions
|
||||
sans effet), utiliser `rscman`.
|
||||
- `rscman` (drone pose, manuelle): chaque RSC tourne a
|
||||
CALIB.RPM_MANUEL (10 rpm); regarder quelle helice tourne et
|
||||
toucher sa position sur l'art (4 coins + prop_l / prop_r);
|
||||
unicite garantie, ANNULER restaure l'etat precedent. Fiabilise
|
||||
aussi prop_l / prop_r (plus d'affectation arbitraire).
|
||||
- `capteurs` (en vol): montee, avancee puis translation gauche
|
||||
identifient l'axe ET la direction de chaque velocity sensor
|
||||
(repere du drone: avant / lateral / vertical, positif =
|
||||
|
|
|
|||
|
|
@ -321,6 +321,7 @@ local ui = {
|
|||
end,
|
||||
rscViolet = function(role) rscViolet = role end,
|
||||
attendreToucher = ihm.attendreToucher,
|
||||
choisirRole = ihm.choisirRole,
|
||||
}
|
||||
|
||||
local function lancerCalibration(quoi)
|
||||
|
|
@ -329,7 +330,7 @@ local function lancerCalibration(quoi)
|
|||
calibProgres, calibTexte = 0, quoi
|
||||
local ok, err = pcall(function()
|
||||
if quoi == "gimbal" or quoi == "joystick" or quoi == "typew"
|
||||
or quoi == "rsc" then
|
||||
or quoi == "rsc" or quoi == "rscman" then
|
||||
if mode ~= "calibrage" then
|
||||
journal.alerte("calib " .. quoi
|
||||
.. ": passer en mode calibrage d'abord")
|
||||
|
|
@ -345,6 +346,8 @@ local function lancerCalibration(quoi)
|
|||
Calibration.typewriter(conf, etat, materiel, journal, Etat, ui)
|
||||
elseif quoi == "rsc" then
|
||||
Calibration.rsc(conf, etat, materiel, journal, Etat, ui)
|
||||
elseif quoi == "rscman" then
|
||||
Calibration.rscManuel(conf, etat, materiel, journal, Etat, ui)
|
||||
elseif quoi == "capteurs" or quoi == "pid" then
|
||||
if mode ~= "vol" then
|
||||
journal.alerte("calib " .. quoi .. ": passer en mode vol d'abord")
|
||||
|
|
@ -392,6 +395,8 @@ local function calibStatuts()
|
|||
typew = etat.typewriter ~= nil,
|
||||
rsc = #materiel.helicesManquantes() == 0
|
||||
and #materiel.propulseursManquants() == 0,
|
||||
rscman = #materiel.helicesManquantes() == 0
|
||||
and #materiel.propulseursManquants() == 0,
|
||||
capteurs = #materiel.axesManquants() == 0,
|
||||
pid = etat.pid ~= nil,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,6 +289,55 @@ function Calibration.rsc(conf, etat, materiel, journal, Etat, ui)
|
|||
return true
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- RSC MANUELLE (drone trop lourd pour les impulsions).
|
||||
-- Chaque RSC tourne a RPM_MANUEL; l'utilisateur touche sur l'art la
|
||||
-- position de l'helice / du propulseur qui tourne.
|
||||
--------------------------------------------------------------------
|
||||
function Calibration.rscManuel(conf, etat, materiel, journal, Etat, ui)
|
||||
-- RECALIBRATION COMPLETE
|
||||
local anciensRoles = etat.roles
|
||||
etat.roles = {}
|
||||
materiel.rafraichirAffectations()
|
||||
materiel.toutArreter()
|
||||
|
||||
local noms = {}
|
||||
for nom in pairs(materiel.rsc) do table.insert(noms, nom) end
|
||||
table.sort(noms)
|
||||
|
||||
local affectes = {} -- role -> nom
|
||||
for i, nom in ipairs(noms) do
|
||||
ui.progres((i - 1) / #noms, nom .. " a "
|
||||
.. conf.CALIB.RPM_MANUEL .. " rpm")
|
||||
materiel.rsc[nom].setTargetSpeed(conf.CALIB.RPM_MANUEL)
|
||||
|
||||
local role = ui.choisirRole(
|
||||
("%s (%d/%d) tourne a %d rpm"):format(nom, i, #noms,
|
||||
conf.CALIB.RPM_MANUEL),
|
||||
affectes)
|
||||
materiel.rsc[nom].setTargetSpeed(0)
|
||||
|
||||
if role == nil then
|
||||
etat.roles = anciensRoles
|
||||
materiel.rafraichirAffectations()
|
||||
journal.info("calib rsc manuelle: annulee")
|
||||
ui.progres(0, "annulee")
|
||||
return false
|
||||
end
|
||||
affectes[role] = nom
|
||||
etat.roles[nom] = role
|
||||
ui.rscViolet(role)
|
||||
journal.info(("calib rsc manuelle: %s -> %s"):format(nom, role))
|
||||
end
|
||||
ui.rscViolet(nil)
|
||||
|
||||
Etat.sauver(etat)
|
||||
materiel.rafraichirAffectations()
|
||||
ui.progres(1, "terminee")
|
||||
journal.info("calib rsc manuelle: terminee")
|
||||
return true
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- VELOCITY SENSORS (en vol): axes ET directions.
|
||||
-- mouvements = { monter, avancer, gauche } (fonctions bloquantes qui
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ return {
|
|||
TIMEOUT = 25, -- pid: duree max d'un echelon (s)
|
||||
MAX_ITER = 6, -- pid: essais par direction
|
||||
IMPULSION_PAS = 16, -- rsc: increment de vitesse (rpm)
|
||||
RPM_MANUEL = 10, -- rsc manuel: vitesse de reperage (rpm)
|
||||
IMPULSION_SEUIL = 0.8, -- rsc/gimbal: variation d'angle declarante (deg)
|
||||
JOYSTICK_SEUIL = 8, -- joystick: niveau declarant une face (0..15)
|
||||
},
|
||||
|
|
|
|||
52
lib/ihm.lua
52
lib/ihm.lua
|
|
@ -276,7 +276,7 @@ function Ihm.nouveau(conf, materiel, journal)
|
|||
colors.lightGray)
|
||||
local x, y = 1, 3
|
||||
for _, c in ipairs({ "gimbal", "joystick", "typew", "rsc",
|
||||
"capteurs", "pid" }) do
|
||||
"rscman", "capteurs", "pid" }) do
|
||||
local statut = ctx.calibStatuts[c]
|
||||
local couleur = colors.gray
|
||||
if statut == "encours" then couleur = colors.yellow
|
||||
|
|
@ -307,7 +307,8 @@ function Ihm.nouveau(conf, materiel, journal)
|
|||
texte(1, y, "en violet: RSC en cours", colors.purple)
|
||||
y = dessinerArt(1, y + 1, ctx)
|
||||
end
|
||||
texte(1, H - 1, "sol: gimbal joystick typew rsc (mode calibrage)",
|
||||
texte(1, H - 1,
|
||||
"sol: gimbal joystick typew rsc rscman (mode calibrage)",
|
||||
colors.lightGray)
|
||||
texte(1, H, "vol: capteurs pid (mode vol)", colors.lightGray)
|
||||
end
|
||||
|
|
@ -362,6 +363,53 @@ function Ihm.nouveau(conf, materiel, journal)
|
|||
|
||||
function ihm.reglerPage(p) page = p end
|
||||
|
||||
-- Art interactif plein ecran: l'utilisateur touche la position de
|
||||
-- l'helice/du propulseur qui tourne. Retourne le role choisi, ou
|
||||
-- nil (annulation). `affectes` (role -> nom) grise le deja pris.
|
||||
function ihm.choisirRole(titre, affectes)
|
||||
local locales = {}
|
||||
local function boutonLocal(x, y, texteB, role, couleur)
|
||||
moniteur.setCursorPos(x, y)
|
||||
moniteur.setBackgroundColor(couleur)
|
||||
moniteur.write(" " .. texteB .. " ")
|
||||
moniteur.setBackgroundColor(colors.black)
|
||||
table.insert(locales, {
|
||||
x1 = x, y1 = y, x2 = x + #texteB + 1, y2 = y, role = role,
|
||||
})
|
||||
end
|
||||
|
||||
moniteur.setBackgroundColor(colors.black)
|
||||
moniteur.clear()
|
||||
texte(1, 1, titre:sub(1, L), colors.yellow)
|
||||
texte(1, 2, "Touchez la position qui TOURNE", colors.lightGray)
|
||||
|
||||
local function couleurChoix(role)
|
||||
if affectes[role] then return colors.gray end
|
||||
return colors.blue
|
||||
end
|
||||
local g, d = 8, L - 12
|
||||
texte(math.floor(L / 2) - 2, 4, "AVANT", colors.lightGray)
|
||||
boutonLocal(g, 5, "lf", "lf", couleurChoix("lf"))
|
||||
boutonLocal(d, 5, "rf", "rf", couleurChoix("rf"))
|
||||
boutonLocal(1, 7, "prop_l", "prop_l", couleurChoix("prop_l"))
|
||||
boutonLocal(L - 8, 7, "prop_r", "prop_r", couleurChoix("prop_r"))
|
||||
boutonLocal(g, 9, "lb", "lb", couleurChoix("lb"))
|
||||
boutonLocal(d, 9, "rb", "rb", couleurChoix("rb"))
|
||||
boutonLocal(1, 11, "ANNULER", nil, colors.red)
|
||||
|
||||
while true do
|
||||
local _, _, tx, ty = os.pullEvent("monitor_touch")
|
||||
for _, z in ipairs(locales) do
|
||||
if tx >= z.x1 and tx <= z.x2 and ty >= z.y1 and ty <= z.y2 then
|
||||
if z.role == nil then return nil end
|
||||
if not affectes[z.role] then return z.role end
|
||||
texte(1, 12, "deja affecte, choisir une autre position",
|
||||
colors.orange)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ihm.attendreToucher()
|
||||
while true do
|
||||
local ev = os.pullEvent("monitor_touch")
|
||||
|
|
|
|||
Loading…
Reference in a new issue