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 human interaction 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 help the reader 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 how many joystick events get triggered per second and create an optimization in our code that 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.

7.1 Hardware Stack

Figure 7.1 shows the hardware stack with the specific components used in this chapter highlighted.

Figure 7.1 Hardware stack: The Joystick will be used to control the robot movements

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

7.6.2 Calculating the level rate

7.7 Moving robots with joysticks

7.7.1 Creating the joystick client

7.8 Summary

sitemap