Automaticly aligning shooter with speaker

hi. We are trying to automaticly align our shooter which is mounted on a single jointed arm , to the speaker. can you help me pls.

Do you guys have limelight?

Need more information or else we’re just guessing.

Whats the design of your shooter (pictures help)? What sensors do you have on it? What have you already tried? Can you share your code?

2 Likes

Following up on @Fletch1373

If you have sensors in your lab like cameras or distance sensors these could be used to measure the distance from an AprilTag or from the subwoofer/speaker to know how far away you are.

Based on that move the arm to a set angle based on the angle calculated.

Overly Simplified Trig

The setup involves measuring the vertical distance from the robot (or its sensor) to the speaker and the horizontal distance from the robot to the base of the speaker. With these measurements, you can calculate the angle using the tangent function, which relates the angle of a right triangle to the ratio of the opposite side (vertical distance) over the adjacent side (horizontal distance).

Similar to how limelight explains finding distance, but for the unknown side of the triangle and the angles needed. We can get the distance and the height of the speaker is known and static so solve for the missing pieces

We need to know what ways you have to measure the distance and what your hardware is for motor controllers and encoders as well to move the arm to a set position

our shooter design works exactly like orbits robot. Unfortunately we dont have the code for this. i have tried getting ty values but didnt work

currently we have a photonvision camera and we just use neos built in encoders

Could you provide some code? Also can you see PhotonVision via network tables?

thats the link to our code
also we havent wired the cameras so im unable to provide the information. Simulated cameras work tho

If you want to automatically aim at the speaker, the only way that I’ve seen is by having a 2d array of setpoints then linearly interpolate between those setpoints.

Here is an quick example:

// {ty, pivot rotation, shooter rpms}
{
    {0, 15, 2000},
    {5, 30, 1500},
    {10, 60, 1000},
};

The first value in each row is the ty that you will get from your vision system and any other values in the row will be setpoints for things like your shooter arm or the shooter rollers.
You would then use Linear Interpolation to adjust the values based on your current ty value.
This is a very simple explanation so if you have any questions, feel free to ask.

can you provide any example java code please?

Here is our code from 2022:
Shooter Subsystem
linearlyInterpolate function

We are planning on using the same method this year but it hasn’t fully been implemented or tested yet. Here is this year’s code anyways for when it eventually gets added in the next couple of days. I will post again in here once we have that code tested so you can use that as a better reference.

1 Like

For simplicity, I’d recommend InterpolatingDoubleTreeMap which is a part of WPILib.

Here’s how you create one, and here’s how you get values from it.

1 Like

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