Plotting the position

Printing out the coordinates is fine for testing, but what we would really like to do is to display the position of the robot on a map of the field displayed on the driver station. For this, we will need a program running on the driver station to handle the plotting of the map. Fortunately, we have one called RobotMapper.  This program connects to the robot, and accepts commands which are used to display the current robot position.  It currently will accept the following two commands (as ascii strings):

The first character determines the command.  This is followed by the current yaw of the robot (in degrees), and the current X and Y position in inches. the ‘c’ command tells the mapper that the data is coming from the camera, and the ‘p’ command tells the mapper that the data is being computed using the dead reckoning.

The first thing we will need to do is add an instance of our Network class.  We declare it as follows:

And initialize it in our Init() function:

This creates a new instance of our Network class and then tells it to listen for an incoming network connection on port k_networkPort which is defined as:

This will be the port to which our RobotMapper program will connect.

After we add this code, we will see that there is an error. This is because we are passing this instance of our Navigator class as the NetworkReceiver parameter of the Listen function.  In order to do this, our Navigator class must implement this interface.  We do this by changing the declaration of our class as follows:

When we do this, it then tells us that we need to add the unimplemented methods of the NetworkReceiver interface, which we do as follows:

This function will be called by the Network class whenever it receives messages from the driver station. We will see how we might use this later.

For now, all we need to do is add code to send commands to the RobotMapper program running on the driver station to update the robot’s position and orientation. Change the Update() function to add two SendMessage calls to the Network class as follows:

At this point your file should look like:

Before you run your program, launch the RobotMapper program by double clicking on the RobotMapper.cmd file in the PiUtil folder.  Then launch your program and drive the robot around.  Remember that you need to align the robot so that it pointing directly at the tower to get the zero point of the gyro set correctly.

You should see it’s position tracked on the map.  You will notice that when the robot can see the tower you see only one green marker.  When the robot cannot see the tower, you see both a red and green marker.  The green marker shows the robot’s position using the dead reckoning, and the red marker shows the last position where the robot could see the tower.

Next: Drive to position

Pierre Pierre, who replica handbag 185cm tall, gucci replica handbags the "Diamond King" in his hermes replica handbags . He has been selected as one of the handbag replica most beautiful 50 people in the "People" magazine. It is also known as replica handbags most elegant and quiet in the world. Unforgettable prince.