Skip to main content

Posts

Reinforcement Learning for Autonomous Exoplanetary Landing Systems

Recent posts

Pure Pursuit Robot Navigation Following Interpolated Cubic Splines

I've been working to improve my school VEX team's autonomous code for my robotics class, and have created a pure pursuit robotics PID that I thought I would share. The code here is in Python, and I'm only using matplotlib as an output to visualize the robot's movement. However, I do hope to rewrite this code in C++ soon, getting a movement vector output which will then be applied to a VEX robot. First is the spline class. I'm currently using a simple parametric cubic spline class. Keep in mind that this is a really  bad way to implement splines, as it demands increasing x-values along the domain which isn't ideal for a robot's path. I am definitely going to rewrite all of this in the future to have a periodic domain, but I thought I would share what I have right now anyways because it might be usef A spline is defined as a piecewise function of polynomials, and in the case of a cubic spline, the polynomials of choice are cubic polynomials. Therefore, the fir...

Emotion Classification NN with Keras Transformers and TensorFlow

  In this post, I discuss an emotional classification model I created and trained for the Congressional App Challenge last month. It's trained on the Google GoEmotions dataset and can detect the emotional qualities of a text. First, create a training script and initialize the following variables. checkpoint = 'distilbert-base-uncased' #model to fine-tune weights_path = 'weights/' #where weights are saved batch_size = 16 num_epochs = 5 Next, import the dataset with the Hugging Face datasets library. dataset = ds . load_dataset( 'go_emotions' , 'simplified' ) Now, we can create train and test splits for our data. def generate_split(split): text = dataset[split] . to_pandas()[ 'text' ] . to_list() labels = [ int (a[ 0 ]) for a in dataset[split] . to_pandas()[ 'labels' ] . to_list()] return (text, labels) (x_text, x_labels) = generate_split( 'train' ) (y_text, y_labels) =...

Understanding Eulerian and Lagrangian Fluid Simulations

In fluid simulations, there are two dominant ways to represent a fluid: Eulerian and Lagrangian. So, what are they? Which can we use to make a good fluid simulation for a specific project? And how can we implement them? First, let's discuss the Navier-Stokes equations, which generalize the motion of Newtonian fluids. The momentum of a particle in a Newtonian fluid is as follows: \begin{equation}\rho\frac{\partial\overrightarrow{\mathbf{u}}}{\partial t}+\rho(\nabla\cdot\overrightarrow{\mathbf{u}})\overrightarrow{\mathbf{u}}=\rho\frac{d\overrightarrow{\mathbf{u}}}{dt}=-\nabla p+\mu\nabla^2\overrightarrow{\mathbf{u}}+\Sigma F\end{equation} The equation above gives us a fluid's motion at a particular point, and a fluid simulation works by calculating the velocity of lots of these points and interpolating between them. (For this model, we'll ignore the viscosity term and assume that the fluid we're simulating is a superfluid, just to make things slightly more manageable.) ...

Alpha-Beta Pruning Minimax Chess Bot

I've written a chess bot that uses the minimax algorithm to play chess, even though I barely know how to play. What could possibly  go wrong? Minimax is a decision rule in game theory that seeks to minimize the possible loss of a situation, or in this case, to prevent the AI from being at a "disadvantage" with the player. The bot plays through a bunch of moves, determines how much of a loss they incur, and chooses a move with the lowest disadvantage. My implementation is in Python and uses the python-chess   library to create a chessboard. So, let's look at the code. First, I set up the board as follows: board = chess . Board() values = {chess . PAWN: 1 , chess . KNIGHT: 3 , chess . BISHOP: 3 , chess . ROOK: 5 , chess . QUEEN: 9 , chess . KING: 0 } To calculate advantage, I iterate through all of the pieces on the chess board and add or subtract their values from a running count depending on their color. By weighing more valuable pieces, you could be...