Quote:
Originally Posted by davidthefat
Add:
free(Elevator_heights);
after that for loop
|
I'm not sure why this would be freed at after that for loop. It looks like there are other functions that want to access that array later on. It should be freed somewhere else (perhaps a destructor), but I don't think that this is the source of the problem. It appears it's only called at most twice during the program's run before it crashes.
As mentioned already, that Elevator_Mechanism structure is very strange looking. It's difficult to follow, so I can't say for sure whether or not that part would work.
Spoiler for incorrect information:
Here's what I noticed at a quick glance in the constructor's initialization list:
Code:
Carriage_motor(new Victor(4)),
Elevator_motor(new Victor(3)),
These are defined earlier as:
Code:
Victor *Elevator_motor;
Victor *Carriage_motor;
I believe you should have instead:
Code:
Carriage_motor(3),
Elevator_motor(4),
This is because the constructor for Victor expects an int with the value of a PWM port, and instead you're passing a pointer to a Victor. Since there are checks to make sure a valid PWM channel number is provided, I'd expect an IndexOutOfRange ("Allocating channel or module that is out of range") fatal error to be thrown by WPILib.
This is a situation where it would be useful to post the console output. The debugger would also be a valuable tool to use.