<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with MathML3 v1.3 20210610//EN"  "JATS-archivearticle1-3-mathml3.dtd"><article xmlns:ali="http://www.niso.org/schemas/ali/1.0/" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="research-article" dtd-version="1.3"><front><journal-meta><journal-id journal-id-type="nlm-ta">elife</journal-id><journal-id journal-id-type="publisher-id">eLife</journal-id><journal-title-group><journal-title>eLife</journal-title></journal-title-group><issn publication-format="electronic" pub-type="epub">2050-084X</issn><publisher><publisher-name>eLife Sciences Publications, Ltd</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="publisher-id">99005</article-id><article-id pub-id-type="doi">10.7554/eLife.99005</article-id><article-id pub-id-type="doi" specific-use="version">10.7554/eLife.99005.3</article-id><article-version article-version-type="publication-state">version of record</article-version><article-categories><subj-group subj-group-type="display-channel"><subject>Research Article</subject></subj-group><subj-group subj-group-type="heading"><subject>Computational and Systems Biology</subject></subj-group><subj-group subj-group-type="heading"><subject>Neuroscience</subject></subj-group></article-categories><title-group><article-title>Sensorimotor delays constrain robust locomotion in a 3D kinematic model of fly walking</article-title></title-group><contrib-group><contrib contrib-type="author" equal-contrib="yes"><name><surname>Karashchuk</surname><given-names>Lili</given-names></name><contrib-id authenticated="true" contrib-id-type="orcid">https://orcid.org/0000-0001-6244-8239</contrib-id><xref ref-type="aff" rid="aff1">1</xref><xref ref-type="aff" rid="aff2">2</xref><xref ref-type="aff" rid="aff3">3</xref><xref ref-type="fn" rid="equal-contrib1">†</xref><xref ref-type="fn" rid="pa1">§</xref><xref ref-type="fn" rid="con1"/><xref ref-type="fn" rid="conf1"/></contrib><contrib contrib-type="author" equal-contrib="yes"><name><surname>Li</surname><given-names>Jing Shuang</given-names></name><contrib-id authenticated="true" contrib-id-type="orcid">https://orcid.org/0000-0003-4931-8709</contrib-id><xref ref-type="aff" rid="aff4">4</xref><xref ref-type="fn" rid="equal-contrib1">†</xref><xref ref-type="other" rid="fund2"/><xref ref-type="fn" rid="con2"/><xref ref-type="fn" rid="conf1"/></contrib><contrib contrib-type="author"><name><surname>Chou</surname><given-names>Grant M</given-names></name><xref ref-type="aff" rid="aff2">2</xref><xref ref-type="fn" rid="con3"/><xref ref-type="fn" rid="conf1"/></contrib><contrib contrib-type="author"><name><surname>Walling-Bell</surname><given-names>Sarah</given-names></name><xref ref-type="aff" rid="aff2">2</xref><xref ref-type="fn" rid="con4"/><xref ref-type="fn" rid="conf1"/></contrib><contrib contrib-type="author"><name><surname>Brunton</surname><given-names>Steven L</given-names></name><xref ref-type="aff" rid="aff5">5</xref><xref ref-type="other" rid="fund10"/><xref ref-type="fn" rid="con5"/><xref ref-type="fn" rid="conf1"/></contrib><contrib contrib-type="author" corresp="yes" equal-contrib="yes"><name><surname>Tuthill</surname><given-names>John C</given-names></name><contrib-id authenticated="true" contrib-id-type="orcid">https://orcid.org/0000-0002-5689-5806</contrib-id><email>tuthill@uw.edu</email><xref ref-type="aff" rid="aff2">2</xref><xref ref-type="fn" rid="equal-contrib2">‡</xref><xref ref-type="other" rid="fund5"/><xref ref-type="other" rid="fund6"/><xref ref-type="other" rid="fund8"/><xref ref-type="fn" rid="con6"/><xref ref-type="fn" rid="conf2"/></contrib><contrib contrib-type="author" corresp="yes" equal-contrib="yes"><name><surname>Brunton</surname><given-names>Bingni W</given-names></name><contrib-id authenticated="true" contrib-id-type="orcid">https://orcid.org/0000-0002-4831-3466</contrib-id><email>bbrunton@uw.edu</email><xref ref-type="aff" rid="aff3">3</xref><xref ref-type="fn" rid="equal-contrib2">‡</xref><xref ref-type="other" rid="fund10"/><xref ref-type="fn" rid="con7"/><xref ref-type="fn" rid="conf1"/></contrib><aff id="aff1"><label>1</label><institution-wrap><institution-id institution-id-type="ror">https://ror.org/00cvxb145</institution-id><institution>Neuroscience Graduate Program, University of Washington</institution></institution-wrap><addr-line><named-content content-type="city">Seattle</named-content></addr-line><country>United States</country></aff><aff id="aff2"><label>2</label><institution-wrap><institution-id institution-id-type="ror">https://ror.org/00cvxb145</institution-id><institution>Department of Neurobiology and Biophysics, University of Washington</institution></institution-wrap><addr-line><named-content content-type="city">Seattle</named-content></addr-line><country>United States</country></aff><aff id="aff3"><label>3</label><institution-wrap><institution-id institution-id-type="ror">https://ror.org/00cvxb145</institution-id><institution>Department of Biology, University of Washington</institution></institution-wrap><addr-line><named-content content-type="city">Seattle</named-content></addr-line><country>United States</country></aff><aff id="aff4"><label>4</label><institution-wrap><institution-id institution-id-type="ror">https://ror.org/00jmfr291</institution-id><institution>Department of Electrical Engineering and Computer Science, University of Michigan</institution></institution-wrap><addr-line><named-content content-type="city">Ann Arbor</named-content></addr-line><country>United States</country></aff><aff id="aff5"><label>5</label><institution-wrap><institution-id institution-id-type="ror">https://ror.org/00cvxb145</institution-id><institution>Department of Mechanical Engineering, University of Washington</institution></institution-wrap><addr-line><named-content content-type="city">Seattle</named-content></addr-line><country>United States</country></aff></contrib-group><contrib-group content-type="section"><contrib contrib-type="editor"><name><surname>Salinas</surname><given-names>Emilio</given-names></name><role>Reviewing Editor</role><aff><institution-wrap><institution-id institution-id-type="ror">https://ror.org/0207ad724</institution-id><institution>Wake Forest University School of Medicine</institution></institution-wrap><country>United States</country></aff></contrib><contrib contrib-type="senior_editor"><name><surname>Cardona</surname><given-names>Albert</given-names></name><role>Senior Editor</role><aff><institution-wrap><institution-id institution-id-type="ror">https://ror.org/013meh722</institution-id><institution>University of Cambridge</institution></institution-wrap><country>United Kingdom</country></aff></contrib></contrib-group><author-notes><fn fn-type="con" id="equal-contrib1"><label>†</label><p>These authors contributed equally to this work</p></fn><fn fn-type="con" id="equal-contrib2"><label>‡</label><p>These authors also contributed equally to this work</p></fn><fn fn-type="present-address" id="pa1"><label>§</label><p>Allen Institute for Neural Dynamics, Seattle, United States</p></fn></author-notes><pub-date publication-format="electronic" date-type="publication"><day>15</day><month>05</month><year>2025</year></pub-date><volume>13</volume><elocation-id>RP99005</elocation-id><history><date date-type="sent-for-review" iso-8601-date="2024-05-03"><day>03</day><month>05</month><year>2024</year></date></history><pub-history><event><event-desc>This manuscript was published as a preprint.</event-desc><date date-type="preprint" iso-8601-date="2024-04-22"><day>22</day><month>04</month><year>2024</year></date><self-uri content-type="preprint" xlink:href="https://doi.org/10.1101/2024.04.18.589965"/></event><event><event-desc>This manuscript was published as a reviewed preprint.</event-desc><date date-type="reviewed-preprint" iso-8601-date="2024-08-27"><day>27</day><month>08</month><year>2024</year></date><self-uri content-type="reviewed-preprint" xlink:href="https://doi.org/10.7554/eLife.99005.1"/></event><event><event-desc>The reviewed preprint was revised.</event-desc><date date-type="reviewed-preprint" iso-8601-date="2025-03-20"><day>20</day><month>03</month><year>2025</year></date><self-uri content-type="reviewed-preprint" xlink:href="https://doi.org/10.7554/eLife.99005.2"/></event></pub-history><permissions><copyright-statement>© 2024, Karashchuk, Li et al</copyright-statement><copyright-year>2024</copyright-year><copyright-holder>Karashchuk, Li et al</copyright-holder><ali:free_to_read/><license xlink:href="http://creativecommons.org/licenses/by/4.0/"><ali:license_ref>http://creativecommons.org/licenses/by/4.0/</ali:license_ref><license-p>This article is distributed under the terms of the <ext-link ext-link-type="uri" xlink:href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution License</ext-link>, which permits unrestricted use and redistribution provided that the original author and source are credited.</license-p></license></permissions><self-uri content-type="pdf" xlink:href="elife-99005-v1.pdf"/><abstract><p>Walking animals must maintain stability in the presence of external perturbations, despite significant temporal delays in neural signaling and muscle actuation. Here, we develop a 3D kinematic model with a layered control architecture to investigate how sensorimotor delays constrain the robustness of walking behavior in the fruit fly, <italic>Drosophila</italic>. Motivated by the anatomical architecture of insect locomotor control circuits, our model consists of three component layers: a neural network that generates realistic 3D joint kinematics for each leg, an optimal controller that executes the joint kinematics while accounting for delays, and an inter-leg coordinator. The model generates realistic simulated walking that resembles real fly walking kinematics and sustains walking even when subjected to unexpected perturbations, generalizing beyond its training data. However, we found that the model’s robustness to perturbations deteriorates when sensorimotor delay parameters exceed the physiological range. These results suggest that fly sensorimotor control circuits operate close to the temporal limit at which they can detect and respond to external perturbations. More broadly, we show how a modular, layered model architecture can be used to investigate physiological constraints on animal behavior.</p></abstract><kwd-group kwd-group-type="author-keywords"><kwd>locomotor control</kwd><kwd>sensorimotor delay</kwd><kwd>generative model</kwd><kwd>quantifying behavior</kwd><kwd>walking</kwd></kwd-group><kwd-group kwd-group-type="research-organism"><title>Research organism</title><kwd><italic>D. melanogaster</italic></kwd></kwd-group><funding-group><award-group id="fund1"><funding-source><institution-wrap><institution-id institution-id-type="FundRef">http://dx.doi.org/10.13039/100000001</institution-id><institution>National Science Foundation</institution></institution-wrap></funding-source><award-id>Graduate Research Fellowship Program</award-id><principal-award-recipient><name><surname>Karashchuk</surname><given-names>Lili</given-names></name></principal-award-recipient></award-group><award-group id="fund2"><funding-source><institution-wrap><institution-id institution-id-type="FundRef">http://dx.doi.org/10.13039/501100000038</institution-id><institution>Natural Sciences and Engineering Research Council of Canada</institution></institution-wrap></funding-source><award-id>PGSD3-557385-2021</award-id><principal-award-recipient><name><surname>Li</surname><given-names>Jing Shuang</given-names></name></principal-award-recipient></award-group><award-group id="fund3"><funding-source><institution-wrap><institution-id institution-id-type="FundRef">http://dx.doi.org/10.13039/100014185</institution-id><institution>Searle Scholars Program</institution></institution-wrap></funding-source><principal-award-recipient><name><surname>Tuthill</surname><given-names>John C</given-names></name></principal-award-recipient></award-group><award-group id="fund4"><funding-source><institution-wrap><institution>Klingenstein-Simons Fellowship</institution></institution-wrap></funding-source><principal-award-recipient><name><surname>Tuthill</surname><given-names>John C</given-names></name></principal-award-recipient></award-group><award-group id="fund5"><funding-source><institution-wrap><institution-id institution-id-type="FundRef">http://dx.doi.org/10.13039/100000875</institution-id><institution>Pew Charitable Trusts</institution></institution-wrap></funding-source><principal-award-recipient><name><surname>Tuthill</surname><given-names>John C</given-names></name></principal-award-recipient></award-group><award-group id="fund6"><funding-source><institution-wrap><institution-id institution-id-type="FundRef">http://dx.doi.org/10.13039/100000872</institution-id><institution>McKnight Endowment Fund for Neuroscience</institution></institution-wrap></funding-source><principal-award-recipient><name><surname>Tuthill</surname><given-names>John C</given-names></name></principal-award-recipient></award-group><award-group id="fund7"><funding-source><institution-wrap><institution-id institution-id-type="FundRef">http://dx.doi.org/10.13039/100000879</institution-id><institution>Alfred P. Sloan Foundation</institution></institution-wrap></funding-source><award-id>Sloan Research Fellowship</award-id><principal-award-recipient><name><surname>Tuthill</surname><given-names>John C</given-names></name></principal-award-recipient></award-group><award-group id="fund8"><funding-source><institution-wrap><institution-id institution-id-type="FundRef">http://dx.doi.org/10.13039/100003194</institution-id><institution>New York Stem Cell Foundation</institution></institution-wrap></funding-source><principal-award-recipient><name><surname>Tuthill</surname><given-names>John C</given-names></name></principal-award-recipient></award-group><award-group id="fund9"><funding-source><institution-wrap><institution-id institution-id-type="FundRef">http://dx.doi.org/10.13039/100000002</institution-id><institution>National Institutes of Health</institution></institution-wrap></funding-source><award-id>R01NS102333</award-id><principal-award-recipient><name><surname>Tuthill</surname><given-names>John C</given-names></name></principal-award-recipient></award-group><award-group id="fund10"><funding-source><institution-wrap><institution-id institution-id-type="FundRef">http://dx.doi.org/10.13039/100000181</institution-id><institution>Air Force Office of Scientific Research</institution></institution-wrap></funding-source><award-id>FA9550-19-1-0386</award-id><principal-award-recipient><name><surname>Brunton</surname><given-names>Steven L</given-names></name><name><surname>Brunton</surname><given-names>Bingni W</given-names></name></principal-award-recipient></award-group><award-group id="fund11"><funding-source><institution-wrap><institution>Richard &amp; Joan Komen University Chair</institution></institution-wrap></funding-source><principal-award-recipient><name><surname>Brunton</surname><given-names>Bingni W</given-names></name></principal-award-recipient></award-group><funding-statement>The funders had no role in study design, data collection and interpretation, or the decision to submit the work for publication.</funding-statement></funding-group><custom-meta-group><custom-meta specific-use="meta-only"><meta-name>Author impact statement</meta-name><meta-value>A model that simulates realistic fly walking uses an anatomically-inspired layered architecture to achieve robust walking, quantifying the tolerance of this circuit to sensorimotor delays.</meta-value></custom-meta><custom-meta specific-use="meta-only"><meta-name>publishing-route</meta-name><meta-value>prc</meta-value></custom-meta></custom-meta-group></article-meta></front><body><sec id="s1" sec-type="intro"><title>Introduction</title><p>Animals as diverse as tardigrades (<xref ref-type="bibr" rid="bib68">Nirody et al., 2021</xref>) and tapirs (<xref ref-type="bibr" rid="bib21">Catavitello et al., 2018</xref>) use inter-limb coordination to walk through complex terrain. When a walking animal encounters an unexpected perturbation (e.g. it is pushed or tripped), its ability to recover and sustain locomotion can be a matter of life and death. However, the presence of significant temporal delays in animal sensorimotor systems establishes fundamental limits on how quickly animals can respond to external perturbations (<xref ref-type="bibr" rid="bib66">More and Donelan, 2018</xref>; <xref ref-type="bibr" rid="bib40">Gebehart and Büschges, 2021</xref>). Sources of temporal delay include neural conduction, synaptic transmission, and electromechanical muscle activation (<xref ref-type="bibr" rid="bib82">Sterling, 2015</xref>; <xref ref-type="bibr" rid="bib51">Ijspeert and Daley, 2023</xref>).</p><p>Sensorimotor delays pose a particular challenge for systems that rely on feedback control, because they limit the availability of up-to-date information on the state of the external environment (<xref ref-type="bibr" rid="bib37">Franklin and Wolpert, 2011</xref>). For example, time delays limit robust performance in feedback control systems (<xref ref-type="bibr" rid="bib35">Doyle et al., 2013</xref>), and model predictive control (MPC) (<xref ref-type="bibr" rid="bib39">García et al., 1989</xref>; <xref ref-type="bibr" rid="bib20">Camacho, 2013</xref>; <xref ref-type="bibr" rid="bib18">Brunton, 2022</xref>) is one algorithmic strategy to improve performance while maintaining robustness. In biological systems, theoretical studies suggest that some animals use predictive internal models to mitigate the effect of delays (<xref ref-type="bibr" rid="bib66">More and Donelan, 2018</xref>; <xref ref-type="bibr" rid="bib60">Li et al., 2023</xref>; <xref ref-type="bibr" rid="bib33">Desmurget and Grafton, 2000</xref>). Limb compliance and other biomechanical adaptations can also compensate for unexpected perturbations within a limited range and mitigate the effect of sensorimotor delays (<xref ref-type="bibr" rid="bib28">Daley, 2018</xref>; <xref ref-type="bibr" rid="bib5">Ashtiani et al., 2021</xref>). However, the constraints that sensorimotor delays impose on robust locomotion have been difficult to quantify, because it is experimentally challenging to manipulate sensorimotor delays and observe their effects on animal locomotion (although this has been achieved in other motor systems, for example using focal cooling in singing birds <xref ref-type="bibr" rid="bib11">Banerjee et al., 2021</xref>). Computational models of locomotion typically have not included delays as a tunable parameter, although some models have included them as fixed values (<xref ref-type="bibr" rid="bib42">Geyer and Herr, 2010</xref>; <xref ref-type="bibr" rid="bib41">Geijtenbeek et al., 2013</xref>). In general, the impact of sensorimotor delays on locomotor control and robustness remains underexplored in computational neuroscience.</p><p>Flies are agile and robust walkers, and the availability of genetic and behavioral tools in <italic>Drosophila</italic> makes them well-suited to investigate neural mechanisms of locomotor control (<xref ref-type="bibr" rid="bib32">DeAngelis et al., 2019</xref>; <xref ref-type="bibr" rid="bib45">Gonçalves et al., 2022</xref>; <xref ref-type="bibr" rid="bib27">Cruz and Chiappe, 2023</xref>). The fly is also the only walking animal whose nervous system is almost completely mapped at synaptic resolution (<xref ref-type="bibr" rid="bib38">Galili et al., 2022</xref>). Flies walk rhythmically with a continuum of stepping patterns that range from tetrapod (where two of six legs are off the ground at a time) to tripod (where three of six legs are off the ground at a time) (<xref ref-type="bibr" rid="bib32">DeAngelis et al., 2019</xref>; <xref ref-type="bibr" rid="bib65">Mendes et al., 2013</xref>; <xref ref-type="bibr" rid="bib86">Szczecinski et al., 2018</xref>; <xref ref-type="bibr" rid="bib95">Wosnitza et al., 2013</xref>; <xref ref-type="bibr" rid="bib83">Strauss and Heisenberg, 1990</xref>; <xref ref-type="bibr" rid="bib69">Nishii, 2000</xref>; <xref ref-type="bibr" rid="bib71">Pratt et al., 2024</xref>). Each fly leg has five joints that move through seven mechanical degrees of freedom (<xref ref-type="bibr" rid="bib54">Karashchuk et al., 2021</xref>; <xref ref-type="bibr" rid="bib62">Lobato-Rios et al., 2022</xref>) and are actuated by ∼18 muscles that are innervated by ∼70 motor neurons (<xref ref-type="bibr" rid="bib10">Azevedo et al., 2024</xref>). Each leg motor neuron is uniquely identifiable (<xref ref-type="bibr" rid="bib10">Azevedo et al., 2024</xref>) and receives thousands of synaptic inputs from hundreds of unique premotor neurons within the fly’s ventral nerve cord (VNC, <xref ref-type="bibr" rid="bib59">Lesser et al., 2024</xref>; <xref ref-type="bibr" rid="bib22">Cheong et al., 2024</xref>), a part of the invertebrate nervous system analogous to the vertebrate spinal cord. The architectural features of <italic>Drosophila</italic> locomotor control—joints, leg motor neurons, and the connectivity of the VNC—motivates the architecture of our proposed model.</p><p>Past models of insect multi-legged walking have taken three general approaches. The first approach models legs as coupled oscillators or inverted pendula without taking into account the mechanics of leg joints. Each leg is a single oscillator, and a network of oscillators is tuned to recreate an oscillatory gait from measurements of footfalls (<xref ref-type="bibr" rid="bib26">Couzin-Fuchs et al., 2015</xref>; <xref ref-type="bibr" rid="bib72">Proctor and Holmes, 2018</xref>); alternatively, tripod gaits are approximated by spring-loaded inverted pendula (<xref ref-type="bibr" rid="bib24">Chun et al., 2021</xref>). The second approach focuses on the physical details of the legs and their joints. <xref ref-type="bibr" rid="bib74">Schilling et al., 2013</xref> use a decentralized reactive controller to recreate hexapod walking patterns; <xref ref-type="bibr" rid="bib43">Goldsmith, 2019</xref> and <xref ref-type="bibr" rid="bib44">Goldsmith et al., 2020</xref> introduce a robotic platform; <xref ref-type="bibr" rid="bib62">Lobato-Rios et al., 2022</xref>, <xref ref-type="bibr" rid="bib94">Wang-Chen et al., 2023</xref>, and <xref ref-type="bibr" rid="bib92">Vaxenburg et al., 2024</xref> develop virtual fly simulations in a physics engine. Walking behavior in these models is also driven by coupled oscillators with tuned parameters that reproduce inter-leg coordination patterns; however, the resultant joint kinematics are typically unrealistic. The third approach uses normative learning and optimization to generate walking behaviors de novo. <xref ref-type="bibr" rid="bib73">Ramdya et al., 2017</xref> maximized fly walking speed by varying inter-leg coordination with a genetic algorithm, whereas (<xref ref-type="bibr" rid="bib46">Heess et al., 2017</xref>) maximized walking speed in both bipedal and quadruped walkers with reinforcement learning. Normative models produce walking with varying degrees of realism, but they require a clever selection of objectives with constraints and are computationally expensive. Furthermore, any change in delay values would require a computationally intensive retraining process. Notably, <xref ref-type="bibr" rid="bib41">Geijtenbeek et al., 2013</xref> include fixed sensorimotor delays in a bipedal model, but do not explore the effect of varying delay values. Overall, existing walking models focus on either kinematic or physiological accuracy, but few achieve both, and none consider the effect of varying sensorimotor delays.</p><p>Here, we develop a new, interpretable, and generalizable model of fly walking, which we use to investigate the impact of varying sensorimotor delays in <italic>Drosophila</italic> locomotion. The model features several key innovations. First, the model is trained on high-resolution 3D joint angle data from walking flies, which has only recently become possible due to new deep learning-based computer vision tools (<xref ref-type="bibr" rid="bib54">Karashchuk et al., 2021</xref>). Second, the model’s multi-layered architecture achieves more than the sum of its parts: specifically, a neural network model recapitulates kinematic coordination of many joints, and an optimal controller allows the data-driven model to generalize to new scenarios (e.g. large delays and perturbations) without retraining. Third, the inclusion of delay as a tunable parameter allows us to systematically investigate the quantitative relationships between sensorimotor delays and robust walking. Fourth, we introduce a new method to quantitatively compare the kinematic similarity of real and simulated walking. Overall, these analyses suggest that neuromuscular delays limit how fast flies can walk while retaining robustness to unexpected perturbations. They also illustrate a general approach to use in silico experiments with virtual animals to investigate how fundamental physiological parameters constrain animal behavior.</p></sec><sec id="s2" sec-type="results"><title>Results</title><sec id="s2-1"><title>A kinematic model of fly walking that incorporates delays and accommodates perturbations</title><p>We designed a walking model with three functional layers (<xref ref-type="fig" rid="fig1">Figure 1B</xref>), inspired by the hierarchical anatomical organization of the fly nervous system (<xref ref-type="fig" rid="fig1">Figure 1A</xref>, <xref ref-type="bibr" rid="bib30">Dallmann et al., 2021</xref>). The three layers are an inter-leg <italic>phase coordinator</italic>, a <italic>trajectory generator</italic>, and an <italic>optimal controller</italic> that interfaces with a leg dynamics model. Each individual leg is modular and governed by its own dynamics, optimal controller, and trajectory generator. Inter-leg coordination is accomplished by the phase coordinator alone. In other words, the movement of each leg is not coupled to any other leg except through the phase of its current step cycle. This modularity is inspired by the segmental neuroanatomy of the VNC, in which each leg is controlled by distinct local premotor circuits and pools of motor neurons (<xref ref-type="bibr" rid="bib59">Lesser et al., 2024</xref>; <xref ref-type="bibr" rid="bib22">Cheong et al., 2024</xref>). While the model is inspired by neuroanatomy, its components do not strictly correspond to components of the nervous system—the construction of a neuroanatomically accurate model is deferred to future work (see Discussion).</p><fig id="fig1" position="float"><label>Figure 1.</label><caption><title>A layered model of fly walking that incorporates link-and-joint dynamics and sensorimotor delays.</title><p>(<bold>A</bold>) The neural systems that control walking are hierarchically organized. The brain sends high-level commands (e.g. walking speed and direction) to the ventral nerve cord (VNC). Approximately 70 motor neurons (MNs, <xref ref-type="bibr" rid="bib10">Azevedo et al., 2024</xref>) control each leg. The cell bodies and dendrites of the MNs are in the VNC, and their axons innervate muscles in the leg. Each leg muscle is actuated, after some delay, following activation by one or more motor neurons. Sensorimotor circuits in the VNC also receive delayed sensory feedback via proprioceptors. (<bold>B</bold>) Multi-layered walking model architecture. Body-world interactions are mediated by a dynamics model. Proprioceptive feedback consists of joint angles and angular velocities (<xref ref-type="bibr" rid="bib64">Mamiya et al., 2018</xref>). Each leg has an optimal controller operating at 600 Hz that interfaces with the dynamics model and a trajectory generator that generates realistic kinematics. The trajectory generator is learned from data and operates at 300 Hz. It interfaces with the phase coordinator, a Kuramoto oscillator that maintains inter-leg coupling. The trajectory generator and optimal controller mimic local circuits within each leg, so they do not interact with other legs. Phase coupling is the only information shared between all legs. (<bold>C</bold>) Dynamics model of a fly leg, derived from link-and-joint models and Euler-Lagrange equations. (<bold>D</bold>) Schematic of model training and execution process. Model parameters for each module are tuned independently, then the modules are assembled to generate walking with delays and in response to unexpected perturbations.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-fig1-v1.tif"/></fig><p>Each layer in the model is an abstraction for the layer below it, such that various elements of walking (e.g. joint control, inter-leg coordination) can be integrated through modules. Below, we describe each modular component of our model; more details on its derivation and implementation are elaborated in the Methods and materials and Appendices. Although the model can turn and side-step, our analysis focuses on forward-walking — the model is driving the fly to walk straight in all simulations, unless otherwise stated.</p></sec><sec id="s2-2"><title>Inter-leg phase coordinator</title><p>To coordinate multi-legged walking, we modeled the step phase of each leg as an oscillator. We refer to the left and right legs as L1–3 and R1–3, respectively, where the front legs are L1 and R1. The phase coupling of the six-leg oscillators establishes realistic inter-leg coordination. We use a Kuramoto oscillator model (<xref ref-type="bibr" rid="bib2">Acebrón et al., 2005</xref>; <xref ref-type="bibr" rid="bib84">Strogatz, 2000</xref>) to perform this coordination, as in <xref ref-type="bibr" rid="bib72">Proctor and Holmes, 2018</xref>; equations and implementation details are in Methods and materials. Briefly, the phase coordinator takes the instantaneous phases <inline-formula><mml:math id="inf1"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>ϕ</mml:mi></mml:mstyle></mml:math></inline-formula> from all legs as input, then outputs the desired phases <inline-formula><mml:math id="inf2"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:msub><mml:mi>ϕ</mml:mi><mml:mrow class="MJX-TeXAtom-ORD"><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mstyle></mml:math></inline-formula> to all legs. These desired phases are synchronized across pairs of legs to maintain a tripod coordination pattern, even when subject to unpredictable perturbations. We estimated the phase coupling coefficient among legs from measured 3D joint kinematics of walking flies (<xref ref-type="bibr" rid="bib54">Karashchuk et al., 2021</xref>). Without the phase coordinator, individual trajectory generators would generate realistic kinematics for each leg, but they would not be coordinated with each other.</p></sec><sec id="s2-3"><title>Joint kinematics trajectory generator</title><p>The trajectory generator layer is responsible for producing realistic 3D joint kinematics of each leg. To express the relationships among all leg joint angles, we use an artificial neural network trained to generate angle trajectories. The modular design makes it possible to train trajectory generators separately from the inter-leg phase coordinator and optimal controller. Ultimately, the optimal controller integrates desired angle trajectories with proprioceptive joint angle feedback to output joint torques to the physical model of each leg.</p><p>As illustrated schematically in <xref ref-type="fig" rid="fig1">Figure 1B</xref>, the inputs to the trajectory generator module are desired leg phase <inline-formula><mml:math id="inf3"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>ϕ</mml:mi><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula>, joint angles <inline-formula><mml:math id="inf4"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>θ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, joint angular velocities <inline-formula><mml:math id="inf5"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>, and walking speed and direction of the fly. The trajectory generator then outputs the leg phase velocity <inline-formula><mml:math id="inf6"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>ϕ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula> and desired angular accelerations <inline-formula><mml:math id="inf7"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>¨</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula>. This output is integrated to produce the desired angle and angular velocities <inline-formula><mml:math id="inf8"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:msub><mml:mi>θ</mml:mi><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub><mml:mo>,</mml:mo><mml:msub><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>, which are the inputs to the optimal controller.</p><p>To train the network from data, we used joint kinematics of flies walking on a spherical treadmill, obtained from tracking 3D joint angles with Anipose (<xref ref-type="bibr" rid="bib54">Karashchuk et al., 2021</xref>). Details on training approach and network properties are described in Methods and materials. The walking speed and directions are signals that are not generated from other modules of the model, but are instead external inputs to the trajectory generator computed from the data; biologically, these signals are analogous to descending signals from the fly brain (<xref ref-type="bibr" rid="bib77">Simpson, 2024</xref>). This organization is motivated by the observation that walking velocity and direction have a substantial effect on joint angles, but they do not have a substantial effect on the parameters and outputs of the phase coordinator (e.g. phase offsets), as substantiated in Appendix 1.</p><p>After training and when assembled with the other layers of the model, the trajectory generator receives proprioceptive information on the observed, current state of the leg <inline-formula><mml:math id="inf9"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mi>θ</mml:mi><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>, as well as the target desired phase <inline-formula><mml:math id="inf10"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>ϕ</mml:mi><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> from the phase coordinator. Thus, it generates a time series of desired angles and angular velocities for some future interval and sends this time series <inline-formula><mml:math id="inf11"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>¨</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> to the controller; it also estimates the current phase velocity <inline-formula><mml:math id="inf12"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow class="MJX-TeXAtom-ORD"><mml:mover><mml:mi>ϕ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mstyle></mml:math></inline-formula> of the leg, which is passed to the phase coordinator.</p><p>In the absence of external perturbations, the trajectory generator produces realistic joint angles similar to those of walking flies, as we show below. When challenged with unpredictable external perturbations, the impact on the trajectory generator is mitigated by the optimal controller layer, which attempts to return the actual state to the desired state. This control is possible because the controller operates at a higher temporal frequency than the trajectory generator in the model. The controller can perform many iterations (and reject disturbances) in between updates to and from the trajectory generator. We emphasize that all data used to train the trajectory generator came from experimental conditions without external perturbations.</p></sec><sec id="s2-4"><title>Control and dynamics</title><p>The optimal controller layer maintains walking kinematics in the presence of sensorimotor delays and helps compensate for external perturbations. This design was inspired by optimal control-based models of movements in humans (<xref ref-type="bibr" rid="bib89">Todorov and Jordan, 2002</xref>; <xref ref-type="bibr" rid="bib76">Scott, 2004</xref>; <xref ref-type="bibr" rid="bib17">Berret et al., 2011</xref>). At regular intervals, the controller receives a short time series of desired state trajectories <inline-formula><mml:math id="inf13"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>θ</mml:mi><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> from the trajectory generator layer. The controller then produces the necessary torques <inline-formula><mml:math id="inf14"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>τ</mml:mi></mml:mstyle></mml:math></inline-formula> to track this trajectory for the given leg dynamics. External perturbations <inline-formula><mml:math id="inf15"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>w</mml:mi></mml:mstyle></mml:math></inline-formula>, when present, enter through the dynamics and affect the state <inline-formula><mml:math id="inf16"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mi>θ</mml:mi><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>; the controller then senses the state and responds accordingly.</p><p>To design the controller, we first derived dynamical equations for each leg using link-and-joint models (<xref ref-type="fig" rid="fig1">Figure 1C</xref>), then linearized these dynamics and designed a linear quadratic regulator (LQR) controller. This optimal controller senses the state of the leg via proprioceptive input, then determines the optimal motor output for walking. The controller makes use of internal predictive states to accommodate sensory and motor delays. A detailed description of the controller derivations can be found in Methods and materials. We note that the walking and compensation capabilities of the full models are not contingent upon any specific dynamics or controller formulation; any controller that adequately tracks the trajectory generator would suffice.</p></sec><sec id="s2-5"><title>The model generates realistic walking kinematics</title><p>The layered model generates 3D walking kinematics that resemble real kinematic data from walking flies (<xref ref-type="fig" rid="fig2">Figure 2</xref>). Below, we provide qualitative and quantitative comparisons of joint angles, joint angular velocities, and phases of walking both within and across legs.</p><fig id="fig2" position="float"><label>Figure 2.</label><caption><title>Walking model simulations produce realistic joint kinematics.</title><p>(<bold>A</bold>) Example time series of femur-tibia flexion (<bold>R1</bold>) and femur rotation (<bold>L2</bold>) for three different walking speeds: 8, 10, and 12 mm/s. Real data (orange) exhibited more variability than simulations (blue). (<bold>B</bold>) Angle vs. computed per-leg phase of femur-tibia flexion on leg R1 and femur rotation on leg L2 for four different walking speeds. Each plot contains data from 4 walking bouts with different initial conditions. (<bold>C</bold>) Average differences between model simulations and data, over a range of forward walking, turning, and side-stepping speeds over 500 distinct bouts. The dotted line (5.56 degrees) indicates uncertainty associated with markerless 3D joint tracking (<xref ref-type="bibr" rid="bib54">Karashchuk et al., 2021</xref>). All simulations used a sensory delay of 10 ms and a motor delay of 30 ms, based on values measured experimentally with electrophysiology from leg sensory and motor neurons/muscles (<xref ref-type="bibr" rid="bib91">Tuthill and Wilson, 2016b</xref>; <xref ref-type="bibr" rid="bib9">Azevedo et al., 2020</xref>).</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-fig2-v1.tif"/></fig></sec><sec id="s2-6"><title>Qualitative evaluation of joint angle time series and videos of walking kinematics</title><p>We first qualitatively compared simulated and real kinematics by examining time series data and videos. In example trajectories of femur-tibia flexion angles of the right front and femur rotation angles of the left middle legs, the simulated time series matched the mean, frequency, and pseudo-triangular shape of the fly data (<xref ref-type="fig" rid="fig2">Figure 2A</xref>). Articulated animations of simulated and real trajectories are shown in <xref ref-type="video" rid="video1">Videos 1</xref>–<xref ref-type="video" rid="video3">3</xref>. Although the model and data were largely similar, some differences stood out. For example, the simulated amplitudes were generally smaller than the real amplitudes, and the simulated trajectories tended to be more regular.</p><media mimetype="video" mime-subtype="mp4" xlink:href="elife-99005-video1.mp4" id="video1"><label>Video 1.</label><caption><title>Model generates forward walking similar to real flies.</title><p>Shown is an example comparison of real and simulated fly walking kinematics, visualized on a fly model by inverse kinematics (no further physics simulation).</p></caption></media><media mimetype="video" mime-subtype="mp4" xlink:href="elife-99005-video2.mp4" id="video2"><label>Video 2.</label><caption><title>Model generates forward walking that is visually similar to data.</title><p>(Top row) Example simulated 3D pose trajectories at 8, 10, 12, and 14 mm/s forward walking (0 mm/s turning and side speeds). (Bottom row) Example 3D pose trajectories from data at the same speeds for comparison. Note that we fix angle joints not included in the model.</p></caption></media><media mimetype="video" mime-subtype="mp4" xlink:href="elife-99005-video3.mp4" id="video3"><label>Video 3.</label><caption><title>Model generates walking with nonzero rotation and side speeds visually similar to the data.</title><p>(Top row) Example simulated 3D pose trajectories of fly walking with some nonzero side or rotation speed. Forward speed is 12 mm/s throughout. (Bottom row) Example 3D pose trajectories from data with similar speeds.</p></caption></media></sec><sec id="s2-7"><title>Comparing joint angles and angular velocities versus phase</title><p>We next sought to quantitatively compare simulated and real joint angles. Direct comparisons of time series trajectories are inadequate, because temporal offsets between time series produce large mismatches even if the time series are similar. For instance, if we shift a time series trajectory by a half-cycle and compare it with itself, this will produce a large mismatch, even though the two trajectories are identical except for a misalignment in phase.</p><p>To compare real and simulated trajectories, we computed the step-cycle phase for each time series and used this to plot the mean angles <inline-formula><mml:math id="inf17"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>θ</mml:mi></mml:mstyle></mml:math></inline-formula> as a function of phase (<xref ref-type="fig" rid="fig2">Figure 2B</xref>). Here, we make the distinction between the <italic>generated phase</italic>, the per-leg phases produced by the phase coordinator of the model, and <italic>computed phase</italic>, which can be computed for each joint from time series data. Since we did not have access to the generated, desired phase for real fly data, all comparisons were made between computed phases.</p><p>When we averaged joint angles for all legs over 500 distinct walking bouts of 0.5–2 s in duration, we found that the mean differences between real and simulated joint angles were less than 6 degrees (<xref ref-type="fig" rid="fig2">Figure 2C</xref>). This difference is comparable to the uncertainty associated with markerless tracking of 3D fly walking kinematics that we used as training data (5.56 degrees, from <xref ref-type="bibr" rid="bib54">Karashchuk et al., 2021</xref>). Errors for angular velocity were higher. Aggregate differences as a function of walking and turning velocity are shown in Appendix 4.</p><p>The similarity between real and simulated data as a function of phase was consistent across the natural range of forward walking speeds (<xref ref-type="fig" rid="fig2">Figure 2B</xref>). Plots for all legs and joints are shown in Appendices 3 and 4. We further demonstrate the model’s capacity to simulate leg kinematics by comparing the phase coupling of simulated joint kinematics with real walking flies, both within and across legs, in Appendix 5.</p></sec><sec id="s2-8"><title>Model maintains walking under unpredictable external perturbations</title><p>When walking in natural environments, animals frequently navigate uneven or slippery terrain. Thus, robust sensorimotor control systems must detect and respond to such unexpected perturbations in order to maintain stable locomotion.</p><p>Here, we show that our model maintains realistic walking in the presence of external dynamic perturbations, despite being trained only on data of walking without perturbations (no perturbation data was available). This performance is made possible by the combination of the trajectory generator and the optimal controller in the model. Taking advantage of proprioceptive feedback, the optimal controller compensates for external perturbations, allowing the trajectory generator to sustain realistic joint angle trajectories.</p><p>We considered two types of perturbations: impulse and persistent stochastic. Impulse perturbations are analogous to when an animal experiences a brief, unexpected motion (e.g. legs slipping on an unstable surface). We simulated impulse perturbations as a velocity that is added to all joints at a single time (i.e. a single time step in our simulation). The magnitude of this velocity was drawn from a normal distribution for each joint, where increasing perturbation strength increases the mean and variance of this distribution. The sign of the velocity was drawn separately so that there is an equal likelihood for negative or positive perturbation velocities. Persistent stochastic perturbations displaced all legs, but not at the same time. We applied perturbations following a Poisson process with a mean rate of 10 Hz; in other words, over a period of time (1 s), for each leg at each timestep, we randomly selected whether an impulse perturbation should be applied based on a Poisson distribution. Ranges of perturbation strengths used in our simulation correspond to estimates of biologically plausible values (as derived in Appendix 6).</p><p>To evaluate the model’s ability to walk in the presence of perturbations, we compared time series data before, during, and after perturbations across a range of walking speeds (<xref ref-type="fig" rid="fig3">Figure 3B–C</xref>). For both types of perturbation, joint angle trajectories were different during perturbations, but recovered after the perturbation period ended. In the case of persistent stochastic perturbations, kinematics appeared approximately oscillatory even during perturbations, indicating that a semblance of walking was maintained.</p><fig id="fig3" position="float"><label>Figure 3.</label><caption><title>The model sustains robust walking during and following perturbations.</title><p>(<bold>A</bold>) Schematic of how perturbations are applied to the walking model. (<bold>B, C</bold>) Example time series of femur-tibia flexion on leg R1 and femur rotation on leg L2 for three different walking speeds (8, 10, and 12 mm/s) before, during, and after perturbation. In panel B, an impulse perturbation of size 3.75 rad/s is applied at a single instant (dotted line), and its effects are analyzed over a brief time window (shaded blue area). In panel C, stochastic perturbations of size 1.875 rad/s are applied over a time window (shaded green area). Angle trajectories are visibly different during the analysis windows, but recover afterward. Perturbation effects appear similar across speeds. All simulations used a sensory delay of 10 ms and a motor delay of 30 ms.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-fig3-v1.tif"/></fig><p>Example animations of simulated walking bouts with perturbations are shown in <xref ref-type="video" rid="video4">Videos 4</xref>–<xref ref-type="video" rid="video7">7</xref>.</p><media mimetype="video" mime-subtype="mp4" xlink:href="elife-99005-video4.mp4" id="video4"><label>Video 4.</label><caption><title>Model generates robust walking under impulse perturbation with varying motor delays.</title><p>Shown are example simulated 3D pose trajectories of fly walking with 10 ms sensory delay and varying motor delays. Below are mean kinematic similarity values during the perturbation.</p></caption></media><media mimetype="video" mime-subtype="mp4" xlink:href="elife-99005-video5.mp4" id="video5"><label>Video 5.</label><caption><title>Model generates robust walking under persistent stochastic perturbation with varying motor delays.</title><p>Shown are example simulated 3D pose trajectories of fly walking with 10 ms sensory delay and varying motor delays. Below are mean kinematic similarity values during the perturbation.</p></caption></media><media mimetype="video" mime-subtype="mp4" xlink:href="elife-99005-video6.mp4" id="video6"><label>Video 6.</label><caption><title>Model generates robust walking under impulse perturbation with varying sensory delays.</title><p>Shown are example simulated 3D pose trajectories of fly walking with 30 ms motor delay and varying sensory delays. Below are mean kinematic similarity values during the perturbation.</p></caption></media><media mimetype="video" mime-subtype="mp4" xlink:href="elife-99005-video7.mp4" id="video7"><label>Video 7.</label><caption><title>Model generates robust walking under persistent stochastic perturbation with varying sensory delays.</title><p>Shown are example simulated 3D pose trajectories of fly walking with 30 ms motor delay and varying sensory delays. Below are mean kinematic similarity values during the perturbation.</p></caption></media><p>To quantify the extent to which perturbed kinematics resemble normal, unperturbed walking, we introduce a new quantitative metric termed <italic>kinematic similarity (KS</italic>). For a given window of a kinematic trajectory, KS is computed by the log-likelihood that it occurred in the real fly-walking data (illustrated in <xref ref-type="fig" rid="fig4">Figure 4A</xref> and detailed in Methods and materials). Briefly, we reduce the experimental data to 2 dimensions using principal components analysis (PCA), then fit a kernel density estimator (KDE) to the resulting distribution. We then project each bout of simulated walking onto this subspace and evaluate the KDE model to obtain a log probability density function estimate, which corresponds to the kinematic similarity of the simulated bout to real walking bouts in the data. Lower values of KS mean lower similarity to data. When we applied this method to bouts from experimental data, we found that the average KS of experimental data was –1.627. Thus, we use KS <inline-formula><mml:math id="inf18"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mo>&gt;</mml:mo><mml:mo>−</mml:mo><mml:mn>1.6</mml:mn></mml:mrow></mml:mstyle></mml:math></inline-formula> as a general threshold for evaluating the realism of joint angle trajectories.</p><fig id="fig4" position="float"><label>Figure 4.</label><caption><title>The walking model sustains realistic walking kinematics following impulse and persistent stochastic perturbations.</title><p>(<bold>A</bold>) Method for computing kinematic similarity between real data and simulated walking. First, the full set of experimental data (from flies) is used to compute a Gaussian kernel density estimator (KDE). To quantify the similarity (to data) of a given bout of simulated walking, we apply the KDE to evaluate the log probability density function of each bout, a scalar value we refer to as kinematic similarity (KS). High KS indicates that the perturbed walking resembles the unperturbed walking from data, while low KS indicates that the perturbed walking deviates from data and results in unnatural angles (as seen at 40 ms motor delay). The average KS value of bouts from experimental data was –1.627. (<bold>B, C</bold>) Kinematic similarity of simulated walking during perturbations for impulse and persistent stochastic perturbations. For each square of the heatmap, four simulations with different initial conditions were simulated and averaged. Simulations became less similar to data with increased perturbation strength. All simulations used a sensory delay of 10 ms and a motor delay of 30 ms. Perturbation velocities were drawn from a random uniform distribution with mean <italic>perturbation strength</italic> (rad/s) and standard deviation of 0.1 × mean.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-fig4-v1.tif"/></fig><p>As expected, larger perturbations led to walking behaviors with lower KS, and KS was not strongly dependent on forward walking speed (<xref ref-type="fig" rid="fig4">Figure 4B–C</xref>). For persistent stochastic perturbations, the model produced realistic joint angle trajectories (KS <inline-formula><mml:math id="inf19"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mo>&gt;</mml:mo><mml:mo>−</mml:mo><mml:mn>1.6</mml:mn></mml:mstyle></mml:math></inline-formula>) for all simulated perturbation strengths. Impulse perturbations appeared to be more challenging for the model, as they resulted in lower KS. From the time series, we observed that impulse perturbations resulted in greater instantaneous deviation from the standard waveform than persistent stochastic perturbations of the same magnitude. This is due to the fact that impulse perturbations produce simultaneous changes to all legs and joints, whereas persistent stochastic perturbations are spread out in time and typically non-simultaneous.</p></sec><sec id="s2-9"><title>Effect of sensory and motor delays on walking</title><p>Temporal delays are inherent properties of sensorimotor control systems, but they are difficult to manipulate experimentally (<xref ref-type="bibr" rid="bib13">Bässler, 1993</xref>). Therefore, we used our model to investigate how changing sensory and motor delays affect locomotor robustness. We used measurements from the literature to estimate physiological delays for leg sensory and motor neurons in the <italic>Drosophila</italic> leg. Our estimate of sensory delay (5–15 ms) was based on the measured delay from spike initiation in a mechanosensory neuron in the <italic>Drosophila</italic> femur to the peak of an excitatory postsynaptic potential in a postsynaptic VNC neuron (<xref ref-type="bibr" rid="bib91">Tuthill and Wilson, 2016b</xref>). Our estimate of motor delay (20–40 ms) was based on the time between spike initiation in a tibia motor neuron cell body to the onset of muscle force production, measured with a force probe (<xref ref-type="bibr" rid="bib9">Azevedo et al., 2020</xref>).</p><p>Without external perturbations, the model produced realistic walking with arbitrary delays, since the controller can effectively compensate for large delays by using predictions of joint angles in the future. However, in the presence of external perturbations and high delay values, the model was unable to maintain realistic walking, since it could not respond rapidly enough to unexpected perturbations. Here, we consider the composite effects of persistent stochastic perturbations with motor and sensor delays. Similar results for impulse perturbations are included in Appendix 7.</p><p>We first fixed the sensory delay at 10 ms and measured the effect of varying motor delays. Examining the time series data, we found that for low values of motor delay (10 ms, 20 ms), even stronger perturbations had almost no effect (<xref ref-type="fig" rid="fig5">Figure 5A</xref>). However, at higher values of motor delay, the effects of the same perturbation became more pronounced, although the model still managed to recover after the perturbations ended. Over a range of perturbation strengths and walking speeds, the model maintained realistic walking (KS <inline-formula><mml:math id="inf20"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mo>&gt;</mml:mo><mml:mo>−</mml:mo><mml:mn>1.6</mml:mn></mml:mstyle></mml:math></inline-formula>) up to about 30 ms of motor delay (<xref ref-type="fig" rid="fig5">Figure 5C</xref>). This value is consistent with motor delays measured from the fruit fly leg, where the time between motor neuron spiking to the onset of muscle force production is about 30 ms (<xref ref-type="bibr" rid="bib9">Azevedo et al., 2020</xref>).</p><fig id="fig5" position="float"><label>Figure 5.</label><caption><title>The model maintains robust walking under persistent stochastic perturbations over specific ranges of motor and sensory delays.</title><p>(<bold>A, B</bold>) Example time series of femur-tibia flexion on leg R1 and femur rotation on leg L2 under various values of motor (10, 20, 30, 40 ms) and sensory delay (0, 5, 10, 15 ms). Perturbation effects became more noticeable with increasing delay values. (<bold>C, D, E</bold>) Similarity of during-perturbation walking to data across delay values, perturbation strengths, and forward speeds. For each square of the heatmap, four simulations with different initial conditions were simulated and evaluated. At low delay values, simulated walking maintained high similarity even under large perturbations. As perturbation strength and delays increased, simulated walking became less similar to data; the effect was more pronounced with increased delays. When we fixed one delay value and varied the other, the model maintained realistic walking (KS &gt; – 1.6) up to about 30 ms of motor delay and 10 ms of sensory delay across a range of conditions. When we allowed both motor and sensory delay to vary, the model maintained realistic walking when the sum of the delays was no more than about 45 ms. (<bold>F</bold>) Post-perturbation walking with motor and sensory delays. The model was unable to recover from perturbations for large delay values. Unless otherwise stated, forward speed = 12 mm/s, and perturbation strength = 1.875 rad/s.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-fig5-v1.tif"/></fig><p>Next, we fixed the motor delay at 30 ms and observed the effect of varying sensory delays. From time series data, we found that even at low values of sensory delay (0 ms, 5 ms), the effects of perturbations on model output were significant (<xref ref-type="fig" rid="fig5">Figure 5B</xref>). When sensory delay increased, the effects of the perturbation became more pronounced. Over a range of perturbation strengths and walking speeds, the model maintained realistic walking (KS <inline-formula><mml:math id="inf21"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mo>&gt;</mml:mo><mml:mo>−</mml:mo><mml:mn>1.6</mml:mn></mml:mrow></mml:mstyle></mml:math></inline-formula>) up to about 10 ms of sensory delay (<xref ref-type="fig" rid="fig5">Figure 5D</xref>). This range is consistent with experimental estimates of delays from mechanosensory neurons in the fly femur (<xref ref-type="bibr" rid="bib91">Tuthill and Wilson, 2016b</xref>), although delays could be even longer for more distal sensors. For example, a sensory neuron at the tip of the tarsus would take ∼20 ms to travel 2 mm at an estimated conduction velocity of ∼0.3 m/s (<xref ref-type="bibr" rid="bib91">Tuthill and Wilson, 2016b</xref>).</p><p>For any fixed set of values of motor and sensory delays, the KS of perturbed walking was not dependent on forward walking speed. In other words, slower walking did not improve the model’s ability to sustain walking during perturbations (<xref ref-type="fig" rid="fig5">Figure 5C and D</xref>). We expand on this observation in the Discussion.</p><p>Last, we explored combinations of values for motor and sensory delays for fixed walking speed and perturbation strength. We observed that robust walking was not contingent on the specific values of motor and sensory delay, but rather the <italic>sum</italic> of these two values (<xref ref-type="fig" rid="fig5">Figure 5E</xref>). Furthermore, as total delay increased, higher frequencies of walking were impacted first before walking collapsed entirely (Appendix 9). Overall, in order for the model to overcome a perturbation, the key parameter was the total delay between the perturbation onset and the motor response.</p><p>In summary, we used a virtual fly model of walking to perform in silico manipulations of sensory and motor delays, including delays exceeding physiologically-realistic values. When we tested the model across a range of delay values, we found that the model was able to maintain robust walking only within the physiological range. Outside of this range, the model could not maintain walking that was kinematically similar to real flies. This finding suggests that the fly locomotor control system operates close to the temporal limit at which it can detect and respond to external perturbations. Thus, we propose that sensory and motor delays establish a fundamental tradeoff between the speed and robustness of fly walking.</p></sec></sec><sec id="s3" sec-type="discussion"><title>Discussion</title><p>In this paper, we develop a computational model that realistically imitates the 3D joint kinematics of walking <italic>Drosophila</italic> and incorporates sensorimotor delay as a tunable parameter. We then used the model to establish a quantitative relationship between sensorimotor delays and locomotor robustness. We found that the model’s ability to maintain walking following external perturbations significantly degrades for delay values that exceed known physiological values, suggesting that these parameters are fundamental constraints on fly locomotion. The formulation of a modular, multi-layered model for locomotor control makes new experimentally testable hypotheses about fly motor control and can also be applied to investigate limbed locomotion in other organisms. Future extensions of the model to improve its realism may include premotor neural circuits from the fly connectome (<xref ref-type="bibr" rid="bib59">Lesser et al., 2024</xref>; <xref ref-type="bibr" rid="bib22">Cheong et al., 2024</xref>) and biomechanical interactions between the limb and the environment (<xref ref-type="bibr" rid="bib62">Lobato-Rios et al., 2022</xref>; <xref ref-type="bibr" rid="bib94">Wang-Chen et al., 2023</xref>; <xref ref-type="bibr" rid="bib92">Vaxenburg et al., 2024</xref>).</p><sec id="s3-1"><title>Fundamental constraints on locomotion imposed by sensory and motor delays</title><p>Sensory and motor delays are inextricable properties of animal locomotor systems. To study the impact of delays on locomotor control, we developed a hierarchical walking model with explicit inclusion of physiological delays as tunable parameters. Importantly, the model incorporates delay while preserving behavioral realism, laying the groundwork for future studies on the effect of delay on other aspects of locomotion and sensorimotor control.</p><p>Our model predicts that at the same perturbation magnitude, walking robustness decreases as delays increase. This could be experimentally tested by altering conduction velocities on the fly, for example by increasing or decreasing the ambient temperature (<xref ref-type="bibr" rid="bib11">Banerjee et al., 2021</xref>). If a warmer ambient temperature decreases delays in the fly, but fly walking robustness remains the same in response to a fixed perturbation, this would indicate a stronger role for central control in walking than our modeling results suggest.</p><p>Trade-offs between energy, performance, and robustness establish fundamental constraints on animal locomotion. It is energetically expensive to build and maintain muscles and neurons that operate with low delay (<xref ref-type="bibr" rid="bib82">Sterling, 2015</xref>). From a performance perspective, long delays limit reaction speed and control robustness, which can ultimately impact animal survival (<xref ref-type="bibr" rid="bib66">More and Donelan, 2018</xref>). A third consideration is locomotor robustness, or the capacity to detect and respond to external perturbations. In flies, the axons of leg motor neurons and some proprioceptor axons are among the largest diameter cables in the leg nerve (<xref ref-type="bibr" rid="bib70">Phelps et al., 2021</xref>), suggesting that the speed of these systems is under selective pressure.</p><p>Our model suggests that fly walking operates in a middle ground with respect to speed and robustness. Specifically, our model maintains normal walking for up to about 30 ms of motor delay and 10 ms of sensory delay. These values are strikingly close to measured values from <italic>Drosophila</italic>: 30 ms from motor neuron spike to peak force production in a femur muscle (<xref ref-type="bibr" rid="bib9">Azevedo et al., 2020</xref>) and 6ms from a femoral mechanosensory neuron spike to the onset of a postsynaptic response in the VNC (<xref ref-type="bibr" rid="bib91">Tuthill and Wilson, 2016b</xref>).</p><p>In our model, robust locomotion was constrained by the cumulative sensorimotor delay. This result could be experimentally validated by comparing how animals with different ratios of sensory to motor delays respond to perturbations. Alternatively, it may be possible to manipulate sensory vs. motor delays in a single animal, perhaps by altering the development of specific neurons or ensheathing glia (<xref ref-type="bibr" rid="bib57">Kottmeier et al., 2020</xref>). If sensory and motor delays have significantly different effects on walking quality, then additional compensatory mechanisms for delays could play a larger role than we expect, such as prediction through sensory integration, mechanical feedback, or compensation through central control. A rich and related topic for future exploration is the interaction of delays with body size and behavioral ecology. Longer limbs, heavier bodies, and more mechanically complex tasks may alter the tradeoffs between energetics, speed of force generation, noise, and robust sensorimotor control (<xref ref-type="bibr" rid="bib58">Labonte et al., 2024</xref>; <xref ref-type="bibr" rid="bib85">Sutton et al., 2023</xref>).</p></sec><sec id="s3-2"><title>Role of proprioceptive feedback in fly walking</title><p>Our model provides insight into the role of proprioceptive feedback in fly walking, which remains an active area of research (<xref ref-type="bibr" rid="bib30">Dallmann et al., 2021</xref>). Many models of fly walking ignore the role of feedback, relying instead on central pattern generators (<xref ref-type="bibr" rid="bib62">Lobato-Rios et al., 2022</xref>; <xref ref-type="bibr" rid="bib86">Szczecinski et al., 2018</xref>; <xref ref-type="bibr" rid="bib3">Aminzare et al., 2018</xref>) or metachondral waves (<xref ref-type="bibr" rid="bib32">DeAngelis et al., 2019</xref>) to model kinematics. Some models incorporate proprioceptive feedback, primarily as a mechanism that alters timing of movements in inter-leg coordination (<xref ref-type="bibr" rid="bib44">Goldsmith et al., 2020</xref>; <xref ref-type="bibr" rid="bib94">Wang-Chen et al., 2023</xref>). Experimental work in cockroaches suggests that these fast-running insects rely on central control and mechanical feedback, particularly at high speeds (<xref ref-type="bibr" rid="bib26">Couzin-Fuchs et al., 2015</xref>; <xref ref-type="bibr" rid="bib8">Ayali et al., 2015b</xref>). In contrast, studies in stick insects have shown that these slow-walking animals are highly dependent on proprioceptive feedback for leg coordination during walking (<xref ref-type="bibr" rid="bib12">Bässler, 1977</xref>; <xref ref-type="bibr" rid="bib7">Ayali et al., 2015a</xref>; <xref ref-type="bibr" rid="bib74">Schilling et al., 2013</xref>).</p><p>Silencing mechanosensory chordotonal neurons alters step kinematics in walking <italic>Drosophila</italic> (<xref ref-type="bibr" rid="bib65">Mendes et al., 2013</xref>; <xref ref-type="bibr" rid="bib71">Pratt et al., 2024</xref>). Additionally, removing proprioceptive signals via amputation interferes with inter-leg coordination in flies at low walking speeds (<xref ref-type="bibr" rid="bib15">Berendes et al., 2016</xref>). However, the role of leg proprioception in overcoming external perturbations has not previously been studied in flies. In our model, which does not include limb compliance or other biomechanical adaptations, the fly effectively overcomes perturbations using only proprioceptive feedback. The need for proprioception to compensate for perturbations may be reduced when biomechanical mechanisms are present. Nonetheless, we hypothesize that removing proprioceptive feedback would impair an insect’s ability to sustain locomotion following external perturbations.</p></sec><sec id="s3-3"><title>Predictive control is critical for responding to perturbations due to motor delay</title><p>Sustaining realistic walking kinematics in the presence of perturbations and motor delays is a challenging task for any model. In our model, this design criterion motivated us to develop a compensatory prediction in the optimal controller formulation, based on <xref ref-type="bibr" rid="bib81">Stenberg et al., 2022</xref>. The controller compensates for the known motor delay by predicting future dynamics. We found that the model was quite sensitive to the <italic>prediction horizon</italic>, i.e., how far into the future the controller predicts. The model works best when the controller’s prediction horizon matches the motor delay — we thus used matched values in all simulations. We experimented with altering the prediction horizon to be less than the motor delay, with catastrophic consequences: the model ceased walking and mostly produced noise (not shown). From this observation, we deduce that future predictions are crucial in compensating for motor delays in our walking model, in agreement with previous theoretical work on predictive or ‘forward’ models for sensorimotor control (<xref ref-type="bibr" rid="bib33">Desmurget and Grafton, 2000</xref>; <xref ref-type="bibr" rid="bib60">Li et al., 2023</xref>). We propose that fly motor circuits may encode predictions of future joint positions, so the fly may generate motor commands that account for motor neuron and muscle delays. Consistent with this hypothesis, <xref ref-type="bibr" rid="bib31">Dallmann et al., 2023</xref> recently found that descending motor commands from the brain excite GABAergic interneurons in the VNC that inhibit velocity-encoding proprioceptors. Thus, some proprioceptive feedback signals from the fly leg are predictively suppressed during self-generated movements.</p></sec><sec id="s3-4"><title>Layered model produces robust walking and facilitates local control</title><p>One key finding of our model is that robust walking in the presence of external perturbations can emerge from a local controller in combination with a trajectory generator that is trained only on perturbation-free walking data. We did not model adaptation because compensation emerges as a property of a tuned controller with feedback. The success of this simple, layered model suggests that fast, robust locomotion could be maintained locally, requiring minimal plasticity within central circuits.</p><p>Layering is a familiar concept in network architecture and hardware/software stacks (<xref ref-type="bibr" rid="bib23">Chiang et al., 2007</xref>) and has recently found applications as a modeling framework in biology and neuroscience (<xref ref-type="bibr" rid="bib34">Doyle and Csete, 2011</xref>; <xref ref-type="bibr" rid="bib67">Nakahira et al., 2021</xref>). In our model, the complex problem of multi-legged locomotion is broken down into three sub-problems (delayed control, joint kinematic generation, inter-leg coordination), each of which is delegated to a different layer.</p><p>Each layer provides an abstracted interface for the layer below it, which can also be thought of as a special case of modularity. The separation of function between layers reinforces that robust locomotion can be produced by local (i.e. per-leg) control signals. Per-leg modules could also be extended to control more legs, generalizing to locomotor control in isopods and millipedes. Instead of redesigning the overall coordination and locomotor control circuits, basic duplication and subsequent fine-tuning may be sufficient.</p><p>Beyond walking, our layered model framework could be applied to other animals with other locomotor strategies, including flying, swimming, slithering, and digging. The key ingredients required for the model are: (1) a functional inter-limb coordinator, (2) sufficient 3D kinematics data to train a trajectory-generator layer, and (3) a controller that adequately tracks the trajectory for some dynamical models of the animal. The dynamical model may be linearized (as we did here) and controlled with a standard controller; other approaches include successive (per-timestep) linearization with linear model predictive control (MPC) (<xref ref-type="bibr" rid="bib14">Berberich et al., 2022</xref>), or fully nonlinear control techniques (<xref ref-type="bibr" rid="bib78">Slotine and Li, 1991</xref>).</p><p>The layered model approach also has potential applications for biomimetic robotic locomotion. For simplicity, we used a linearized link-and-joint dynamical model. However, one could also replace this dynamical model to control a hexapod robot such as in <xref ref-type="bibr" rid="bib43">Goldsmith, 2019</xref>. Due to its modular nature, the other modules (trajectory generator, inter-leg coordinator) would remain unchanged and the resulting model could, in theory, generate 3D kinematics for bio-mimetic walking on a robotic platform. Overall, the model can be thought of as performing a layered implementation of imitation learning, which is a popular technique in robotics (<xref ref-type="bibr" rid="bib48">Hua et al., 2021</xref>; <xref ref-type="bibr" rid="bib53">Johns, 2021</xref>).</p></sec><sec id="s3-5"><title>Towards biomechanical and neural realism</title><p>The goal of our model was to produce realistic 3D joint kinematics while incorporating sensory and motor delays. To achieve this, the model contains several physiological simplifications. First, our dynamics model did not allow dynamical coupling between legs through the mechanics of the body, as the legs are only coupled neurally through the phase coordinator. However, in real bodies, the legs are also dynamically coupled through the body and its weight distribution over the legs (<xref ref-type="bibr" rid="bib29">Dallmann et al., 2017</xref>). Our model also did not consider explicit leg-ground contact interactions. Rather, interactions with the ground were implicitly taken into account by the trajectories learned by the neural network, though they were not made explicit in the dynamics. Our goal was to mimic the kinematic trajectory, a problem known in robotics as <italic>motion control</italic>. However, including ground contact interactions would require computing ground contact forces, which are currently unavailable in the kinematics dataset we used.</p><p>In order to model ground contact forces and joint torques, force-based learning would need to be incorporated into the trajectory generator, requiring a new dataset or extrapolating force values (e.g. via a physics-based model). Furthermore, the controller would need to be reformulated to use <italic>impedance control</italic> or <italic>hybrid control</italic> techniques (<xref ref-type="bibr" rid="bib19">Buss et al., 2002</xref>; <xref ref-type="bibr" rid="bib4">Arevalo and Garcia, 2012</xref>; <xref ref-type="bibr" rid="bib75">Sciavicco and Siciliano, 2012</xref>). These approaches are common in robotics to deal with dynamics control problems, which concern both kinematic trajectories <italic>and</italic> external contact forces. The inclusion of explicit leg-ground contact interactions would also make it harder for the model to recover when perturbed, because perturbations during walking often occur upon contact with the ground (e.g. the ground is slippery or bumpy).</p><p>A promising avenue for future investigation is an integration of our controller architecture with a virtual physics model (<xref ref-type="bibr" rid="bib62">Lobato-Rios et al., 2022</xref>; <xref ref-type="bibr" rid="bib94">Wang-Chen et al., 2023</xref>; <xref ref-type="bibr" rid="bib92">Vaxenburg et al., 2024</xref>), which would facilitate the incorporation of dynamical coupling between legs, as well as leg-ground contact interactions. The inclusion of these features may require additional coordination between the legs, which might decrease allowable values of sensory and motor delay.</p><p>Another step toward biological realism is the incorporation of explicit dynamical models of proprioceptors, muscles, tendons, and other biomechanical aspects of the exoskeleton. The proprioceptive neurons in the femoral chordotonal organ of each fly leg encode angles and angular derivatives (<xref ref-type="bibr" rid="bib64">Mamiya et al., 2018</xref>). Additional proprioceptive feedback is provided by hair plate sensory neurons (limit detectors) and campaniform sensilla (load sensors), which are distributed across each leg (<xref ref-type="bibr" rid="bib90">Tuthill and Wilson, 2016a</xref>). Thus, our use of joint state <inline-formula><mml:math id="inf22"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>θ</mml:mi><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>, likely underestimates the resolution of proprioceptive feedback to the fly motor system. We anticipate that the increased sensory resolution from more detailed proprioceptor models and the stability from mechanical compliance of limbs in a more detailed biomechanical model would make the system easier to control and increase the allowable range of delay parameters. Conversely, we expect that modeling the nonlinearity and noise inherent to biological sensors and actuators may decrease the allowable range of delay parameters. In the stick insect, load-sensing campaniform sensilla appear to have greater conduction delays than movement-sensing proprioceptors in the femoral chordotonal organ (<xref ref-type="bibr" rid="bib40">Gebehart and Büschges, 2021</xref>). Future models may investigate how these different delays from different proprioceptive sensors impact sensorimotor control.</p><p>A further step towards neural realism would be to constrain the trajectory generator and optimal controller using patterns of synaptic connectivity within sensorimotor circuits of the fly VNC. This is now feasible using recent connectomes of the <italic>Drosophila</italic> VNC (<xref ref-type="bibr" rid="bib10">Azevedo et al., 2024</xref>; <xref ref-type="bibr" rid="bib87">Takemura, 2023</xref>). However, many challenges remain for connectome-constrained models, because many important physiological parameters are still unknown.</p><p>Future work may also model how higher-level planning of fly behavior interacts with the lower-level coordination of joint angles and legs. Walking flies continuously change their direction and speed as they navigate the environment (<xref ref-type="bibr" rid="bib55">Katsov et al., 2017</xref>; <xref ref-type="bibr" rid="bib52">Iwasaki et al., 2024</xref>). Past work shows that flies tend to recover and walk at similar speeds following perturbations (<xref ref-type="bibr" rid="bib32">DeAngelis et al., 2019</xref>), but individual flies might still change walking speed, phase coupling, or even transition to other behaviors, such as grooming. Modeling these higher-level changes in behavior would involve combining our sensorimotor model with models for navigation (<xref ref-type="bibr" rid="bib36">Fisher, 2022</xref>) and behavioral transitions (<xref ref-type="bibr" rid="bib16">Berman et al., 2016</xref>).</p><p>Although we believe our model matches the fly walking sufficiently for this investigation, we do note that our model still underfits the joint angle oscillations in the walking cycle of the fly (see <xref ref-type="fig" rid="fig2">Figure 2</xref> and Appendix 2). More precise fitting of the joint angle kinematics may come from increasing the complexity of the neural network architecture, improving the training procedure based on advances in imitation learning (<xref ref-type="bibr" rid="bib50">Hussein et al., 2018</xref>), or explicitly accounting for individual differences in kinematics across flies (<xref ref-type="bibr" rid="bib32">DeAngelis et al., 2019</xref>; <xref ref-type="bibr" rid="bib71">Pratt et al., 2024</xref>).</p><p>Our layered approach could be a useful framework for learning principles from closed-loop models, despite having incomplete information about the biological system. For instance, the trajectory generator model could be replaced by a combination of a connectome simulation and artificial neural networks, with the constraint on the artificial neural network dynamics coming from the complete circuit generating robust walking in simulation. Future work could also incorporate more detailed delay structures based on compartmental models of neurons from the connectome. With increasing realism, such closed-loop models provide a promising means to investigate how complex neural circuits interact with proprioceptive feedback to control robust locomotor behaviors.</p></sec></sec><sec id="s4" sec-type="materials|methods"><title>Materials and methods</title><sec id="s4-1"><title>Tracking joint angles of <italic>D. melanogaster</italic> walking in 3D</title><p>We obtained fruit fly <italic>D. melanogaster</italic> walking kinematics data following the procedure previously described in <xref ref-type="bibr" rid="bib54">Karashchuk et al., 2021</xref>. Briefly, a fly was tethered to a tungsten wire and positioned on a frictionless spherical treadmill ball suspended on compressed air. Six cameras (Basler acA800-510 μm with Computar zoom lens MLM3X-MP) captured the movement of all of the fly’s legs at 300 Hz. The fly size in pixels ranges from about 300×300 up to 700×500 pixels across the six cameras. Using Anipose, we tracked 30 keypoints on the fly, which are the following five points on each of the six legs: body-coxa, coxa-femur, femur-tibia, and tibia-tarsus joints, as well as the tip of the tarsus.</p><p>To fit the model described in this paper, we extracted a subset of the tracking data when the fly walking, as opposed to non-walking behaviors including standing, grooming, etc. To isolate bouts of walking, we used the behavior classifier described in <xref ref-type="bibr" rid="bib54">Karashchuk et al., 2021</xref>. We further selected walking bouts of at least 0.5 s (150 video frames) in length, and where the femur-tibia flexion angle of the left front leg had a range of at least 30 degrees.</p><p>In total, our dataset consisted of 3473 walking bouts from 45 flies total. The average length of a walking bout was 0.877 s (263 frames), with 3049.7 s of walking total (914,909 frames).</p></sec><sec id="s4-2"><title>Inter-leg phase coordinator</title><p>We model the coordination between legs as phase-coupled Kuramoto oscillators (<xref ref-type="bibr" rid="bib84">Strogatz, 2000</xref>), where the frequency of each oscillator is driven by the trajectory generator described in the next section.</p><p>Specifically, the phase for a leg <inline-formula><mml:math id="inf23"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>i</mml:mi></mml:mstyle></mml:math></inline-formula> is <inline-formula><mml:math id="inf24"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>ϕ</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> and evolves according to its derivative <inline-formula><mml:math id="inf25"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:msub><mml:mrow class="MJX-TeXAtom-ORD"><mml:mover><mml:mi>ϕ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mrow class="MJX-TeXAtom-ORD"><mml:mi>i</mml:mi></mml:mrow></mml:msub></mml:mstyle></mml:math></inline-formula><disp-formula id="equ1"><label>(1)</label><mml:math id="m1"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:msub><mml:mrow><mml:mover><mml:mi>ϕ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mo>=</mml:mo><mml:msub><mml:mi>F</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>θ</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mo>,</mml:mo><mml:msub><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mo>,</mml:mo><mml:mi>v</mml:mi><mml:mo>,</mml:mo><mml:msub><mml:mi>ϕ</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>α</mml:mi><mml:munder><mml:mo>∑</mml:mo><mml:mrow><mml:mi>j</mml:mi><mml:mo>≠</mml:mo><mml:mi>i</mml:mi></mml:mrow></mml:munder><mml:mi>sin</mml:mi><mml:mo>⁡</mml:mo><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>ϕ</mml:mi><mml:mrow><mml:mi>j</mml:mi></mml:mrow></mml:msub><mml:mo>−</mml:mo><mml:msub><mml:mi>ϕ</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mo>−</mml:mo><mml:msub><mml:mrow><mml:mover><mml:mi>ϕ</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf26"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>F</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> is the trajectory generator function for leg <inline-formula><mml:math id="inf27"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>i</mml:mi></mml:mstyle></mml:math></inline-formula>, <inline-formula><mml:math id="inf28"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>α</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is the coupling strength, and <inline-formula><mml:math id="inf29"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mrow><mml:mover><mml:mi>ϕ</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> is the steady-state phase offset between legs <inline-formula><mml:math id="inf30"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> and <inline-formula><mml:math id="inf31"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>j</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>.</p><p>We model the coupling across the legs as all-to-all coupling, with coupling strength <inline-formula><mml:math id="inf32"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>α</mml:mi><mml:mo>=</mml:mo><mml:mn>6.5</mml:mn></mml:mrow></mml:mstyle></mml:math></inline-formula>. We found this coupling strength best reproduced the phase coupling distributions from the real data (as shown in Appendix 5).</p><p>We estimate <inline-formula><mml:math id="inf33"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mrow><mml:mover><mml:mi>ϕ</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> from the walking data by taking the circular mean over phase differences of pairs of legs during walking bouts. We find that the phase offset across legs is not strongly modulated across walking speeds in our dataset (see Appendix 1), so we model <inline-formula><mml:math id="inf34"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mrow><mml:mover><mml:mi>ϕ</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> as a single constant independent of speed. In future studies, this could be a function of forward and rotation speeds to account for fine phase modulation differences.</p></sec><sec id="s4-3"><title>Trajectory generator</title><p>A trajectory generator model was formulated for each of the six legs and fit separately to fly walking data tracked during tethered walking without any external perturbations.</p></sec><sec id="s4-4"><title>Model formulation</title><p>We formulate the trajectory generator as the function<disp-formula id="equ2"><label>(2)</label><mml:math id="m2"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>¨</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>ϕ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>F</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>θ</mml:mi><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mi>v</mml:mi><mml:mo>,</mml:mo><mml:mi>ϕ</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf35"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>θ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is a vector of joint angles, <inline-formula><mml:math id="inf36"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula> is a vector of joint angle derivatives, <inline-formula><mml:math id="inf37"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>v</mml:mi></mml:mstyle></mml:math></inline-formula> is the desired walking speed and direction, and <inline-formula><mml:math id="inf38"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>ϕ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is the phase of the leg. Initially, we explored using the trajectory generator to directly output angles and angular velocities <inline-formula><mml:math id="inf39"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mi>θ</mml:mi><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>; however, we found that more realistic (i.e. similar to data) trajectories were produced when we used the trajectory generator to output angular acceleration <inline-formula><mml:math id="inf40"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow class="MJX-TeXAtom-ORD"><mml:mover><mml:mi>θ</mml:mi><mml:mo>¨</mml:mo></mml:mover></mml:mrow></mml:mstyle></mml:math></inline-formula>, which we integrated to produce the desired angle and angular velocities. Note that <inline-formula><mml:math id="inf41"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>v</mml:mi></mml:mstyle></mml:math></inline-formula> is not communicated to or from the layers above and below; instead, we consider walking speed and direction to be given as commands descending from the brain.</p><p>To compute a trajectory given an input <inline-formula><mml:math id="inf42"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>v</mml:mi></mml:mstyle></mml:math></inline-formula> and an initial <inline-formula><mml:math id="inf43"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>ϕ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, <inline-formula><mml:math id="inf44"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>θ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, and <inline-formula><mml:math id="inf45"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>, we integrate the function <inline-formula><mml:math id="inf46"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>F</mml:mi></mml:mstyle></mml:math></inline-formula> numerically using the midpoint method (<xref ref-type="bibr" rid="bib63">Lotkin, 1956</xref>). Following methods from <xref ref-type="bibr" rid="bib47">Holden et al., 2017</xref> and <xref ref-type="bibr" rid="bib96">Zhang et al., 2018</xref>, we represent the function <inline-formula><mml:math id="inf47"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>F</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> as a multi-layer perceptron neural network with 2 hidden layers of 512 units each. We use ELU (<xref ref-type="bibr" rid="bib25">Clevert et al., 2015</xref>) as our nonlinearity. In total, the multi-layer perceptron has 274,437 parameters for T1 legs and 272,388 parameters for T2 and T3 legs, with the slight difference in parameters due to the different number of joint angles (dimension of <inline-formula><mml:math id="inf48"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>θ</mml:mi></mml:mstyle></mml:math></inline-formula>) modeled for a given leg.</p></sec><sec id="s4-5"><title>Training data</title><p>To train the multi-layer perceptron network used to represent <inline-formula><mml:math id="inf49"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>F</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, we used the fly walking data, tracked as described in the section above. The training data consists of joint angles <inline-formula><mml:math id="inf50"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>θ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, computed <inline-formula><mml:math id="inf51"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula> and <inline-formula><mml:math id="inf52"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>¨</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>, and walking velocity <inline-formula><mml:math id="inf53"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>v</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>. We estimated the walking cycle phase <inline-formula><mml:math id="inf54"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>ϕ</mml:mi></mml:mstyle></mml:math></inline-formula> using a Hilbert transform over the femur-tibia flexion angle for T1 legs, femur rotation angle for T2 legs, and coxa-femur angle for T3 legs. For each phase, we filtered the corresponding angle using a first-order Butterworth bandpass filter with 3 Hz and 60 Hz as critical frequencies, using the scipy library (<xref ref-type="bibr" rid="bib93">Virtanen et al., 2020</xref>). Then, we applied a Hilbert transform to each angle to obtain a complex waveform. We estimate the walking cycle phase from each complex waveform by estimating the angle of each point in the waveform.</p></sec><sec id="s4-6"><title>Training procedure</title><p>Training the neural network representing <inline-formula><mml:math id="inf55"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>F</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> from data was performed in two steps, minimizing its error in predicting one time step, then minimizing its error in predicting a short time trajectory.</p><p>In the first step, we minimized the error of <inline-formula><mml:math id="inf56"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>F</mml:mi></mml:mstyle></mml:math></inline-formula> for predicting <inline-formula><mml:math id="inf57"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>¨</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>ϕ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mstyle></mml:math></inline-formula> over one time step, given the corresponding <inline-formula><mml:math id="inf58"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mi>θ</mml:mi><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mi>v</mml:mi><mml:mo>,</mml:mo><mml:mi>ϕ</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mstyle></mml:math></inline-formula> from the training data. We minimized the mean squared error of the prediction, normalized by the variance for each dimension. We trained our network for 300 iterations over the full training data using a batch size of 2500 training samples, using gradient descent with the Adam algorithm (<xref ref-type="bibr" rid="bib56">Kingma and Ba, 2017</xref>). To ensure a robust function at this step, we applied dropout to a random 5% of the hidden units (<xref ref-type="bibr" rid="bib80">Srivastava et al., 2014</xref>). We standardized the input and output training data to the multi-layer perceptron so that it has a mean of 0 and standard deviation of 1.</p><p>In the second step, we minimize the error of <inline-formula><mml:math id="inf59"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>F</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> for predicting a trajectory <inline-formula><mml:math id="inf60"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>θ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> when numerically integrated over a short time horizon in the future. Specifically, we integrate <inline-formula><mml:math id="inf61"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>F</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> over <inline-formula><mml:math id="inf62"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>T</mml:mi><mml:mo>=</mml:mo><mml:mn>60</mml:mn></mml:mrow></mml:mstyle></mml:math></inline-formula> steps given initial conditions <inline-formula><mml:math id="inf63"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mi>θ</mml:mi><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mi>v</mml:mi><mml:mo>,</mml:mo><mml:mi>ϕ</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mstyle></mml:math></inline-formula> to produce an estimated desired trajectory of <inline-formula><mml:math id="inf64"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>θ</mml:mi><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mstyle></mml:math></inline-formula>. Here, we minimized the loss:<disp-formula id="equ3"><label>(3)</label><mml:math id="m3"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:munderover><mml:mo>∑</mml:mo><mml:mrow><mml:mi>t</mml:mi></mml:mrow><mml:mrow><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:munderover><mml:msubsup><mml:mrow><mml:mo symmetric="true">‖</mml:mo><mml:mrow><mml:mi>cos</mml:mi><mml:mo>⁡</mml:mo><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>θ</mml:mi><mml:mi>d</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo stretchy="false">)</mml:mo><mml:mo>−</mml:mo><mml:mi>cos</mml:mi><mml:mo>⁡</mml:mo><mml:mo stretchy="false">(</mml:mo><mml:mi>θ</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo stretchy="false">)</mml:mo></mml:mrow><mml:mo symmetric="true">‖</mml:mo></mml:mrow><mml:mrow><mml:mn>2</mml:mn></mml:mrow><mml:mrow><mml:mn>2</mml:mn></mml:mrow></mml:msubsup><mml:mo>+</mml:mo><mml:msubsup><mml:mrow><mml:mo symmetric="true">‖</mml:mo><mml:mrow><mml:mi>sin</mml:mi><mml:mo>⁡</mml:mo><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>θ</mml:mi><mml:mi>d</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo stretchy="false">)</mml:mo><mml:mo>−</mml:mo><mml:mi>sin</mml:mi><mml:mo>⁡</mml:mo><mml:mo stretchy="false">(</mml:mo><mml:mi>θ</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo stretchy="false">)</mml:mo></mml:mrow><mml:mo symmetric="true">‖</mml:mo></mml:mrow><mml:mrow><mml:mn>2</mml:mn></mml:mrow><mml:mrow><mml:mn>2</mml:mn></mml:mrow></mml:msubsup></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>using gradient descent with the Adam algorithm (<xref ref-type="bibr" rid="bib56">Kingma and Ba, 2017</xref>). During training, we clip gradients to a norm of 10 to stabilize training.</p><p>The training was implemented using Tensorflow (<xref ref-type="bibr" rid="bib1">Abadi, 2015</xref>) running on a computer with NVIDIA GeForce RTX 2070 GPU and AMD Ryzen Threadripper 1920X 12-Core Processor.</p></sec><sec id="s4-7"><title>Leg dynamics and optimal controller formulation</title><p>All techniques used for dynamics formulation are standard tools from control theory. We begin with a link-and-joint model of the fly leg, as shown in <xref ref-type="fig" rid="fig1">Figure 1C</xref>. For simplicity, we only model joints that exhibit large ranges of movement during naturalistic walking and turning. For instance, varying femur rotation is important to the movements of the middle legs, but the front legs exhibit near-constant femur rotation <xref ref-type="bibr" rid="bib54">Karashchuk et al., 2021</xref>; thus, a femur rotation joint is included for the middle and hind legs only. The joints included for each leg are shown in <xref ref-type="table" rid="table1">Table 1</xref>.</p><table-wrap id="table1" position="float"><label>Table 1.</label><caption><title>Joints included for leg models.</title></caption><table frame="hsides" rules="groups"><thead><tr><th align="left" valign="bottom">Joint</th><th align="left" valign="bottom">Front legs</th><th align="left" valign="bottom">Middle legs</th><th align="left" valign="bottom">Hind legs</th></tr></thead><tbody><tr><td align="left" valign="bottom">Body-coxa flexion</td><td align="left" valign="bottom">✓</td><td align="left" valign="bottom"/><td align="left" valign="bottom"/></tr><tr><td align="left" valign="bottom">Coxa rotation</td><td align="left" valign="bottom">✓</td><td align="left" valign="bottom"/><td align="left" valign="bottom"/></tr><tr><td align="left" valign="bottom">Coxa-femur flexion</td><td align="left" valign="bottom">✓</td><td align="left" valign="bottom">✓</td><td align="left" valign="bottom">✓</td></tr><tr><td align="left" valign="bottom">Femur rotation</td><td align="left" valign="bottom"/><td align="left" valign="bottom">✓</td><td align="left" valign="bottom">✓</td></tr><tr><td align="left" valign="bottom">Femur-tibia flexion</td><td align="left" valign="bottom">✓</td><td align="left" valign="bottom">✓</td><td align="left" valign="bottom">✓</td></tr></tbody></table></table-wrap><p>We write the Denavit-Hartenberg (DH) table of the leg model and use this to systematically derive the Euler-Lagrange matrix equations of motion:<disp-formula id="equ4"><label>(4)</label><mml:math id="m4"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>τ</mml:mi><mml:mo>=</mml:mo><mml:mi>M</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>θ</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>¨</mml:mo></mml:mover></mml:mrow><mml:mo>+</mml:mo><mml:mi>C</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>θ</mml:mi><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">)</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mo>+</mml:mo><mml:mi>B</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>θ</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mo>+</mml:mo><mml:mi>g</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>θ</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf65"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>τ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is the vector of joint torques; <inline-formula><mml:math id="inf66"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>θ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, <inline-formula><mml:math id="inf67"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow class="MJX-TeXAtom-ORD"><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mstyle></mml:math></inline-formula>, and <inline-formula><mml:math id="inf68"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow class="MJX-TeXAtom-ORD"><mml:mover><mml:mi>θ</mml:mi><mml:mo>¨</mml:mo></mml:mover></mml:mrow></mml:mstyle></mml:math></inline-formula> are vectors of joint angles, angular velocity, and angular acceleration; <inline-formula><mml:math id="inf69"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>M</mml:mi></mml:mstyle></mml:math></inline-formula>, <inline-formula><mml:math id="inf70"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>C</mml:mi></mml:mstyle></mml:math></inline-formula>, <inline-formula><mml:math id="inf71"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>B</mml:mi></mml:mstyle></mml:math></inline-formula>, are the inertia, Coriolis, and friction matrices, and <inline-formula><mml:math id="inf72"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>g</mml:mi></mml:mstyle></mml:math></inline-formula> is the gravity vector.</p><p>Let us define the state to be the angles and angular derivatives <inline-formula><mml:math id="inf73"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>q</mml:mi><mml:mo>=</mml:mo><mml:mrow><mml:mo>[</mml:mo><mml:mtable rowspacing="4pt" columnspacing="1em"><mml:mtr><mml:mtd><mml:msub><mml:mi>q</mml:mi><mml:mrow><mml:mn>1</mml:mn></mml:mrow></mml:msub></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:msub><mml:mi>q</mml:mi><mml:mrow><mml:mn>2</mml:mn></mml:mrow></mml:msub></mml:mtd></mml:mtr></mml:mtable><mml:mo>]</mml:mo></mml:mrow><mml:mo>=</mml:mo><mml:mrow><mml:mo>[</mml:mo><mml:mtable rowspacing="4pt" columnspacing="1em"><mml:mtr><mml:mtd><mml:mi>θ</mml:mi></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mrow><mml:mover><mml:mi>θ</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mtd></mml:mtr></mml:mtable><mml:mo>]</mml:mo></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula> and input to be torques <inline-formula><mml:math id="inf74"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>τ</mml:mi></mml:mstyle></mml:math></inline-formula>. We next rearrange (4) into the form <inline-formula><mml:math id="inf75"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>q</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mo>=</mml:mo><mml:mi>F</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>q</mml:mi><mml:mo>,</mml:mo><mml:mi>τ</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mstyle></mml:math></inline-formula>, so that<disp-formula id="equ5"><label>(5)</label><mml:math id="m5"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mo>[</mml:mo><mml:mtable rowspacing="4pt" columnspacing="1em"><mml:mtr><mml:mtd><mml:mrow><mml:mover><mml:msub><mml:mi>q</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mrow><mml:mover><mml:msub><mml:mi>q</mml:mi><mml:mn>2</mml:mn></mml:msub><mml:mo>˙</mml:mo></mml:mover></mml:mrow></mml:mtd></mml:mtr></mml:mtable><mml:mo>]</mml:mo></mml:mrow><mml:mo>=</mml:mo><mml:mrow><mml:mo>[</mml:mo><mml:mtable rowspacing="4pt" columnspacing="1em"><mml:mtr><mml:mtd><mml:msub><mml:mi>q</mml:mi><mml:mn>2</mml:mn></mml:msub></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mo>−</mml:mo><mml:mi>M</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:msup><mml:mo stretchy="false">)</mml:mo><mml:mrow><mml:mo>−</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:msup><mml:mrow><mml:mo>(</mml:mo><mml:mrow><mml:mi>C</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mo>,</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mn>2</mml:mn></mml:msub><mml:mo stretchy="false">)</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mn>2</mml:mn></mml:msub><mml:mo>+</mml:mo><mml:mi>B</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mo stretchy="false">)</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mn>2</mml:mn></mml:msub><mml:mo>+</mml:mo><mml:mi>g</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mo stretchy="false">)</mml:mo></mml:mrow><mml:mo>)</mml:mo></mml:mrow></mml:mtd></mml:mtr></mml:mtable><mml:mo>]</mml:mo></mml:mrow><mml:mo>+</mml:mo><mml:mrow><mml:mo>[</mml:mo><mml:mtable rowspacing="4pt" columnspacing="1em"><mml:mtr><mml:mtd><mml:mn>0</mml:mn></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mi>M</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:msup><mml:mo stretchy="false">)</mml:mo><mml:mrow><mml:mo>−</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:msup></mml:mtd></mml:mtr></mml:mtable><mml:mo>]</mml:mo></mml:mrow><mml:mi>τ</mml:mi><mml:mo>.</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>To linearize this system, we choose equilibrium values <inline-formula><mml:math id="inf76"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>q</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula> and <inline-formula><mml:math id="inf77"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>τ</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>, such that <inline-formula><mml:math id="inf78"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>F</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mover><mml:mi>q</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>τ</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mn>0</mml:mn></mml:mrow></mml:mstyle></mml:math></inline-formula>. In particular, <inline-formula><mml:math id="inf79"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:msub><mml:mi>q</mml:mi><mml:mrow><mml:mn>1</mml:mn></mml:mrow></mml:msub><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula> is taken to be the average joint angles for each leg joint computed from the data. It follows that <inline-formula><mml:math id="inf80"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:msub><mml:mi>q</mml:mi><mml:mrow><mml:mn>2</mml:mn></mml:mrow></mml:msub><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mo>=</mml:mo><mml:mn>0</mml:mn></mml:mrow></mml:mstyle></mml:math></inline-formula>, and <inline-formula><mml:math id="inf81"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>τ</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mo>=</mml:mo><mml:mi>g</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mrow><mml:mover><mml:mi>q</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mn>1</mml:mn></mml:mrow></mml:msub><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mstyle></mml:math></inline-formula> gives the desired equilibrium.</p><p>We linearized about this equilibrium point, which leads to an equation of the following form:<disp-formula id="equ6"><label>(6)</label><mml:math id="m6"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mover><mml:mi>x</mml:mi><mml:mo>˙</mml:mo></mml:mover></mml:mrow><mml:mo>=</mml:mo><mml:msub><mml:mi>A</mml:mi><mml:mi>c</mml:mi></mml:msub><mml:mi>x</mml:mi><mml:mo>+</mml:mo><mml:msub><mml:mi>B</mml:mi><mml:mi>c</mml:mi></mml:msub><mml:mi>u</mml:mi><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf82"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>x</mml:mi><mml:mo>=</mml:mo><mml:mi>q</mml:mi><mml:mo>−</mml:mo><mml:mrow><mml:mover><mml:mi>q</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula> and <inline-formula><mml:math id="inf83"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>B</mml:mi><mml:mrow><mml:mi>c</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> are the Jacobians with respect to <inline-formula><mml:math id="inf84"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>q</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> and <inline-formula><mml:math id="inf85"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>τ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, respectively. In other words,<disp-formula id="equ7"><label>(7)</label><mml:math id="m7"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:msub><mml:mi>A</mml:mi><mml:mi>c</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mfrac><mml:mrow><mml:mi mathvariant="normal">∂</mml:mi><mml:mi>F</mml:mi></mml:mrow><mml:mrow><mml:mi mathvariant="normal">∂</mml:mi><mml:mi>q</mml:mi></mml:mrow></mml:mfrac><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mover><mml:mi>q</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>τ</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">)</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula><disp-formula id="equ8"><label>(8)</label><mml:math id="m8"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:msub><mml:mi>B</mml:mi><mml:mi>c</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mfrac><mml:mrow><mml:mi mathvariant="normal">∂</mml:mi><mml:mi>F</mml:mi></mml:mrow><mml:mrow><mml:mi mathvariant="normal">∂</mml:mi><mml:mi>τ</mml:mi></mml:mrow></mml:mfrac><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mover><mml:mi>q</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>τ</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">)</mml:mo><mml:mo>.</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>In our code, we use the SymPyBotics toolbox (<xref ref-type="bibr" rid="bib79">Sousa, 2013</xref>) to obtain symbolic equations for the quantities in <xref ref-type="disp-formula" rid="equ4">Equation 4</xref>, then numerically compute Jacobian values.</p><p>Next, we rewrite the system in discrete time using a sampling interval <inline-formula><mml:math id="inf86"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>T</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, which is typically chosen to be an integer multiple of the sampling interval from the data (the tracking data was acquired every <inline-formula><mml:math id="inf87"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>T</mml:mi><mml:mo>=</mml:mo><mml:mn>1</mml:mn><mml:mrow><mml:mo>/</mml:mo></mml:mrow><mml:mn>300</mml:mn></mml:mrow></mml:mstyle></mml:math></inline-formula> s). In our controller simulations, we use <inline-formula><mml:math id="inf88"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>T</mml:mi><mml:mo>=</mml:mo><mml:mn>1</mml:mn><mml:mrow><mml:mo>/</mml:mo></mml:mrow><mml:mn>600</mml:mn></mml:mrow></mml:mstyle></mml:math></inline-formula> s. The discretized dynamics are thus written as:<disp-formula id="equ9"><label>(9)</label><mml:math id="m9"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>x</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mi>T</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>A</mml:mi><mml:mi>x</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>B</mml:mi><mml:mi>u</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf89"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>A</mml:mi><mml:mo>=</mml:mo><mml:mi>I</mml:mi><mml:mo>+</mml:mo><mml:msub><mml:mi>A</mml:mi><mml:mi>c</mml:mi></mml:msub><mml:mi>T</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> and <inline-formula><mml:math id="inf90"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>B</mml:mi><mml:mo>=</mml:mo><mml:msub><mml:mi>B</mml:mi><mml:mi>c</mml:mi></mml:msub><mml:mi>T</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>.</p><p>Finally, we perform a coordinate shift to error dynamics. This allows us to apply standard control techniques for trajectory tracking. We define the tracking error to be <inline-formula><mml:math id="inf91"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>y</mml:mi><mml:mo>=</mml:mo><mml:mi>q</mml:mi><mml:mo>−</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula>, where <inline-formula><mml:math id="inf92"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>q</mml:mi><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> is the desired state, and this error obeys the following dynamics:<disp-formula id="equ10"><label>(10a)</label><mml:math id="m10"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>y</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>A</mml:mi><mml:mi>y</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>B</mml:mi><mml:mi>u</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>w</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:msub><mml:mi>w</mml:mi><mml:mrow><mml:mi>t</mml:mi><mml:mi>r</mml:mi><mml:mi>a</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula><disp-formula id="equ11"><label>(10b)</label><mml:math id="m11"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:msub><mml:mi>w</mml:mi><mml:mrow><mml:mi>t</mml:mi><mml:mi>r</mml:mi><mml:mi>a</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>A</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mi>d</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>−</mml:mo><mml:mrow><mml:mover><mml:mi>q</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mrow><mml:mover><mml:mi>q</mml:mi><mml:mo stretchy="false">¯</mml:mo></mml:mover></mml:mrow><mml:mo>−</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mi>d</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf93"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>w</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is the external perturbation. <inline-formula><mml:math id="inf94"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>w</mml:mi><mml:mrow><mml:mi>t</mml:mi><mml:mi>r</mml:mi><mml:mi>a</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> represents the effect of constantly changing trajectories — for example, if the desired trajectory at the current time-step is some value <inline-formula><mml:math id="inf95"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>a</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, and the desired trajectory at the next time-step is some other value <inline-formula><mml:math id="inf96"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>b</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, then this is equivalent to introducing a perturbation of <inline-formula><mml:math id="inf97"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>b</mml:mi><mml:mo>−</mml:mo><mml:mi>a</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>. Error <inline-formula><mml:math id="inf98"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>y</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is a column vector with length <inline-formula><mml:math id="inf99"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>n</mml:mi><mml:mrow><mml:mi>y</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> (8 for front legs, and 6 for the other legs), and input <inline-formula><mml:math id="inf100"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>u</mml:mi></mml:mstyle></mml:math></inline-formula> is a column vector with length <inline-formula><mml:math id="inf101"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>n</mml:mi><mml:mrow><mml:mi>u</mml:mi></mml:mrow></mml:msub><mml:mo>=</mml:mo><mml:msub><mml:mi>n</mml:mi><mml:mrow><mml:mi>y</mml:mi></mml:mrow></mml:msub><mml:mrow><mml:mo>/</mml:mo></mml:mrow><mml:mn>2</mml:mn></mml:mrow></mml:mstyle></mml:math></inline-formula>.</p><p>To include motor delay (known as <italic>actuation</italic> delay in controls literature) and sensory delay, we make use of augmented state formulations as introduced in <xref ref-type="bibr" rid="bib81">Stenberg et al., 2022</xref>. Let the motor delay be <inline-formula><mml:math id="inf102"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>μ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> steps. We re-define <inline-formula><mml:math id="inf103"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>u</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> as the <italic>intended</italic> actuation, which is delayed by <inline-formula><mml:math id="inf104"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>μ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> steps before it affects the state. We introduce a variable <inline-formula><mml:math id="inf105"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>a</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> such that <inline-formula><mml:math id="inf106"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>a</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> represents <inline-formula><mml:math id="inf107"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>u</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> delayed by <inline-formula><mml:math id="inf108"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> steps. <inline-formula><mml:math id="inf109"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>a</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is a column vector with length <inline-formula><mml:math id="inf110"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>μ</mml:mi><mml:mo>×</mml:mo><mml:msub><mml:mi>n</mml:mi><mml:mrow><mml:mi>u</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula>, and it can be written as:<disp-formula id="equ12"><label>(11)</label><mml:math id="m12"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:msub><mml:mi>a</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>u</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo><mml:mspace width="1em"/><mml:msub><mml:mi>a</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:msub><mml:mi>a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mo>−</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo><mml:mspace width="1em"/><mml:mi>i</mml:mi><mml:mo>∈</mml:mo><mml:mo stretchy="false">[</mml:mo><mml:mn>2</mml:mn><mml:mo>,</mml:mo><mml:mi>μ</mml:mi><mml:mo stretchy="false">]</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>Similarly, let the sensory delay be <inline-formula><mml:math id="inf111"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>δ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> steps. The state information <inline-formula><mml:math id="inf112"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>y</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is delayed by <inline-formula><mml:math id="inf113"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>δ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> steps before it reaches the controller. We introduce another variable <inline-formula><mml:math id="inf114"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>s</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> such that <inline-formula><mml:math id="inf115"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>s</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> represents <inline-formula><mml:math id="inf116"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>y</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> delayed by <inline-formula><mml:math id="inf117"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> steps. <inline-formula><mml:math id="inf118"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>s</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is a column vector with length <inline-formula><mml:math id="inf119"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>δ</mml:mi><mml:mo>×</mml:mo><mml:msub><mml:mi>n</mml:mi><mml:mrow><mml:mi>y</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula>, and can be written as:<disp-formula id="equ13"><label>(12)</label><mml:math id="m13"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:msub><mml:mi>s</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>y</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo><mml:mspace width="1em"/><mml:msub><mml:mi>s</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:msub><mml:mi>s</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mo>−</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo><mml:mspace width="1em"/><mml:mi>i</mml:mi><mml:mo>∈</mml:mo><mml:mo stretchy="false">[</mml:mo><mml:mn>2</mml:mn><mml:mo>,</mml:mo><mml:mi>δ</mml:mi><mml:mo stretchy="false">]</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>We define <inline-formula><mml:math id="inf120"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>g</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> as the effect of changing trajectories in the future, where <inline-formula><mml:math id="inf121"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>g</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mo>=</mml:mo><mml:msub><mml:mi>w</mml:mi><mml:mrow><mml:mi>t</mml:mi><mml:mi>r</mml:mi><mml:mi>a</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mi>i</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mstyle></mml:math></inline-formula>. Note that this does not correspond to any physical signal — rather, it is a virtual variable that allows us to incorporate knowledge of the future trajectory. <inline-formula><mml:math id="inf122"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>g</mml:mi></mml:mstyle></mml:math></inline-formula> is a column vector with length <inline-formula><mml:math id="inf123"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mi>μ</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>×</mml:mo><mml:msub><mml:mi>n</mml:mi><mml:mrow><mml:mi>y</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula>, and it can be written as:<disp-formula id="equ14"><label>(13)</label><mml:math id="m14"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:msub><mml:mi>g</mml:mi><mml:mrow><mml:mi>μ</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:msub><mml:mi>w</mml:mi><mml:mrow><mml:mi>t</mml:mi><mml:mi>r</mml:mi><mml:mi>a</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mi>μ</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo><mml:mspace width="1em"/><mml:msub><mml:mi>g</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:msub><mml:mi>g</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo><mml:mspace width="1em"/><mml:mi>i</mml:mi><mml:mo>∈</mml:mo><mml:mo stretchy="false">[</mml:mo><mml:mn>0</mml:mn><mml:mo>,</mml:mo><mml:mi>μ</mml:mi><mml:mo>−</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">]</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>We can now rewrite the dynamics (<xref ref-type="disp-formula" rid="equ10">Equation 10a</xref>) to include delays using these variables:<disp-formula id="equ15"><label>(14)</label><mml:math id="m15"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>y</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>A</mml:mi><mml:mi>y</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>B</mml:mi><mml:msub><mml:mi>a</mml:mi><mml:mrow><mml:mi>μ</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:msub><mml:mi>g</mml:mi><mml:mn>0</mml:mn></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>w</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>Finally, we define <inline-formula><mml:math id="inf124"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>f</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> as the prediction of <inline-formula><mml:math id="inf125"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>y</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> in the future (assuming no perturbations), where <inline-formula><mml:math id="inf126"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>f</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> represents the prediction <inline-formula><mml:math id="inf127"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> steps into the future. Like <inline-formula><mml:math id="inf128"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>g</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, this variable does not correspond to any physical signal, and is used to incorporate predictive capability into the controller. <inline-formula><mml:math id="inf129"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>f</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is a column vector of length <inline-formula><mml:math id="inf130"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>μ</mml:mi><mml:mo>×</mml:mo><mml:msub><mml:mi>n</mml:mi><mml:mrow><mml:mi>y</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula>. The first portion of <inline-formula><mml:math id="inf131"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>f</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> can be written as<disp-formula id="equ16"><label>(15)</label><mml:math id="m16"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mml:mtr><mml:mtd><mml:msub><mml:mi>f</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo></mml:mtd><mml:mtd><mml:mi/><mml:mo>=</mml:mo><mml:mi>A</mml:mi><mml:mi>y</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>B</mml:mi><mml:msub><mml:mi>a</mml:mi><mml:mrow><mml:mi>μ</mml:mi><mml:mo>−</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:msub><mml:mi>g</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mtd></mml:mtr><mml:mtr><mml:mtd/><mml:mtd><mml:mi/><mml:mo>=</mml:mo><mml:msup><mml:mi>A</mml:mi><mml:mn>2</mml:mn></mml:msup><mml:mi>y</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>A</mml:mi><mml:mi>B</mml:mi><mml:msub><mml:mi>a</mml:mi><mml:mrow><mml:mi>μ</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>A</mml:mi><mml:msub><mml:mi>g</mml:mi><mml:mn>0</mml:mn></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>A</mml:mi><mml:mi>w</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>B</mml:mi><mml:msub><mml:mi>a</mml:mi><mml:mrow><mml:mi>μ</mml:mi><mml:mo>−</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:msub><mml:mi>g</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mtd></mml:mtr></mml:mtable></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>and subsequent values can be written as<disp-formula id="equ17"><label>(16)</label><mml:math id="m17"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mml:mtr><mml:mtd><mml:msub><mml:mi>f</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo></mml:mtd><mml:mtd><mml:mi/><mml:mo>=</mml:mo><mml:mi>A</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>f</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mo>−</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>B</mml:mi><mml:msub><mml:mi>a</mml:mi><mml:mrow><mml:mi>μ</mml:mi><mml:mo>−</mml:mo><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:msub><mml:mi>g</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo><mml:mspace width="1em"/><mml:mi>i</mml:mi><mml:mo>∈</mml:mo><mml:mo stretchy="false">[</mml:mo><mml:mn>2</mml:mn><mml:mo>,</mml:mo><mml:mi>μ</mml:mi><mml:mo>−</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">]</mml:mo></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:msub><mml:mi>f</mml:mi><mml:mi>μ</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo></mml:mtd><mml:mtd><mml:mi/><mml:mo>=</mml:mo><mml:mi>A</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>f</mml:mi><mml:mrow><mml:mi>μ</mml:mi><mml:mo>−</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>B</mml:mi><mml:mi>u</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:msub><mml:mi>g</mml:mi><mml:mi>μ</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mtd></mml:mtr></mml:mtable></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where the <inline-formula><mml:math id="inf132"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>A</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> term must be written out and simplified as is done in <xref ref-type="disp-formula" rid="equ16">Equation 15</xref>. We define an augmented state vector <inline-formula><mml:math id="inf133"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>z</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>:<disp-formula id="equ18"><label>(17)</label><mml:math id="m18"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>z</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mrow><mml:mo>[</mml:mo><mml:mtable rowspacing="4pt" columnspacing="1em"><mml:mtr><mml:mtd><mml:mrow><mml:mi>y</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mi>f</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mi>a</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mi>s</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mi>g</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mtd></mml:mtr></mml:mtable><mml:mo>]</mml:mo></mml:mrow></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>and write the overall system in the form of<disp-formula id="equ19"><label>(18)</label><mml:math id="m19"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>z</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>F</mml:mi><mml:mi>z</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>G</mml:mi><mml:mi>u</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:msub><mml:mi>w</mml:mi><mml:mrow><mml:mi>a</mml:mi><mml:mi>u</mml:mi><mml:mi>g</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula><disp-formula id="equ20"><label>(19)</label><mml:math id="m20"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>r</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>H</mml:mi><mml:mi>z</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where F, G, H, and <inline-formula><mml:math id="inf134"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>w</mml:mi><mml:mrow><mml:mi>a</mml:mi><mml:mi>u</mml:mi><mml:mi>g</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mstyle></mml:math></inline-formula> can be directly obtained by rearranging <xref ref-type="disp-formula" rid="equ12">Equation 11</xref>, <xref ref-type="disp-formula" rid="equ13">Equation 12</xref>, <xref ref-type="disp-formula" rid="equ14">Equation 13</xref>, <xref ref-type="disp-formula" rid="equ15">Equation 14</xref>, <xref ref-type="disp-formula" rid="equ17">Equation 16</xref>. In particular, H is zero everywhere except at the block corresponding to <inline-formula><mml:math id="inf135"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>s</mml:mi><mml:mrow><mml:mi>δ</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula>, where it is identity, i.e., <inline-formula><mml:math id="inf136"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>r</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:msub><mml:mi>s</mml:mi><mml:mrow><mml:mi>δ</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mstyle></mml:math></inline-formula>. This is the only information from the system that is received by the controller.</p><p>To achieve effective trajectory tracking, we seek a control law under which <inline-formula><mml:math id="inf137"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>y</mml:mi></mml:mstyle></mml:math></inline-formula> remains small. This can be achieved using the Linear Quadratic Gaussian (LQG) controller (<xref ref-type="bibr" rid="bib6">Åström and Murray, 2021</xref>). The controller is governed by the following equations:<disp-formula id="equ21"><label>(20)</label><mml:math id="m21"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mover><mml:mi>z</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mn>1</mml:mn><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>F</mml:mi><mml:mrow><mml:mover><mml:mi>z</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>G</mml:mi><mml:mi>u</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>+</mml:mo><mml:mi>L</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>r</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>−</mml:mo><mml:mi>H</mml:mi><mml:mrow><mml:mover><mml:mi>z</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo stretchy="false">)</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula><disp-formula id="equ22"><label>(21)</label><mml:math id="m22"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>u</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:mi>K</mml:mi><mml:mrow><mml:mover><mml:mi>z</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf138"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>z</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula> is the estimate of the augmented state (comprised of <inline-formula><mml:math id="inf139"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>y</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>f</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>a</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow><mml:mo>,</mml:mo><mml:mrow><mml:mover><mml:mi>s</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>, and <inline-formula><mml:math id="inf140"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>g</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow></mml:mrow></mml:mstyle></mml:math></inline-formula>), estimated via a steady-state Kalman filter; L and K are the optimal observer and controller matrices, respectively, synthesized via discrete algebraic Riccati equations. We directly feed in future values of the trajectory by setting <inline-formula><mml:math id="inf141"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mrow><mml:mover><mml:mi>g</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow><mml:mrow><mml:mi>μ</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo>=</mml:mo><mml:msub><mml:mi>w</mml:mi><mml:mrow><mml:mi>t</mml:mi><mml:mi>r</mml:mi><mml:mi>a</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>t</mml:mi><mml:mo>+</mml:mo><mml:mi>μ</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mstyle></mml:math></inline-formula>. By doing this, we ensure that the future trajectory ‘estimate’ is perfect, i.e., <inline-formula><mml:math id="inf142"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mrow><mml:mover><mml:mi>g</mml:mi><mml:mo stretchy="false">^</mml:mo></mml:mover></mml:mrow><mml:mo>=</mml:mo><mml:mi>g</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>. This helps the controller estimate values of <inline-formula><mml:math id="inf143"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>f</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> (future states) and <inline-formula><mml:math id="inf144"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>y</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>. The overall information flow within, to, and from the controller is shown in <xref ref-type="fig" rid="fig6">Figure 6</xref>.</p><fig id="fig6" position="float"><label>Figure 6.</label><caption><title>Detailed schematic of optimal controller.</title><p>The controller receives delayed sensory information from the dynamics model, as well as future trajectory information from the trajectory generator. The controller interacts with the dynamics model via a delayed motor action signal. The internal structure of the controller is that of a standard output feedback controller, which incorporates estimation via a Kalman filter. Dotted lines indicate muscle and sensor delays.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-fig6-v1.tif"/></fig></sec><sec id="s4-8"><title>Generate joint trajectories of the complete model with perturbations</title><p>The full model integrates all of the modules to generate trajectories of joint angles over time. The phase coordinator and trajectory generators combine to compute the desired joint angles <inline-formula><mml:math id="inf145"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>θ</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> for each leg <inline-formula><mml:math id="inf146"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, and the controller implements them constrained by the dynamics. We run the full model at 600 Hz.</p><p>At each time step, we first update the phases of the legs <inline-formula><mml:math id="inf147"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>ϕ</mml:mi><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> based on the phase coupling equation above. Every 2 timesteps, we update the target joint angles <inline-formula><mml:math id="inf148"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>θ</mml:mi><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> using the trajectory generator model. We run the trajectory generator <inline-formula><mml:math id="inf149"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>F</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> for <inline-formula><mml:math id="inf150"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>d</mml:mi><mml:mrow><mml:mtext>motor</mml:mtext></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula> time steps on its own, by continually integrating its output. This future trajectory forms the basis of <inline-formula><mml:math id="inf151"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>f</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, the predicted future errors used to guide the controller.</p><p>Each time step, we run the controller and dynamics model to control the torque <inline-formula><mml:math id="inf152"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>τ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> so that the joint angles <inline-formula><mml:math id="inf153"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>θ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> go towards the target joint angles <inline-formula><mml:math id="inf154"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>θ</mml:mi><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mstyle></mml:math></inline-formula>. If there is a disturbance, we apply it to the joint angles and derivatives at this point. Every 8 timesteps, we set <inline-formula><mml:math id="inf155"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:msub><mml:mi>θ</mml:mi><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub><mml:mo>=</mml:mo><mml:mi>θ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, so that the trajectory generator predicts an intended trajectory in line with the current state.</p><p>For the perturbation numerical experiments described in the Results, we ran all simulations for 1800 timesteps at 600 Hz. For persistent stochastic perturbations, we applied the perturbation from 600<sup>th</sup> timesteps to 1200<sup>th</sup> timesteps. For impulse perturbations, we applied a single strong perturbation at 600<sup>th</sup> timesteps.</p><p>We ran all our simulations on an Intel(R) Core(TM) i9-9940X CPU. We used GNU Parallel (<xref ref-type="bibr" rid="bib88">Tange, 2011</xref>) to run simulations on multiple cores simultaneously.</p></sec><sec id="s4-9"><title>Computing kinematic similarity (KS) by quantifying likelihood of walking kinematics relative to ground truth</title><p>We followed a multi-step procedure in order to quantify the likelihood of the simulated walking kinematics relative to observed distribution of walking kinematics. This procedure is schematized in <xref ref-type="fig" rid="fig4">Figure 4A</xref>.</p><p>To fit our likelihood model, we first performed Principal Components Analysis (PCA) to reduce the tracked joint angles from our 3D kinematics data to two dimensions per frame. To account for the circular nature of rotation angles, we performed PCA on the combination of sines and cosines of each angle. Next, we used a Gaussian Kernel Density Estimation (KDE) to estimate the probability density function of the principal components. Thus, we obtained a likelihood model for joint angle kinematics at each frame.</p><p>We chose two dimensions for PCA for two key reasons. First, these two dimensions alone accounted for a large portion of the variance in the data (52.7% total, with 42.1% for the first component and 10.6% for the second component). There was a big drop in variance explained from the first to the second component, but no sudden drop in the next 10 components (see Appendix 8). Second, the KDE procedure only works effectively in low-dimensional spaces, and the minimal number of dimensions needed to obtain circular dynamics for walking is 2. We investigate the effect of varying the number of dimensions of PCA in Appendix 9.</p><p>We run our model described above to produce simulated joint angle trajectories. To estimate a likelihood of a simulated set of angles, we first projected them onto the same principal components identified from the observed kinematics. Then, we use the KDE model to estimate the logarithmic probability density function (log PDF) for each frame during the perturbation; we refer to this as the <italic>kinematic similarity (KS</italic>). For persistent stochastic perturbations, we estimated mean KS during the perturbation, from 600<sup>th</sup> timesteps to 1200<sup>th</sup> timesteps. For impulse perturbations, we estimated mean KS in the transient recovery process, which we estimated to be from 610<sup>th</sup> timesteps to the 800<sup>th</sup> timesteps.</p></sec><sec id="s4-10"><title>Visualization of joint movement trajectories</title><p>For <xref ref-type="video" rid="video1">Video 1</xref>, we visualized the simulated and real joint movements using the biomechanical fly body model from <xref ref-type="bibr" rid="bib92">Vaxenburg et al., 2024</xref>. For each frame, we ran an inverse kinematics optimization over the model angles to match the simulated or real joint positions of the fly. We did not simulate realistic physics of the fly legs and their interactions with the ground in these visualizations. In our data, the fly thorax was fixed, and the wings were removed, so in these visualizations, we also fixed every other degree-of-freedom in the fly model besides the six legs. For the remaining videos, we visualized the joints as ball-and-stick models using matplotlib (<xref ref-type="bibr" rid="bib49">Hunter, 2007</xref>).</p></sec></sec></body><back><sec sec-type="additional-information" id="s5"><title>Additional information</title><fn-group content-type="competing-interest"><title>Competing interests</title><fn fn-type="COI-statement" id="conf1"><p>No competing interests declared</p></fn><fn fn-type="COI-statement" id="conf2"><p>Reviewing editor, eLife</p></fn></fn-group><fn-group content-type="author-contribution"><title>Author contributions</title><fn fn-type="con" id="con1"><p>Conceptualization, Data curation, Software, Formal analysis, Visualization, Writing – original draft, Writing – review and editing</p></fn><fn fn-type="con" id="con2"><p>Conceptualization, Software, Formal analysis, Writing – original draft, Writing – review and editing</p></fn><fn fn-type="con" id="con3"><p>Data curation, Visualization, Methodology, Writing – review and editing</p></fn><fn fn-type="con" id="con4"><p>Methodology</p></fn><fn fn-type="con" id="con5"><p>Conceptualization, Funding acquisition, Writing – review and editing</p></fn><fn fn-type="con" id="con6"><p>Conceptualization, Formal analysis, Supervision, Funding acquisition, Investigation, Writing – original draft, Project administration, Writing – review and editing</p></fn><fn fn-type="con" id="con7"><p>Conceptualization, Formal analysis, Supervision, Funding acquisition, Investigation, Writing – original draft, Project administration, Writing – review and editing</p></fn></fn-group></sec><sec sec-type="supplementary-material" id="s6"><title>Additional files</title><supplementary-material id="mdar"><label>MDAR checklist</label><media xlink:href="elife-99005-mdarchecklist1-v1.pdf" mimetype="application" mime-subtype="pdf"/></supplementary-material></sec><sec sec-type="data-availability" id="s7"><title>Data availability</title><p>The current manuscript is a computational study, so no data have been generated for this manuscript. All code is openly available <ext-link ext-link-type="uri" xlink:href="https://github.com/lambdaloop/layered-walking/">https://github.com/lambdaloop/layered-walking/</ext-link> (copy archived at <xref ref-type="bibr" rid="bib61">Li and Karashchuk, 2025</xref>).</p></sec><ack id="ack"><title>Acknowledgements</title><p>We thank J Doyle for initial discussions on layered feedback models, N Csomay-Shanklin for initial discussions on deriving models of legged locomotion, A Nair for discussions around coupled oscillator models, A Schwarze for discussions around sensorimotor feedback loops, E Dickinson for technical assistance, and members of the Tuthill and Brunton labs for helpful discussions and feedback on this manuscript. We are grateful to R Vaxenburg, I Siwanowicz, and S Turaga for help adapting their virtual fly model for visualizing real and simulated fly walking. This work has been funded by a National Science Foundation Graduate Research Fellowship to LK; a NSERC Postgraduate Scholarship (NSERC PGSD3-557385-2021) to JSL; a Searle Scholar Award, a Klingenstein-Simons Fellowship, a Pew Biomedical Scholar Award, a McKnight Scholar Award, a Sloan Research Fellowship, the New York Stem Cell Foundation, and NIH R01NS102333 to JCT; JCT is a New York Stem Cell Foundation – Robertson Investigator; Air Force Office of Scientific Research award FA9550-19-1-0386 and the Richard &amp; Joan Komen University Chair to BWB.</p></ack><ref-list><title>References</title><ref id="bib1"><element-citation publication-type="preprint"><person-group person-group-type="author"><name><surname>Abadi</surname><given-names>M</given-names></name></person-group><year iso-8601-date="2015">2015</year><article-title>TensorFlow: large-scale machine learning on heterogeneous distributed systems</article-title><source>arXiv</source><ext-link ext-link-type="uri" xlink:href="https://arxiv.org/abs/1603.04467">https://arxiv.org/abs/1603.04467</ext-link></element-citation></ref><ref id="bib2"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Acebrón</surname><given-names>JA</given-names></name><name><surname>Bonilla</surname><given-names>LL</given-names></name><name><surname>Pérez Vicente</surname><given-names>CJ</given-names></name><name><surname>Ritort</surname><given-names>F</given-names></name><name><surname>Spigler</surname><given-names>R</given-names></name></person-group><year iso-8601-date="2005">2005</year><article-title>The Kuramoto model: a simple paradigm for synchronization phenomena</article-title><source>Reviews of Modern Physics</source><volume>77</volume><fpage>137</fpage><lpage>185</lpage><pub-id pub-id-type="doi">10.1103/RevModPhys.77.137</pub-id></element-citation></ref><ref id="bib3"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Aminzare</surname><given-names>Z</given-names></name><name><surname>Srivastava</surname><given-names>V</given-names></name><name><surname>Holmes</surname><given-names>P</given-names></name></person-group><year iso-8601-date="2018">2018</year><article-title>Gait transitions in a phase oscillator model of an insect central pattern generator</article-title><source>SIAM Journal on Applied Dynamical Systems</source><volume>17</volume><fpage>626</fpage><lpage>671</lpage><pub-id pub-id-type="doi">10.1137/17M1125571</pub-id></element-citation></ref><ref id="bib4"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Arevalo</surname><given-names>JC</given-names></name><name><surname>Garcia</surname><given-names>E</given-names></name></person-group><year iso-8601-date="2012">2012</year><article-title>Impedance control for legged robots: an insight into the concepts involved</article-title><source>IEEE Transactions on Systems, Man, and Cybernetics, Part C Applications and Reviews</source><volume>42</volume><fpage>1400</fpage><lpage>1411</lpage><pub-id pub-id-type="doi">10.1109/TSMCC.2012.2187190</pub-id></element-citation></ref><ref id="bib5"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Ashtiani</surname><given-names>MS</given-names></name><name><surname>Aghamaleki Sarvestani</surname><given-names>A</given-names></name><name><surname>Badri-Spröwitz</surname><given-names>A</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title>Hybrid parallel compliance allows robots to operate with sensorimotor delays and low control frequencies</article-title><source>Frontiers in Robotics and AI</source><volume>8</volume><elocation-id>645748</elocation-id><pub-id pub-id-type="doi">10.3389/frobt.2021.645748</pub-id><pub-id pub-id-type="pmid">34312595</pub-id></element-citation></ref><ref id="bib6"><element-citation publication-type="book"><person-group person-group-type="author"><name><surname>Åström</surname><given-names>KJ</given-names></name><name><surname>Murray</surname><given-names>RM</given-names></name></person-group><year iso-8601-date="2021">2021</year><source>Feedback Systems: An Introduction for Scientists and Engineers</source><publisher-name>Princeton University Press</publisher-name></element-citation></ref><ref id="bib7"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Ayali</surname><given-names>Amir</given-names></name><name><surname>Borgmann</surname><given-names>A</given-names></name><name><surname>Büschges</surname><given-names>A</given-names></name><name><surname>Couzin-Fuchs</surname><given-names>E</given-names></name><name><surname>Daun-Gruhn</surname><given-names>S</given-names></name><name><surname>Holmes</surname><given-names>P</given-names></name></person-group><year iso-8601-date="2015">2015a</year><article-title>The comparative investigation of the stick insect and cockroach models in the study of insect locomotion</article-title><source>Current Opinion in Insect Science</source><volume>12</volume><fpage>1</fpage><lpage>10</lpage><pub-id pub-id-type="doi">10.1016/j.cois.2015.07.004</pub-id></element-citation></ref><ref id="bib8"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Ayali</surname><given-names>A</given-names></name><name><surname>Couzin-Fuchs</surname><given-names>E</given-names></name><name><surname>David</surname><given-names>I</given-names></name><name><surname>Gal</surname><given-names>O</given-names></name><name><surname>Holmes</surname><given-names>P</given-names></name><name><surname>Knebel</surname><given-names>D</given-names></name></person-group><year iso-8601-date="2015">2015b</year><article-title>Sensory feedback in cockroach locomotion: current knowledge and open questions</article-title><source>Journal of Comparative Physiology A</source><volume>201</volume><fpage>841</fpage><lpage>850</lpage><pub-id pub-id-type="doi">10.1007/s00359-014-0968-1</pub-id></element-citation></ref><ref id="bib9"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Azevedo</surname><given-names>AW</given-names></name><name><surname>Dickinson</surname><given-names>ES</given-names></name><name><surname>Gurung</surname><given-names>P</given-names></name><name><surname>Venkatasubramanian</surname><given-names>L</given-names></name><name><surname>Mann</surname><given-names>RS</given-names></name><name><surname>Tuthill</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2020">2020</year><article-title>A size principle for recruitment of <italic>Drosophila</italic> leg motor neurons</article-title><source>eLife</source><volume>9</volume><elocation-id>e56754</elocation-id><pub-id pub-id-type="doi">10.7554/eLife.56754</pub-id><pub-id pub-id-type="pmid">32490810</pub-id></element-citation></ref><ref id="bib10"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Azevedo</surname><given-names>A</given-names></name><name><surname>Lesser</surname><given-names>E</given-names></name><name><surname>Phelps</surname><given-names>JS</given-names></name><name><surname>Mark</surname><given-names>B</given-names></name><name><surname>Elabbady</surname><given-names>L</given-names></name><name><surname>Kuroda</surname><given-names>S</given-names></name><name><surname>Sustar</surname><given-names>A</given-names></name><name><surname>Moussa</surname><given-names>A</given-names></name><name><surname>Khandelwal</surname><given-names>A</given-names></name><name><surname>Dallmann</surname><given-names>CJ</given-names></name><name><surname>Agrawal</surname><given-names>S</given-names></name><name><surname>Lee</surname><given-names>S-YJ</given-names></name><name><surname>Pratt</surname><given-names>B</given-names></name><name><surname>Cook</surname><given-names>A</given-names></name><name><surname>Skutt-Kakaria</surname><given-names>K</given-names></name><name><surname>Gerhard</surname><given-names>S</given-names></name><name><surname>Lu</surname><given-names>R</given-names></name><name><surname>Kemnitz</surname><given-names>N</given-names></name><name><surname>Lee</surname><given-names>K</given-names></name><name><surname>Halageri</surname><given-names>A</given-names></name><name><surname>Castro</surname><given-names>M</given-names></name><name><surname>Ih</surname><given-names>D</given-names></name><name><surname>Gager</surname><given-names>J</given-names></name><name><surname>Tammam</surname><given-names>M</given-names></name><name><surname>Dorkenwald</surname><given-names>S</given-names></name><name><surname>Collman</surname><given-names>F</given-names></name><name><surname>Schneider-Mizell</surname><given-names>C</given-names></name><name><surname>Brittain</surname><given-names>D</given-names></name><name><surname>Jordan</surname><given-names>CS</given-names></name><name><surname>Dickinson</surname><given-names>M</given-names></name><name><surname>Pacureanu</surname><given-names>A</given-names></name><name><surname>Seung</surname><given-names>HS</given-names></name><name><surname>Macrina</surname><given-names>T</given-names></name><name><surname>Lee</surname><given-names>W-CA</given-names></name><name><surname>Tuthill</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2024">2024</year><article-title>Connectomic reconstruction of a female <italic>Drosophila</italic> ventral nerve cord</article-title><source>Nature</source><volume>631</volume><fpage>360</fpage><lpage>368</lpage><pub-id pub-id-type="doi">10.1038/s41586-024-07389-x</pub-id><pub-id pub-id-type="pmid">38926570</pub-id></element-citation></ref><ref id="bib11"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Banerjee</surname><given-names>A</given-names></name><name><surname>Egger</surname><given-names>R</given-names></name><name><surname>Long</surname><given-names>MA</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title>Using focal cooling to link neural dynamics and behavior</article-title><source>Neuron</source><volume>109</volume><fpage>2508</fpage><lpage>2518</lpage><pub-id pub-id-type="doi">10.1016/j.neuron.2021.05.029</pub-id></element-citation></ref><ref id="bib12"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Bässler</surname><given-names>U</given-names></name></person-group><year iso-8601-date="1977">1977</year><article-title>Sensory control of leg movement in the stick insect Carausius morosus</article-title><source>Biological Cybernetics</source><volume>25</volume><fpage>61</fpage><lpage>72</lpage><pub-id pub-id-type="doi">10.1007/BF00337264</pub-id></element-citation></ref><ref id="bib13"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Bässler</surname><given-names>U</given-names></name></person-group><year iso-8601-date="1993">1993</year><article-title>The femur-tibia control system of stick insects--a model system for the study of the neural basis of joint control</article-title><source>Brain Research. Brain Research Reviews</source><volume>18</volume><fpage>207</fpage><lpage>226</lpage><pub-id pub-id-type="doi">10.1016/0165-0173(93)90002-h</pub-id><pub-id pub-id-type="pmid">8339107</pub-id></element-citation></ref><ref id="bib14"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Berberich</surname><given-names>J</given-names></name><name><surname>Kohler</surname><given-names>J</given-names></name><name><surname>Muller</surname><given-names>MA</given-names></name><name><surname>Allgower</surname><given-names>F</given-names></name></person-group><year iso-8601-date="2022">2022</year><article-title>Linear tracking MPC for nonlinear systems—part i: the model-based case</article-title><source>IEEE Transactions on Automatic Control</source><volume>67</volume><fpage>4390</fpage><lpage>4405</lpage><pub-id pub-id-type="doi">10.1109/TAC.2022.3166872</pub-id></element-citation></ref><ref id="bib15"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Berendes</surname><given-names>V</given-names></name><name><surname>Zill</surname><given-names>SN</given-names></name><name><surname>Büschges</surname><given-names>A</given-names></name><name><surname>Bockemühl</surname><given-names>T</given-names></name></person-group><year iso-8601-date="2016">2016</year><article-title>Speed-dependent interplay between local pattern-generating activity and sensory signals during walking in <italic>Drosophila</italic></article-title><source>The Journal of Experimental Biology</source><volume>219</volume><fpage>3781</fpage><lpage>3793</lpage><pub-id pub-id-type="doi">10.1242/jeb.146720</pub-id><pub-id pub-id-type="pmid">27688052</pub-id></element-citation></ref><ref id="bib16"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Berman</surname><given-names>GJ</given-names></name><name><surname>Bialek</surname><given-names>W</given-names></name><name><surname>Shaevitz</surname><given-names>JW</given-names></name></person-group><year iso-8601-date="2016">2016</year><article-title>Predictability and hierarchy in <italic>Drosophila</italic> behavior</article-title><source>PNAS</source><volume>113</volume><fpage>11943</fpage><lpage>11948</lpage><pub-id pub-id-type="doi">10.1073/pnas.1607601113</pub-id><pub-id pub-id-type="pmid">27702892</pub-id></element-citation></ref><ref id="bib17"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Berret</surname><given-names>B</given-names></name><name><surname>Chiovetto</surname><given-names>E</given-names></name><name><surname>Nori</surname><given-names>F</given-names></name><name><surname>Pozzo</surname><given-names>T</given-names></name></person-group><year iso-8601-date="2011">2011</year><article-title>Evidence for composite cost functions in arm movement planning: an inverse optimal control approach</article-title><source>PLOS Computational Biology</source><volume>7</volume><elocation-id>e1002183</elocation-id><pub-id pub-id-type="doi">10.1371/journal.pcbi.1002183</pub-id><pub-id pub-id-type="pmid">22022242</pub-id></element-citation></ref><ref id="bib18"><element-citation publication-type="book"><person-group person-group-type="author"><name><surname>Brunton</surname><given-names>SL</given-names></name></person-group><year iso-8601-date="2022">2022</year><source>Data-Driven Science and Engineering: Machine Learning, Dynamical Systems, and Control</source><publisher-name>Cambridge University Press</publisher-name><pub-id pub-id-type="doi">10.1017/9781009089517</pub-id></element-citation></ref><ref id="bib19"><element-citation publication-type="book"><person-group person-group-type="author"><name><surname>Buss</surname><given-names>M</given-names></name><name><surname>Glocker</surname><given-names>M</given-names></name><name><surname>Hardt</surname><given-names>M</given-names></name><name><surname>VonStryk</surname><given-names>O</given-names></name></person-group><year iso-8601-date="2002">2002</year><chapter-title>Nonlinear hybrid dynamical systems: modeling, optimal control, and applications</chapter-title><person-group person-group-type="editor"><name><surname>Glocker</surname><given-names>M</given-names></name><name><surname>Hardt</surname><given-names>M</given-names></name></person-group><source>In Modelling, Analysis, and Design of Hybrid Systems</source><publisher-name>Springer</publisher-name><fpage>311</fpage><lpage>325</lpage><pub-id pub-id-type="doi">10.1007/3-540-45426-8_18</pub-id></element-citation></ref><ref id="bib20"><element-citation publication-type="book"><person-group person-group-type="author"><name><surname>Camacho</surname><given-names>EF</given-names></name></person-group><year iso-8601-date="2013">2013</year><source>Model Predictive Control</source><publisher-name>Springer Science &amp; Business Media</publisher-name><pub-id pub-id-type="doi">10.1007/978-0-85729-398-5</pub-id></element-citation></ref><ref id="bib21"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Catavitello</surname><given-names>G</given-names></name><name><surname>Ivanenko</surname><given-names>Y</given-names></name><name><surname>Lacquaniti</surname><given-names>F</given-names></name></person-group><year iso-8601-date="2018">2018</year><article-title>A kinematic synergy for terrestrial locomotion shared by mammals and birds</article-title><source>eLife</source><volume>7</volume><elocation-id>e38190</elocation-id><pub-id pub-id-type="doi">10.7554/eLife.38190</pub-id><pub-id pub-id-type="pmid">30376448</pub-id></element-citation></ref><ref id="bib22"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Cheong</surname><given-names>HS</given-names></name><name><surname>Eichler</surname><given-names>K</given-names></name><name><surname>Stürner</surname><given-names>T</given-names></name><name><surname>Asinof</surname><given-names>SK</given-names></name><name><surname>Champion</surname><given-names>AS</given-names></name><name><surname>Marin</surname><given-names>EC</given-names></name><name><surname>Oram</surname><given-names>TB</given-names></name><name><surname>Sumathipala</surname><given-names>M</given-names></name><name><surname>Venkatasubramanian</surname><given-names>L</given-names></name><name><surname>Namiki</surname><given-names>S</given-names></name><name><surname>Siwanowicz</surname><given-names>I</given-names></name><name><surname>Costa</surname><given-names>M</given-names></name><name><surname>Berg</surname><given-names>S</given-names></name><name><surname>Jefferis</surname><given-names>GS</given-names></name><name><surname>Card</surname><given-names>GM</given-names></name><collab>Janelia FlyEM Project Team</collab></person-group><year iso-8601-date="2024">2024</year><article-title>Transforming descending input into behavior: the organization of premotor circuits in the <italic>Drosophila</italic> male adult nerve cord connectome</article-title><source>eLife</source><volume>1</volume><elocation-id>96084</elocation-id><pub-id pub-id-type="doi">10.7554/eLife.96084</pub-id></element-citation></ref><ref id="bib23"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Chiang</surname><given-names>M</given-names></name><name><surname>Low</surname><given-names>SH</given-names></name><name><surname>Calderbank</surname><given-names>AR</given-names></name><name><surname>Doyle</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2007">2007</year><article-title>Layering as optimization decomposition: a mathematical theory of network architectures</article-title><source>Proceedings of the IEEE</source><volume>95</volume><fpage>255</fpage><lpage>312</lpage><pub-id pub-id-type="doi">10.1109/JPROC.2006.887322</pub-id></element-citation></ref><ref id="bib24"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Chun</surname><given-names>C</given-names></name><name><surname>Biswas</surname><given-names>T</given-names></name><name><surname>Bhandawat</surname><given-names>V</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title><italic>Drosophila</italic> uses a tripod gait across all walking speeds, and the geometry of the tripod is important for speed control</article-title><source>eLife</source><volume>10</volume><elocation-id>e65878</elocation-id><pub-id pub-id-type="doi">10.7554/eLife.65878</pub-id><pub-id pub-id-type="pmid">33533718</pub-id></element-citation></ref><ref id="bib25"><element-citation publication-type="preprint"><person-group person-group-type="author"><name><surname>Clevert</surname><given-names>DA</given-names></name><name><surname>Unterthiner</surname><given-names>T</given-names></name><name><surname>Hochreiter</surname><given-names>S</given-names></name></person-group><year iso-8601-date="2015">2015</year><article-title>Fast and Accurate Deep Network Learning by Exponential Linear Units (Elus)</article-title><source>arXiv</source><ext-link ext-link-type="uri" xlink:href="https://arxiv.org/abs/1511.07289">https://arxiv.org/abs/1511.07289</ext-link></element-citation></ref><ref id="bib26"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Couzin-Fuchs</surname><given-names>E</given-names></name><name><surname>Kiemel</surname><given-names>T</given-names></name><name><surname>Gal</surname><given-names>O</given-names></name><name><surname>Ayali</surname><given-names>A</given-names></name><name><surname>Holmes</surname><given-names>P</given-names></name></person-group><year iso-8601-date="2015">2015</year><article-title>Intersegmental coupling and recovery from perturbations in freely running cockroaches</article-title><source>The Journal of Experimental Biology</source><volume>218</volume><fpage>285</fpage><lpage>297</lpage><pub-id pub-id-type="doi">10.1242/jeb.112805</pub-id><pub-id pub-id-type="pmid">25609786</pub-id></element-citation></ref><ref id="bib27"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Cruz</surname><given-names>TL</given-names></name><name><surname>Chiappe</surname><given-names>ME</given-names></name></person-group><year iso-8601-date="2023">2023</year><article-title>Multilevel visuomotor control of locomotion in <italic>Drosophila</italic></article-title><source>Current Opinion in Neurobiology</source><volume>82</volume><elocation-id>102774</elocation-id><pub-id pub-id-type="doi">10.1016/j.conb.2023.102774</pub-id></element-citation></ref><ref id="bib28"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Daley</surname><given-names>MA</given-names></name></person-group><year iso-8601-date="2018">2018</year><article-title>Understanding the agility of running birds: sensorimotor and mechanical factors in avian bipedal locomotion</article-title><source>Integrative and Comparative Biology</source><volume>58</volume><fpage>884</fpage><lpage>893</lpage><pub-id pub-id-type="doi">10.1093/icb/icy058</pub-id><pub-id pub-id-type="pmid">29897448</pub-id></element-citation></ref><ref id="bib29"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Dallmann</surname><given-names>CJ</given-names></name><name><surname>Hoinville</surname><given-names>T</given-names></name><name><surname>Dürr</surname><given-names>V</given-names></name><name><surname>Schmitz</surname><given-names>J</given-names></name></person-group><year iso-8601-date="2017">2017</year><article-title>A load-based mechanism for inter-leg coordination in insects</article-title><source>Proceedings. Biological Sciences</source><volume>284</volume><elocation-id>20171755</elocation-id><pub-id pub-id-type="doi">10.1098/rspb.2017.1755</pub-id><pub-id pub-id-type="pmid">29187626</pub-id></element-citation></ref><ref id="bib30"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Dallmann</surname><given-names>CJ</given-names></name><name><surname>Karashchuk</surname><given-names>P</given-names></name><name><surname>Brunton</surname><given-names>BW</given-names></name><name><surname>Tuthill</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title>A leg to stand on: computational models of proprioception</article-title><source>Current Opinion in Physiology</source><volume>22</volume><elocation-id>100426</elocation-id><pub-id pub-id-type="doi">10.1016/j.cophys.2021.03.001</pub-id><pub-id pub-id-type="pmid">34595361</pub-id></element-citation></ref><ref id="bib31"><element-citation publication-type="preprint"><person-group person-group-type="author"><name><surname>Dallmann</surname><given-names>CJ</given-names></name><name><surname>Luo</surname><given-names>Y</given-names></name><name><surname>Agrawal</surname><given-names>S</given-names></name><name><surname>Chou</surname><given-names>GM</given-names></name><name><surname>Cook</surname><given-names>A</given-names></name><name><surname>Brunton</surname><given-names>BW</given-names></name><name><surname>Tuthill</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2023">2023</year><article-title>Presynaptic inhibition selectively suppresses leg proprioception in behaving <italic>Drosophila</italic></article-title><source>bioRxiv</source><pub-id pub-id-type="doi">10.1101/2023.10.20.563322</pub-id></element-citation></ref><ref id="bib32"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>DeAngelis</surname><given-names>BD</given-names></name><name><surname>Zavatone-Veth</surname><given-names>JA</given-names></name><name><surname>Clark</surname><given-names>DA</given-names></name></person-group><year iso-8601-date="2019">2019</year><article-title>The manifold structure of limb coordination in walking <italic>Drosophila</italic></article-title><source>eLife</source><volume>8</volume><elocation-id>e46409</elocation-id><pub-id pub-id-type="doi">10.7554/eLife.46409</pub-id><pub-id pub-id-type="pmid">31250807</pub-id></element-citation></ref><ref id="bib33"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Desmurget</surname><given-names>M</given-names></name><name><surname>Grafton</surname><given-names>S</given-names></name></person-group><year iso-8601-date="2000">2000</year><article-title>Forward modeling allows feedback control for fast reaching movements</article-title><source>Trends in Cognitive Sciences</source><volume>4</volume><fpage>423</fpage><lpage>431</lpage><pub-id pub-id-type="doi">10.1016/S1364-6613(00)01537-0</pub-id></element-citation></ref><ref id="bib34"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Doyle</surname><given-names>JC</given-names></name><name><surname>Csete</surname><given-names>M</given-names></name></person-group><year iso-8601-date="2011">2011</year><article-title>Architecture, constraints, and behavior</article-title><source>PNAS</source><volume>108 Suppl 3</volume><fpage>15624</fpage><lpage>15630</lpage><pub-id pub-id-type="doi">10.1073/pnas.1103557108</pub-id><pub-id pub-id-type="pmid">21788505</pub-id></element-citation></ref><ref id="bib35"><element-citation publication-type="book"><person-group person-group-type="author"><name><surname>Doyle</surname><given-names>JC</given-names></name><name><surname>Francis</surname><given-names>BA</given-names></name><name><surname>Tannenbaum</surname><given-names>AR</given-names></name></person-group><year iso-8601-date="2013">2013</year><source>Feedback Control Theory</source><publisher-name>Courier Corporation</publisher-name></element-citation></ref><ref id="bib36"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Fisher</surname><given-names>YE</given-names></name></person-group><year iso-8601-date="2022">2022</year><article-title>Flexible navigational computations in the <italic>Drosophila</italic> central complex</article-title><source>Current Opinion in Neurobiology</source><volume>73</volume><elocation-id>102514</elocation-id><pub-id pub-id-type="doi">10.1016/j.conb.2021.12.001</pub-id><pub-id pub-id-type="pmid">35196623</pub-id></element-citation></ref><ref id="bib37"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Franklin</surname><given-names>DW</given-names></name><name><surname>Wolpert</surname><given-names>DM</given-names></name></person-group><year iso-8601-date="2011">2011</year><article-title>Computational mechanisms of sensorimotor control</article-title><source>Neuron</source><volume>72</volume><fpage>425</fpage><lpage>442</lpage><pub-id pub-id-type="doi">10.1016/j.neuron.2011.10.006</pub-id><pub-id pub-id-type="pmid">22078503</pub-id></element-citation></ref><ref id="bib38"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Galili</surname><given-names>DS</given-names></name><name><surname>Jefferis</surname><given-names>GS</given-names></name><name><surname>Costa</surname><given-names>M</given-names></name></person-group><year iso-8601-date="2022">2022</year><article-title>Connectomics and the neural basis of behaviour</article-title><source>Current Opinion in Insect Science</source><volume>54</volume><elocation-id>100968</elocation-id><pub-id pub-id-type="doi">10.1016/j.cois.2022.100968</pub-id><pub-id pub-id-type="pmid">36113710</pub-id></element-citation></ref><ref id="bib39"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>García</surname><given-names>CE</given-names></name><name><surname>Prett</surname><given-names>DM</given-names></name><name><surname>Morari</surname><given-names>M</given-names></name></person-group><year iso-8601-date="1989">1989</year><article-title>Model predictive control: Theory and practice—A survey</article-title><source>Automatica</source><volume>25</volume><fpage>335</fpage><lpage>348</lpage><pub-id pub-id-type="doi">10.1016/0005-1098(89)90002-2</pub-id></element-citation></ref><ref id="bib40"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Gebehart</surname><given-names>C</given-names></name><name><surname>Büschges</surname><given-names>A</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title>Temporal differences between load and movement signal integration in the sensorimotor network of an insect leg</article-title><source>Journal of Neurophysiology</source><volume>126</volume><fpage>1875</fpage><lpage>1890</lpage><pub-id pub-id-type="doi">10.1152/jn.00399.2021</pub-id></element-citation></ref><ref id="bib41"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Geijtenbeek</surname><given-names>T</given-names></name><name><surname>van de Panne</surname><given-names>M</given-names></name><name><surname>van der Stappen</surname><given-names>AF</given-names></name></person-group><year iso-8601-date="2013">2013</year><article-title>Flexible muscle-based locomotion for bipedal creatures</article-title><source>ACM Transactions on Graphics</source><volume>32</volume><fpage>1</fpage><lpage>11</lpage><pub-id pub-id-type="doi">10.1145/2508363.2508399</pub-id></element-citation></ref><ref id="bib42"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Geyer</surname><given-names>H</given-names></name><name><surname>Herr</surname><given-names>H</given-names></name></person-group><year iso-8601-date="2010">2010</year><article-title>A muscle-reflex model that encodes principles of legged mechanics produces human walking dynamics and muscle activities</article-title><source>IEEE Transactions on Neural Systems and Rehabilitation Engineering</source><volume>18</volume><fpage>263</fpage><lpage>273</lpage><pub-id pub-id-type="doi">10.1109/TNSRE.2010.2047592</pub-id></element-citation></ref><ref id="bib43"><element-citation publication-type="book"><person-group person-group-type="author"><name><surname>Goldsmith</surname><given-names>C</given-names></name></person-group><year iso-8601-date="2019">2019</year><chapter-title>Drosophibot: A fruit fly inspired bio-robot</chapter-title><person-group person-group-type="editor"><name><surname>Goldsmith</surname><given-names>C</given-names></name></person-group><source>In Biomimetic and Biohybrid Systems</source><publisher-name>Springer International Publishing</publisher-name><fpage>146</fpage><lpage>157</lpage><pub-id pub-id-type="doi">10.1007/978-3-030-24741-6_13</pub-id></element-citation></ref><ref id="bib44"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Goldsmith</surname><given-names>CA</given-names></name><name><surname>Szczecinski</surname><given-names>NS</given-names></name><name><surname>Quinn</surname><given-names>RD</given-names></name></person-group><year iso-8601-date="2020">2020</year><article-title>Neurodynamic modeling of the fruit fly <italic>Drosophila melanogaster</italic></article-title><source>Bioinspiration &amp; Biomimetics</source><volume>15</volume><elocation-id>065003</elocation-id><pub-id pub-id-type="doi">10.1088/1748-3190/ab9e52</pub-id></element-citation></ref><ref id="bib45"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Gonçalves</surname><given-names>AI</given-names></name><name><surname>Zavatone-Veth</surname><given-names>JA</given-names></name><name><surname>Carey</surname><given-names>MR</given-names></name><name><surname>Clark</surname><given-names>DA</given-names></name></person-group><year iso-8601-date="2022">2022</year><article-title>Parallel locomotor control strategies in mice and flies</article-title><source>Current Opinion in Neurobiology</source><volume>73</volume><elocation-id>102516</elocation-id><pub-id pub-id-type="doi">10.1016/j.conb.2022.01.001</pub-id><pub-id pub-id-type="pmid">35158168</pub-id></element-citation></ref><ref id="bib46"><element-citation publication-type="preprint"><person-group person-group-type="author"><name><surname>Heess</surname><given-names>N</given-names></name><name><surname>Sriram</surname><given-names>S</given-names></name><name><surname>Lemmon</surname><given-names>J</given-names></name><name><surname>Merel</surname><given-names>J</given-names></name><name><surname>Wayne</surname><given-names>G</given-names></name><name><surname>Tassa</surname><given-names>Y</given-names></name></person-group><year iso-8601-date="2017">2017</year><article-title>Emergence of Locomotion Behaviours in Rich Environments</article-title><source>arXiv</source><ext-link ext-link-type="uri" xlink:href="https://arxiv.org/abs/1707.02286">https://arxiv.org/abs/1707.02286</ext-link></element-citation></ref><ref id="bib47"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Holden</surname><given-names>D</given-names></name><name><surname>Komura</surname><given-names>T</given-names></name><name><surname>Saito</surname><given-names>J</given-names></name></person-group><year iso-8601-date="2017">2017</year><article-title>Phase-functioned neural networks for character control</article-title><source>ACM Transactions on Graphics</source><volume>36</volume><fpage>1</fpage><lpage>13</lpage><pub-id pub-id-type="doi">10.1145/3072959.3073663</pub-id></element-citation></ref><ref id="bib48"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Hua</surname><given-names>J</given-names></name><name><surname>Zeng</surname><given-names>L</given-names></name><name><surname>Li</surname><given-names>G</given-names></name><name><surname>Ju</surname><given-names>Z</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title>Learning for a robot: deep reinforcement learning, imitation learning, transfer learning</article-title><source>Sensors</source><volume>21</volume><elocation-id>1278</elocation-id><pub-id pub-id-type="doi">10.3390/s21041278</pub-id><pub-id pub-id-type="pmid">33670109</pub-id></element-citation></ref><ref id="bib49"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Hunter</surname><given-names>JD</given-names></name></person-group><year iso-8601-date="2007">2007</year><article-title>Matplotlib: a 2D graphics environment</article-title><source>Computing in Science &amp; Engineering</source><volume>9</volume><fpage>90</fpage><lpage>95</lpage><pub-id pub-id-type="doi">10.1109/MCSE.2007.55</pub-id></element-citation></ref><ref id="bib50"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Hussein</surname><given-names>A</given-names></name><name><surname>Gaber</surname><given-names>MM</given-names></name><name><surname>Elyan</surname><given-names>E</given-names></name><name><surname>Jayne</surname><given-names>C</given-names></name></person-group><year iso-8601-date="2018">2018</year><article-title>Imitation Learning: a survey of learning methods</article-title><source>ACM Computing Surveys</source><volume>50</volume><fpage>1</fpage><lpage>35</lpage><pub-id pub-id-type="doi">10.1145/3054912</pub-id></element-citation></ref><ref id="bib51"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Ijspeert</surname><given-names>AJ</given-names></name><name><surname>Daley</surname><given-names>MA</given-names></name></person-group><year iso-8601-date="2023">2023</year><article-title>Integration of feedforward and feedback control in the neuromechanics of vertebrate locomotion: a review of experimental, simulation and robotic studies</article-title><source>The Journal of Experimental Biology</source><volume>226</volume><elocation-id>jeb245784</elocation-id><pub-id pub-id-type="doi">10.1242/jeb.245784</pub-id><pub-id pub-id-type="pmid">37565347</pub-id></element-citation></ref><ref id="bib52"><element-citation publication-type="preprint"><person-group person-group-type="author"><name><surname>Iwasaki</surname><given-names>K</given-names></name><name><surname>Neuhauser</surname><given-names>C</given-names></name><name><surname>Stokes</surname><given-names>C</given-names></name><name><surname>Rayshubskiy</surname><given-names>A</given-names></name></person-group><year iso-8601-date="2024">2024</year><article-title>The fruit fly, <italic>Drosophila melanogaster</italic>, as a micro-robotics platform</article-title><source>bioRxiv</source><pub-id pub-id-type="doi">10.1101/2024.05.24.595748</pub-id></element-citation></ref><ref id="bib53"><element-citation publication-type="confproc"><person-group person-group-type="author"><name><surname>Johns</surname><given-names>E</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title>Coarse-to-Fine Imitation Learning: Robot Manipulation from a Single Demonstration</article-title><conf-name>2021 IEEE International Conference on Robotics and Automation (ICRA)</conf-name><conf-loc>Xi’an, China</conf-loc><pub-id pub-id-type="doi">10.1109/ICRA48506.2021.9560942</pub-id></element-citation></ref><ref id="bib54"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Karashchuk</surname><given-names>P</given-names></name><name><surname>Rupp</surname><given-names>KL</given-names></name><name><surname>Dickinson</surname><given-names>ES</given-names></name><name><surname>Walling-Bell</surname><given-names>S</given-names></name><name><surname>Sanders</surname><given-names>E</given-names></name><name><surname>Azim</surname><given-names>E</given-names></name><name><surname>Brunton</surname><given-names>BW</given-names></name><name><surname>Tuthill</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title>Anipose: a toolkit for robust markerless 3D pose estimation</article-title><source>Cell Reports</source><volume>36</volume><elocation-id>109730</elocation-id><pub-id pub-id-type="doi">10.1016/j.celrep.2021.109730</pub-id><pub-id pub-id-type="pmid">34592148</pub-id></element-citation></ref><ref id="bib55"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Katsov</surname><given-names>AY</given-names></name><name><surname>Freifeld</surname><given-names>L</given-names></name><name><surname>Horowitz</surname><given-names>M</given-names></name><name><surname>Kuehn</surname><given-names>S</given-names></name><name><surname>Clandinin</surname><given-names>TR</given-names></name></person-group><year iso-8601-date="2017">2017</year><article-title>Dynamic structure of locomotor behavior in walking fruit flies</article-title><source>eLife</source><volume>6</volume><elocation-id>e26410</elocation-id><pub-id pub-id-type="doi">10.7554/eLife.26410</pub-id><pub-id pub-id-type="pmid">28742018</pub-id></element-citation></ref><ref id="bib56"><element-citation publication-type="preprint"><person-group person-group-type="author"><name><surname>Kingma</surname><given-names>DP</given-names></name><name><surname>Ba</surname><given-names>J</given-names></name></person-group><year iso-8601-date="2017">2017</year><article-title>Adam: A Method for Stochastic Optimization</article-title><source>arXiv</source><ext-link ext-link-type="uri" xlink:href="https://arxiv.org/abs/1412.6980">https://arxiv.org/abs/1412.6980</ext-link></element-citation></ref><ref id="bib57"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Kottmeier</surname><given-names>R</given-names></name><name><surname>Bittern</surname><given-names>J</given-names></name><name><surname>Schoofs</surname><given-names>A</given-names></name><name><surname>Scheiwe</surname><given-names>F</given-names></name><name><surname>Matzat</surname><given-names>T</given-names></name><name><surname>Pankratz</surname><given-names>M</given-names></name><name><surname>Klämbt</surname><given-names>C</given-names></name></person-group><year iso-8601-date="2020">2020</year><article-title>Wrapping glia regulates neuronal signaling speed and precision in the peripheral nervous system of <italic>Drosophila</italic></article-title><source>Nature Communications</source><volume>11</volume><elocation-id>4491</elocation-id><pub-id pub-id-type="doi">10.1038/s41467-020-18291-1</pub-id><pub-id pub-id-type="pmid">32901033</pub-id></element-citation></ref><ref id="bib58"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Labonte</surname><given-names>D</given-names></name><name><surname>Bishop</surname><given-names>PJ</given-names></name><name><surname>Dick</surname><given-names>TJM</given-names></name><name><surname>Clemente</surname><given-names>CJ</given-names></name></person-group><year iso-8601-date="2024">2024</year><article-title>Dynamic similarity and the peculiar allometry of maximum running speed</article-title><source>Nature Communications</source><volume>15</volume><elocation-id>2181</elocation-id><pub-id pub-id-type="doi">10.1038/s41467-024-46269-w</pub-id><pub-id pub-id-type="pmid">38467620</pub-id></element-citation></ref><ref id="bib59"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Lesser</surname><given-names>E</given-names></name><name><surname>Azevedo</surname><given-names>AW</given-names></name><name><surname>Phelps</surname><given-names>JS</given-names></name><name><surname>Elabbady</surname><given-names>L</given-names></name><name><surname>Cook</surname><given-names>A</given-names></name><name><surname>Syed</surname><given-names>DS</given-names></name><name><surname>Mark</surname><given-names>B</given-names></name><name><surname>Kuroda</surname><given-names>S</given-names></name><name><surname>Sustar</surname><given-names>A</given-names></name><name><surname>Moussa</surname><given-names>A</given-names></name><name><surname>Dallmann</surname><given-names>CJ</given-names></name><name><surname>Agrawal</surname><given-names>S</given-names></name><name><surname>Lee</surname><given-names>S-YJ</given-names></name><name><surname>Pratt</surname><given-names>B</given-names></name><name><surname>Skutt-Kakaria</surname><given-names>K</given-names></name><name><surname>Gerhard</surname><given-names>S</given-names></name><name><surname>Lu</surname><given-names>R</given-names></name><name><surname>Kemnitz</surname><given-names>N</given-names></name><name><surname>Lee</surname><given-names>K</given-names></name><name><surname>Halageri</surname><given-names>A</given-names></name><name><surname>Castro</surname><given-names>M</given-names></name><name><surname>Ih</surname><given-names>D</given-names></name><name><surname>Gager</surname><given-names>J</given-names></name><name><surname>Tammam</surname><given-names>M</given-names></name><name><surname>Dorkenwald</surname><given-names>S</given-names></name><name><surname>Collman</surname><given-names>F</given-names></name><name><surname>Schneider-Mizell</surname><given-names>C</given-names></name><name><surname>Brittain</surname><given-names>D</given-names></name><name><surname>Jordan</surname><given-names>CS</given-names></name><name><surname>Macrina</surname><given-names>T</given-names></name><name><surname>Dickinson</surname><given-names>M</given-names></name><name><surname>Lee</surname><given-names>W-CA</given-names></name><name><surname>Tuthill</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2024">2024</year><article-title>Synaptic architecture of leg and wing premotor control networks in <italic>Drosophila</italic></article-title><source>Nature</source><volume>631</volume><fpage>369</fpage><lpage>377</lpage><pub-id pub-id-type="doi">10.1038/s41586-024-07600-z</pub-id><pub-id pub-id-type="pmid">38926579</pub-id></element-citation></ref><ref id="bib60"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Li</surname><given-names>JS</given-names></name><name><surname>Sarma</surname><given-names>AA</given-names></name><name><surname>Sejnowski</surname><given-names>TJ</given-names></name><name><surname>Doyle</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2023">2023</year><article-title>Internal feedback in the cortical perception-action loop enables fast and accurate behavior</article-title><source>PNAS</source><volume>120</volume><elocation-id>e2300445120</elocation-id><pub-id pub-id-type="doi">10.1073/pnas.2300445120</pub-id><pub-id pub-id-type="pmid">37738297</pub-id></element-citation></ref><ref id="bib61"><element-citation publication-type="software"><person-group person-group-type="author"><name><surname>Li</surname><given-names>L</given-names></name><name><surname>Karashchuk</surname><given-names>L</given-names></name></person-group><year iso-8601-date="2025">2025</year><data-title>Layered-walking</data-title><version designator="swh:1:rev:1810703562c3e5679912dab231140dda31dc5c73">swh:1:rev:1810703562c3e5679912dab231140dda31dc5c73</version><source>Software Heritage</source><ext-link ext-link-type="uri" xlink:href="https://archive.softwareheritage.org/swh:1:dir:988bc057efb900fafd1d4e476c50706977868910;origin=https://github.com/lambdaloop/layered-walking;visit=swh:1:snp:e59b1513a0c098537576a85187a6aeb62cb1cd48;anchor=swh:1:rev:1810703562c3e5679912dab231140dda31dc5c73">https://archive.softwareheritage.org/swh:1:dir:988bc057efb900fafd1d4e476c50706977868910;origin=https://github.com/lambdaloop/layered-walking;visit=swh:1:snp:e59b1513a0c098537576a85187a6aeb62cb1cd48;anchor=swh:1:rev:1810703562c3e5679912dab231140dda31dc5c73</ext-link></element-citation></ref><ref id="bib62"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Lobato-Rios</surname><given-names>V</given-names></name><name><surname>Ramalingasetty</surname><given-names>ST</given-names></name><name><surname>Özdil</surname><given-names>PG</given-names></name><name><surname>Arreguit</surname><given-names>J</given-names></name><name><surname>Ijspeert</surname><given-names>AJ</given-names></name><name><surname>Ramdya</surname><given-names>P</given-names></name></person-group><year iso-8601-date="2022">2022</year><article-title>NeuroMechFly, a neuromechanical model of adult <italic>Drosophila melanogaster</italic></article-title><source>Nature Methods</source><volume>19</volume><fpage>620</fpage><lpage>627</lpage><pub-id pub-id-type="doi">10.1038/s41592-022-01466-7</pub-id><pub-id pub-id-type="pmid">35545713</pub-id></element-citation></ref><ref id="bib63"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Lotkin</surname><given-names>M</given-names></name></person-group><year iso-8601-date="1956">1956</year><article-title>A note on the midpoint method of integration</article-title><source>Journal of the ACM</source><volume>3</volume><fpage>208</fpage><lpage>211</lpage><pub-id pub-id-type="doi">10.1145/320831.320840</pub-id></element-citation></ref><ref id="bib64"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Mamiya</surname><given-names>A</given-names></name><name><surname>Gurung</surname><given-names>P</given-names></name><name><surname>Tuthill</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2018">2018</year><article-title>Neural coding of leg proprioception in <italic>Drosophila</italic></article-title><source>Neuron</source><volume>100</volume><fpage>636</fpage><lpage>650</lpage><pub-id pub-id-type="doi">10.1016/j.neuron.2018.09.009</pub-id><pub-id pub-id-type="pmid">30293823</pub-id></element-citation></ref><ref id="bib65"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Mendes</surname><given-names>CS</given-names></name><name><surname>Bartos</surname><given-names>I</given-names></name><name><surname>Akay</surname><given-names>T</given-names></name><name><surname>Márka</surname><given-names>S</given-names></name><name><surname>Mann</surname><given-names>RS</given-names></name></person-group><year iso-8601-date="2013">2013</year><article-title>Quantification of gait parameters in freely walking wild type and sensory deprived <italic>Drosophila melanogaster</italic></article-title><source>eLife</source><volume>2</volume><elocation-id>e00231</elocation-id><pub-id pub-id-type="doi">10.7554/eLife.00231</pub-id><pub-id pub-id-type="pmid">23326642</pub-id></element-citation></ref><ref id="bib66"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>More</surname><given-names>HL</given-names></name><name><surname>Donelan</surname><given-names>JM</given-names></name></person-group><year iso-8601-date="2018">2018</year><article-title>Scaling of sensorimotor delays in terrestrial mammals</article-title><source>Proceedings. Biological Sciences</source><volume>285</volume><elocation-id>20180613</elocation-id><pub-id pub-id-type="doi">10.1098/rspb.2018.0613</pub-id><pub-id pub-id-type="pmid">30158304</pub-id></element-citation></ref><ref id="bib67"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Nakahira</surname><given-names>Y</given-names></name><name><surname>Liu</surname><given-names>Q</given-names></name><name><surname>Sejnowski</surname><given-names>TJ</given-names></name><name><surname>Doyle</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title>Diversity-enabled sweet spots in layered architectures and speed-accuracy trade-offs in sensorimotor control</article-title><source>PNAS</source><volume>118</volume><elocation-id>e1916367118</elocation-id><pub-id pub-id-type="doi">10.1073/pnas.1916367118</pub-id><pub-id pub-id-type="pmid">34050009</pub-id></element-citation></ref><ref id="bib68"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Nirody</surname><given-names>JA</given-names></name><name><surname>Duran</surname><given-names>LA</given-names></name><name><surname>Johnston</surname><given-names>D</given-names></name><name><surname>Cohen</surname><given-names>DJ</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title>Tardigrades exhibit robust interlimb coordination across walking speeds and terrains</article-title><source>PNAS</source><volume>118</volume><elocation-id>e2107289118</elocation-id><pub-id pub-id-type="doi">10.1073/pnas.2107289118</pub-id><pub-id pub-id-type="pmid">34446560</pub-id></element-citation></ref><ref id="bib69"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Nishii</surname><given-names>J</given-names></name></person-group><year iso-8601-date="2000">2000</year><article-title>Legged insects select the optimal locomotor pattern based on the energetic cost</article-title><source>Biological Cybernetics</source><volume>83</volume><fpage>435</fpage><lpage>442</lpage><pub-id pub-id-type="doi">10.1007/s004220000175</pub-id><pub-id pub-id-type="pmid">11073207</pub-id></element-citation></ref><ref id="bib70"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Phelps</surname><given-names>JS</given-names></name><name><surname>Hildebrand</surname><given-names>DGC</given-names></name><name><surname>Graham</surname><given-names>BJ</given-names></name><name><surname>Kuan</surname><given-names>AT</given-names></name><name><surname>Thomas</surname><given-names>LA</given-names></name><name><surname>Nguyen</surname><given-names>TM</given-names></name><name><surname>Buhmann</surname><given-names>J</given-names></name><name><surname>Azevedo</surname><given-names>AW</given-names></name><name><surname>Sustar</surname><given-names>A</given-names></name><name><surname>Agrawal</surname><given-names>S</given-names></name><name><surname>Liu</surname><given-names>M</given-names></name><name><surname>Shanny</surname><given-names>BL</given-names></name><name><surname>Funke</surname><given-names>J</given-names></name><name><surname>Tuthill</surname><given-names>JC</given-names></name><name><surname>Lee</surname><given-names>W-CA</given-names></name></person-group><year iso-8601-date="2021">2021</year><article-title>Reconstruction of motor control circuits in adult <italic>Drosophila</italic> using automated transmission electron microscopy</article-title><source>Cell</source><volume>184</volume><fpage>759</fpage><lpage>774</lpage><pub-id pub-id-type="doi">10.1016/j.cell.2020.12.013</pub-id><pub-id pub-id-type="pmid">33400916</pub-id></element-citation></ref><ref id="bib71"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Pratt</surname><given-names>BG</given-names></name><name><surname>Lee</surname><given-names>SYJ</given-names></name><name><surname>Chou</surname><given-names>GM</given-names></name><name><surname>Tuthill</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2024">2024</year><article-title>Miniature linear and split-belt treadmills reveal mechanisms of adaptive motor control in walking <italic>Drosophila</italic></article-title><source>Current Biology</source><volume>34</volume><fpage>4368</fpage><lpage>4381</lpage><pub-id pub-id-type="doi">10.1016/j.cub.2024.08.006</pub-id><pub-id pub-id-type="pmid">39216486</pub-id></element-citation></ref><ref id="bib72"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Proctor</surname><given-names>JL</given-names></name><name><surname>Holmes</surname><given-names>P</given-names></name></person-group><year iso-8601-date="2018">2018</year><article-title>The effects of feedback on stability and maneuverability of a phase-reduced model for cockroach locomotion</article-title><source>Biological Cybernetics</source><volume>112</volume><fpage>387</fpage><lpage>401</lpage><pub-id pub-id-type="doi">10.1007/s00422-018-0762-1</pub-id><pub-id pub-id-type="pmid">29948143</pub-id></element-citation></ref><ref id="bib73"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Ramdya</surname><given-names>P</given-names></name><name><surname>Thandiackal</surname><given-names>R</given-names></name><name><surname>Cherney</surname><given-names>R</given-names></name><name><surname>Asselborn</surname><given-names>T</given-names></name><name><surname>Benton</surname><given-names>R</given-names></name><name><surname>Ijspeert</surname><given-names>AJ</given-names></name><name><surname>Floreano</surname><given-names>D</given-names></name></person-group><year iso-8601-date="2017">2017</year><article-title>Climbing favours the tripod gait over alternative faster insect gaits</article-title><source>Nature Communications</source><volume>8</volume><elocation-id>14494</elocation-id><pub-id pub-id-type="doi">10.1038/ncomms14494</pub-id><pub-id pub-id-type="pmid">28211509</pub-id></element-citation></ref><ref id="bib74"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Schilling</surname><given-names>M</given-names></name><name><surname>Hoinville</surname><given-names>T</given-names></name><name><surname>Schmitz</surname><given-names>J</given-names></name><name><surname>Cruse</surname><given-names>H</given-names></name></person-group><year iso-8601-date="2013">2013</year><article-title>Walknet, a bio-inspired controller for hexapod walking</article-title><source>Biological Cybernetics</source><volume>107</volume><fpage>397</fpage><lpage>419</lpage><pub-id pub-id-type="doi">10.1007/s00422-013-0563-5</pub-id><pub-id pub-id-type="pmid">23824506</pub-id></element-citation></ref><ref id="bib75"><element-citation publication-type="book"><person-group person-group-type="author"><name><surname>Sciavicco</surname><given-names>L</given-names></name><name><surname>Siciliano</surname><given-names>B</given-names></name></person-group><year iso-8601-date="2012">2012</year><source>Modelling and Control of Robot Manipulators</source><publisher-name>Springer Science &amp; Business Media</publisher-name><pub-id pub-id-type="doi">10.1007/978-1-4471-0449-0</pub-id></element-citation></ref><ref id="bib76"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Scott</surname><given-names>SH</given-names></name></person-group><year iso-8601-date="2004">2004</year><article-title>Optimal feedback control and the neural basis of volitional motor control</article-title><source>Nature Reviews. Neuroscience</source><volume>5</volume><fpage>532</fpage><lpage>546</lpage><pub-id pub-id-type="doi">10.1038/nrn1427</pub-id><pub-id pub-id-type="pmid">15208695</pub-id></element-citation></ref><ref id="bib77"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Simpson</surname><given-names>JH</given-names></name></person-group><year iso-8601-date="2024">2024</year><article-title>Descending control of motor sequences in <italic>Drosophila</italic></article-title><source>Current Opinion in Neurobiology</source><volume>84</volume><elocation-id>102822</elocation-id><pub-id pub-id-type="doi">10.1016/j.conb.2023.102822</pub-id><pub-id pub-id-type="pmid">38096757</pub-id></element-citation></ref><ref id="bib78"><element-citation publication-type="book"><person-group person-group-type="author"><name><surname>Slotine</surname><given-names>JJE</given-names></name><name><surname>Li</surname><given-names>W</given-names></name></person-group><year iso-8601-date="1991">1991</year><source>Applied Nonlinear Control</source><publisher-name>Prentice hall Englewood Cliffs</publisher-name></element-citation></ref><ref id="bib79"><element-citation publication-type="software"><person-group person-group-type="author"><name><surname>Sousa</surname><given-names>CD</given-names></name></person-group><year iso-8601-date="2013">2013</year><data-title>Sympybotics</data-title><version designator="v1.0">v1.0</version><source>Github</source><ext-link ext-link-type="uri" xlink:href="https://github.com/cdsousa/SymPyBotics">https://github.com/cdsousa/SymPyBotics</ext-link></element-citation></ref><ref id="bib80"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Srivastava</surname><given-names>N</given-names></name><name><surname>Hinton</surname><given-names>V</given-names></name><name><surname>Krizhevsky</surname><given-names>A</given-names></name></person-group><year iso-8601-date="2014">2014</year><article-title>Dropout: a simple way to prevent neural networks from overfitting</article-title><source>The Journal of Machine Learning Research</source><volume>15</volume><fpage>1929</fpage><lpage>1958</lpage></element-citation></ref><ref id="bib81"><element-citation publication-type="confproc"><person-group person-group-type="author"><name><surname>Stenberg</surname><given-names>J</given-names></name><name><surname>Lisa Li</surname><given-names>JS</given-names></name><name><surname>Sarma</surname><given-names>AA</given-names></name><name><surname>Doyle</surname><given-names>JC</given-names></name></person-group><year iso-8601-date="2022">2022</year><article-title>Internal Feedback in Biological Control: Diversity, Delays, and Standard Theory</article-title><conf-name>2022 American Control Conference (ACC)</conf-name><pub-id pub-id-type="doi">10.23919/ACC53348.2022.9867794</pub-id></element-citation></ref><ref id="bib82"><element-citation publication-type="book"><person-group person-group-type="author"><name><surname>Sterling</surname><given-names>P</given-names></name></person-group><year iso-8601-date="2015">2015</year><source>Principles of Neural Design</source><publisher-name>MIT Press</publisher-name><pub-id pub-id-type="doi">10.7551/mitpress/9780262028707.001.0001</pub-id></element-citation></ref><ref id="bib83"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Strauss</surname><given-names>R</given-names></name><name><surname>Heisenberg</surname><given-names>M</given-names></name></person-group><year iso-8601-date="1990">1990</year><article-title>Coordination of legs during straight walking and turning in <italic>Drosophila melanogaster</italic></article-title><source>Journal of Comparative Physiology. A, Sensory, Neural, and Behavioral Physiology</source><volume>167</volume><fpage>403</fpage><lpage>412</lpage><pub-id pub-id-type="doi">10.1007/BF00192575</pub-id><pub-id pub-id-type="pmid">2121965</pub-id></element-citation></ref><ref id="bib84"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Strogatz</surname><given-names>SH</given-names></name></person-group><year iso-8601-date="2000">2000</year><article-title>From Kuramoto to Crawford: exploring the onset of synchronization in populations of coupled oscillators</article-title><source>Physica D</source><volume>143</volume><fpage>1</fpage><lpage>20</lpage><pub-id pub-id-type="doi">10.1016/S0167-2789(00)00094-4</pub-id></element-citation></ref><ref id="bib85"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Sutton</surname><given-names>GP</given-names></name><name><surname>Szczecinski</surname><given-names>NS</given-names></name><name><surname>Quinn</surname><given-names>RD</given-names></name><name><surname>Chiel</surname><given-names>HJ</given-names></name></person-group><year iso-8601-date="2023">2023</year><article-title>Phase shift between joint rotation and actuation reflects dominant forces and predicts muscle activation patterns</article-title><source>PNAS Nexus</source><volume>2</volume><elocation-id>pgad298</elocation-id><pub-id pub-id-type="doi">10.1093/pnasnexus/pgad298</pub-id><pub-id pub-id-type="pmid">37822766</pub-id></element-citation></ref><ref id="bib86"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Szczecinski</surname><given-names>N</given-names></name><name><surname>Quinn</surname><given-names>R</given-names></name><name><surname>Chiel</surname><given-names>H</given-names></name></person-group><year iso-8601-date="2018">2018</year><article-title>Static stability predicts the continuum of interleg coordination patterns in <italic>Drosophila</italic></article-title><source>Journal of Experimental Biology</source><volume>221</volume><elocation-id>jeb189142</elocation-id><pub-id pub-id-type="doi">10.1242/jeb.189142</pub-id></element-citation></ref><ref id="bib87"><element-citation publication-type="preprint"><person-group person-group-type="author"><name><surname>Takemura</surname><given-names>S</given-names></name></person-group><year iso-8601-date="2023">2023</year><article-title>A connectome of the male <italic>Drosophila</italic> ventral nerve cord</article-title><source>bioRxiv</source><pub-id pub-id-type="doi">10.1101/2023.06.05.543757</pub-id></element-citation></ref><ref id="bib88"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Tange</surname><given-names>O</given-names></name></person-group><year iso-8601-date="2011">2011</year><article-title>GNU parallel- the command-line power tool</article-title><source>Login: The USENIX Magazine</source><volume>36</volume><fpage>42</fpage><lpage>47</lpage></element-citation></ref><ref id="bib89"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Todorov</surname><given-names>E</given-names></name><name><surname>Jordan</surname><given-names>MI</given-names></name></person-group><year iso-8601-date="2002">2002</year><article-title>Optimal feedback control as a theory of motor coordination</article-title><source>Nature Neuroscience</source><volume>5</volume><fpage>1226</fpage><lpage>1235</lpage><pub-id pub-id-type="doi">10.1038/nn963</pub-id></element-citation></ref><ref id="bib90"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Tuthill</surname><given-names>JC</given-names></name><name><surname>Wilson</surname><given-names>RI</given-names></name></person-group><year iso-8601-date="2016">2016a</year><article-title>Mechanosensation and adaptive motor control in insects</article-title><source>Current Biology</source><volume>26</volume><fpage>R1022</fpage><lpage>R1038</lpage><pub-id pub-id-type="doi">10.1016/j.cub.2016.06.070</pub-id><pub-id pub-id-type="pmid">27780045</pub-id></element-citation></ref><ref id="bib91"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Tuthill</surname><given-names>JC</given-names></name><name><surname>Wilson</surname><given-names>RI</given-names></name></person-group><year iso-8601-date="2016">2016b</year><article-title>Parallel transformation of tactile signals in central circuits of <italic>Drosophila</italic></article-title><source>Cell</source><volume>164</volume><fpage>1046</fpage><lpage>1059</lpage><pub-id pub-id-type="doi">10.1016/j.cell.2016.01.014</pub-id><pub-id pub-id-type="pmid">26919434</pub-id></element-citation></ref><ref id="bib92"><element-citation publication-type="preprint"><person-group person-group-type="author"><name><surname>Vaxenburg</surname><given-names>R</given-names></name><name><surname>Siwanowicz</surname><given-names>I</given-names></name><name><surname>Merel</surname><given-names>J</given-names></name><name><surname>Robie</surname><given-names>AA</given-names></name><name><surname>Morrow</surname><given-names>C</given-names></name><name><surname>Novati</surname><given-names>G</given-names></name><name><surname>Stefanidi</surname><given-names>Z</given-names></name><name><surname>Both</surname><given-names>G-J</given-names></name><name><surname>Card</surname><given-names>GM</given-names></name><name><surname>Reiser</surname><given-names>MB</given-names></name><name><surname>Botvinick</surname><given-names>MM</given-names></name><name><surname>Branson</surname><given-names>KM</given-names></name><name><surname>Tassa</surname><given-names>Y</given-names></name><name><surname>Turaga</surname><given-names>SC</given-names></name></person-group><year iso-8601-date="2024">2024</year><article-title>Whole-Body Simulation of Realistic Fruit Fly Locomotion with Deep Reinforcement Learning</article-title><source>bioRxiv</source><pub-id pub-id-type="doi">10.1101/2024.03.11.584515</pub-id></element-citation></ref><ref id="bib93"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Virtanen</surname><given-names>P</given-names></name><name><surname>Gommers</surname><given-names>R</given-names></name><name><surname>Oliphant</surname><given-names>TE</given-names></name><name><surname>Haberland</surname><given-names>M</given-names></name><name><surname>Reddy</surname><given-names>T</given-names></name><name><surname>Cournapeau</surname><given-names>D</given-names></name><name><surname>Burovski</surname><given-names>E</given-names></name><name><surname>Peterson</surname><given-names>P</given-names></name><name><surname>Weckesser</surname><given-names>W</given-names></name><name><surname>Bright</surname><given-names>J</given-names></name><name><surname>van der Walt</surname><given-names>SJ</given-names></name><name><surname>Brett</surname><given-names>M</given-names></name><name><surname>Wilson</surname><given-names>J</given-names></name><name><surname>Millman</surname><given-names>KJ</given-names></name><name><surname>Mayorov</surname><given-names>N</given-names></name><name><surname>Nelson</surname><given-names>ARJ</given-names></name><name><surname>Jones</surname><given-names>E</given-names></name><name><surname>Kern</surname><given-names>R</given-names></name><name><surname>Larson</surname><given-names>E</given-names></name><name><surname>Carey</surname><given-names>CJ</given-names></name><name><surname>Polat</surname><given-names>İ</given-names></name><name><surname>Feng</surname><given-names>Y</given-names></name><name><surname>Moore</surname><given-names>EW</given-names></name><name><surname>VanderPlas</surname><given-names>J</given-names></name><name><surname>Laxalde</surname><given-names>D</given-names></name><name><surname>Perktold</surname><given-names>J</given-names></name><name><surname>Cimrman</surname><given-names>R</given-names></name><name><surname>Henriksen</surname><given-names>I</given-names></name><name><surname>Quintero</surname><given-names>EA</given-names></name><name><surname>Harris</surname><given-names>CR</given-names></name><name><surname>Archibald</surname><given-names>AM</given-names></name><name><surname>Ribeiro</surname><given-names>AH</given-names></name><name><surname>Pedregosa</surname><given-names>F</given-names></name><name><surname>van Mulbregt</surname><given-names>P</given-names></name><collab>SciPy 1.0 Contributors</collab></person-group><year iso-8601-date="2020">2020</year><article-title>SciPy 1.0: fundamental algorithms for scientific computing in Python</article-title><source>Nature Methods</source><volume>17</volume><fpage>261</fpage><lpage>272</lpage><pub-id pub-id-type="doi">10.1038/s41592-019-0686-2</pub-id><pub-id pub-id-type="pmid">32015543</pub-id></element-citation></ref><ref id="bib94"><element-citation publication-type="preprint"><person-group person-group-type="author"><name><surname>Wang-Chen</surname><given-names>S</given-names></name><name><surname>Stimpfling</surname><given-names>VA</given-names></name><name><surname>Özdil</surname><given-names>PG</given-names></name><name><surname>Genoud</surname><given-names>L</given-names></name><name><surname>Hurtak</surname><given-names>F</given-names></name><name><surname>Ramdya</surname><given-names>P</given-names></name></person-group><year iso-8601-date="2023">2023</year><article-title>NeuroMechFly 2.0, a framework for simulating embodied sensorimotor control in adult <italic>Drosophila</italic></article-title><source>bioRxiv</source><pub-id pub-id-type="doi">10.1101/2023.09.18.556649</pub-id></element-citation></ref><ref id="bib95"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Wosnitza</surname><given-names>A</given-names></name><name><surname>Bockemühl</surname><given-names>T</given-names></name><name><surname>Dübbert</surname><given-names>M</given-names></name><name><surname>Scholz</surname><given-names>H</given-names></name><name><surname>Büschges</surname><given-names>A</given-names></name></person-group><year iso-8601-date="2013">2013</year><article-title>Inter-leg coordination in the control of walking speed in <italic>Drosophila</italic></article-title><source>The Journal of Experimental Biology</source><volume>216</volume><fpage>480</fpage><lpage>491</lpage><pub-id pub-id-type="doi">10.1242/jeb.078139</pub-id><pub-id pub-id-type="pmid">23038731</pub-id></element-citation></ref><ref id="bib96"><element-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Zhang</surname><given-names>H</given-names></name><name><surname>Starke</surname><given-names>S</given-names></name><name><surname>Komura</surname><given-names>T</given-names></name><name><surname>Saito</surname><given-names>J</given-names></name></person-group><year iso-8601-date="2018">2018</year><article-title>Mode-adaptive neural networks for quadruped motion control</article-title><source>ACM Transactions on Graphics</source><volume>37</volume><fpage>1</fpage><lpage>11</lpage><pub-id pub-id-type="doi">10.1145/3197517.3201366</pub-id></element-citation></ref></ref-list><app-group><app id="appendix-1"><title>Appendix 1</title><sec sec-type="appendix" id="s8"><title>Velocity and phase distributions in data</title><fig id="app1fig1" position="float"><label>Appendix 1—figure 1.</label><caption><title>Velocity and phase distributions in data justify the selection of model simulation parameters.</title><p>(<bold>A</bold>) Cumulative distribution functions and number of frames associated with various forward, rotation, and side-step velocities in data. Right/left (side-step) walking peaked at 0 mm/s, while forward/backward walking achieved a sustained peak from approximately 4 mm/s to 10 mm/s. Rotation velocity peaked at 0 rad/s. Most model-generated simulations in the paper adhered to this range. (<bold>B</bold>) Rotation vs. side-step velocity. Each dot on the scatter plot represents a single bout from data. Rotation velocity and side-step velocity were highly correlated with one another in data. (<bold>C</bold>) Phase offsets between legs in data over a range of walking velocities and rotational velocities. Side-step velocities were omitted from the study since (as previously demonstrated) they were highly correlated with rotation velocity. Phase offsets remained relatively constant over a range of forward and rotational velocities.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-app1-fig1-v1.tif"/></fig></sec></app><app id="appendix-2"><title>Appendix 2</title><sec sec-type="appendix" id="s9"><title>Angle vs. phase plots for all legs and joints</title><p>These plots are supplementary to <xref ref-type="fig" rid="fig2">Figure 2B</xref>.</p><fig id="app2fig1" position="float"><label>Appendix 2—figure 1.</label><caption><title>Simulated walking reproduced realistic joint angles.</title><p>Angle vs. computed per-leg phase of all joints on all legs for four different walking speeds. All simulations used a sensory delay of 10 ms and motor delay of 30 ms, consistent with experimental values. Some oddities were observed in real data, for instance in L3 femur flexion and R1 body-coxa flexion. The model does not quite capture these oddities.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-app2-fig1-v1.tif"/></fig></sec></app><app id="appendix-3"><title>Appendix 3</title><sec sec-type="appendix" id="s10"><title>Angular velocity vs. phase plots for all legs and joints</title><p>These plots are supplementary to <xref ref-type="fig" rid="fig2">Figure 2D</xref>.</p><fig id="app3fig1" position="float"><label>Appendix 3—figure 1.</label><caption><title>Simulated walking reproduced realistic joint angular velocities.</title><p>Angular velocity vs. computed per-leg phase of all joints on all legs for four different walking speeds. All simulations used a sensory delay of 10 ms and motor delay of 30 ms, consistent with experimental values.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-app3-fig1-v1.tif"/></fig></sec></app><app id="appendix-4"><title>Appendix 4</title><sec sec-type="appendix" id="s11"><title>Differences between model and data</title><p>These plots are supplementary to <xref ref-type="fig" rid="fig2">Figure 2E</xref>.</p><fig id="app4fig1" position="float"><label>Appendix 4—figure 1.</label><caption><title>Simulated walking resembled data over a range of forward, turning, and side-stepping velocities.</title><p>Average differences between model simulations over 500 distinct bouts. All simulations use a sensory delay of 10 ms and motor delay of 30 ms, consistent with experimental values. The dotted line (5.56 degrees) indicates uncertainty associated with data collection.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-app4-fig1-v1.tif"/></fig></sec></app><app id="appendix-5"><title>Appendix 5</title><sec sec-type="appendix" id="s12"><title>Phase coupling within and across legs</title><p>We quantify the model’s capacity to simulate leg kinematics by comparing the phase coupling of simulated joint kinematics with real walking flies, both within and across legs. A phase difference probability density peak close to zero between two joint angles means that they are strongly coupled, whereas a broader peak means they are weakly coupled.</p><p>To assess the effectiveness of the model’s inter-leg coordination, we compared phase coupling across legs for simulated vs. real walking. We found that the model reproduced patterns in the data, with some exceptions. Here, a phase difference of zeros means the two legs are synchronized, whereas a phase difference of <inline-formula><mml:math id="inf156"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>π</mml:mi></mml:mstyle></mml:math></inline-formula> means the two legs move in anti-phase. Fly data showed largely tripod coordination, so that L1-R2-L3 are synchronized with each other and also anti-phase with R1-L2-R3. The model showed coupling properties that were qualitatively similar to the coupling properties of the data, with moderate variations in phase difference (i.e. peak location) and synchronization strength (i.e. peak height). Some minor differences may also be due to violations of our assumption of constant phase offset across forward walking speeds. This assumption holds true over a large range of speeds, but breaks down at the lowest walking speeds (see Appendix 1). In the model, the phase coordinator is responsible for representing inter-leg coupling; these results suggest that the underlying Kuramoto oscillator reproduces naturalistic coupling patterns.</p><p>Next, we examined within-leg coupling in data, where phase synchronizations between different joints on the same leg can be both strong (e.g. L3 coxa-femur flexion to femur-tibia flexion) and weak (e.g. R2 femur-tibia flexion to femur rotation). Despite the mirror symmetry of the fly, within-leg coupling is not necessarily symmetric in the data — for instance, compare L2 and R2 coxa-femur flexion. All within-leg synchronizations (i.e. peaks) in data were reproduced by the model; however, the model generally exhibited stronger synchronization (i.e. higher peaks) than the data. In some cases (e.g. L3 femur rotation to femur-tibia flexion), the model exhibited synchronizations that are not present in the data. Overall, the model generally exhibits stronger within-leg coupling when compared to the data.</p><p>The trajectory generator is responsible for reproducing the per-leg inter-joint coupling, so these results suggest that the neural network learned stronger coupling values than are present in the data. This result is consistent with the time series comparisons, where we observed that the model produced more regular joint angle trajectories than the fly (<xref ref-type="fig" rid="fig2">Figure 2A</xref>).</p><fig id="app5fig1" position="float"><label>Appendix 5—figure 1.</label><caption><title>Simulated walking reproduced across- and within-leg coupling characteristics of data.</title><p>(<bold>A</bold>) Phase coupling across legs. We compared phases of representative joints across legs. Model coupling qualitatively resembled data coupling, with moderate variations in phase difference (i.e. peak location) and synchronization strength (i.e. peak height). A strong peak in probability density indicates synchronization, whereas broader peaks indicate weak synchronization. A single peak at zero on the horizontal axis indicates that the two joint phases are coupled to match; a single peak elsewhere indicates that the two joint phases are coupled with some phase offset. Simulations were performed over a range of forward walking, turning, and side-stepping speeds over 500 distinct bouts. (<bold>B, C</bold>) Phase coupling within each leg. For each leg, we compared phases between a representative joint for the leg (denoted ‘target’ on the image) and other joints on the leg. Gaps are present as we did not include all five joints for all legs in the model. All synchronizations (i.e. peaks) in data are reproduced by the model. However, simulations generally exhibited stronger synchronization (i.e. higher peaks).</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-app5-fig1-v1.tif"/></fig></sec></app><app id="appendix-6"><title>Appendix 6</title><sec sec-type="appendix" id="s13"><title>Estimate of plausible stochastic perturbation values</title><p>Here, we derive an estimate of the maximum plausible stochastic perturbation magnitude corresponding to a sudden gust of wind. Wind force experienced by a given leg is<disp-formula id="equ23"><label>(22)</label><mml:math id="m23"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>F</mml:mi><mml:mo>=</mml:mo><mml:mfrac><mml:mn>1</mml:mn><mml:mn>2</mml:mn></mml:mfrac><mml:mi>ρ</mml:mi><mml:msup><mml:mi>v</mml:mi><mml:mn>2</mml:mn></mml:msup><mml:mi>A</mml:mi><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf157"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>ρ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, <inline-formula><mml:math id="inf158"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>v</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>, and <inline-formula><mml:math id="inf159"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>A</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> are the density of air, wind speed, and perpendicular area (to wind direction) of the leg. The resulting acceleration is<disp-formula id="equ24"><label>(23)</label><mml:math id="m24"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>a</mml:mi><mml:mo>=</mml:mo><mml:mfrac><mml:mi>F</mml:mi><mml:mi>m</mml:mi></mml:mfrac><mml:mo>=</mml:mo><mml:mfrac><mml:mn>1</mml:mn><mml:mrow><mml:mn>2</mml:mn><mml:mi>m</mml:mi></mml:mrow></mml:mfrac><mml:mi>ρ</mml:mi><mml:msup><mml:mi>v</mml:mi><mml:mn>2</mml:mn></mml:msup><mml:mi>A</mml:mi><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf160"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>m</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is the mass of the fly.</p><p>We assume, generously, that the leg experiences the same acceleration. Since the controller operates at a frequency of <inline-formula><mml:math id="inf161"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>f</mml:mi></mml:mstyle></mml:math></inline-formula>, we can approximate the angular velocity (i.e. perturbation) <inline-formula><mml:math id="inf162"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>ω</mml:mi></mml:mstyle></mml:math></inline-formula> generated by the slip acceleration in one timestep for one joint on the leg as<disp-formula id="equ25"><label>(24)</label><mml:math id="m25"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>ω</mml:mi><mml:mo>=</mml:mo><mml:mfrac><mml:mi>a</mml:mi><mml:mrow><mml:mi>f</mml:mi><mml:mi>r</mml:mi></mml:mrow></mml:mfrac><mml:mo>=</mml:mo><mml:mfrac><mml:mn>1</mml:mn><mml:mrow><mml:mn>2</mml:mn><mml:mi>m</mml:mi><mml:mi>f</mml:mi><mml:mi>r</mml:mi></mml:mrow></mml:mfrac><mml:mi>ρ</mml:mi><mml:msup><mml:mi>v</mml:mi><mml:mn>2</mml:mn></mml:msup><mml:mi>A</mml:mi><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf163"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>r</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is the length of the leg.</p><p>Substituting in values used in our model (<italic>m</italic>=0.7e-6 kg, <italic>f</italic> = 600 Hz, r = 0.0015 m), and let  <inline-formula><mml:math id="inf164"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>ρ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> = 1.2 kg/m<sup>3</sup> (standard value), <inline-formula><mml:math id="inf165"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>v</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> = 6 m/s (corresponding to a strong 21 km/hr wind), and  <inline-formula><mml:math id="inf166"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>A</mml:mi></mml:mstyle></mml:math></inline-formula> = 0.15e-6 m<sup>2</sup> (corresponding to a 1.5 mm by 0.1 mm leg), we obtain a maximum joint perturbation magnitude of  <inline-formula><mml:math id="inf167"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>ω</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> = 5.1 rad/s.</p></sec><sec sec-type="appendix" id="s14"><title>Estimate of plausible impulse perturbation values</title><p>We estimate the maximum plausible impulse perturbation corresponding to a sudden slip. Assume that a leg steps at an angle of <inline-formula><mml:math id="inf168"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>θ</mml:mi></mml:mstyle></mml:math></inline-formula> (from the vertical) onto a flat, frictionless ground. The resulting horizontal acceleration would be<disp-formula id="equ26"><label>(25)</label><mml:math id="m26"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>a</mml:mi><mml:mo>=</mml:mo><mml:mi>g</mml:mi><mml:mi>tan</mml:mi><mml:mo>⁡</mml:mo><mml:mrow><mml:mi>θ</mml:mi></mml:mrow><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf169"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>g</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> is acceleration due to gravity.</p><p>Assume the controller operates at a frequency of <inline-formula><mml:math id="inf170"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>f</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula>. We can approximate the angular velocity (i.e. perturbation) <inline-formula><mml:math id="inf171"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>ω</mml:mi></mml:mstyle></mml:math></inline-formula> generated by the slip acceleration in one timestep for a joint on the leg as<disp-formula id="equ27"><label>(26)</label><mml:math id="m27"><mml:mrow><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>ω</mml:mi><mml:mo>=</mml:mo><mml:mfrac><mml:mi>a</mml:mi><mml:mrow><mml:mi>f</mml:mi><mml:mi>r</mml:mi></mml:mrow></mml:mfrac><mml:mo>=</mml:mo><mml:mfrac><mml:mrow><mml:mi>g</mml:mi><mml:mi>tan</mml:mi><mml:mo>⁡</mml:mo><mml:mrow><mml:mi>θ</mml:mi></mml:mrow></mml:mrow><mml:mrow><mml:mi>f</mml:mi><mml:mi>r</mml:mi></mml:mrow></mml:mfrac><mml:mo>,</mml:mo></mml:mstyle></mml:mrow></mml:math></disp-formula></p><p>where <inline-formula><mml:math id="inf172"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mi>r</mml:mi></mml:mstyle></mml:math></inline-formula> is the length of the leg. Plugging in values of  <inline-formula><mml:math id="inf173"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>g</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> = 9.81 m/s<sup>2</sup> (standard value), <inline-formula><mml:math id="inf174"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>f</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> = 600 Hz (value used in the model), <inline-formula><mml:math id="inf175"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>r</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> = 0.0015 m (value used in the model), and  <inline-formula><mml:math id="inf176"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>θ</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> = 45 degrees (quite a large slip angle), we obtain a perturbation value of n <inline-formula><mml:math id="inf177"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mrow><mml:mi>ω</mml:mi></mml:mrow></mml:mstyle></mml:math></inline-formula> = 10.9 rad/s.</p></sec></app><app id="appendix-7"><title>Appendix 7</title><sec sec-type="appendix" id="s15"><title>Effect of sensory and motor delays on walking under impulse perturbations</title><p>The results shown in <xref ref-type="fig" rid="fig5">Figure 5</xref> correspond to persistent stochastic perturbations. Here, we present similar results for impulse perturbations here. Maximum values of motor and sensory delay values remain reasonably close to known values in physiology.</p><fig id="app7fig1" position="float"><label>Appendix 7—figure 1.</label><caption><title>Model generated robust walking under persistent stochastic perturbations over select ranges of motor and sensory delays, revealing fundamental constraints on delay values.</title><p>(<bold>A, B</bold>) Example simulated time series of femur-tibia flexion on leg R1 and femur rotation on leg L2 under various values of motor (10, 20, 30, 40 ms) and sensory delay (0, 5, 10, 15 ms). Perturbation effects were more noticeable with increased delay values. (<bold>C, D, E</bold>) KS of simulated during-perturbation walking to data, for various values of delay, perturbation strength, and forward speeds. For each square of the heatmap, four simulations with different initial conditions were simulated and evaluated. As perturbation strength and delays increased, simulated walking became less similar to data; the effect was more pronounced with increased delays. When we fixed one delay value and varied the other, the model maintained realistic walking (KS <inline-formula><mml:math id="inf178"><mml:mstyle displaystyle="true" scriptlevel="0"><mml:mo>&gt;</mml:mo><mml:mo>−</mml:mo><mml:mn>1.6</mml:mn></mml:mstyle></mml:math></inline-formula>) up to about 25 ms of motor delay and 8 ms of sensory delay across a range of conditions. When we allowed both motor and sensory delay to vary, the model maintained realistic walking when the sum of the delays was no more than about 40 ms. (<bold>F</bold>) Post-perturbation walking with motor and sensory delays. The model is able to recover from perturbations for very large values of delay. Unless otherwise stated, forward speed = 12 mm/s, and perturbation strength = 5 rad/s.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-app7-fig1-v1.tif"/></fig></sec></app><app id="appendix-8"><title>Appendix 8</title><sec sec-type="appendix" id="s16"><title>Characterization of principal components of kinematics</title><p>These plots are supplementary to <xref ref-type="fig" rid="fig4">Figure 4</xref>.</p><fig id="app8fig1" position="float"><label>Appendix 8—figure 1.</label><caption><title>Principal components model the range of kinematics observed in the data.</title><p>(<bold>A</bold>) An example time series of R1 femur-tibia flexion along with principal components of all the angles. The first two principal components (PC1 and PC2) capture the step cycle of walking. The later principal components capture increasingly higher-frequency aspects of the angle trajectories. (<bold>B</bold>) Explained variance of the principal components. Seven components explain over 81% of the variance and 12 components explain over 91% of the variance in joint angles.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-app8-fig1-v1.tif"/></fig></sec></app><app id="appendix-9"><title>Appendix 9</title><sec sec-type="appendix" id="s17"><title>Effect of PCA dimension in kinematic similarity metric</title><p>These plots are supplementary to <xref ref-type="fig" rid="fig5">Figure 5</xref>.</p><fig id="app9fig1" position="float"><label>Appendix 9—figure 1.</label><caption><title>Results on sensory delay thresholds are generally robust to varying principal components analysis (PCA) dimension used in the kinematic similarity metric.</title><p>Effect of varying principal component number on kinematic similarity (KS) measurement for stochastic (<bold>A</bold>) and impulse (<bold>B</bold>) perturbations. The results look similar across components for impulse perturbations. For stochastic perturbations, the range of similar walking decreases as we increase the number of components used to evaluate walking kinematics. As higher principal components represent higher temporal frequencies, it is likely that higher frequencies are impacted at the edge of stability before walking collapses entirely at increasing delays.</p></caption><graphic mimetype="image" mime-subtype="tiff" xlink:href="elife-99005-app9-fig1-v1.tif"/></fig></sec></app></app-group></back><sub-article article-type="editor-report" id="sa0"><front-stub><article-id pub-id-type="doi">10.7554/eLife.99005.3.sa0</article-id><title-group><article-title>eLife Assessment</article-title></title-group><contrib-group><contrib contrib-type="author"><name><surname>Salinas</surname><given-names>Emilio</given-names></name><role specific-use="editor">Reviewing Editor</role><aff><institution>Wake Forest University School of Medicine</institution><country>United States</country></aff></contrib></contrib-group><kwd-group kwd-group-type="evidence-strength"><kwd>Convincing</kwd></kwd-group><kwd-group kwd-group-type="claim-importance"><kwd>Valuable</kwd></kwd-group></front-stub><body><p>This <bold>valuable</bold> study presents a computational model that simulates walking motions in <italic>Drosophila</italic> and suggests that, if sensorimotor delays in the neural circuitry were any longer, the system would be easily destabilized by external perturbations. The hierarchical control model is sensible and the evidence supporting the conclusions <bold>convincing</bold>. The modular model, which has many interacting components with varying degrees of biological realism, will serve as a well-grounded starting point for future studies that incorporate richer or more complete empirical data.</p></body></sub-article><sub-article article-type="referee-report" id="sa1"><front-stub><article-id pub-id-type="doi">10.7554/eLife.99005.3.sa1</article-id><title-group><article-title>Reviewer #1 (Public Review):</article-title></title-group><contrib-group><contrib contrib-type="author"><anonymous/><role specific-use="referee">Reviewer</role></contrib></contrib-group></front-stub><body><p>Summary:</p><p>In this work, the authors present a novel, multi-layer computational model of motor control to produce realistic walking behaviour of a <italic>Drosophila</italic> model in the presence of external perturbations and under sensory and motor delays. The novelty of their model of motor control is that it is modular, with divisions inspired by the fly nervous system, with one component based on deep learning while the rest are based on control theory. They show that their model can produce realistic walking trajectories. Given the mostly reasonable assumptions of their model, they convincingly show that the sensory and motor delays present in the fly nervous system are the maximum allowable for robustness to unexpected perturbations.</p><p>Their fly model outputs torque at each joint in the leg, and their dynamics model translates these into movements, resulting in time-series trajectories of joint angles. Inspired by the anatomy of the fly nervous system, their fly model is a modular architecture that separates motor control at three levels of abstraction:</p><p>(1) oscillator-based model of coupling of phase angles between legs,</p><p>(2) generation of future joint-angle trajectories based on the current state and inputs for each leg (the trajectory generator), and</p><p>(3) closed-loop control of the joint-angles using torques applied at every joint in the model (control and dynamics).</p><p>These three levels of abstraction ensure coordination between the legs, future predictions of desired joint angles, and corrections to deviations from desired joint-angle trajectories. The parameters of the model are tuned in the absence of external perturbations using experimental data of joint angles of a tethered fly. A notable disconnect from reality is that the dynamics model used does not model the movement of the body and ground contacts as is the case in natural walking, nor the movement of a ball for a tethered fly, but instead something like legs moving in the air for a tethered fly.</p><p>In order to validate the realism of the generated simulated walking trajectories, the authors compare various attributes of simulated to real tethered fly trajectories and show qualitative and quantitative similarities, including using a novel metric coined as Kinematic Similarity (KS). The KS score of a trajectory is a measure of the likelihood that the trajectory belongs to the distribution of real trajectories estimated from the experimental data. While such a metric is a useful tool to validate the quality of simulated data, there is some room for improvement in the actual computation of this score. For instance, the KS score is computed for any given time-window of walking simulation using a fraction of information from the joint-angle trajectories. It is unclear if the remaining information in joint-angle trajectories that are not used in the computation of the KS score can be ignored in the context of validating the realism of simulated walking trajectories.</p><p>The authors validate simulated walking trajectories generated by the trained model under a range of sensorimotor delays and external perturbations. The trained model is shown to generate realistic joint-angle trajectories in the presence of external perturbations as long as the sensorimotor delays are constrained within a certain range. This range of sensorimotor delays is shown to be comparable to experimental measurements of sensorimotor delays, leading to the conclusion that the fly nervous system is just fast enough to be robust to perturbations.</p><p>Strengths:</p><p>This work presents a novel framework to simulate <italic>Drosophila</italic> walking in the presence of external perturbations and sensorimotor delay. Although the model makes some simplifying assumptions, it has sufficient complexity to generate new, testable hypotheses regarding motor control in <italic>Drosophila</italic>. The authors provide evidence for realistic simulated walking trajectories by comparing simulated trajectories generated by their trained model with experimental data using a novel metric proposed by the authors. The model proposes a crucial role in future predictions to ensure robust walking trajectories against external perturbations and motor delay. Realistic simulations under a range of prediction intervals, perturbations, and motor delays generating realistic walking trajectories support this claim. The modular architecture of the framework provides opportunities to make testable predictions regarding motor control in <italic>Drosophila</italic>. The work can be of interest to the <italic>Drosophila</italic> community interested in digitally simulating realistic models of <italic>Drosophila</italic> locomotion behaviors, as well as to experimentalists in generating testable hypotheses for novel discoveries regarding neural control of locomotion in <italic>Drosophila</italic>. Moreover, the work can be of broad interest to neuroethologists, serving as a benchmark in modelling animal locomotion in general.</p><p>Weaknesses:</p><p>As the authors acknowledge in their work, the control and dynamics model makes some simplifying assumptions about <italic>Drosophila</italic> physics/physiology in the context of walking. For instance, the model does not incorporate ground contact forces and inertial effects of the fly's body. It is not clear how these simplifying assumptions would affect some of the quantitative results derived by the authors. The range of tolerable values of sensorimotor delays that generate realistic walking trajectories is shown to be comparable with sensorimotor delays inferred from physiological measurements. It is unclear if this comparison is meaningful in the context of the model's simplifying assumptions. The authors propose a novel metric coined as Kinematic Similarity (KS) to distinguish realistic walking trajectories from unrealistic walking trajectories. Defining such an objective metric to evaluate the model's predictions is a useful exercise, and could potentially be applied to benchmark other computational animal models that are proposed in the future. However, the KS score proposed in this work is calculated using only the first two PCA modes that cumulatively account for less than 50% of the variance in the joint angles. It is not obvious that the information in the remaining PCA modes may not change the log-likelihood that occurs in the real walking data.</p><p>Comments on revisions:</p><p>The authors have addressed the concerns and questions raised in the original review.</p></body></sub-article><sub-article article-type="referee-report" id="sa2"><front-stub><article-id pub-id-type="doi">10.7554/eLife.99005.3.sa2</article-id><title-group><article-title>Reviewer #2 (Public Review):</article-title></title-group><contrib-group><contrib contrib-type="author"><anonymous/><role specific-use="referee">Reviewer</role></contrib></contrib-group></front-stub><body><p>Summary:</p><p>In this study, Karashchuk et al. develop a hierarchical control system to control the legs of a dynamic model of the fly. They intend to demonstrate that temporal delays in sensorimotor processing can destabilize walking and that the fly's nervous system may be operating with as long of delays as could possibly be corrected for.</p><p>Strengths:</p><p>Overall, the approach the authors take is impressive. Their model is trained using a huge dataset of animal data, which is a strength. Their model was not trained to reproduce animal responses to perturbations, but it successfully rejects small perturbations and continues to operate stably. Their results are consistent with the literature, that sensorimotor delays destabilize movements.</p><p>Weaknesses:</p><p>The model is sophisticated and interesting, but the reviewer has great concerns regarding this manuscript's contributions, as laid out in the abstract:</p><p>(1) Much simpler models can be used to show that delays in sensorimotor systems destabilize behavior (e.g., Bingham, Choi, and Ting 2011; Ashtiani, Sarvestani, and Badri-Sproewitz 2021), so why create this extremely complex system to test this idea? The complexity of the system obscures the results and leaves the reviewer wondering if the instability is due to the many, many moving parts within the model. The reviewer understands (and appreciates) that the authors tested the impact of the delay in a controlled way, which supports their conclusion. However, the reviewer thinks the authors did not use the most parsimonious model possible, and as such, leave many possible sources for other causes of instability.</p><p>(2) In a related way, the reviewer is not sure that the elements the authors introduced reflect the structure or function of the fly's nervous system. For example, optimal control is an active field of research and is behind the success of many-legged robots, but the reviewer is not sure what evidence exists that suggests the fly ventral nerve cord functions as an optimal controller. If this were bolstered with additional references, the reviewer would be less concerned.</p><p>(3) &quot;The model generates realistic simulated walking that matches real fly walking kinematics...&quot;. The reviewer appreciates the difficulty in conducting this type of work, but the reviewer cannot conclude that the kinematics &quot;match real fly walking kinematics&quot;. The range of motion of several joints is 30% too small compared to the animal (Figure 2B) and the reviewer finds the video comparisons unpersuasive. The reviewer would understand if there were additional constraints, e.g., the authors had designed a robot that physically could not complete the prescribed motions. However the reviewer cannot think of a reason why this simulation could not replicate the animal kinematics with arbitrary precision, if that is the goal.</p><p>Comments on revisions:</p><p>The authors have addressed the concerns and questions raised in the original review.</p></body></sub-article><sub-article article-type="author-comment" id="sa3"><front-stub><article-id pub-id-type="doi">10.7554/eLife.99005.3.sa3</article-id><title-group><article-title>Author response</article-title></title-group><contrib-group><contrib contrib-type="author"><name><surname>Karashchuk</surname><given-names>Lili</given-names></name><role specific-use="author">Author</role><aff><institution>University of Washington</institution><addr-line><named-content content-type="city">Seattle</named-content></addr-line><country>United States</country></aff></contrib><contrib contrib-type="author"><name><surname>Li</surname><given-names>Jing Shuang</given-names></name><role specific-use="author">Author</role><aff><institution>University of Michigan-Ann Arbor</institution><addr-line><named-content content-type="city">Ann Arbor</named-content></addr-line><country>United States</country></aff></contrib><contrib contrib-type="author"><name><surname>Chou</surname><given-names>Grant M</given-names></name><role specific-use="author">Author</role><aff><institution>University of Washington</institution><addr-line><named-content content-type="city">Seattle</named-content></addr-line><country>United States</country></aff></contrib><contrib contrib-type="author"><name><surname>Walling-Bell</surname><given-names>Sarah</given-names></name><role specific-use="author">Author</role><aff><institution>University of Washington</institution><addr-line><named-content content-type="city">Seattle</named-content></addr-line><country>United States</country></aff></contrib><contrib contrib-type="author"><name><surname>Brunton</surname><given-names>Steven</given-names></name><role specific-use="author">Author</role><aff><institution>University of Washington</institution><addr-line><named-content content-type="city">Seattle</named-content></addr-line><country>United States</country></aff></contrib><contrib contrib-type="author"><name><surname>Tuthill</surname><given-names>John C</given-names></name><role specific-use="author">Author</role><aff><institution>University of Washington</institution><addr-line><named-content content-type="city">Seattle</named-content></addr-line><country>United States</country></aff></contrib><contrib contrib-type="author"><name><surname>Brunton</surname><given-names>Bingni W</given-names></name><role specific-use="author">Author</role><aff><institution>University of Washington</institution><addr-line><named-content content-type="city">Seattle</named-content></addr-line><country>United States</country></aff></contrib></contrib-group></front-stub><body><p>The following is the authors’ response to the original reviews.</p><p>We thank the editor and reviewers for their supportive comments about our modeling approach and conclusions, and for raising several valid concerns; we address them briefly below. In addition, a detailed, point-by-point response to the reviewers’ comments are below, along with additions and edits we have made to the revised manuscript.</p><p>Concerns about model’s biological realism and impact on interpretations</p><p>The goal of this paper was to use an interpretable and modular model to investigate the impact of varying sensorimotor delays. Aspects of the model (e.g. layered architecture, modularity) are inspired by biology; at the same time, necessary abstractions and simplifications (e.g. using an optimal controller) are made for interpretability and generalizability, and they reflect common approaches from past work. The hypothesized effects of certain simplifying assumptions are discussed in detail in Section 3.5. Furthermore, the modularity of our model allows us to readily incorporate additional biological realism (e.g. biomechanics, connectomics, and neural dynamics) in future work. In the revision, we have added citations and edits to the text to clarify these points.</p><p>Concerns that the model is overly complex</p><p>To investigate the impact of sensorimotor delays on locomotion, we built a closed-loop model that recapitulates the complex joint trajectories of fly walking. We agree that locomotion models face a tradeoff between simplicity/interpretability and realism — therefore, we developed a model that was as simple and interpretable as possible, while still reasonably recapitulating joint trajectories and generalizing to novel simulation scenarios. Along these lines, we also did not select a model that primarily recreates empirical data, as this would hinder generalizability and add unnecessary complexity to the model. We do not think these design choices are significant weaknesses of this model; in fact, few comparable models account for all joints involved in locomotion, and fewer explicitly compare model kinematics with kinematics from data. We have add citations and edits to the text to clarify these points in the revision.</p><p>Concerns about the validity of the Kinematic Similarity (KS) metric to evaluate walking</p><p>We chose to incorporate only the first two PCA modes dimensions in the KS metric because the kernel density estimator performs poorly for high dimensional data. Our primary use of this metric was to indicate whether the simulated fly continues walking in the presence of perturbations. For technical reasons, it is not feasible to perform equivalent experiments on real walking flies, which is one of the reasons we explore this phenomenon with the model. We note the dramatic shift from walking to nonwalking as delay increases (Figure 5). To be thorough, in the revision, we have investigated the effect of incorporating additional PCA modes, and whether this affects the interpretation of our results. We have additionally added to the discussion and presentation of the KS metric to clarify its purpose in this study. We agree with the reviewers that the KS metric is too coarse to reflect fine details of joint kinematics; indeed, in the unperturbed case, we evaluate our model’s performance using other metrics based on comparisons with empirical data (Figures 2, 7, 8).</p><disp-quote content-type="editor-comment"><p><bold>Public Reviews:</bold></p><p><bold>Reviewer #1 (Public Review):</bold></p><p>Summary:</p><p>In this work, the authors present a novel, multi-layer computational model of motor control to produce realistic walking behaviour of a <italic>Drosophila</italic> model in the presence of external perturbations and under sensory and motor delays. The novelty of their model of motor control is that it is modular, with divisions inspired by the fly nervous system, with one component based on deep learning while the rest are based on control theory. They show that their model can produce realistic walking trajectories. Given the mostly reasonable assumptions of their model, they convincingly show that the sensory and motor delays present in the fly nervous system are the maximum allowable for robustness to unexpected perturbations.</p><p>Their fly model outputs torque at each joint in the leg, and their dynamics model translates these into movements, resulting in time-series trajectories of joint angles. Inspired by the anatomy of the fly nervous system, their fly model is a modular architecture that separates motor control at three levels of abstraction:</p><p>(1) oscillator-based model of coupling of phase angles between legs,</p><p>(2) generation of future joint-angle trajectories based on the current state and inputs for each leg (the trajectory generator), and</p><p>(3) closed-loop control of the joint-angles using torques applied at every joint in the model (control and dynamics).</p><p>These three levels of abstraction ensure coordination between the legs, future predictions of desired joint angles, and corrections to deviations from desired joint-angle trajectories. The parameters of the model are tuned in the absence of external perturbations using experimental data of joint angles of a tethered fly. A notable disconnect from reality is that the dynamics model used does not model the movement of the body and ground contacts as is the case in natural walking, nor the movement of a ball for a tethered fly, but instead something like legs moving in the air for a tethered fly.</p><p>n order to validate the realism of the generated simulated walking trajectories, the authors compare various attributes of simulated to real tethered fly trajectories and show qualitative and quantitative similarities, including using a novel metric coined as Kinematic Similarity (KS). The KS score of a trajectory is a measure of the likelihood that the trajectory belongs to the distribution of real trajectories estimated from the experimental data. While such a metric is a useful tool to validate the quality of simulated data, there is some room for improvement in the actual computation of this score. For instance, the KS score is computed for any given time-window of walking simulation using a fraction of information from the joint-angle trajectories. It is unclear if the remaining information in joint-angle trajectories that are not used in the computation of the KS score can be ignored in the context of validating the realism of simulated walking trajectories.</p><p>The authors validate simulated walking trajectories generated by the trained model under a range of sensorimotor delays and external perturbations. The trained model is shown to generate realistic jointangle trajectories in the presence of external perturbations as long as the sensorimotor delays are constrained within a certain range. This range of sensorimotor delays is shown to be comparable to experimental measurements of sensorimotor delays, leading to the conclusion that the fly nervous system is just fast enough to be robust to perturbations.</p><p>Strengths:</p><p>This work presents a novel framework to simulate <italic>Drosophila</italic> walking in the presence of external perturbations and sensorimotor delay. Although the model makes some simplifying assumptions, it has sufficient complexity to generate new, testable hypotheses regarding motor control in <italic>Drosophila</italic>. The authors provide evidence for realistic simulated walking trajectories by comparing simulated trajectories generated by their trained model with experimental data using a novel metric proposed by the authors. The model proposes a crucial role in future predictions to ensure robust walking trajectories against external perturbations and motor delay. Realistic simulations under a range of prediction intervals, perturbations, and motor delays generating realistic walking trajectories support this claim. The modular architecture of the framework provides opportunities to make testable predictions regarding motor control in <italic>Drosophila</italic>. The work can be of interest to the <italic>Drosophila</italic> community interested in digitally simulating realistic models of <italic>Drosophila</italic> locomotion behaviors, as well as to experimentalists in generating testable hypotheses for novel discoveries regarding neural control of locomotion in <italic>Drosophila</italic>. Moreover, the work can be of broad interest to neuroethologists, serving as a benchmark in modelling animal locomotion in general.</p></disp-quote><p>We thank the reviewer for their positive comments.</p><disp-quote content-type="editor-comment"><p>Weaknesses:</p><p>As the authors acknowledge in their work, the control and dynamics model makes some simplifying assumptions about <italic>Drosophila</italic> physics/physiology in the context of walking. For instance, the model does not incorporate ground contact forces and inertial effects of the fly's body. It is not clear how these simplifying assumptions would affect some of the quantitative results derived by the authors. The range of tolerable values of sensorimotor delays that generate realistic walking trajectories is shown to be comparable with sensorimotor delays inferred from physiological measurements. It is unclear if this comparison is meaningful in the context of the model's simplifying assumptions.</p></disp-quote><p>We now discuss how some of these assumptions affect the quantitative results in the section “Towards biomechanical and neural realism”. We reproduce the relevant sentences below:</p><p>“The inclusion of explicit leg-ground contact interactions would also make it harder for the model to recover when perturbed, because perturbations during walking often occur upon contact with the ground (e.g. the ground is slippery or bumpy).”</p><p>“We anticipate that the increased sensory resolution from more detailed proprioceptor models and the stability from mechanical compliance of limbs in a more detailed biomechanical model would make the system easier to control and increase the allowable range of delay parameters. Conversely, we expect that modeling the nonlinearity and noise inherent to biological sensors and actuators may decrease the allowable range of delay parameters.”</p><disp-quote content-type="editor-comment"><p>The authors propose a novel metric coined as Kinematic Similarity (KS) to distinguish realistic walking trajectories from unrealistic walking trajectories. Defining such an objective metric to evaluate the model's predictions is a useful exercise, and could potentially be applied to benchmark other computational animal models that are proposed in the future. However, the KS score proposed in this work is calculated using only the first two PCA modes that cumulatively account for less than 50% of the variance in the joint angles. It is not obvious that the information in the remaining PCA modes may not change the log-likelihood that occurs in the real walking data.</p></disp-quote><p>The primary reason we designed the KS metric was to determine whether the simulated fly continues walking in the presence of perturbations. We initially limited the analysis of the KS to the first 2 principal components. For completeness, we now investigate the additional principal components in Appendix 8 and the effect of evaluating KS with different numbers of components in Appendix 9.</p><p>Overall, the results look similar when including additional components for impulse perturbations. For stochastic perturbations, the range of similar walking decreases as we increase the number of components used to evaluate walking kinematics. Comparing this with Appendix 8, which shows that higher components represent higher frequencies of the walking cycle, we conclude that at the edge of stability for delays (where sum of sensory and actuation delays are about 40ms), flies can continue walking but with impaired higher frequencies (relative to no perturbations) during and after perturbation.</p><p>We added the following text in the methods:</p><p>“We chose 2 dimensions for PCA for two key reasons. First, these 2 dimensions alone accounted for a large portion of the variance in the data (52.7% total, with 42.1% for first component and 10.6% for second component). There was a big drop in variance explained from the first to the second component, but no sudden drop in the next 10 components (see Appendix 8). Second, the KDE procedure only works effectively in low-dimensional spaces, and the minimal number of dimensions needed to obtain circular dynamics for walking is 2. We investigate the effect of varying the number of dimensions of PCA in Appendix 9.”</p><p>(Note that we have corrected the percentage of variance accounted for by the principal components, as these numbers were from an older analysis prior to the first draft.)</p><p>We also reference Appendix 9 in the results:</p><p>“We observed that robust walking was not contingent on the specific values of motor and sensory delay, but rather the sum of these two values (Fig. 5E). Furthermore, as delay increases, higher frequencies of walking are impacted first before walking collapses entirely (Appendix 9).”</p><disp-quote content-type="editor-comment"><p><bold>Reviewer #2 (Public Review):</bold></p><p>Summary:</p><p>In this study, Karashchuk et al. develop a hierarchical control system to control the legs of a dynamic model of the fly. They intend to demonstrate that temporal delays in sensorimotor processing can destabilize walking and that the fly's nervous system may be operating with as long of delays as could possibly be corrected for.</p><p>Strengths:</p><p>Overall, the approach the authors take is impressive. Their model is trained using a huge dataset of animal data, which is a strength. Their model was not trained to reproduce animal responses to perturbations, but it successfully rejects small perturbations and continues to operate stably. Their results are consistent with the literature, that sensorimotor delays destabilize movements.</p><p>Weaknesses:</p><p>The model is sophisticated and interesting, but the reviewer has great concerns regarding this manuscript's contributions, as laid out in the abstract:</p><p>(1) Much simpler models can be used to show that delays in sensorimotor systems destabilize behavior (e.g., Bingham, Choi, and Ting 2011; Ashtiani, Sarvestani, and Badri-Sproewitz 2021), so why create this extremely complex system to test this idea? The complexity of the system obscures the results and leaves the reviewer wondering if the instability is due to the many, many moving parts within the model. The reviewer understands (and appreciates) that the authors tested the impact of the delay in a controlled way, which supports their conclusion. However, the reviewer thinks the authors did not use the most parsimonious model possible, and as such, leave many possible sources for other causes of instability.</p></disp-quote><p>We thank the reviewer for this observation — we agree that we did not make the goal of the work quite clear. The goal of this paper was to build an interpretable and generalizable model of fly walking, which was then used to investigate varying sensorimotor delays in the context of locomotion. To this end, we used a modular model to recreate walking kinematics, and then investigated the effect of delays on locomotion. Locomotion in itself is a complex phenomenon — thus, we have chosen a model that is complex enough to reasonably recapitulate joint trajectories, while remaining interpretable.</p><p>We have clarified this in the text near the end of the introduction:</p><p>“Here, we develop a new, interpretable, and generalizable model of fly walking, which we use to investigate the impact of varying sensorimotor delays in <italic>Drosophila</italic> locomotion.”</p><p>We also emphasize the investigation of sensorimotor delays in the context of locomotion in the beginning of the “Effect of sensory and motor delays on walking” section:</p><p>“... we used our model to investigate how changing sensory and motor delays affects locomotor robustness.”</p><p>We also remark that while they are very relevant papers for our work, neither of the prior papers focus on locomotion: the first involves a 2D balance model of a biped, and the second involves drop landings of quadrupeds.</p><p>Lastly, we note that the investigation of delay is not the only use for this model — in the future, this model can also be used to study other aspects of locomotion such as the role of proprioceptive feedback (see “Role of proprioceptive feedback in fly walking” section). The layered framework of the model can also be extended to other animals and locomotor strategies (see “Layered model produces robust walking and facilitates local control” section”).</p><disp-quote content-type="editor-comment"><p>(2) In a related way, the reviewer is not sure that the elements the authors introduced reflect the structure or function of the fly's nervous system. For example, optimal control is an active field of research and is behind the success of many-legged robots, but the reviewer is not sure what evidence exists that suggests the fly ventral nerve cord functions as an optimal controller. If this were bolstered with additional references, the reviewer would be less concerned.</p></disp-quote><p>We thank the reviewer for the comment — we have now further clarified how our model elements reflect the fly’s nervous system. The elements we introduce are plausible but only loosely analogous to the fly’s nervous system. While we draw parallels from these elements to anatomy (e.g. in Fig 1A-B, and in the first paragraph of the Results section), we do not mean to suggest that these functional elements directly correspond to specific structures in the fly’s nervous system. A substantial portion of the suggested future work (see “Towards biomechanical and neural realism”) aims to bridge the gap between these functional elements and fly physiology, which is beyond the scope of this work.</p><p>We have added clarifying text to the Results section:</p><p>“While the model is inspired by neuroanatomy, its components do not strictly correspond to components of the nervous system --- the construction of a neuroanatomically accurate model is deferred to future work (see Discussion).”</p><p>In the specific case of optimal control — optimal control is a theoretical model that predicts various aspects of motor control in humans, there is evidence that optimal control is implemented by the human nervous system (Todorov and Jordan, 2002; Scott, 2004; Berret et al., 2011). Based on this, we make the assumption that optimal control is a reasonable model for motor control in flies implemented by the fly nervous system as well. Fly movement makes use of proprioceptive feedback signals (Mendes et al., 2013; Pratt et al., 2024; Berendes et al., 2016), and optimal control is a plausible mechanism that incorporates feedback signals into movement.</p><p>We have added the following clarifying text in the Results section:</p><p>“The optimal controller layer maintains walking kinematics in the presence of sensori motor delays and helps compensate for external perturbations. This design was inspired by optimal control-based models of movements in humans (Todorov and Jordan, 2002; Scott, 2004; Berret et al., 2011)”</p><disp-quote content-type="editor-comment"><p>(3) &quot;The model generates realistic simulated walking that matches real fly walking kinematics...&quot;. The reviewer appreciates the difficulty in conducting this type of work, but the reviewer cannot conclude that the kinematics &quot;match real fly walking kinematics&quot;. The range of motion of several joints is 30% too small compared to the animal (Figure 2B) and the reviewer finds the video comparisons unpersuasive. The reviewer would understand if there were additional constraints, e.g., the authors had designed a robot that physically could not complete the prescribed motions. However the reviewer cannot think of a reason why this simulation could not replicate the animal kinematics with arbitrary precision, if that is the goal.</p></disp-quote><p>We agree with the reviewer that the model-generated kinematics are not perfectly indistinguishable from real walking kinematics, and now clarify this in the text. We also agree with the reviewer that one could build a model that precisely replicates real kinematics, but as they intuit, that was not our goal. Our goal was to build a model that both replicates animal kinematics, and is interpretable and generalizable (which allows us to investigate what happens when perturbations and varying sensorimotor delays are introduced). There is a trade-off between realism and generalizability — a simulation that fully recreates empirical data would require a model that is completely fit to data, which is likely to be more complex (in terms of parameters required) and less generalizable to novel scenarios. We have made design choices that result in a model that balances these trade-offs. We do not consider this to be a weakness of the model; in fact, few comparable models account for all joints involved in locomotion, and fewer explicitly compare model kinematics with kinematics from data.</p><p>We have tempered the language in the abstract:</p><p>“The model generates realistic simulated walking that resembles real fly walking kinematics”</p><p>The tempered statement, we believe, is a fair characterization of the walking — it resembles but does not perfectly match real kinematics.</p><p>We have also introduced clarifying text in the introduction:</p><p>“Overall, existing walking models focus on either kinematic or physiological accuracy, but few achieve both, and none consider the effect of varying sensorimotor delays. Here, we develop a new, interpretable, and generalizable model of fly walking, which we use to investigate the impact of varying sensorimotor delays in <italic>Drosophila</italic> locomotion.”</p><disp-quote content-type="editor-comment"><p><bold>Recommendations for the authors:</bold></p><p><bold>Reviewer #1 (Recommendations For The Authors):</bold></p><p>Potential typo on page 5:</p><p>2.1.2 Joint kinematics trajectory generator</p><p>Paragraph 4, last line: Original text - &quot;.....it also estimates the current phase&quot;. Suggested correction - &quot;...it also estimates the current phase velocity&quot;</p></disp-quote><p>Done</p><disp-quote content-type="editor-comment"><p>Potential typo on page 8:</p><p>2.3 Model maintains walking under unpredictable external perturbations.</p><p>Paragraph 3, line 2: Original text - &quot;...brief, unexpected force (e.g. legs slipping on an unstable surface)&quot;.</p><p>Consider replacing force with motion, or providing an example of a force as opposed to displacement (slipping).</p></disp-quote><p>Done</p><disp-quote content-type="editor-comment"><p>Potential typo on page 8:</p><p>2.3 Model maintains walking under unpredictable external perturbations.</p><p>Paragraph 3, line 4: Original text - &quot;The magnitude of this velocity is drawn from a normal distribution...&quot;.</p><p>Is this really magnitude? If so, please discuss how the sign (+/-) is assigned to velocity, and how the normal distribution is centred so as to sample only positive values representing magnitude.</p></disp-quote><p>Indeed the magnitude of the velocity is drawn from a normal distribution. A positive or negative sign is then assigned with equal odds. We have added text to clarify this:</p><p>“The sign of the velocity was drawn separately so that there is equal likelihood for negative or positive perturbation velocities.”</p><disp-quote content-type="editor-comment"><p>Page 8:</p><p>2.3 Model maintains walking under unpredictable external perturbations.</p><p>In Paragraph 5: Why is the data reduced to only 2 dimensions? Could higher order PCA modes (cumulatively accounting for more than 50% variance in the data) not have distinguishing information between realistic and unrealistic walking trajectories?</p></disp-quote><p>We provide a longer response for this in the public review above.</p><disp-quote content-type="editor-comment"><p>Page 11:</p><p>Why wouldn't a system trained in the presence of external perturbations perform better? What is the motivation to remove external perturbations during training?</p></disp-quote><p>We agree that a system trained in the presence of external perturbations would probably perform better — however, we do not have data that contains walking with external perturbations. Nothing was removed — all the data used in this study involve a fly walking without perturbations.</p><p>We have added a clarification:</p><p>“our model maintains realistic walking in the presence of external dynamic perturbations, despite being trained only on data of walking without perturbations (no perturbation data was available).”</p><disp-quote content-type="editor-comment"><p>Page 16:</p><p>4.1 Tracking joint angles of <italic>D. melanogaster</italic> walking in 3D.</p><p>Paragraph 1: Readers who wish to collect similar data might benefit from specifying the exposure time, animal size in pixels (or camera sensor format and field of view), in addition to the frame rate. Alternatively, consider mentioning the camera and lens part numbers provided by the manufacturer.</p></disp-quote><p>This is a good point. We have updated the text to include these specifications:</p><p>“We obtained fruit fly <italic>D. melanogaster</italic> walking kinematics data following the procedure previously described in (Karashchuk et al, 2021). Briefly, a fly was tethered to a tungsten wire and positioned on a frictionless spherical treadmill ball suspended on compressed air. Six cameras (Basler acA800-510um with Computar zoom lens MLM3X-MP) captured the movement of all of the fly's legs at 300 Hz. The fly size in pixels ranges from about 300x300 up to 700x500 pixels across the 6 cameras. Using Anipose, we tracked 30 keypoints on the fly, which are the following 5 points on each of the 6 legs: body-coxa, coxa-femur, femur-tibia, and tibia-tarsus joints, as well as the tip of the tarsus.”</p><disp-quote content-type="editor-comment"><p>Potential typos on page 18:</p><p>4.3.3 Training procedure</p><p>Paragraph 2, line 1: Original text - &quot;..(, p)&quot;</p><p>Do the authors mean &quot;...(,)&quot;</p><p>Paragraph 2, line 2: Original text - &quot;... (,, v, p)&quot; Do the authors mean &quot;... (,, v,)&quot;?</p><p>Paragraph 3, line 3: Original text - &quot;... (,, v, p)&quot; Do the authors mean &quot;... (,, v,)&quot;?</p></disp-quote><p>Thank you for pointing out this issue. We have now fixed the phase p to be \phi to be consistent with the rest of the text.</p><disp-quote content-type="editor-comment"><p>Paragraph 3, line 3: Original text - &quot;...()&quot;</p><p>Do the authors mean &quot;(d)&quot;? If not, please discuss the difference between and d.</p></disp-quote><p>Thank you for pointing this out. \hat \theta and \theta_d were used interchangeably which is confusing. We have standardized our reference to the desired trajectory as \theta_d throughout the text.</p><disp-quote content-type="editor-comment"><p>Page 19:</p><p>Typo after eqn. (6):</p><p>Original text: &quot;where x : = q - q, ... A and B are Jacobians with respect to....&quot;</p><p>Correction: &quot;where x : = q - q, ... Ac and Bc are Jacobians with respect to....&quot;</p><p>Similar corrections in eqn. 7 and eqn. 8: A and B should be replaced with Ac and Bc. Done</p></disp-quote><p>Page 19, eqn. (10b):</p><p>Should the last term be qd(t+T) as opposed to qd(t+1)?</p><p>No: in fact (10a) contains the typo: it should be y(t+1) as opposed to y(t+T). This has been fixed.</p><disp-quote content-type="editor-comment"><p>Page 19</p><p>The authors' detailed description of the initial steps leading up to the dynamics model, involving the construction of the ODE, linearizing the system about the fixed point makes the text broadly accessible to the general reader. Similarly, adding some more description of the predictive model (eqn. 11 - 15) could improve the text's accessibility and the reader's appreciation for the model. This is especially relevant since the effects of sensorimotor delay and external perturbations, which are incorporated in the control and dynamics model, form a major contribution to this work. What do the matrices F, G, L, H, and K look like for the <italic>Drosophila</italic> model? Are there any differences between the model in Stenberg et al. (referenced in the paper) and the authors' model for predictive control? Are there any differences in the assumptions made in Stenberg et al. compared to the model presented in this work? The readers would likely also benefit from a figure showing the information flow in the model, and describing all the variables used in the predictive control model in eqn. 11 through eqn. 15 (analogous to Figure 1 in Stenberg et al. (2022)). Such a detailed description of the control and dynamics model would help the reader easily appreciate the assumptions made in modelling the effects of sensorimotor delay and external perturbations.</p></disp-quote><p>Done</p><disp-quote content-type="editor-comment"><p>Page 20:</p><p>Eqn. 12: Should z(t+1) be z(t+T) instead?</p><p>Similar comment for eqn. 14</p></disp-quote><p>No: we made a mistake in (10a); there should be no (t+T) terms; all terms should be (t+1) terms to reflect a standard discrete-time difference equation.</p><disp-quote content-type="editor-comment"><p>Eqn. 13: r(t) can be defined explicitly</p></disp-quote><p>Done</p><disp-quote content-type="editor-comment"><p>4.5 Generate joint trajectories of the complete model with perturbations Paragraph 2, line 2: Please read the previous comment</p></disp-quote><p>\hat \theta and \theta_d were previously used interchangeably which is confusing. We have standardized our reference to the desired trajectory as \theta_d throughout the text.</p><disp-quote content-type="editor-comment"><p>Original text - &quot;Every 8 timesteps, we set :=....&quot;</p><p>Does this mean dis set to? If so, the motivation for this is not clear.</p></disp-quote><p>We mean that \theta_d is set to be equal to \theta. We have replaced “:=” with “=” for clarity.</p><disp-quote content-type="editor-comment"><p>General comments for the authors:</p><p>Could the authors discuss the assumptions regarding <italic>Drosophila</italic> physiology implied in the control model?</p></disp-quote><p>The control model is primarily included as a plausible functional element of the fly’s nervous system, and as such implies minimal assumptions on physiology itself. The main assumption, which is evident from the description of the model components, is that the fly uses proprioceptive feedback information to inform future movements.</p><p>We have added clarifying text to the Results section:</p><p>“While the model is inspired by neuroanatomy, its components do not strictly correspond to components of the nervous system --- the construction of a neuroanatomically accurate model is deferred to future work (see Discussion).”</p><disp-quote content-type="editor-comment"><p>The authors acknowledge the absence of ground contact forces in the model. It is probably worth discussing how this simplification may affect inferences regarding the acceptable range of sensorimotor delay in generating realistic walking trajectories.</p></disp-quote><p>We agree, and discuss how some of these assumptions affect the quantitative results in the section “Towards biomechanical and neural realism”. We replicate the relevant sentences below:</p><p>“The inclusion of explicit leg-ground contact interactions would also make it harder for the model to recover when perturbed, because perturbations during walking often occur upon contact with the ground (e.g. the ground is slippery or bumpy).”</p><p>The effects of other simplifications are also mentioned in the same section.</p><disp-quote content-type="editor-comment"><p>Can the authors provide an insight into why the use of a second derivative of joint angles as the output of the trajectory generator () leads to more realistic trajectories (4.3.1 Model formulation, paragraph 1)?</p><p>Does the use of a second-order derivative of joint angles lead to drift error because of integration?</p><p>Could the distribution of θd produced be out of the domain due to drift errors? Could this affect the performance of the neural network model approximating the trajectory generator?</p></disp-quote><p>We are not sure why the second derivative works better than the first derivative. It is possible that modeling the system as a second order differential equation gives the network more ability to produce complex dynamics.</p><p>As can be seen in the example time series in Figures 2 and 3 and supplemental videos, there is no drift error from integration, so it is unlikely to affect the performance of the neural network.</p><disp-quote content-type="editor-comment"><p>What does the model's failure (quantified by a low KS score) look like in the context of fly dynamics? What do the joint angles look like for low values of KS score? Does the fly fall down, for example?</p></disp-quote><p>Since the model primarily considers kinematics, a low KS score means that kinematics are unrealistic, e.g. the legs attain unnatural angles or configurations. Examples of this can be seen in videos 4-7, as well as in the bottom row of Fig. 5, panel A. Here, at 40ms of motor delay, L2 femur rotation is seen to attain values that far exceed the normal ranges.</p><p>We have added a small clarification in the caption of Fig.5 panel A:</p><p>“low KS indicates that the perturbed walking deviates from data and results in unnatural angles</p><p>(as seen at 40ms motor delay)”</p><p>We remark that since our simulations do not incorporate contact forces (as the reviewer remarks above, we simulate something like legs moving in the air for a tethered fly), the fly cannot “fall down” per se. However, if forces were incorporated then yes, these unrealistic kinematics would correspond to a fly that falls down or is no longer walking.</p><disp-quote content-type="editor-comment"><p><bold>Reviewer #2 (Recommendations For The Authors):</bold></p><p>L49: &quot;Computational models of locomotion do not typically include delay as a tunable parameter, and most existing models of walking cannot sustain locomotion in the presence of delays and external perturbations&quot;. This remark confuses the reviewer.</p><p>(1) If models do not &quot;typically&quot; include delay as a tunable parameter, this suggests that atypical models do. Which models do? Please provide references.</p></disp-quote><p>Our initial phrasing was confusing. We meant to say that most models do not include delay, and some models do include delay as a fixed value (rather than a tunable value). We clarify in the updated text, which is replicated below:</p><p>“Computational models of locomotion typically have not included delays as a tunable parameter, although some models have included them as fixed values (Geyer and Herr, 2010; Geijtenbeek et al., 2013).”</p><disp-quote content-type="editor-comment"><p>(2) Has the statement that most existing models cannot sustain locomotion with delays been tested? If so, provide references. If not, please remove this statement or temper the language.</p></disp-quote><p>Since most models don’t include delays, they cannot be run in scenarios with delays. We clarify in the updated text, which is replicated below:</p><p>“Computational models of locomotion have not typically included delays. Some have included delay as a fixed value rather than a tunable parameter (Geyer and Herr, 2010; Geijtenbeek et al., 2013). However, in general, the impact of sensorimotor delays on locomotor control and robustness remains an underexplored topic in computational neuroscience.”</p><disp-quote content-type="editor-comment"><p>L57: &quot;two of six legs lift off the ground at a time&quot; - Two legs are off the ground at any time, but they do not &quot;lift off&quot; simultaneously in the fruit fly. To lift off simultaneously, contralateral leg pairs would need to be 33% out of phase with one another, but they are almost always 50% out of phase.</p></disp-quote><p>Thank you for pointing out this oversight. We have updated the text accordingly:</p><p>“Flies walk rhythmically with a continuum of stepping patterns that range from tetrapod (where two of six legs are off the ground at a time) to tripod (where three of six legs are off the ground at a time)&quot;</p><disp-quote content-type="editor-comment"><p>L88: &quot;a new model of fly walking&quot; - The intention of the authors is to produce a model from which to learn about walking in the fly, is that correct? The reviewer has read the paper several times now and wants to be sure that this is the authors' goal, not to engineer a control system for an animation or a robot.</p></disp-quote><p>Indeed, this is our goal. We were previously unclear about this, and have made text edits to clarify this — we provide a longer response for this in the public review above (see (1)).</p><disp-quote content-type="editor-comment"><p>L126: &quot;These desired phases are synchronized across pairs of legs to maintain a tripod coordination pattern, even when subject to unpredictable perturbations.&quot; - Does the animal maintain tripod coordination even when perturbed? In the reviewer's experience, flies vary their interleg coordination all the time. The reviewer would also expect that if perturbed strongly (as the supplemental videos show), the animal would adapt its interleg coordination in response. The author finds this assumption to be a weak point in the paper for the use of this disturbance exploring animal locomotion.</p></disp-quote><p>We do not know exactly how flies may react to our mechanical perturbations. However, we may hypothesize based on past papers.</p><p>Couzin-Fuchs et al (2015) apply a mechanical perturbation to walking cockroaches. They find that that tripod is temporarily broken immediately after the perturbation but the cockroach recovers to a full tripod within one step cycle.</p><p>DeAngelis et al (2019) apply optogenetic perturbations to fly moonwalker neurons that drive backward walking. Flies slow down following perturbation, but then recover after 200ms (about 2-3 steps) to their original speed (on average).</p><p>Thus, we think it is reasonable to model a fly’s internal phase coupling to maintain tripod and for its intended speed to remain the same even after a perturbation.</p><p>We do agree with the reviewer that it is plausible a fly might also slow down or even stop after a perturbation and we do not model such cases. We have added some text to the discussion on future work:</p><p>“Future work may also model how higher-level planning of fly behavior interacts with the lowerlevel coordination of joint angles and legs. Walking flies continuously change their direction and speed as they navigate the environment (Katsov et al, 2017; Iwasaki et al 2024). Past work shows that flies tend to recover and walk at similar speeds following perturbations (DeAngelis et al, 2019), but individual flies might still change walking speed, phase coupling, or even transition to other behaviors, such as grooming. Modeling these higher-level changes in behavior would involve combining our sensorimotor model with models for navigation (Fisher 2022) or behavioral transitions (Berman et al, 2016).”</p><disp-quote content-type="editor-comment"><p>L136: &quot;...to output joint torques to the physical model of each leg&quot; - Is this the ultimate output of the nervous system? Muscles are certainly not idealized torque generators. There are dynamics related to activation and mechanics. The reviewer is skeptical that this is a model of neural control in the animal, because the computation of the nervous system would be tuned to account for all these additional dynamics.</p></disp-quote><p>We agree with the reviewer that joint torques are not the ultimate output of the nervous system. We use a torque controller because it is parsimonious, and serves our purpose of creating an interpretable and modular locomotion model.</p><p>We also agree that muscles are an important consideration — we make mention of them later on in the paper under the section “Toward biomechanical and neural realism”, where we state “Another step toward biological realism is the incorporation of explicit dynamical models of proprioceptors, muscles, tendons, and other biomechanical aspects of the exoskeleton.”</p><p>Our goal is not to directly model neural control of the animal. We have introduced text clarifications to emphasize this — we provide a longer response for this in the public review above (see (2)).</p><disp-quote content-type="editor-comment"><p>L143: &quot;To train the network from data, we used joint kinematics of flies walking on a spherical treadmill...&quot; This is an impressive approach, but then the reviewer is confused about why the kinematics of the model are so different from those of the animal. The animal takes longer strides at a lower frequency than the model. If the model were trained with data, why aren't they identical? This kind of mismatch makes the reviewer think the approach in this paper is too complicated to address the main problem.</p></disp-quote><p>The design of our trajectory generator model is one of the simplest for reproducing the output of a dynamical system. It consists of a multilayer perceptron model that models the phase velocity and joint angle accelerations at each timestep. All of its inputs are observable and interpretable: the current joint angles, joint angle derivatives, desired walking speed, and phase angle.</p><p>We chose this model for ease of interpretability, integration with the optimal controller, and to allow for generalization across perturbations. Given all of these constraints, this is the best model of desired kinematics we could obtain. We note that the simulated kinematics do match real fly kinematics qualitatively (Figure 2A and supplemental videos) and are close quantitatively (Figure 2B and C). We speculate that matching the animals’ strides at all walking frequencies may require explicitly modeling differences across individual flies. We leave the design and training of more accurate (but more complex) walking models for future work.</p><p>We add some further discussion about fitting kinematics in the discussion:</p><p>“Although we believe our model matches the fly walking sufficiently for this investigation, we do note that our model still underfits the joint angle oscillations in the walking cycle of the fly (see Figure 2 and Appendix 2). More precise fitting of the joint angle kinematics may come from increasing the complexity of the neural network architecture, improving the training procedure based on advances in imitation learning (Hussein et al., 2018), or explicitly accounting for individual differences in kinematics across flies (Deangelis et al., 2019; Pratt et al., 2024).”</p><disp-quote content-type="editor-comment"><p>Figure 2: The reviewer thinks the violin plots in Figure 2C are misleading. Joint angles could be greater or less than 0, correct? If so, why not keep the sign (pos/neg) in the data? Taking the absolute value of the errors and &quot;folding over&quot; the distribution results in some strange statistics. Furthermore, the absolute value would shroud any systematic bias in the model, e.g., joint angles are always too small. The reviewer suggests the authors plot the un-rectified data and simply include 2 dashed lines, one at 5.56 degrees and one at -5.56 degrees.</p></disp-quote><p>These violin plots are averages of errors over all phases within each speed. We chose to do this to summarize the errors across all phase angle plots, which are shown in detail in Appendix 2 and 3.</p><p>For the reviewer, we have added a plot of the raw errors across all phase angle plots in Appendix 4, E.</p><disp-quote content-type="editor-comment"><p>L156: Should &quot;\phi\dot&quot; be &quot;\phi&quot;?</p></disp-quote><p>We originally had a typo: we said “phase” when we meant “phase velocity”. This has been fixed. \phi\dot is correct.</p><p>L160: &quot;This control is possible because the controller operates at a higher temporal frequency than the trajectory generator...&quot;. This statement concerns the reviewer. To the reviewer, this sounds like the higher-level control system communicates with the &quot;muscles&quot; at a higher frequency than the low-level control system, which conflicts with the hierarchical timescales at which the nervous system operates. Or do the authors mean that the optimal controller can perform many iterations in between updates from the trajectory generator level? If so, please clarify.</p><p>We mean that the optimal controller can perform many iterations in between updates from the trajectory generator level. The text has been clarified:</p><p>“This control is possible because the controller operates at a higher temporal frequency than the trajectory generator in the model. The controller can perform many iterations (and reject disturbances) in between updates to and from the trajectory generator.”</p><disp-quote content-type="editor-comment"><p>L225: &quot;We considered two types of perturbations: impulse and persistent stochastic&quot;. Are these realistic perturbations? Realistic perturbations such as a single leg slipping, or the body movement being altered would produce highly correlated joint velocities.</p></disp-quote><p>These perturbations are not quite realistic — nonetheless, we illustrate their analogousness to real perturbations in the subsequent text in the paper, and restrict our simulations to ranges that would be biologically plausible (see Appendix 6). We agree that realistic perturbations would produce highly correlated joint accelerations and velocities, whereas our perturbations produce random joint accelerations.</p><disp-quote content-type="editor-comment"><p>L265: &quot;...but they are difficult to manipulate experimentally...&quot; This is true, but it can and has been done. The authors should cite:</p></disp-quote><p>Bässler, U. (1993). The femur-tibia control system of stick insects-A model system for the study of the neural basis of joint control. Brain Research Reviews, 18(2), 207-226.</p><p>Thank you for the suggestion, we have incorporated it into the text at the end of the referenced sentence.</p><disp-quote content-type="editor-comment"><p>L274: &quot;...since the controller can effectively compensate for large delays by using predictions of joint angles in the future&quot;. But can the nervous system do this? Or, is there a reason to think that the nervous system can? The reviewer thinks the authors need stronger justification from the literature for their optimal control layer.</p></disp-quote><p>To clarify, this sentence describes a feature of the model’s behavior when no external perturbations are present. This is not directly relevant to the nervous system, since organisms do not typically exist in an environment free of perturbations — we are not suggesting that the nervous system does this.</p><p>In response to the question of whether the nervous system can compensate for delays using predictions: we know that delays are present in the nervous system, perturbations exist in the environment, and that flies manage to walk in spite of them. Thus, some type of compensation must exist to offset the effects of delays (the reviewer themself has provided some excellent citations that study the effects of delays). In our model, we use prediction as the compensation mechanism — this is one of our central hypotheses. We further discuss this in the section “Predictive control is critical for responding to perturbations due to motor delay”.</p><disp-quote content-type="editor-comment"><p>L319: &quot;The formulation of a modular, multi-layered model for locomotor control makes new experimentally-testable hypotheses about fly motor control...&quot;. What testable hypotheses are these? The authors should explicitly state them. They are not clear to the reviewer, especially given the nonphysiological nature of the control system and the mechanics.</p></disp-quote><p>A number of testable hypotheses are mentioned throughout the Discussion section:</p><p>“Our model predicts that at the same perturbation magnitude, walking robustness decreases as delays increase. This could be experimentally tested by altering conduction velocities in the fly, for example by increasing or decreasing the ambient temperature (Banerjee et al, 2021). If a warmer ambient temperature decreases delays in the fly, but fly walking robustness remains the same in response to a fixed perturbation, this would indicate a stronger role for central control in walking than our modeling results suggest.”</p><p>“In our model, robust locomotion was constrained by the cumulative sensorimotor delay. This result could be experimentally validated by comparing how animals with different ratios of sensory to motor delays respond to perturbations. Alternatively, it may be possible to manipulate sensory vs. motor delays in a single animal, perhaps by altering the development of specific neurons or ensheathing glia (Kottmeier et al., 2020). If sensory and motor delays have significantly different effects on walking quality, then additional compensatory mechanisms for delays could play a larger role than we expect, such as prediction through sensory integration, mechanical feedback, or compensation through central control.”</p><p>“we hypothesize that removing proprioceptive feedback would impair an insect's ability to sustain locomotion following external perturbations.”</p><p>“We propose that fly motor circuits may encode predictions of future joint positions, so the fly may generate motor commands that account for motor neuron and muscle delays.”</p><disp-quote content-type="editor-comment"><p>L323: &quot;...and biomechanical interactions between the limb and the environment&quot;. In the reviewer's experience, the primary determinant of delay tolerance is the mechanical parameters of the limb: inertia, damping, and parallel elasticity. For example, in Ashtiani et al. 2021, equation 5 shows exactly how this comes about: the delay changes the roots and poles of the control system. This is why the reviewer is confused by the complexity of the model in this submission; a simpler model would explain why delays cannot be tolerated in certain circumstances.</p></disp-quote><p>We were previously unclear about the goal of the model, and have made text edits to clarify this — we provide a longer response for this in the public review above (see (1)).</p><disp-quote content-type="editor-comment"><p>L362: Another highly relevant reference here would be Sutton et al. 2023.</p></disp-quote><p>Done</p><disp-quote content-type="editor-comment"><p>L366: Szczecinski et al. 2018 is hardly a &quot;model&quot;; it is mostly a description of experimental data. How about Goldsmith, Szczecinski, and Quinn 2020 in B&amp;B? Their model of fly walking has patterngenerating elements that are coordinated through sensory feedback. In their model, motor activation is also altered by sensory feedback. The reviewer thinks the statement &quot;Models of fly walking have ignored the role of feedback&quot; is inaccurate and their description of these references should be refined.</p></disp-quote><p>Thank you for the suggestion; we have tempered the language and revised this section to include more references, including the suggested one — text is replicated below.</p><p>“Many models of fly walking ignore the role of feedback, relying instead on central pattern generators (Lobato-Rios et al., 2022; Szczecinski et al., 2018; Aminzare et al., 2018) or metachondral waves (Deangelis et al., 2019) to model kinematics. Some models incorporate proprioceptive feedback, primarily as a mechanism that alters timing of movements in inter-leg coordination (Goldsmith et al., 2020; Wang-Chen et al., 2023).”</p><p>We remark that Szczecinski et al does include a model that replicates data without using sensory feedback, so we think it is fair to include.</p><disp-quote content-type="editor-comment"><p>L371: &quot;...highly dependent on proprioceptive feedback for leg coordination during walking.&quot; What about Berendes et al. 2016, which showed that eliminating CS feedback from one leg greatly diminished its ability to coordinate with the other legs? This suggests that even flies depend on sensory feedback for proper coordination, at least in some sense.</p></disp-quote><p>Interesting suggestion – we have integrated it into the text a little further down, where it better fits:</p><p>“Silencing mechanosensory chordotonal neurons alters step kinematics in walking <italic>Drosophila</italic> (Mendes et al., 2013; Pratt et al., 2024). Additionally, removing proprioceptive signals via amputation interferes with inter-leg coordination in flies at low walking speeds (Berendes et al., 2016)”</p><disp-quote content-type="editor-comment"><p>L426: &quot;The layered model approach also has potential applications for bio-mimetic robotic locomotion.&quot;. How fast can this model be computed? Can it run faster than real-time? This would be an important prerequisite for use as a robot control system.</p></disp-quote><p>The model should be able to be run quite fast, as it involves only</p><p>(1) Addition, subtraction, matrix multiplication, and sinusoidal computation on scalars (for the phase coordinator and optimal controller)</p><p>(2) Neural network inference with a relatively small network (for the trajectory generator) Whether this can run in real-time depends on the hardware capabilities of the specific robot and the frequency requirements — it is possible to run this on a desktop or smaller embedded device.</p><p>We do note that the model needs to first be set up and trained before it can be run, which takes some time (see panel D of Figure 1).</p><disp-quote content-type="editor-comment"><p>L432: &quot;...which is a popular technique in robotics.&quot;. Please cite references supporting this statement.</p></disp-quote><p>We have added citations: the text and relevant citations are reproduced below:</p><p>“... which is a popular technique in robotics (Hua et al., 2021; Johns, 2021)</p><p>Hua J, Zeng L, Li G, Ju Z. Learning for a robot: Deep reinforcement learning, imitation learning, transfer learning. Sensors. 2021; 21(4):1278</p><p>Johns E. Coarse-to-fine imitation learning: Robot manipulation from a single demonstration. In:</p><p>2021 IEEE international conference on robotics and automation (ICRA) IEEE; 2021. p. 4613–4619</p><disp-quote content-type="editor-comment"><p>L509: &quot;We find that the phase offset across legs is not modulated across walking speeds in our dataset&quot;. This is a surprising result to the reviewer. Looking at Figure 6C, the reviewer understands that there are no drastic changes in coordinate with speed, but there are certainly some changes, e.g., L1-R3, L3-R1. In the reviewer's experience, even very small changes in interleg phasing can change the visual classification of walking from &quot;tripod&quot; to &quot;tetrapod&quot; or &quot;metachronal&quot;. Furthermore, several leg pairs do not reside exactly at 0 or \pi radians apart, e.g., L1-L3, L2-L3, R1-R3, R2-R3. In conclusion, the reviewer thinks that setting the interleg coordination to tripod in all cases is a large assumption that requires stronger justification (or, should be eliminated altogether).</p></disp-quote><p>We made a simplifying assumption of a tripod coordination across all speeds. The change in relative phase coordination across speeds is indeed relatively small and additionally we see little change in our results across forward speeds (see Figures 4B, 5C and 5D).</p><p>We have added text to clarify this assumption and what could be changed for future studies in the methods:</p><p>“We estimate $\bar \phi_{ij}$ from the walking data by taking the circular mean over phase differences of pairs the legs during walking bouts. We find that the phase offset across legs is not strongly modulated across walking speeds in our dataset (see Appendix 1) so we model $\bar \phi_{ij}$ as a single constant independent of speed. In future studies, this could be a function of forward and rotation speeds to account for fine phase modulation differences.”</p><disp-quote content-type="editor-comment"><p>L581: &quot;of dimension...&quot;. Should the asterisk be replaced by \times? The asterisk makes the reviewer think of convolution. This change should be made throughout this paragraph.</p></disp-quote><p>Good point, done.</p><p>Figure 6: Rotational velocities in all 3 sections are reported in mm/s, but these units do not make sense. Rotational velocities must be reported in rad/s or deg/s.</p><p>The rotation velocity of mm/s corresponded to the tangential velocity of the ball the fly walked on. We agree that this does not easily generalize across setups, so we have updated the figure rotation velocities in rad/s.</p><disp-quote content-type="editor-comment"><p>L619: The reviewer is unconvinced by using only 2 principal components of the data to compare the model and animal kinematics. The authors state on line 626 that the 2 principal components do not capture 56.9% of the variation in the data, which seems like a lot to the reviewer. This is even more extreme considering that the model has 20 joints, and the authors are reducing this to 2 variables; the reviewer can't see how any of the original waveforms, aside from the most fundamental frequencies, could possibly be represented in the PCA dataset. If the walking fly models looked similar to each other, the reviewer could accept that this method works. But the fact that this method says the kinematics are similar, but the motion is clearly different, leads the reviewer to suspect this method was used so the authors could state that the data was a good match.</p></disp-quote><p>Our primary use of the KS metric was to indicate whether the simulated fly continues walking in the presence of perturbations, hence we limited the analysis of the KS to the first 2 principal components.</p><p>For completeness, we investigate the principal components in Appendix 8 and the effect of evaluating KS with different numbers of components in Appendix 9.</p><p>The results look similar across components for impulse perturbations. For stochastic perturbations, the range of similar walking decreases as we increase the number of components used to evaluate walking kinematics. Comparing this with Appendix 8 showing that higher components represent higher frequencies of the walking cycle, we conclude that at the edge of stability for delays (where sum of sensory and actuation delays are about 40ms), flies can continue walking but with impaired higher frequencies (relative to no perturbations) during and after perturbation.</p><p>We add text in the methods:</p><p>“We chose 2 dimensions for PCA for two key reasons. First, these 2 dimensions alone accounted for a large portion of the variance in the data (52.7% total, with 42.1% for first component and 10.6% for second component). There was a big drop in variance explained from the first to the second component, but no sudden drop in the next 10 components (see Appendix 8). Second, the KDE procedure only works effectively in low-dimensional spaces, and the minimal number of dimensions needed to obtain circular dynamics for walking is 2. We investigate the effect of varying the number of dimensions of PCA in Appendix 9.”</p><p>(Note that we have corrected the percentage of variance accounted for by the principal components, as these numbers were from an older analysis prior to the first draft.)</p><p>We also reference Appendix 9 in the results:</p><p>“We observed that robust walking was not contingent on the specific values of motor and sensory delay, but rather the sum of these two values (Fig. 5E). Furthermore, as delay increases, higher frequencies of walking are impacted first before walking collapses entirely (Appendix 9).”</p></body></sub-article></article>