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 VPython program creating an animation of your group’s object (a person walking up a...
Develop a VPython program creating an animation of your group’s object (a person walking up a flight up stairs) and cause it to move so that the animation simulates the motion of the object assigned. A .py file
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.
IN PYTHON Develop a program in python that includes a number of functions for the multi-server...
IN PYTHON Develop a program in python that includes a number of functions for the multi-server queue. The program accepts arrival and services rates and the number of servers and calls your functions to output the average number of customers and average waiting time in the system.
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...
Circle Object Python program Compute the area and perimeter of a circle using Python classes. take...
Circle Object Python program Compute the area and perimeter of a circle using Python classes. take the radius from the user and find the area and perimeter of a circle please use comments to explain so i better understand
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...
You are asking to develop a “Triangle Guessing” game in Python for the assignment. The program...
You are asking to develop a “Triangle Guessing” game in Python for the assignment. The program accepts the lengths of three (3) sides of a triangle as input from a player. The program output should indicate whether the triangle is a right triangle, an acute triangle, or an obtuse triangle. 1.Tips to help you for this assignment: Make sure each side of the triangle is a positive integer. Use try/except for none positive integer input. 2. Validating the triangle. That...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT