RobotPy Sim -- Windows fatal exception: access violation

We are running our code in 2020 sim and receiving fatal exception error. The sim dies when it runs a command group and says:

Windows fatal exception: access violation

We are speculating it could be due to a change in the 2020 command package. We used requires(Subsystem) and are wondering if this could be the cause of it failing.

Any suggestions would be greatly appreciated!

Could you share your code?

See also https://robotpy.readthedocs.io/en/latest/2020_notes.html - something will probably be relevant there.

The error in the console of the robot when trying to upload the code is
File ‘path to the file on the rio/commands/do_winch.py’, line 13 in init

Line 13 in do_winch reads
self.requires(robot.winch)

I have a feeling the way to use self.requires has changed since the super().init() is not used for 2020 wpilib commands but I don’t know how to use it correctly anymore

also we have checked the 2020 release notes and haven’t found anything, but maybe there’s something we missed

Yeah, you’re missing __init__ calls to the superclass for all your Subsystems and Commands.

Right, but here’s an example from the 2020 update notes

from wpilib.command import Command

class GoodCommand(Command):

# no custom __init__, nothing extra required

def foo(self):
    pass

Yes, that example does not define its own __init__, so the superclass __init__ does get called.

where does it get called in that example? Or should I just add this
Command.init(self)

?

If you override __init__ (i.e. you define it in your subclass), then you need to call Command.__init__(self) etc. in your __init__.

2 Likes

Okay I will try that thanks

We tried to put Command.init(self) in commands and tried to put super().init_() in subsystems which didn’t work in the sim. So, we removed superinit from subsystems but this still didn’t run in the sim.

We’re getting an error that says
init(): incompatible constructor arguments

The rule of thumb is that you call the base class constructor directly. So if you have:

class Foo(Bar):
    pass

Then calling it’s constructor in your custom __init__ is going to be

class Foo(Bar):
    def __init__(self):
        Bar.__init__(self)

So a subsystem would call Subsystem.__init__, etc.

1 Like

Also, I fixed some issues in your repo, and made a pull request. https://github.com/beavertronics/2020code5970/pull/1

1 Like

Where can we find the arguments for the command group init? Also thanks for the pull

This year’s command API documentation is at https://robotpy.readthedocs.io/projects/commands-v1/en/latest/api.html

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.