Skip to content

Output calcs produce 0's at every other call #1009

@corbinklett

Description

@corbinklett

I've noticed that subsystems can produce outputs = 0 on every other call to a system's output function. The final result of the simulation is correct; however if you are doing something like processing quaternions in the output function, a quaternion of all zeros is invalid and an error results (without some hacky handling of that situation).

In the code below, line 1 printouts alternate between 0 and 1 rather than printing 1 at each call.

import numpy as np
import control as ct

def output_sys_outputs(t, x, u, params):
    print(u) # alternates between zero and 1
    return u

output_sys = ct.nlsys(updfcn=None, outfcn=output_sys_outputs, inputs=1, outputs=1, name="output_sys")

def input_sys_outputs(t, x, u, params):
    return 1

input_sys = ct.nlsys(updfcn=None, outfcn=input_sys_outputs, outputs=1, inputs=0, name="input_sys")

# outputs just 1's
input_sim = ct.input_output_response(input_sys, T=np.linspace(0, 1, 100))

system = ct.interconnect(
    (input_sys, output_sys),
    connections=[
        ['output_sys.u', 'input_sys.y']
    ],
    inplist=[],
    outlist=['output_sys.y']
)

timeseries = ct.input_output_response(system, T=np.linspace(0, 1, 100))
y = timeseries.outputs
print(y) # prints all 1's

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy