Write a program for the pololu robot

Assignment Help C/C++ Programming
Reference no: EM131598809

Robot Position Calculation

1. Program Overview and Theory
Overview

The Pololu robot has a mechanical encoder attached to each wheel. Each encoder produces 45 electronic pulses for each revolution of the wheel. The program will use the wheel pulse counts to calculate the position and heading (direction) of the robot.

The program is a C++ program that runs on the Pololu robot. The program gets the wheel pulse counts on the robot and calculates the resulting robot position and heading. Each calculated position is transmitted by the Wixel wireless module to the PC, to be displayed on the PC screen.

Program Calculations
Use the following formulas to calculate the change in robot position and then the new position, based on the physical dimensions of the robot and the number of pulses from each wheel since the previous position calculation.

robot constants
   a = robot axle length = 5.0 cm
   w = robot wheel diameter = 3.6 cm
   p = pulses per wheel revolution = 45
   d = distance a wheel travels for each wheel pulse = Π.w/p cm
robot position and heading variables
    X = robot x coordinate
    Y = robot y coordinate
    H = robot heading (direction, measured anticlockwise from the positive x axis)
number of pulses (since the previous calculation)
    L = number of pulses from the left wheel
    R = number of pulses from the right wheel

position calculations if L equals R:
    δH = change in robot heading = 0
    δX = change in robot x coordinate = L.d.cos(H)
    δY = change in robot y coordinate = L.d.sin(H)

if L is not equal to R:
   r = radius of curvature of the robot trajectory = ½.a.(R+L)/(R-L)
   δH = change in heading = (R-L).d/a
   δX = change in x coordinate = r.(sin(H+δH) - sin(H))
   δY = change in y coordinate = r.(cos(H) - cos(H+δH))
   [Be especially careful to write the formula for δY correctly!]

Then calculate the new values of H, X and Y as follows:

H = H+δH
X = X+δX
Y = Y+δY

Suggestion: In your program use the variable names dH, dX and dY for δH, δX, and δY.
The above formulas assume the wheels are running forward. If a wheel is running backwards (in reverse) then the above formulas are also correct, if the number of pulses from a reversing wheel is converted to a negative value.

Mathematics Theory
The appendix to this document "Derivation of the Robot Position Formulas" shows the derivation of the formulas for the change in robot position and heading. The derivation is given for information only. You are only required to use the resulting formulas in your program. However, this derivation shows a typical use of mathematics in engineering.

2. Program Specification

Overview

Write a program for the Pololu robot using the mbed compiler, where:
- the robot moves, with each wheel running at its own constant speed,
- the wheel speeds can be any number between 0.0 and 1.0, inclusive,
- the wheel speeds will be constants in the program, so to change the speeds, the program must be modified and recompiled,
- use a time delay to get the wheel pulse counts every 10-100 ms (depending on the wheel motor speed),
- functions are provided to get the wheel pulse counts when required,
- the robot position is calculated using appropriate formulas (as given),
- the position is transmitted to the PC using the Wixel wireless module (where the position is displayed and the robot trajectory is plotted using the PololuPositionDisplay program provided on Blackboard).

Program Details (Pseudocode)
Once only, at the start, the program should:
- display the program title on the robot LCD,
- set the Wixel speed (baud rate) to 115200,
- display the program title on the PC,
- display the battery voltage, wheel speeds and loop time delay on the PC,
- initialise the robot coordinates X, Y and heading H to zero,
- display suitable headings for the columns of numbers,
- display the initial values of X, Y and H on the PC,
- call the provided function to initialise the encoders,
- turn the motors on using the speed constants.
Then inside the while(1) loop, the program should repeatedly:
- wait for 10-100ms (depending on the wheel speed) using the mbed wait_ms function,
- get the number of pulses from each encoder (L, R) using the given functions,
- display the pulse counts L, R on the LCD display,
- if either pulse count is not zero, calculate the change in robot position dX, dY, dH (using the given formulas),
- calculate the new robot position X, Y, H (using the given formulas),
- display the new robot position X, Y, H and the pulse counts L, R on the PC.

Program Code
The file Assignment.cpp on Blackboard contains program code you can use. You need to:
- add code where there are blank lines,
- add conditions to the two if statements.
The source files encoder.cpp and encoder.h are provided on Blackboard. You need to copy and paste this code into mbed files, with the same names, in your program on the mbed website.
These files contain functions to operate the robot encoders.

Hints
Remember the trig functions need angles in radians, so use H in radians in your program, but display the angles in degrees, not radians.
The given cpp file contains the definition for Π because Π is not defined in the mbed math libraries.
Once the robot starts moving, the while (1) loop ensures the robot keeps moving until the robot power is turned off.
When sending the robot position to the PC, the string for each line must start with "POS," and the numbers must be separated by commas. This ensures the PC program recognises the lines of text that are the robot position, so the plot can be drawn correctly. Extra spaces are allowed.

3. Sample Program Settings and Output
The following example shows typical output transmitted from the robot to the PC. Your program should produce similar output, but your output will not be exactly the same due to differences between the robots. The PololuPositionDisplay application program is available on Blackboard as part of this assignment

1963_Figure.jpg

The wait period between position calculations was set to 50ms. However, the calculations and data transmission to the PC take about 10ms in addition to this, so the position calculations are approximately 60ms apart.
The left wheel speed was 0.8 and the right wheel speed was 0.9.
From the scale, the robot trajectory circle diameter is about 80cm, so it is possible to run this program with the robot on the floor, when there is this much clear space.
If the wheel speeds are set to the same value, the robot travels in a much larger circle with a diameter up to 10 m, which is too big for the confined space available on the floor in the lab or the nearby corridor. The trajectory is also much less circular because small changes in the actual wheel speeds cause significant variations in the trajectory.
The plot on the next page used the same robot, with the same speed and time delay settings as used above. This plot shows the end of the run (when the robot was stopped).
Notice that the robot heading steadily increases, because the heading increases by 360 degrees for each circle of the trajectory. At the end of the run, the heading is 1120.3 degrees because the robot has just completed its third circle.

1605_Figure1.jpg

4. Assessment
The assessment of your program for this assignment will be based mainly on (but may not be limited to) the following points:
- Source code compiles and links ("builds") without any errors or (significant) warnings.
- Source code is correctly formatted (correct layout).
- Uses appropriate named constants.
- Uses appropriate variable names.
- Displays a program title on the LCD and PC.
- Displays the battery voltage on the PC.
- Displays the motor speeds and loop time delay on the PC.
- Displays column headings on the PC.
- Displays pulse counts on the LCD.
- The calculations are correct.
- On the PC, the displayed robot position and pulse counts are well formatted.
- The robot trajectory is displayed on the PC.

The program will be tested using various wheel speeds, including equal wheel speeds and different wheel speeds.

Attachment:- Appendix.rar

Reference no: EM131598809

Questions Cloud

Prepare a cash budget for the first quarter : Deitz Corporation is projecting a cash balance of $ 30,000 in its December 31, 2016 balance sheet. Prepare a cash budget for the first quarter
Was andrew jackson an american hero or villain : Andrew Jackson was a political figure that Americans either loved or hated for a variety of reasons. Americans are still passionately divided on their feelings.
Reaction between magnesium metal : The reaction between magnesium metal ( a silver ribbon) and hydro chloric acid (clear, colorless solution) produces bubbles of hydrogen gas.
Build the two-variable data table : Build the Two-Variable Data Table. Apply conditional formatting to highlight Net Income of at least $250,000 for each of the two-variable data table.
Write a program for the pololu robot : ENSE504 Introduction to Computing Write a program for the Pololu robot using the mbed compiler, where the robot moves, with each wheel running at its own constant speed
Create navigation links on each page : Create links on each page that link to the other two (2) pages.Create navigation links on each page that link to the other two (2) pages.
Examine how accounting standards impact financial measures : Examine how accounting standards impact financial measures. Prepare a coherent report and integrated analysis that meets specific user needs
Why did the founding fathers keep slavery in constitution : The Declaration of Independence claims that "all men are created equal" referencing Enlightenment philosophies that God instills equal rights into every human.
Different blood group phenotypes are possible : In humans, four different blood group phenotypes are possible: type A, type B, type AB, and type O. What produces the type O phenotype?

Reviews

len1598809

8/12/2017 3:33:22 AM

Hey, THIS ASSIGNMENT IS A COMPUTING ONE INVOLVING C++, HOWEVER YOU GUYS WILL NEED TO LOG IN TO MY MBED COMPILER TO COMPLETE THE ASSIGNMENT. THE , THE MAXIMUM AMOUNT OF TIME TO COMPLETE THIS ASSIGNMENT IS 3 DAYS. THE COMPLEMENTARY CPP FILES GIVEN WITH THE ASSIGNMENT ARE ALREADY UPLOADED TO THE MBED COMPILER , IF YOU FEEL THAT SOMETHING IS MISSING I WILL ATTEMPT TO SEND THE CPP FILES NEEDED, ALSO THERE IS A VIDEO EXPLAINING WHAT IS REQUIRED.

len1598809

8/12/2017 3:31:42 AM

• After uploading the file, be sure to click the "Submit" button before leaving Turnitin. If you do not click the Submit button, the upload will not be complete. • After the upload is complete, you will see a Turnitin Digital Receipt. You can save or print this as evidence that you have submitted your file successfully. • You can upload the file more than once. I will only receive the last file you upload. This means, if you upload a file and then decide to modify it, you can upload the modified file and it will replace the file uploaded earlier. Full details about using Turnitin are in the document AUTonline Student Information which is available on the Online Support tab on the Blackboard DCT:ECMS Student Home page.

len1598809

8/12/2017 3:31:34 AM

DO NOT email files to me or give me printed copies of your program. To make a submission to Turnitin: • Make a text file copy of your C++ program code: ? copy the entire contents of your C++ (cpp) file from the mbed website, ? paste it into a text file on the PC, ? save the text file, with your ID number in the file name. • Log in to Blackboard (formerly AUTonline) and go to the page for this paper. • Click on the "Assessment" button. • Click on the "Current Assessments" folder. • Click on the "View/Complete" link for the "Assignment 1 Program".

len1598809

8/12/2017 3:31:26 AM

10% of the total mark for this paper. Marks will be posted on Blackboard as soon as they are all available. Date and Time Due 6pm Friday 18. Requirements Design and implement a C++ program for the following specification. The program is to be written using the online mbed compiler for the Pololu robot.

Write a Review

C/C++ Programming Questions & Answers

  Write a program which has a base process which communicates

write a program which has a base process which communicates with child processes acting as bombers that it

  Create two new arrays to hold the results of calculations

Create two new arrays to hold the results of calculations. Result array one is to hold the Euclidean distance between each point and the next point in the row.

  Parallel implementations of sum-scan operation

Parallel Implementations of (sum-)Scan Operation and Its Applications - Data Parallel scan operations have the potential to reduce this requirement to O(lg n), thereby speeding up the process drastically for a large number of input elements.

  Write a program to do calculations with a 2-d array

You are to development the following functions to support this effort. Write a function for each of the following actions.

  Explain how priority queue list works

Hi. I have done a priority queue list. We have been giving test code to test our list. I will post what I have along with the issues. I keep getting an error with the getelement() part in the main program where we are supposed to print out the ele..

  Implement a graphics system that has classes

Implement a graphics System that has classes for various figures: rectangles, squares, triangles and circles. A rectangle has data members height, width, color , and center point. A square has center point and an edge and color

  Write function that is passe an array of n pointers to float

Write a function that is passed an array of n pointers to floats and returns a newly created array that contains those n float values. Implement a function for integrating a function by means of Riemann sums.

  A for loop to compare each character

a for loop to compare each character

  Afunction that raises an integer to a positive integer

Write a function that raises an integer to a positive integer power. Call the function x_to_the_n, taking two integer arguments x and n.

  Add a copy constructor

Take the code below and add a copy constructor, assignment operator definition and destructor to the class. These functions have already been started for you.

  File extension of the stock details file

Which class of the .NET Framework should Hayley use to enable Sharon to view the file extension of the stock details file? Describe any four properties of the selected class.

  C# programming in microsoft visual studio to complete

Please use C# programming in Microsoft Visual Studio to complete this assignment.  You are to write a program that will prompt the user for the following information and then calculate and display the monthly payment.  Amount borrowed

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd