This is a really annoying aspect of CommandGroup. Basically, all the code that you write for a CommandGroup is in the constructor. This means that the code itself is going to run instantaneously, probably when you first turn on the robot. What addSequential() and addParallel() do is pretty much just add the commands you requested into a queue. Those commands are then iterated through later when the CommandGroup is actually started.
What this means is that if you have a 3 line command group, like such:
Code:
Robot.drivedistance = 10;
addSequential(new Command1());
addSequestial(new Command2(Robot.drivedistance));
with Command1 containing the following line in its initialize method:
Code:
Robot.drivedistance = 100;
When the robot is turned on, the 3 lines of code in your CommandGroup will be executed. This means that drivedistance will be set to 10, then a new Command1() will be created and added to the queue, then a new Command2 will be created
with the current value of Robot.drivedistance (which is 10) as the parameter, and added to the queue. When this command is actually run, Command1 will change Robot.drivedistance to be 100, but that doesn't matter because Command2 has already been told the distance it is supposed to drive.
There are a few different ways to fix this, although I don't consider any of them pretty. The simplest way is probably just to create a new command that will drive the distance specified by Robot.drivedistance, and have it be separate from your normal driveRobotToDistance command. In this new command you should check what the value of Robot.drivedistance is in the initialize method, not the constructor.