Python Forum
Parallel Processing in Python with Robot
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parallel Processing in Python with Robot
#1
I have coded a robot that runs modules containing the commands necessary to carry out a specific process. As of now, the user inputs the desired command, my code uses an if statement to determine what command they entered, and it runs the appropriate command. However, the command must be finished before the user can input another command.

Now I would like to do the following: have the user input a command, start the command, and, while the command is running, rerun the command to get the users input. For example, the user inputs move forward, the robot starts moving, then the user changes the command to move backward midway through the robot moving forward, and the robot resets and starts moving backward in response.

Below is the code of the while loop that runs the modules and asks for user input. Let me know if you have any ideas on how I can achieve this or if you need any clarification. I am a high schooler who is still learning how to code, so any help would be greatly appreciated.

Thanks in advance.

Best,

Christopher

#runs all the modules and gets user input
while True: 
    defultPosition()
    command = raw_input("Enter move forward, move backward, turn or cancel: ")
    defultPosition()
    if command == "cancel":
        break 
    if command == ("move forward") or (command == "move backward"):
        speedInput = input("Enter the desired speed: ")
        distanceInput = input("Enter the number of inches you wish the robot to move (must be a factor of 5): ")
    if command == "turn":
        speedInput = input("Enter the desired speed: ")
        degrees = input("Enter the number of degrees for the robot to move: ")

    print ("\nINPUTED COMMAND: %s \n" % command)

    if command == "move forward":
        #run the moveForward module

        print "Initiating command\n"

        moveForward(speedInput, distanceInput)

        print "Finished command; restarting and waiting for another input \n"

    if command == "move backward":
        #run the moveBackward module

        print "Initiating command\n"

        moveBackward(speedInput, distanceInput)

        print "Finished command; restarting and waiting for another input \n"

    if command == "turn":
        #runs the turn module

        print "Initiating command\n"

        turnCounterClockwise(speedInput, degrees)

        print "Finished command; restarting and waiting for another input \n" 
Reply


Messages In This Thread
Parallel Processing in Python with Robot - by crcali - Apr-04-2018, 06:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Parallel processing - AttributeError: Can't get attribute 'sktimekmeans' Mohana1983 1 801 Jun-22-2023, 02:33 AM
Last Post: woooee
  parallel loop python caro 4 1,891 Jun-16-2022, 08:46 PM
Last Post: woooee
  The Wall-E Robot Argentum 1 1,458 Apr-03-2022, 03:01 PM
Last Post: sastonrobert
  mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python ilknurg 3 5,725 Jan-18-2022, 06:25 PM
Last Post: ilknurg
  SimpleHTTPRequestHandler ( verses ) Files Python Processing JohnnyCoffee 0 1,802 Apr-29-2021, 02:47 AM
Last Post: JohnnyCoffee
  Real Time Audio Processing with Python Sound-Device not working Slartybartfast 2 4,047 Mar-14-2021, 07:20 PM
Last Post: Slartybartfast
  DarkPaw Robot code Tyrelex78 3 2,175 Nov-27-2020, 12:06 AM
Last Post: Tyrelex78
  Image Processing in Python JoeDainton123 1 23,857 Oct-05-2020, 12:08 AM
Last Post: Larz60+
  Matlab to Python -- Parallel Computing zistambo 1 2,001 Jun-10-2020, 04:59 PM
Last Post: pyzyx3qwerty
  Use dynamic variable from parallel running python script Sicksym 0 1,885 May-15-2020, 02:52 PM
Last Post: Sicksym

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020