Low Cost Trailer Estimation

The purpose of our project is to aid Professor Charles Birdsong in his automated trucking research by designing a sensor system that can output data on the trailer's motion. This project was inspired by Daimler Trucks of Daimler AG and will hope to aid in the development of safer autonomous truck journeys.

Our Team

We are the Trailer Park Boys and we worked with Professor Charles Birdsong to help in his research on autonomous trucking. Our team designed a system to track a trailer behind an autonomous truck to increase control of the overall computer system. 

Blake Carbonneau

Blake Carbonneau

mechatronics lead

Blake is a Mechanical Engineering major from Redwood City, CA, in the Bay Area. His engineering interest include solving real world problems using mechatronic and/or sustainable energy design. After completion of his undergraduate classes, he will pursue a M.S. degree in Mechanical Engineering with the 4+1 Blended Program here at Cal Poly. In his free time, Blake enjoys working out and playing sports. 

Pouria Fariborzi

Pouria Fariborzi

project manager

Pouria is a Mechanical Engineering major from San Diego. In his spare time, Pouria enjoys playing soccer, hiking, and playing the piano. As a Mechanical Engineer, Pouria hopes to work for companies that aim to do good for society. He will be furthering his education by starting Cal Poly’s 4+1 graduate Mechanical Engineering program in Winter 2021. His main fields of interest are mechanical design and thermodynamics.

Max Lafavour

Max Lafavour

Manufacturing Lead

Max is a Mechanical Engineering major with a minor in Environmental Studies from Seattle, WA. In his free time he enjoys working on cars, DJing, or doing pretty much any outdoor activity. His hands on experience with working on cars in high school sparked his interest in engineering. After graduation in spring, he hopes to enter the renewable energy field or some other field focusing on sustainability.


We would like to thank everyone who helped us on this project including our Senior Project advisor, Professor Rossman and our sponsor, Dr. Birdsong. We would also like to thank the the engineers at Daimler, who helped gauge our scope of the project to better fit their needs. 

Digital Poster

Problem Statement

Design a low-cost system to track the real-time angular position and angular velocity of a trailer that is being towed behind a tractor. This system will be mounted and tested on Dr. Birdsong’s existing 1:14 scale model that he is using for his autonomous trucking research. The system should also be able to measure the length of the trailer and must only be mounted on the tractor in order to allow for use with different types of trailers.


Initial Design Ideas

It became clear to us early on in the initial design process that we would have two functions that we needed to focus on: the hitch angle measurement and the trailer length measurement.

Both of these functions would require a method for measuring a value without being able to physically touch the thing that they were measuring. Because of this, we settled on sensors to measure distances and using those distances to calculate the desired values.

We used this decision table to determine which sensors we would use and decided on using Time-of-Flight (ToF) sensors, a smaller, cheaper version of 1D LiDAR. 

To measure trailer length, a potential solution was to take measurements with a distance sensor to avoid placing any components on the trailer. To accomplish this, we had to design a component to raise the sensor beyond the tractor profile then lower it before the journey takes place.

Cal Poly College of Engineering

This project is sponsored by Dr. Charles Birdsong of the Cal Poly Mechanical Engineering Department

In Conjunction with:

Hitch Angle and Angular Velocity Measurement

The angular position system had the primary task of outputting the hitch angle (angular position) and the angular velocity of the trailer. 

The result was a very simple physical system consisting of two distance sensors, one mounted toward the left of the tractor, and one mounted toward the right of the tractor, which would measure the distances from each sensor to the face of the trailer. As the trailer angle changes, the difference of the distances would be used with trigonometry used to calculate the angle. A derivative function is then used in the microcontroller to get the angular velocity.

There were two existing pillars that were part of the tractor’s superstructure which we were able to use as mounts for the sensors.

Trailer Length Measurement

The length measuring system is more complex. We needed a way to measure the length of the trailer without touching it. 

Design Solution: 

  • ToF sensor placed on the shown mounting block, at a known angle fixed atop a lead screw on a through type stepper motor
    • stepper motor allows for sensor to be raised and lowered to be within tractor profile limit 

Sensor Mount that sits atop lead screw

The distance from sensor is used in a trigonometric relation with the known mount angle to calculate the length. 

 The stepper motor had to be mounted near the top of the tractor profile to allow for the largest lead screw, but still within our .5 inch profile limit.

Manufacturing: A mount is needed to hold the stepper motor and  the sensor on top of the stepper motor. The stepper motor was to be attached to a custom mount using preexisting holes in the tractor’s frame. 

Final Design

The sensors and stepper motor were controlled using an STM32L476 microcontroller. The original intention was to implement our functions into the existing truck’s autonomous framework, but due to COVID-19, we had to use a separate controller for our project.

Angle Measuring Function

Solution Components: 

  • two ST VL6180X ToF sensors 


  • 1 mm resolution 
  • equipped with an ambient light sensor to adjust for error from intense UV light
  • easy to mount on the tractor with existing mounting holes 

Assembly: To mount the sensors, brass inserts were installed in the vertical superstructures of the truck frame to allow the sensors to be fixed to the tractor with screws.

Trailer Length Function

Solution Components: 

  • ST VL53L0X ToF sensor to measure the distance to the back edge 

  • DRV8825 stepper motor driver by Pololu

  • custom perf board to mount the motor driver and wire all of the sensors together 


  • closed-loop controller where the stepper motor translates up until a large change in distance is detected 
    • signifies the end of the trailer length; stepper motor would then translate back down to the distance before the large change
  • allows for all trailer lengths to be measured


Manufacturing/Assembly Components

  • 3D printed motor mount 
    • intended to hold the motor in a milled pocket 
    • mount is fitted to the tractor’s existing superstructure
  • 3D printed sensor mount
    • fixes the sensor at 7.5°
    • sits atop a bearing to prevent the mount from rotating with the shaft
  •  motor bracket
    •  18 gauge sheet steel that was cut into a strip, bent, and drilled to hold the motor 
  • metal sliding rail
    • attaches to the back of both the sensor mount and motor mount in order to keep the sensor pointing straight while translating
    • slot machined up the middle of the inner piece to accommodate the mounting screws

Software Flowchart

This is the final flowchart showing how the functions were implemented in software on our microcontroller.


  • the rail system with the slotted cut out introduced too much friction for the motor to handle so the motor cannot translate properly
    • Recommendation: motor should be swapped out for a larger one or the rail should be swapped out for a guide system with less friction 
  • the length sensor needed paper held perpendicular to the back of the trailer face to accurately measure the length
    • this is due to the 35° cone-like field of view (FoV) of the sensor; which could not pick up the back of the trailer edge due to the metallic surface scattering the laser emitted from the sensor 
    • the actual full-scale model will have a painted trailer 
  • sensors for the needed degree of accuracy and small FoV are typically in the range of $500 – $2000
    • outside our budget for the project, but well within a low-cost budget for full-scale production 

Testing and Results

The main design verification tests were conducted on the angle and trailer measurement functions. For the length measurement, this was simple; we measured the length of the trailer with a tape measure and compared the reading to our sensor output. Averaging in code and/or post-processing can be used to output a more accurate length from the microcontroller. For our test after averaging, the measured length was off of the true length by 0.5809%

For the hitch angle measurement, we needed a way to measure sensor output over a period of time to signify a trip. To accomplish this, we attached a phone to the top of the trailer and recorded video of the tractor angle changing in relation to the truck.Tracker, a simple video analysis software, was used to measure the hitch angle and compare that to angle output from the microcontroller.

Using the Tracker software to measure hitch angle
Comparing measured angle to expected angle

By comparing the sensor data to the data from Tracker, we found that the average percent error to be 3.114%, which is within our accepted values.

Summary and Conclusions

Throughout the project, the scope of the project slowly changed, most notably in the spring of 2020 with coronavirus restrictions. Our project was originally intended to produce a functional prototype that would function fully on the small scale test vehicle as well as provide a proof of concept for the development of a similar system for use on full-scale vehicles.

Unfortunately, with the pandemic, other projects working parallel with ours on the truck system were unable to be completed which left us unable to fully incorporate our project into the system using the State Estimator as intended. This resulted in a prototype that is mostly functional but will require additional work to fully integrate it into the current autonomous truck.

The State Estimator would incorporate the theory of Kalman filtering, which is an algorithm that uses a series of measurements over a time span that contain statistical noise (random data irregularities) and other inaccuracies to produce more accurate angular velocity estimates. Rather than using single measurements, Kalman filtering would estimate more accurately by considering a variety of probability distributions for each independent time frame.

As proof of concept, however, our project worked extremely well. We were able to complete a prototype that outputs all of the necessary data to a surprisingly accurate degree despite the limitations. This concept has a certain level of error in the outputs, particularly with the angular velocity measurement since analyzing a change in angles over time exacerbates the error. This is to be somewhat expected with the $10 sensors that we are using, however. The design built should be able to be scaled up successfully with a budget for more accurate sensors and more comprehensive post processing code (such as Kalman filtering).

Project Photos


VL6180X Image taken from Pololu via https://www.pololu.com/product/2489

Have a Question About this Senior Project?

Send an email to pschuste@calpoly.edu to be connected with the project team. Please include the title of the senior project you’re inquiring about in the subject line.

Interested in Sponsoring a Mechanical Engineering Senior Project?

Visit our Sponsorship Page to learn more!

Check Out More Projects!

Visit our ME Senior Projects Page to view the latest Mechanical Engineering senior projects from the class of 2021!


Share on facebook
Share on twitter
Share on linkedin