Question

In: Computer Science

Develop a python program to autonomously operate an adeept tank robot to pick up an object...

Develop a python program to autonomously operate an adeept tank robot to pick up an object placed randomly in an arena.

Solutions

Expert Solution

Following is the code for an autonomously navigating robot. The code is pretty easy to understand. Numpy is the only dependency needed to generate a 2D matrix that behaves like the world in which the robot lives in.

CODE:

import numpy as np
from random import choice

# generating a random 2D world with 1s and 0s
# In this 2D world if a tile at :
#    location(x,y) = 1   object is present
#    location(x,y) = 0   object is not present

# Length of the world
L = 5
# Breadth of the world
B = 5

world = np.random.randint(2, size=(L, B)) 
print(world.shape)

print(world)

# lets initialize the robot in this world at some location
robot_x = 0
robot_y = 0

# for the robot to autonomously navigate in this world lets program it as follows
# the robot can randomly move left right up or down

# let the robot move 10 steps
for steps in range(10):

  # check if robot found any item
  if world[robot_x,robot_y] == 1:
    print(f'Robot picked up item at location ({robot_x},{robot_y})')
    world[robot_x,robot_y] = 0

  moves = ['L','R','U','D']
  # select a random move
  random_move = choice(moves)

  if random_move == 'L':
    robot_x = (robot_x - 1)%B   # we mod it with the breath to avoid the robot going out of the world

  elif random_move == 'R':
    robot_x = (robot_x + 1)%B   # we mod it with the breath to avoid the robot going out of the world

  if random_move == 'U':
    robot_y = (robot_y - 1)%L   # we mod it with the length to avoid the robot going out of the world

  if random_move == 'L':
    robot_y = (robot_y + 1)%L   # we mod it with the length to avoid the robot going out of the world

# lets see how the world looks after 10 steps
print(world)

# final location of the robot
print(robot_x,robot_y)

Related Solutions

Design a two-axis pneumatic pick and place robot. The robot is to pick up a part...
Design a two-axis pneumatic pick and place robot. The robot is to pick up a part with a mass of 2.0 kg. The length of the horizontal motion is 250mm. The length of the vertical motion is 240mm. The available air pressure is 650000 Pa. The mass of the gripper and slide is 2.5 kg. The mass of the horizontal axis is 4.0 kg. Assume g = 9.81m/s2. P is pressure [Pa], F is force[N], A is area {m2], m...
Develop a Python program that brings together APIs and web scraping. Be creative. Pick something you...
Develop a Python program that brings together APIs and web scraping. Be creative. Pick something you are interested in - a hobby, a job, history, cooking, travel, sports, a foreign language, music, art, whatever you have some passion about. Find an API that connects with your interest. Write a Python program that demonstrates the use of that api AND does some web scraping as well. It must include the ability to download images to your computer. Submit the following to...
Develop a python program that prompts the user to take up the quiz (which has choices)...
Develop a python program that prompts the user to take up the quiz (which has choices) with limited attempts and limited time. Suppose if the user answered wrong then they have to get numer of attempts(limited) Quiz should have questions on General knowldge & multiple choices for those questions
Develop a python program to ask the user to take up the quiz(General knowledge) which has...
Develop a python program to ask the user to take up the quiz(General knowledge) which has around 4 or 5 questions & choices for those questions. For each question user should have 2 or 3 attempts suppose if they are wrong. Develop the in such a manner to add few more questions and remove some questions.
This program should be done in python. This must use the principles of object oriented program....
This program should be done in python. This must use the principles of object oriented program. Create one or more classes to play Four-in-a-Row (also called Connect Four) with a user. It’s similar to tic-tac-toe but the board is of size 7×6 and discs fall straight through so the legal moves are more stringent than tic-tac-toe. The state of the board should be printed to the terminal after each legal move. You can represent the different colored discs as X’s...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with the random numbers between 1 and 9 (including 0 and 9). - Assume that you are located at (0,0) (upper-left corner) and want to move to (9,9) (lower-right corner) step by step. In each step, you can only move right or down in the array. - Develop a function to simulate random movement from (0,0) to (9,9) and return sum of all cell values...
in python You will be writing a program that can be used to sum up and...
in python You will be writing a program that can be used to sum up and report lab scores. Your program must allow a user to enter points values for the four parts of the problem solving process (0-5 points for each step), the code (0-20 points), and 3 partner ratings (0-10) points each. It should sum the points for each problem-solving step, the code, and the average of the three partner ratings and print out a string reporting the...
TheMathGame Develop a program in PYTHON that will teach children the basic math facts of addition....
TheMathGame Develop a program in PYTHON that will teach children the basic math facts of addition. The program generates random math problems for students to answer. User statistics need to be kept in RAM as the user is playing the game and recorded in a text file so that they may be loaded back into the program when the student returns to play the game again. In addition, the youngster should be allowed to see how (s)he is doing at...
Develop a python program to create a quiz with limited time and attempts!!! Add comments and...
Develop a python program to create a quiz with limited time and attempts!!! Add comments and screenshot of running the program quiz could be of anything like , what's the sum of 2&2. There should be number of attempts(limited) suppose if the answer is wrong.
Develop a program using python to demonstrate data exchange using USB protocol.
Develop a program using python to demonstrate data exchange using USB protocol.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT