Analysis of a Physics-Based Trajectory Generator for Automated Robotic Ball Launching
By: Sajiv Shah
Tags: Physics, Engineering, Robotics, Simulation, Python

Analysis of a Physics-Based Trajectory Generator for Automated Robotic Ball Launching

Links to earlier parts in series:

In parts 1 and 2 we discussed the design of our robotic shooter for the 2021 FIRST high school robotics challenge and explained how we used a physics-based trajectory generator to determine what velocity and angle we must launch the ball at to score into the middle of the scoring target accurately and consistently. Our python simulator allowed us to then create a table of values of what we need to set our motor speed and angle to based on a distance we set.

In part 3, we will first discuss how we implemented automated launching processes into our robot, then analyze why the trajectory simulator was inaccurate, and then end with a discussion of the real-world applications of physics models and simulators in robotics.

Fig. 1, Our robot automatically aligning itself to the target, determining its shooter angle and motor speed, and launching the balls. Image by Author.

Automation

After generating a table of values, we designed a process for our robot to determine its distance from the target, and from that use a look-up table to find the correct motor speed and angle setpoints, which were calculated through the trajectory generator. We use elementary PID control loops to set these values.

Our automation process begins with using the onboard vision camera, limelight, to calculate the distance to the target. Our scoring target has a border made of retroreflective tape, which allows the camera system to identify its location and determine the angle to the tape boundary and distance. Using these values, we can calculate the horizontal and vertical distance to the target. Simultaneously, the robot will attempt to align itself to the center of the target(fig. 1). It does so by determining the angle in a rotational axis towards the center of the vision target and uses a control loop that updates its position using a combination of the drive-base gyro, encoders, and the vision target angle.

Fig. 2, View of a target from the limelight vision system. Image by WPILibs.

The launcher then raises its hood to the found value and ramps the shooter wheels up to the desired speed. Once up to speed, the feeder mechanism slides balls into the shooter at a given interval in order to account for slight perturbations in the wheel speed as balls are launched.

We generated a look-up table that covers about 20 different distance values. For the gaps in the middle, our code simply determines which table value is closest, and utilizes that table value to configure the shooter. We find that when our shooter deviates further than ~0.75 feet away from a table-value distance, the balls no longer score. Because our shooting range is only 18 feet, 20 values cover the entire range.

When first testing, our whole team had the same question in mind. How much tuning would we need to perfect the values determined by the trajectory simulator? None of us expected any accuracy, but to our surprise, we got results that were even worse. Not a single configuration from our generated table resulted in a score.

Errors

Fig 3, CAD render of our mechanism for reference. Image by Author.

We quickly determined two major sources of error. Unfortunately, they were two we could not really solve. The first comes from the non-rigid nature of the ball. The ball is made from a foam inner core and attempting to dynamically model the characteristics of an object that is as deformable as these balls would be a task for Ph.D.’s, not high school students. The second comes from the energy transfer to the ball from the mechanism.

Ball Compression

Compression is a factor that is not directly related to the path of the ball but is a large factor that determines whether the ball will follow the path at all. The ball is made of a foam-like compressive material that expands with some force when compressed a certain amount, given by its stiffness constant:

This force is important as it acts as the normal force on the wheels that creates the frictional force allowing the ball to accelerate by the contact of the wheels. To accelerate the ball up to speed from the moment the flywheels (seen in fig. 3) touch the ball, a high frictional force is required. Friction is given by:

where μ is the coefficient of friction between the ball and the wheel. Because the balls we are using are classic non-rigid objects, we know that they experience stress relaxation[1]. Stress relaxation explains the reducing amount of resistance a material applies to deformation. For example, a mattress will eventually develop a slight divot because the springs have experienced stress relaxation and no longer provide an upward force high enough on your body to hold the mattress flat.

Because of this, we had to determine a certain compression value for our shooter that would allow for the balls to consistently get up to speed. We did so by creating a tunable mechanism, where we could change the compression in 1/4" increments and then launched a set of balls horizontally and measured the distance they traveled. We launched two sets of balls, one which had balls that were relaxed, and one which had balls that were rigid. Balls begin fairly rigid, and over time become softer, so we labeled the rigid balls “new.” After creating a large table of values, we used box-and-whisker plots to analyze our data.

Fig. 4, Plots of Ball Distances at Various Compression Values. Image by Author.

While 2.25 inches of compression clearly gives us the most precision within the set of “new” balls, we see that the old balls perform the worst at that compression value. Our main data point is consistency within a set and consistency between the two datasets (N) and (O) as we cannot control which type of ball the robot will interact with. That said, a compression value of 2.75 inches is clearly ideal as the medians of the (N) and (O) datasets are closest.

Compression comes with an unforeseen cost and a high one for an object like ours. In part 1, we detailed that two major aerodynamic forces govern the motion of the ball: the lift and drag force. Both of these forces accelerate the ball and are dependent on factors that change when the ball is compressed.

The lift equation for a spinning ball, which is given by NASA [2], is proportional to the radius of the ball cubed and the spin of the ball. When the ball is compressed on two sides by a flywheel mechanism, it no longer takes the shape of a ball and its effective radius changes. This causes the lift force to change, and because we cannot model the change in radius as the ball re-expands during flight, the calculation of this force is highly inaccurate. Furthermore, the spin on the ball is given by the equation:

which, again, is dependent on the radius. As the radius changes, so does the cross-sectional area, which is directly proportional to the drag force. Now that the changing values of these two forces are impossible to calculate given our limited sensing and resources, we are unable to model the trajectory of a ball. Additionally, we are yet to conclude the lift coefficient and drag coefficient that accompany these forces. The combination of these inaccuracies due to the compression of the ball gives us a highly inaccurate trajectory.

Fig. 5, Ball compressing as it travels through Shooter. Image by Author

Energy Transfer

As mentioned in part 1, energy from the motors and from the change in velocity of the flywheels is transferred to the ball to give it rotational speed and linear speed. We see from motor graphs that the flywheel speeds dip a significant amount when firing balls(fig. 6).

Fig. 6, Image by Author

To compensate, we considered adding more mass to the flywheels. Higher inertia would mean that the energy transfer is more significant with a slight flywheel speed dip, and we can therefore keep our flywheel speed more constant. However, to make a serious impact a good amount of mass would be required, and to spin the shooter up to the set speed we would have to wait longer because the inertia of the shooter value is higher and therefore the angular acceleration is lower by the equation:

We considered calculating the change in flywheel speed based on the energy equations below but found it to be impossible.

If we were to decide that to achieve a scored trajectory from a certain distance the initial velocity of the ball and the set spin value are v_b and w_b, then we may possibly be able to estimate the change in flywheel speed required. However, the new flywheel speeds would in turn give us what the ball velocity is actually set to, and therefore we cannot conclude what the ball velocity really is. Additionally, we cannot accurately measure the time the ball is in the shooter, and therefore cannot determine how much work is done directly by the motors. Lastly, we have no direct way of measuring the moment of inertia of either of the flywheels nor the ball itself, which we must remember is changing with the radius of the ball by the equation:

Because the moment of inertia of the ball, and therefore the spin (by conservation of momentum) is changing, we cannot determine anything about the magnitude of the lift or drag force.

Our Solution (Not Really)

In the end, our team did what thousands of others have been doing in robotics for decades. We ran the shooter and used trial and error to come up with a table of values. In about an hour, we were able to test to our satisfaction and ran our shooter with 100% accuracy in the two-point region and about 54% accuracy from the 3 point region from trials over a week. Toward the end when recording for our competitions, we even got all 3-pointers. Despite the success, some of us were still baffled and frustrated that we cannot use the concepts that we have been learning for years in math and physics classes to model what we thought is a fairly basic system. After all, NASA isn’t modeling the launching of a foam ball right? Why is it so hard?

Robotics and Physics

When it comes to object manipulation and throwing, unaccounted dynamical factors that play a large role in dictating motion are simply overlooked or not possible to calculate using common sensors and tools. In most cases, it is far easier to use basic trial and error to control systems than a physics-based model. Especially when working with non-rigid objects, as we were, it is nearly impossible to draw conclusions on the forces we do consider exist because they depend on factors that change unknowingly. For robots interacting with objects through fluidic mediums, many aerodynamic forces and phenomena are encountered that are dependent on qualitative features of the object, and from those, a force coefficient is determined. But without proper equipment, the average engineer cannot calculate these values.

Real-World non-rigid Object manipulation and launching is difficult to model but required to advance robots to achieve task flexibility and obtain a human-like skill-set in the future. So what can we do about these problems?

The answer might be AI. Reinforcement Learning (RL) in robotics is becoming increasingly popular as robots are able to learn novel behaviors through constrained trial and error behaviors, removing the need for a human operator to pre-program motion[3]. RL has a multitude of problems including safety, but as it grows in robotics so will methods of making it more applicable at a lower level.

Hopefully, high-schoolers can build robots that learn how to operate themselves someday.

References

[1] Ashter, Syed Ali. “Introduction To Thermoforming”. Thermoforming Of Single And Multilayer Laminates, 2014, pp. 1–12. Elsevier, doi:10.1016/b978–1–4557–3172–5.00001–3. Accessed 8 Apr 2021.

[2] “Lift Of A Baseball”. Grc.Nasa.Gov, 2021, https://www.grc.nasa.gov/www/k-12/airplane/balllift.html. Accessed 5 Mar 2021.

[3] “Reinforcement Learning In Robotics: A Survey — Jens Kober, J. Andrew Bagnell, Jan Peters, 2013”. 2021, p. ., https://journals.sagepub.com/doi/abs/10.1177/0278364913495721. Accessed 8 Apr 2021.

Acknowledgments

The students of MSET 649 would like to thank all our donors, adult mentors, student mentors, parent volunteers, and especially our sponsors for allowing us to explore the STEM field and design robots, even in the toughest of times.