View Single Post
  #5   Spotlight this post!  
Unread 22-01-2017, 21:04
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: CIM coders help!

In your example you are creating CANTalon objects, so the number in the constructor is actually the CAN ID and not a roboRIO port number. So that in itself should not be a conflict.

Code:
DriveCommand::DriveCommand() {
	victor = new Victor(0);
	victor2 = new Victor(1);
	talon = new CANTalon(1);
	talon2 = new CANTalon(2);
	CIM = new Encoder(0, 1, false, Encoder::EncodingType::k4X);
}
I'm wondering if the command is being created more than once, which would cause duplicate allocations which are indicated by your output:

Code:
ERROR -1029 HAL: Resource already allocated, Minimum Value: 0, Maximum Value: 20, Requested Value: 0 PWM [PWM.cpp:43] 
ERROR -1029 HAL: Resource already allocated, Minimum Value: 0, Maximum Value: 20, Requested Value: 1 PWM [PWM.cpp:43] 
ERROR -1029 HAL: Resource already allocated, Minimum Value: 0, Maximum Value: 31, Requested Value: 0 DigitalInput [DigitalInput.cpp:43] 
ERROR -1029 HAL: Resource already allocated, Minimum Value: 0, Maximum Value: 31, Requested Value: 1 DigitalInput [DigitalInput.cpp:43] 
ERROR -1098 HAL: A handle parameter was passed incorrectly InitEncoder [Encoder.cpp:43]
Ideally you would want to create the sensors and speed controllers in a subsystem rather than a command and refer to methods on the subsystem to actually operate the drive base. That way, creating multiple instance of commands won't double-allocate the sensors.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote