A Pythonic Triumph Over Turtles

This entry is part 2 of 2 in the series CS Onboarding 2024

During our first two meetings of the year, new members on the CS team were introduced to ROS via the Pizza Factory activity and got hands-on with Turtlesim – a simulated robot in a ROS environment. We then began guided coding sessions in Turtlesim to understand how to program with the ROS framework.

Power Down, Code Up

Duke administrators informed us that on Saturday, September 14, the club’s usual meeting location – the Foundry – would not have electrical power due to maintenance work being performed. The CS team instead decided to meet in the Wilkinson Building.

At Wilkinson, we split into two groups. One group, led by Raul, consisted of those that had missed our previous meeting, which meant they needed to set up their codespace and be introduced to Turtlesim. The other group, led by Vedarsh and Nathan, began the guided coding session.

Vedarsh set up a Visual Studio Code liveshare to allow the new members to follow along with the code he wrote in real-time.

The first objective was to make the turtle draw a square. New members had experienced the difficulty of doing this first-hand in the previous meeting when they moved the turtle with their arrow keys, but failed to make a perfect square.

To draw a square, the turtle had to repeat the following four times: move forward and rotate 90 degrees. We first focused on the rotation. We wrote the function rotate_to_global_theta where we rotated the turtle in-place to a given orientation. We refined our function to optimize rotation time.

This session introduced basic Python syntax, how to subscribe and publish to topics, and feedback loops – a key concept of robotics software and something used widely in our code for Oogway.

Throughout the meeting, we gave opportunities for the new members to think on their own about how to implement the code, before we came back together and provided our solution. This allowed the new members to get feedback on the flaws in their line of thinking, ultimately improving their problem-solving abilities as robotics software engineers.

Nathan addressed any technical issues the new members experienced and provided clarification on the code written. We supported everyone of all skill levels – from those who were new to programming to those who had developed software for robots before.

We made sure to record our meetings and make our code publicly accessible on GitHub. Anyone who wasn’t able to make it to the meeting would be able to watch the recording and view the code written to get caught up.

We found that the Wilkinson building provided a better environment for CS onboarding. It was much quieter and had large screens, making it easier for the new members to hear us speak and view the code being written. Even though the Foundry was open the following week, we decided to host the final two days of CS onboarding in the Wilkinson building.

Mastering Polygons

Thursday, September 19, marked the fourth day of CS onboarding and the second half of our guided coding session.

We started by revisiting our first objective: draw a square. We had developed the capability to rotate the turtle by 90 degrees. However, we still needed to make the turtle move forward.

To do this, we developed a more advanced movement function named move_to_global_pos_and_stop. This function would move the turtle to a given (x, y) position on the canvas.

To implement this function, we introduced the concepts of local position (turtle’s frame of reference) vs. global position (canvas’ frame of reference). We explained the linear algebra involved in converting from one coordinate system to another. We also revisited the concept of a feedback loop. Putting all of that together, we were able to make the turtle draw a perfect square.

With our first objective completed, we moved onto our second objective: draw a regular polygon with a given number of sides and side length. This function was best implemented with movement commands expressed in the local frame of reference. We implemented additional functions to enable this, and saw the turtle draw beautiful pentagons, octagons, dodecagons, and many more.

We then shifted our focus to ROS services. We created service clients for the reset and set_pen services. The reset service allowed us to automatically clear the canvas and reset the turtle’s position between runs. The set_pen service allowed us to change the color and width of the line drawn by the turtle, so that we could make multicolored and more aesthetically pleasing drawings.

The Arc of Victory

At last, we arrived on our fifth and final day of CS onboarding  – September 21st.

We first asked our members to find a partner to work with after onboarding. All new members will help migrate our codebase to ROS2. With their partner, we asked them to rank their preferences on what modules they’d be interested in helping migrate. 

Afterwards, we reviewed the code we’d written so far and made a few final changes.

We then pivoted to the final part of the Turtlesim exercise: draw_arc. This function required the turtle to draw an arc (a portion of a circle), given the center point, radius, and start and end angles of the arc. All new members were required to independently implement this function to show they had mastered the fundamentals of robotics software. We explained the function definition and provided a few hints on how to get started. The rest of the time was for them to implement it.

As a fun challenge, we announced that everyone who completes draw_arc and uses it to draw something creative will receive a free Duke Robotics Club T-shirt.

Most new members finished draw_arc, completed the challenge, and received their T-shirts on this day. They were happy to have completed CS onboarding and excited for what’s to come.

Oogway, Here We Come

This week, with CS onboarding complete, we returned to the Foundry. We collected feedback on the onboarding experience, and we’ve already identified several areas of improvement for future years.

We began preparing for the ROS2 migration. A few new members who had missed previous meetings focused on finishing Turtlesim and draw_arc. Others set up their computers to develop software for Oogway.

Vedarsh wrote a detailed document with the instructions for how to perform this set up. Raul and Vedarsh hopped on what they thought would be a quick Zoom call to test the instructions on Raul’s PC. The call ended up lasting seven hours, until 4:30 AM, as they ran into many issues with performing the instructions on Windows and tried to cover as many edge cases as they could possibly find.

We were able to assign every pair their first-choice module to migrate. By working in partners, we ensured that every member had a peer who they could turn to any time they had a question or were stuck.

Max explained the basics of Docker, as we develop all software inside Docker containers. Mathew & Nathanael explained our workflow for git and GitHub. Will explained the basics of migrating code from ROS1 to ROS2. They read through the ROS1 code for their module and associated documentation, and began the migration process.

Mission Accomplished

We set out to make this year’s CS onboarding the best one by far out of all previous years, and we believe we succeeded in our mission.

We led the new members in an organized, hands-on manner through various exercises that built on top of each other and prepared them to develop software for our robot.  From the metaphor of the Pizza Factory, to the practical application of learned concepts in draw_arc, we ensured that each new member understood the fundamental concepts that drive our AUV. We believe that they are well-prepared to write software for our AUV and take on even more challenging tasks.

We’re excited to see our new members contribute to the CS team and to the club. We can’t wait for what’s to come!

Cheers from Raul, Nathan, and Vedarsh!

Series Navigation<< Kicking Off With Pizzas & Turtles!