In my last project, I went full on a challenging yet rewarding journey to reimagine our class’s bug navigation project, originally done in C++, using Python. This project not only pushed my programming skills but also deepened my understanding of robotic control systems.
My previous experience with the bug navigation project in C++ laid a solid foundation for this Python venture. The core principles of robotic movement and obstacle avoidance remained the same, but the shift to Python introduced new libraries and syntax, offering a more streamlined approach. This transition emphasized the importance of language flexibility in coding and the ability to adapt to different programming environments. But at the same time, the delay python introduces, as a high language class had to be taken into account, when managing the data inflows from the lidar to the wheel movement.
A significant problem in this project was mastering the PID (Proportional-Integral-Derivative) control to guide the robot smoothly to its destination. Initially, the robot faced issues with orientation, spiraling near the goal instead of stopping. This problem highlighted the intricacies of PID tuning and the delicate balance required for stable control.
The breakthrough came with guidance from Dr. Wu, who suggested implementing a conditional statement to halt the robot precisely (credits to Dr Jones too for the idea). This adjustment in the code elegantly solved the spiraling issue, demonstrating the power of simple, logical solutions in complex systems.
Pseudocode for the Conditional Stopping Mechanism
# PID Control for robot navigation
while not at_goal:
error = calculate_error(goal, current_position)
control_signal = PID_controller(error)
send_control_to_robot(control_signal)
# Conditional to stop the robot from spiraling
if is_near_goal(current_position, goal) and is_oriented_correctly(current_orientation, goal_orientation):
stop_robot()
break
Here is the robot running:
This pseudocode represents the logic behind the implemented solution. The `is_near_goal` and `is_oriented_correctly` functions check the robot’s position and orientation relative to the goal, triggering the `stop_robot` function to prevent the spiraling issue.
Reflecting on this project, I learned the importance of persistence and creative problem-solving in programming. Challenges like the PID control issue are not just obstacles but opportunities to deepen understanding and refine skills. This experience has been invaluable in my growth as a programmer and a robotics enthusiast.
Looking ahead, I aim to explore more advanced navigation algorithms and perhaps integrate machine learning techniques for more dynamic and intelligent robot behavior maybe in future projects, in grad school. The journey from C++ to Python was just the beginning, and I am excited to see where this path leads.