WALL-E Version 1.0
The "WALL-E" Project is a ME 507 quarter term project inspired to recreate the robot WALL-E. The WALL-E robot is a fully 3D printed robot with modified components in order to fit the needs of the chosen peripherals and electronics. WALL-E contains a custom made PCB which is housed in the main body of WALL-E. WALL-E's peripherals and components include 2 pololu Romi Motors with encoders, 4 MG90s servos, BNO055 IMU, and a OV2640 ArduCam camera. The objective of WALL-E is to scan the surrounding area for the closest object to it. Once that object is detected, WALL-E drives up to the object, attempts to pick up or hold the object and detect the color of the object.
Loading...
Searching...
No Matches
servos.h
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
19#ifndef SERVOS_H
20#define SERVOS_H
21
22#include "stm32f4xx_hal.h"
23
27class Servo {
28 public:
29 Servo(TIM_HandleTypeDef* htim, uint32_t channel);
30
31 void attach(); // Start PWM
32 void detach(); // Stop PWM
33 void setPulseWidth(uint16_t pulse_us); // Set pulse in microseconds (e.g., 1000–2000)
34 void setAngle(uint8_t angleDeg); // Optional: 0–180 degrees
35 void startStopAngle(uint8_t angle1, uint8_t angle2);
36
37 private:
38
42 TIM_HandleTypeDef* htim;
43
47 uint32_t channel;
48
49 uint16_t angleToPulse(uint8_t angleDeg); // Internal map: 0–180 → 1000–2000 µs
50 };
51
52#endif
53
void detach()
Function stops the PWM Signal received from the PWM.
Definition servos.cpp:40
Servo(TIM_HandleTypeDef *htim, uint32_t channel)
Constructor Function for Servo Motor Class.
Definition servos.cpp:25
uint16_t angleToPulse(uint8_t angleDeg)
Function calculates the angle requested to the PWM pulse that is needed to create the angle.
Definition servos.cpp:77
uint32_t channel
Definition servos.h:47
void attach()
Function starts the PWM Channel for the Servo Movement.
Definition servos.cpp:32
void setPulseWidth(uint16_t pulse_us)
Function sets the Servo's motor pulse width to determin the angle at which the servo moves to or hold...
Definition servos.cpp:50
void setAngle(uint8_t angleDeg)
Function set's the Servo motor's pulse width based on the desired angle from the servo.
Definition servos.cpp:62
TIM_HandleTypeDef * htim
Definition servos.h:42
void startStopAngle(uint8_t angle1, uint8_t angle2)
Function sets Servo to start to stop angle incrementing till requested angle.
Definition servos.cpp:88