7 Joystick-controlled robots

 

This chapter covers

  • Reading joystick data using Pygame
  • Reading and parsing raw joystick event data
  • Measuring the rate of joystick events
  • Creating a remote joystick robot controller

Joysticks are one of the most powerful input devices. When it comes to controlling robot motors, they offer much more superior control compared to keyboards and mice. The scenarios covered in this chapter will help you create a fully functional joystick-controlled robot. This chapter will teach you multiple ways of reading events from joystick hardware. We can then create our own event handlers that will perform different robot movements based on specific joystick movements. Along the way, we will also learn how to measure the number of joystick events triggered per second and optimize our code so that it prevents the robot motors from getting flooded with movement requests. Finally, we end the chapter by creating an application that moves the robot using a joystick over the network.

Joystick-controlled robots have a wide array of applications, ranging from remotely operating heavy vehicles on factory floors to performing delicate medical procedures using robotic arms. In the case of robot-assisted surgery, by controlling very small robotic arms, the doctor can perform surgical procedures that would not be possible otherwise.

7.1 Hardware stack

7.2 Software stack

7.3 Joystick events

7.4 Reading joystick events using Pygame

7.4.1 Detecting events in Pygame

7.4.2 Detecting joystick events

7.5 Reading Linux joystick events

7.5.1 Exploring the Linux input subsystem

7.5.2 Unpacking joystick events

7.5.3 Mapping joystick events

7.5.4 Working with axis events

7.6 Measuring the rate of joystick events

7.6.1 Calculating the event rate

Summary

sitemap