RoBorregos / robocup-soccer-open-2024

RoboCup Soccer Open
2 stars 0 forks source link

Week 25-31 #1

Closed JocelynVelarde closed 9 months ago

JocelynVelarde commented 9 months ago

Ensure motor control is working properly. There have been some issues regarding the movement such as:

To discard programming problems with the robot the following tasks will be performed

Currently the robot performs the following way when placed on the ground (see video below)

https://github.com/RoBorregos/robocup-soccer-open-2024/assets/70779495/8ba192f9-fbae-40c7-8d33-efeb8d246874

Looks like the movement of the motors is not totally free and something is preventing them from spinning correctly. On the second video the robot is tested in the air (watch below)

https://github.com/RoBorregos/robocup-soccer-open-2024/assets/70779495/0a6011da-aa4a-4413-ae2d-83bf7ab2c242

This could be mainly a mechanics problem, still the mentioned tests will be performed to discard any issue with the code.

JocelynVelarde commented 9 months ago

Found possible reason on why 4th motor not working properly. (see picture below)

It seems that the pins for IN1 and IN2 are encountering continuity issues due to bad welding.

https://github.com/RoBorregos/robocup-soccer-open-2024/assets/70779495/e50fd0cd-fc1b-46b2-970e-4d778ad283e3

Additionally pins where separated into the different categories when using the TB6612FNG controller

For motor 1:

For motor 2:

For motor 3:

For motor 4:

JocelynVelarde commented 9 months ago

The code was updated to function in a modular manner.

The Motor class encapsulates the functionality related to a single motor, providing methods to set the motor parameters (speed, pins), initialize the motor, and control its movement (forward, backward, stop).

Then the Motors class acts as a container for multiple instances of the Motor class, representing a set of motors.

Additionally methods for using the motor controller and setting speed to a specified PWM where included.

The robot now correctly moves forward and backward (see video below)

https://github.com/RoBorregos/robocup-soccer-open-2024/assets/70779495/25a3ba50-ec02-4ff5-beb8-3810a8b6a194

Using the instances is as simple as writting the following to control the robot:

myMotors.moveForward(); delay(1000); myMotors.stopMotors(); delay(1000); myMotors.moveBackward();

JocelynVelarde commented 9 months ago

Update on robot movement for method moveMotors(int degree, int speed);

The polarity of the pins for IN1 and IN2 was checked in order to ensure correct motor control, additionally numbers and order for each motor where assigned corresponding the kinematic equations

float m1 = cos(((45+degree) * PI / 180)); (and so on for each motor)

A picture below with the robot diagram is shown

JocelynVelarde commented 9 months ago

Finished correct robot movement with moveMotors(); method, the method receives and angle and PWM.

As seen in video below. Note that the code follows a pattern of 45°, 135°, 225° and 315°, it is important to keep in mind that because of lack in floor friction the motors might not move as expected.

https://github.com/RoBorregos/robocup-soccer-open-2024/assets/70779495/340492a9-5ec0-4481-80bf-96d7638f06c2