GAPTER: Ball Tracking

Note

In this tutorial you will learn how to:

  • run ball tracking code with gapter

For any query, please feel free to post your questions in the Gaitech EDU Forum

Prerequisite

Get ball tracking code

Download the ball tracking code from Github

Run the code

After running the Gapter Simulator, in a new terminal run following command:

$ python ball_tracking.py

You will see the following screen:

../_images/ball-tracking-frame.png

It will run with default camera of computer, can be easily changed for other camera. If ball is green press ‘c’ on image window, or place the ball inside the rectanglar region and press ‘a’, press ‘n’ to re-calibrate and space-bar for pause, ‘q’ for quiting. If you have a green ball, you can hold it in as in the following screen:

../_images/ball-tracking-frame-with-ball.png

After presing ‘c’, another window with a mask will appear:

../_images/ball-tracking-mask.png

Now in a new terminal run:

$ python pid_control.py

You can now move the ball, and see your Gapter following it. You can use rqt_plot to visualize current position using following command:

$  rqt_plot /mavros/setpoint_velocity/cmd_vel/twist/linear/x:y:z
../_images/ball-tracking-rqt-plot.png