cavenel / ev3-print3rbot

Python code for the EV3-Print3rbot, based on ev3dev project.
58 stars 34 forks source link

Error with mymotor class #9

Closed broncosfan18 closed 8 years ago

broncosfan18 commented 8 years ago

Hi @cavenel,

I ran the program and recieved the following error:

robot@ev3dev:~/ev3-print3rbot$ python writer.py Traceback (most recent call last): File "writer.py", line 10, in class mymotor(motor): NameError: name 'motor' is not defined

Does this have to do with the update that @melonhead2 was requesting in an earlier issue or is it a problem on my end?

Thanks!

cavenel commented 8 years ago

Hi @broncosfan18,

It is possible that this is the same issue as @melonhead2. Unfortunately, I did not have time to change the bindings, plus ev3dev is going through some major changes in the motor class these days. Thus I don't fill like changing everything now and again in a couple of weeks. I don't have the robot built right now!

Thus you could try to use an older version of ev3dev, or to adapt the code yourself. I can help and give advice if you go for option 2!

Bests,

Christophe

cavenel commented 8 years ago

First thing to change would be:

from ev3dev import *

in

from ev3dev.ev3 import *

But you will have other adjustments such as touch_sensor into TouchSensor and some motor functions.

broncosfan18 commented 8 years ago

I am fairly new to Linux, but will try my best to update it, as long as you are willing to walk me through it. Do you suggest I open an issue on the main ev3dev site to get support from the other developers or do you think that you can sufficiently help me? Let me know, and thanks!

cavenel commented 8 years ago

As the issue is only about this project and not about ev3dev, I don't think they would like you to open an issue there :) I can try to help here! Do you know how to edit a file on the brick?

On Thu, Jan 21, 2016 at 5:59 PM, broncosfan18 notifications@github.com wrote:

I am fairly new to Linux, but will try my best to update it, as long as you are willing to walk me through it. Do you suggest I open an issue on the main ev3dev site to get support from the other developers or do you think that you can sufficiently help me? Let me know, and thanks!

— Reply to this email directly or view it on GitHub https://github.com/cavenel/ev3-print3rbot/issues/9#issuecomment-173634369 .

broncosfan18 commented 8 years ago

I have learned how to do edit a file at some point, but after fiddling around with it for a bit, I can't seem to remember.

cavenel commented 8 years ago

OK, what system do you use on the computer? Windows or Linux? Le 22 janv. 2016 03:50, "broncosfan18" notifications@github.com a écrit :

I have learned how to do edit a file at some point, but after fiddling around with it for a bit, I can't seem to remember.

— Reply to this email directly or view it on GitHub https://github.com/cavenel/ev3-print3rbot/issues/9#issuecomment-173786688 .

melonhead2 commented 8 years ago

Windows On Jan 21, 2016 10:43 PM, "cavenel" notifications@github.com wrote:

OK, what system do you use on the computer? Windows or Linux? Le 22 janv. 2016 03:50, "broncosfan18" notifications@github.com a écrit :

I have learned how to do edit a file at some point, but after fiddling around with it for a bit, I can't seem to remember.

— Reply to this email directly or view it on GitHub < https://github.com/cavenel/ev3-print3rbot/issues/9#issuecomment-173786688> .

— Reply to this email directly or view it on GitHub https://github.com/cavenel/ev3-print3rbot/issues/9#issuecomment-173819045 .

broncosfan18 commented 8 years ago

I use Windows (10) as well

iWildStyle commented 8 years ago

Hi. I have same problem. Trying to build old version python-ev3dev, but unsuccessful. With current version after I changed from ev3dev import * to from ev3dev.ev3 import * and class mymotor(motor): to class mymotor(Motor): i've got:

robot@ev3dev:~/ev3-print3rbot$ ./writer.py
Traceback (most recent call last):
  File "./writer.py", line 485, in <module>
    main()
  File "./writer.py", line 476, in main
    wri = Writer(calibrate = True)
  File "./writer.py", line 78, in __init__
    self.calibrate()
  File "./writer.py", line 90, in calibrate
    self.mot_lift.rotate_forever(speed=-50, regulate='off')
  File "./writer.py", line 28, in rotate_forever
    self.stop_command = stop_command
  File "/usr/lib/python2.7/dist-packages/ev3dev/core.py", line 578, in stop_command
    self.set_attr_string('stop_command', value)
  File "/usr/lib/python2.7/dist-packages/ev3dev/core.py", line 216, in set_attr_string
    self._set_attribute(attribute, "{0}".format(value))
  File "/usr/lib/python2.7/dist-packages/ev3dev/core.py", line 204, in _set_attribute
    self._attribute_cache.write(abspath(self._path + '/' + attribute), value)
AttributeError: 'mymotor' object has no attribute '_path'
Exception AttributeError: "'mymotor' object has no attribute '_path'" in <bound method mymotor.__del__ of <__main__.mymotor object at 0xb67b3f70>> ignored

@cavenel, please help me to solve this problem

iWildStyle commented 8 years ago

Bingo! I found solution! I just check motor init section and set correct port for all motors self.mot_A = mymotor(OUTPUT_D) self.mot_B = mymotor(OUTPUT_A) self.mot_lift = mymotor(OUTPUT_C) self.touch_A = TouchSensor(INPUT_3) self.touch_B = TouchSensor(INPUT_2)

broncosfan18 commented 8 years ago

Hi @iWildStyle, Is there anyway that you can talk me through the process of how to make those changes? I would really appreciate it if you have the time to help me. Is it changes that I make on the brick, or in another program? Thanks a bunch!

iWildStyle commented 8 years ago

HI @broncosfan18, I'm just changed from ev3dev import * to from ev3dev.ev3 import * and class mymotor(motor): to class mymotor(Motor): as described above. And replace touch_sensor to TouchSensor. Exception AttributeError: 'mymotor' object has no attribute '_path' Exception AttributeError: "'mymotor' object has no attribute '_path'" in happens because I'm connect motors improperly.

All changes I made in writer.py on a brick. You need connect to your EV3 as described here: http://www.ev3dev.org/docs/tutorials/ in section Networking. I'm connected via USB. After that, I'm install Midnight Commander apt-get install mc to manage and edit files on a brick.

broncosfan18 commented 8 years ago

Thank you @iWildStyle! That totally worked to correct the errors.

After running the program, I ran into some issues. During the running the program ./writer.py the robot successfully wrote "Ceci est un test". However, the arm that lifts and lowers the pen didn't move. When I first started the program, the arm spun around 180°, and then whenever the arm should have moved, I just heard a light hum. Is there a way that I can prevent the arm from moving at the beginning, and change the distance during the rest of the program so that the arm actually moves?

Secondly, when I tried to use the mouse as input, I got this error:

wri = Writer(calibrate = True)
-bash: syntax error near unexpected token `('

Do you know how to correct this?

Thanks for all your help!

cavenel commented 8 years ago

Thank you @iWildStyle for correctiong the code to follow the API! And sorry for not having the time to look that through :-(

@broncosfan18 please open a new issue as this is not related to the first one and the issue will be solved as soon as I include the code from @iWildStyle

(and when you open the new issue, please put a bit more code so that we can understand where the error comes from)

cavenel commented 8 years ago

If someone can check if the last commited version is good, then I can close this issue :)

iWildStyle commented 8 years ago

@cavenel, according instruction (https://www.dropbox.com/s/5jtnpaf18ibalj0/ev3_Print3rbot.pdf?dl=1):

Connect left large motor to port C, right large motor to port A, and small motor to port B. Connect left touch sensor to port 2 and right touch sensor to port 3.

correct code for init motors will be: self.mot_A = mymotor(OUTPUT_C) self.mot_B = mymotor(OUTPUT_A) self.mot_lift = mymotor(OUTPUT_B)

cavenel commented 8 years ago

Thank you, I trusted your previous message :-p Code updated and commited.

iWildStyle commented 8 years ago

@cavenel, ok. I'll check your code tommorow. @broncosfan18 - motor with "arm" to manipulate pen have self-tuning finction. It is trying to rotate until it can do it, After the stop arm and pen is up, motor reset your position to zero. Two functions: pen_up and pen_down move "arm" and pen in corresponding directions. You may comment code (lines 89-100 in writer.py) to skip "arm" adjustment - set it manualy in correct position. To skip drawing svg and directly going to mouse mode you need comment line 477 (wri.draw_image(image_file = 'images/test.svg',max_speed=50)) and uncomment next line (#wri.follow_mouse()) Also you may need pass 1 string parameter to this function - mouse device on you brick (e.g. wri.follow_mouse("/dev/input/by-id/usb-0461_USB_Optical_Mouse-event-mouse"), you need connect mouse and check (run ls /dev/input/by-id/ to display mouse name) correct name in your system, name depends on mouse type.

cavenel commented 8 years ago

For the pen up problem, you can check my answer on https://github.com/cavenel/ev3-print3rbot/issues/3 as well. It could give you some ideas to fix the problem. From what you say, I think the arm isn't stopped in the calibration process, which means you have a problem in the way you built that part (instruction number 8 in the instruction pdf file is very important, as well as the roundish pin in instruction number 9.2)

iWildStyle commented 8 years ago

@cavenel writer.py is correct.

cavenel commented 8 years ago

Thank you! For all other problems we can go on new issues so that other users can follow.