Hi there, I am planning to create one robot choosing center. But I do not know how to use the idea to execute in python software.
my idea is, let say a customer wants to choose a robot how to use the rule below to execute in python:

IF the robot application is Assembly,
AND the load is 0-5kg
AND the reach is 0.58m
AND the mounting is floor OR the mounting is wall
THEN the model number of the robot is IRB 120

IF the robot application is Assembly,
AND the load is 6-10kg
AND the reach is 1.2m
AND the mounting is floor OR the mounting is wall
THEN the model number of the robot is IRB 1600 – 6/1.2

IF the robot application is Assembly,
AND the load is 6-10kg
AND the reach is 1.45m
AND the mounting is floor
OR the mounting is wall
THEN IRB 1600 – 6/1.45

IF application Assembly,
AND the load is 11-15kg
AND the reach is 1.65m
AND the mounting is floor
OR the mounting is wall
THEN IRB 2600 – 12/1.65

IF application Assembly,
AND the load is 11-15kg
AND the reach is 1.85m
AND the mounting is floor
OR the mounting is wall
THEN IRB 2600 – 12/1.85

Thank you.This is my assignment and I really need help.

The output will be like below:

  1. what type of robot application you like choose?
    a) assembly
    b) spot welding

then let say the customer choose a or b, it will go to next question:

2.How much the load you expect for the robot to carry?
a) 0-2 kg
b) 0-5 kg

and so on.This is just the example. Untill the system choose the correct robot.

Python lends itself to jumping right in and start coding...

This example code below may give you some ideas about how to get started ...

# selectRobot.py #  # 2014-03-26 #

'''
The output will be like below:

    what type of robot application you like choose?
    a) assembly
    b) spot welding

Then let say the customer choose a or b, it will go to next question:

2.How much the load you expect for the robot to carry?
a) 0-2 kg
b) 0-5 kg

And so on ...

This is just a start ... need to continue ...
until finished choosing all attributes of the desired robot.

'''

menu1 = \
'''Please choose the type of robot application ?
    a) assembly
    b) spot welding
Please enter a or b    :  '''

menu2 = \
'''What is the max load for this robot?
    a) 0-5   kg
    b) 6-10  kg
    c) 11-15 kg
Please enter a, b or c :  '''

menu3 = \
'''What is the reach for this robot?
    a) 0-1 m
    b) 1-2 m
Please enter a or b    :  '''

menu4 = \
'''What is the mounting for this robot?
    a) floor
    b) wall
Please enter a or b    :  '''

def showMenuGetChoice( menu, low, high ):
    while True:
        reply = input( menu ).lower()
        if low <= reply and reply <= high:
            return reply
        else:
            print( "'", reply, "' was NOT in valid " \
                   'input range ', low, '..', high, sep = '' )

modelsStr = [] # get empty list to hold models
solns = [] # get empty list to hold all possible solution lists
count = 0

for i, a in enumerate(['a', 'b']):
    for j, b in enumerate(['a', 'b', 'c']):
        for k, c in enumerate(['a', 'b']):
            for m, d in enumerate(['a', 'b']):
                count += 1
                modelsStr.append( 'model_' + str(count) )
                solns.append( [a,b,c,d])

# print( modelsStr )


def mainLoop():
    robot_specs = [] # get an empty list

    robot_specs.append( showMenuGetChoice( menu1, 'a', 'b' ))

    robot_specs.append( showMenuGetChoice( menu2, 'a', 'c' ))

    #print( 'So far, robot_specs =', robot_specs )

    robot_specs.append( showMenuGetChoice( menu3, 'a', 'b' ))

    robot_specs.append( showMenuGetChoice( menu4, 'a', 'b' ))

    #print( 'So far, robot_specs =', robot_specs )

    for i, lst in enumerate( solns ):
        if lst == robot_specs:
            print( robot_specs, '==>', modelsStr[i] )
            return
    print( 'There was an unexpected error ...' ) 


more = True
while( more ):
    mainLoop()
    reply = input( '\nMore (y/n) ? ' ).lower()
    if reply == 'n':
        more = False
        input( "Press 'Enter' to continue/exit ... " )

this is really nice. but the line 55 is showing error as invalid syntax. How to fix that? Thank you. Anyway this is really awesome.

What version of Python are you using? If it is a Python 2, then you'll want to add this to the beginning of the file:

from __future__ import print_function

In Python 2.x, the print statement has it's own syntax, whereas this was removed in Python 3.x and replaced with a print function. Adding this import brings in a version of the print function for the 2.x version of the language.

sorry for late reply. I am using python 2.7. Thanks a lot. I am really appreciates it.Thanks once again.

sorry once again. I am using 2.7 version and when i key in the a,a,a,a it will changed to b,b,b,b and giving model number for b,b,b,b. Is anything I need to import here in order when I key in a,a,a,a it will give a,a,a,a result.?

okie I am done. Thanks a lot guys. Really appreciates it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.