Input via the console

I would like to receive a value sent by the console in UCS (to change the value of a variable), like the “Serial.read()” of the C language.
How could I do this ?

Thanks !

UFACTORY Website:
www.ufactory.cc
uArm User Facebook Group
Contact Us:
English Channel
中文通道

Hi @Onetchou, you can use the getAngles interface uArmCreatorStudio/Robot.py at c25c975cd298a60f38e335b568068fe2bafabe3e · wisechengyi/uArmCreatorStudio · GitHub

e.g. uArmCreatorStudio/ObjectManagerGUI.py at f108b481437f0d2691302ba4a9afdd00341295b0 · wisechengyi/uArmCreatorStudio · GitHub

1 Like

Thanks for your help !
I don’t understand how to use this to get a value that the user enters in the console :sweat_smile:.
I would like, that, with a print() with the python command in UCS, the program asks the user to enter a number in the console, then, the user enter a number, and the program put it into a variable.
But i can’t find a way to do this because the input() doesn’t work
An idea ?

Ah ok, sounds more just like a python question how to get keyboard input. You can refer to python - How to read keyboard input? - Stack Overflow for example, it gets the input in a string format then converts it into a integer.

There should be a lot of other references on the internet as well.

I tried “nb = raw_input('Choisis un nombre : ')” and the program stoped with this message in the console :

-----------------------------------ERROR-----------------------------------
Traceback (most recent call last):
File “x:\project\metal\python\GUI\GUI\Logic\Interpreter.py”, line 293, in evaluateScript
File “”, line 1, in
NameError: name ‘raw_input’ is not defined
---------------------------------------------------------------------------

I also tried nb = input('Choisis un nombre : ') and it did the same thing with this message :

-----------------------------------ERROR-----------------------------------
Traceback (most recent call last):
File “x:\project\metal\python\GUI\GUI\Logic\Interpreter.py”, line 293, in evaluateScript
File “”, line 1, in
RuntimeError: input(): lost sys.stdin
---------------------------------------------------------------------------

Maybe I’me doing sth wrong ? :confused:

I would search for issues around “RuntimeError: input(): lost sys.stdin”. Seems like a windows thing, and I do not have a PC :confused:

I’m a real begginer in python so i’m a little lost :sweat_smile:
Don’t you think that it’s a problem with UCS ? Does the “input()” work for you ?

I think python - Py2Exe lost sys.stdin error? - Stack Overflow might be relevant, which is saying that if you use input() in a GUI setting, then it may not function correctly.

You can try input() in command line to see if it works:

$ python
Python 2.7.10 (default, Aug 26 2015, 09:29:31) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = input()
123     # type '123' here
>>> a
123

but going back to UCS, it has the functionality to do so (just not directly from command line), here is some tutorial UCS Tutorial - Part 3: Logic and Functions - YouTube

@Onetchou if you can push your code to github and link to the section you changed, I may be able to take a look.

I’m confused :sweat_smile:
I’m a big beginner and I don’t know what is “command lines” with uarm, moreover I only know how to program in C so python is very new for me :sweat_smile:
In fact, if I understand, there is no way to enter a value in a variable when the program is playing in UCS ?
(Sorry for my bad english, i’m french :slight_smile: )

There are two ways to use UCS, one is to directly run from command line (equivalently windows prompt) to execute your script like uArmCreatorStudio/Examples/RunTaskNoGUI.py at range_change · wisechengyi/uArmCreatorStudio · GitHub

A more common way is to use the GUI, which is probably what you have been using, in which case getting input from keyboard directly may not be that straight forward and likely requires changing the code base.

For beginners, you can use the GUI interface to define where the robot needs to go based on the tutorial above.

(Sorry for my bad english, i’m french :slight_smile: )

ah that explains… lol jk. all are welcome

Aaa ok !
I don’t think that I have the level to use command lines :sweat_smile:
so I will, instead of setting the value of the variable with the console, assign keys to increment or decrement it !

Thanks a lot for your help !
It’s thanks to guys like you that uarm become accessible to beginners, even to program complexe tasks !
Thanks ! :smile:

Find out your internet speed as well as downloading and uploading speed in many manners.