Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the end position of a TrajectoryActionBuilder #111

Closed
polarbub opened this issue Oct 27, 2024 · 1 comment
Closed

Getting the end position of a TrajectoryActionBuilder #111

polarbub opened this issue Oct 27, 2024 · 1 comment

Comments

@polarbub
Copy link

polarbub commented Oct 27, 2024

I have two TrajectoryActionBuilders. After the first one the robot stops and then it executes the second one, but doesn't start from the end of the first one, but instead the path starts at the start of the first one. I am using .fresh() to get a new TrajectoryActionBuilder that should start from the end of the last TrajectoryActionBuilder, but it starts at the start of the first TrajectoryActionBuilder. Manually calculating the end pose of the first path and putting it in as the start pose for the second path works, but it seems like .fresh() should work. Video one shows what happens and video two shows what the path should be, but the robot doesn't stop between the two paths.

Code:

import com.acmerobotics.roadrunner.Action;
import com.acmerobotics.roadrunner.Pose2d;
import com.acmerobotics.roadrunner.SequentialAction;
import com.acmerobotics.roadrunner.TrajectoryActionBuilder;
import com.acmerobotics.roadrunner.Vector2d;
import com.noahbres.meepmeep.MeepMeep;
import com.noahbres.meepmeep.roadrunner.DefaultBotBuilder;
import com.noahbres.meepmeep.roadrunner.entity.RoadRunnerBotEntity;

public class MeepMeepTesting {
    public static void main(String[] args) {
        System.setProperty("sun.java2d.opengl", "true");
        MeepMeep meepMeep = new MeepMeep(800);

        RoadRunnerBotEntity myBot = new DefaultBotBuilder(meepMeep)
                // Required: Set bot constraints: maxVel, maxAccel, maxAngVel, maxAngAccel, track width
                .setConstraints(60, 60, Math.toRadians(180), Math.toRadians(180), 15)
                .build();

        TrajectoryActionBuilder toBasketBuilder1 = myBot.getDrive().actionBuilder(new Pose2d(-10.5, -70, Math.toRadians(90)))
                .splineTo(new Vector2d(-47, -54), Math.toRadians(180));
                
        TrajectoryActionBuilder toBasketBuilder2 = toBasketBuilder1.fresh()
                .splineTo(new Vector2d(-55, -59), Math.toRadians(225));



        Action action1 = toBasketBuilder1.build();
        Action action2 = toBasketBuilder2.build();
        
        myBot.runAction(new SequentialAction(
                action1,
                action2
        ));

        meepMeep.setBackground(MeepMeep.Background.FIELD_INTO_THE_DEEP_JUICE_DARK)
                .setDarkMode(true)
                .setBackgroundAlpha(0.95f)
                .addEntity(myBot)
                .start();
    }
}
@polarbub
Copy link
Author

It turns out running endTrajectory() before fresh() fixes the problem. To apply this fix replace TrajectoryActionBuilder toBasketBuilder2 = toBasketBuilder1.fresh() with TrajectoryActionBuilder toBasketBuilder2 = toBasketBuilder1.endTrajectory().fresh(). Is this the intended behavior?

@rbrott rbrott closed this as completed in dff5d3f Nov 7, 2024
AnIntelligentHuman added a commit to AutomatedAndroids/road-runner that referenced this issue Nov 25, 2024
End active trajectory in `fresh()` (fixes acmerobotics#111)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant