 # Assignment: C‐Space and C‐space obstacles Computing the C‐...

## Question

Show transcribed text

## Transcribed Text

Assignment: C‐Space and C‐space obstacles Computing the C‐Obstacles In this environment, there is a 2‐link robot. The C‐space for the robot is 𝑆 2 . There are two degrees of freedom: 𝜃1 and 𝜃2, for the first link and the second link, respectively. Your first job for this homework is to plot out the C‐space and C‐ space obstacles. Draw the C‐space in 2‐D plane as follows: So your first job is mainly to compute the C‐obstacles. To do this, you can discretized the C‐space into 1‐degree by 1‐degree square cells. So your will have 360 rows and 360 columns of cells. The center of each of these cells represents a configuration. For example the cell centered at (0,0) represents configuration (0, 0), which, when matched to the workspace, corresponds to a configuration in which the two links lay flat horizontally, pointing to the right. For each and every of the 360 x 360 cells, you need to compute if the robot at that configuration is in collision with the obstacles (the two red squares). So you will need a function to detect the collision. If it is in collision, give the corresponding cell a value of 1, otherwise 0. To store the information, use a 360 x 360 2‐D array called cObstacles. Now you can visualize what the c‐obstacles look like by plot out cObstacles. If you use MATLAB, this can be done by a single command: >> pcolor(cObstacles) Which will give you an image like the following (whose cells are assigned a value of 0 or 1 randomly) PATH PLANNING Now the image you get (similar in some way to the image above) is a just like 2‐D maze that we worked with in project1. Use your favorite search algorithm that you developed for project1 to solve the following path planning problem: find a path from Start to Goal. Start: (0, 0) Goal: (180, 270) The Start and Goal look like the following in the work space. They are labelled by the red dots in the C‐space in the maze figure above. After you have found a path in C‐space, save the path (a sequence of cells) in a file called path.txt. VISUALIZE THE PATH

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

from math import sin, cos, pi

# returns >0 if triangle (p1p2p3) is right-oriented
def vp(p1, p2, p3):
return (p1-p3)*(p2-p3) - (p2-p3)*(p1-p3)

# checks whether lines (ab) and (cd) intersect
# checks the whether a and b are from different side of the line (cd)
# and the same for c and d and line (ab)
def lineintersect(a, b, c, d):
return (vp(a,b,c)*vp(a,b,d) < 0 and vp(c,d,a) * vp(c,d,b) < 0)

# point is in rect if all triangles (p rect[i] rect[i+1]) have same orientation
def pointInRect(p, rect):
vp1 = vp(p, rect, rect)

for i in range(1,4):
if vp(p, rect[i], rect[(i+1) % 4]) * vp1 < 0:
return...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

\$38.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.