Skip to content

ev3 Multiplexer running different sensors #182

Closed

Description

@Master-Matt

I am trying to set up the ev3 multiplexer with 2 touch sensors and one color sensor. I'm having trouble setting each port to analog or digital, and then setting what device is on each port then reading values off the port.
Any documentation on how to do this in python? I'm trying to use core.py as my base, but still having issues.
Thanks
~Matt

Activity

  1. dlech commented on Jul 27, 2016

    @dlech
    Member

    No python docs. Just this.

    I don't see anything in the python docs, but there should be a Port class that lets you manipulate the ports.

  2. Master-Matt commented on Jul 27, 2016

    @Master-Matt
    Author

    I'm not sure on the syntax for using a port. with the touch sensor directly connected I can do something like ts=ev3.TouchSensor('in2'), but with the ports can I do something like this?
    mux2=ev3.LegoPort('in2:12c82:mux2')

    *my brick just ran out of batteries and my rechargeable pack is in the mail, so I can't test more until i go grab some double-A's...

  3. dlech commented on Jul 27, 2016

    @dlech
    Member

    Yeah, it should be something like that.

  4. Master-Matt commented on Jul 27, 2016

    @Master-Matt
    Author

    Ok, when trying above, making sure the address is valid, I get this error.
    FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/lego_port'

  5. rhempel commented on Jul 27, 2016

    @rhempel
    Member

    @Master-Matt - are you using the latest (0.7.0~rc1) version of the Python binding (python3-ev3dev)?
    The reason it's still ~rc1 is that there may still be some corner cases for device classes that are not working as expected.

  6. Master-Matt commented on Jul 27, 2016

    @Master-Matt
    Author

    I'm not sure. I thought it was the 0.6.0, but how do I check in python or just on the brick?
    *I also can't anything to work using LegoPort

  7. Master-Matt commented on Jul 27, 2016

    @Master-Matt
    Author

    Python allows me to do this, but I don't seem to get any attributes that are useful to me
    mux3=ev3.Device('lego-port', driver_name=['ms-ev3-smux-port'], address='in1:i2c82:mux3', mode='analog')
    This doesn't really do anything, as checking my connection always gives me false.

  8. ddemidov commented on Jul 27, 2016

    @ddemidov
    Member
  9. dlech commented on Jul 27, 2016

    @dlech
    Member

    FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/lego_port'

    Looks like a bug. Should be lego-port, not lego_port. However, this has been fixed since 0.6.0 already.

    I'm not sure. I thought it was the 0.6.0

    Unless you are using a nightly ev3dev image from 2016-07-26 or later, you probably are using 0.6.0.

    To get 0.7.0rc1, run sudo apt-get install python3-ev3dev. This also requires that you upgrade your kernel sudo apt-get install linux-latest-ev3. Or grab a nightly image and re-flash your SD card. Download

    As you might guess by the name, the new package is python 3 only.

  10. Master-Matt commented on Jul 27, 2016

    @Master-Matt
    Author

    I did check, and yes I'm using 0.6.0. I will run the update and try again. I also have the absoluteIMU from mindsensors, and was wondering how I would communicate with it. Would it be the normal sensor class or the special sensor class?

    Also, I'm ready to start testing elements of my program on my actual robot. Up untill now I've just connected everything in a lab setting. What is the fastest/easiest way to load my program from my comp to the brick, then run it from the brick?

    Thanks for your help guys. Once I get a good test run in, I'll show you my M.O.O.C.A.

  11. dlech commented on Jul 27, 2016

    @dlech
    Member

    absoluteIMU

    There is a driver for that one. You can find a list of all supported sensors here.

    What is the fastest/easiest way to load my program from my comp to the brick, then run it from the brick?

    Assuming your computer is Windows, Filezilla or WinSCP. Save the file to /home/robot on the EV3. Also be sure to check set the executable permission on the file. Then you can start the program from the file browser on the EV3. You can also use a remote ssh terminal to start the program.

  12. Master-Matt commented on Jul 27, 2016

    @Master-Matt
    Author

    Okay, I guess It's just a naming convention thing because when I try
    s=ev3.AbsIMU('in3') or s=ev3.ms-absolute-imu('in3') it doesn't work.
    is it all caps like s=ev3.MsAbsoluteImu('in3')? or do I have to use a base-class then load the driver?
    or would this work s=ev3.LegoSensor('in3', driver_name='ms-absolute-imu')

  13. ddemidov commented on Jul 27, 2016

    @ddemidov
    Member

    The correct syntax is

    gyro = ev3.Sensor(driver_name='ms-absolute-imu')
    assert gyro.connected
    gyro.mode = 'TILT'
    print(gyro.value(0), gyro.value(1), gyro.value(2))
  14. Master-Matt commented on Jul 27, 2016

    @Master-Matt
    Author

    Sweet. Do you recommend cycling through the modes to take a reading off each? 'ALL' mode seems a bit trickier to parse the data.

  15. ddemidov commented on Jul 27, 2016

    @ddemidov
    Member

    This used to work for me:

    gyro.mode = 'ALL'
    v = gyro.bin_data('<bbbhhhhhhhhhh')
    print(v)
  16. 3 remaining items

  17. dlech commented on Jul 28, 2016

    @dlech
    Member

    Any tips on how to get this brick to stop being a brick?

    Disable Internet connection sharing on windows and enable it again.

    Also- the date is set to January 1 1970

    This will be corrected when you connect to the internet. There is no battery backup for the clock.

  18. Master-Matt commented on Jul 28, 2016

    @Master-Matt
    Author

    Grrr... I hate overlooking the simple things... Thanks!

  19. Master-Matt commented on Jul 28, 2016

    @Master-Matt
    Author

    Thanks a lot guys. Mux is working great. Is it recommended to assert after assigning any sensor? I haven't had any issues so far without it, but I'm wondering what the benefits are.

  20. ddemidov commented on Jul 28, 2016

    @ddemidov
    Member

    I guess there are no benefits except you terminate early if the required sensor is not connected (launched program for wrong robot?).

  21. Master-Matt commented on Jul 28, 2016

    @Master-Matt
    Author

    Is there any way to add RGB-RAW mode to the color sensor when used in the multiplexer? I want to use the separate values in my calculations.

  22. Master-Matt commented on Jul 28, 2016

    @Master-Matt
    Author

    @ddemidov when using mode 'ALL' on the AbsoluteIMU does the data read left to right as it's displayed up to down on the ev3dev site>

  23. ddemidov commented on Jul 28, 2016

    @ddemidov
    Member

    Yes, I believe so. It should 3 values for TILT, 3:ACCEL, a COMPASS, 3:MAG, and 3:GYRO.

  24. Master-Matt commented on Jul 29, 2016

    @Master-Matt
    Author

    So, I'm planning on using the absolute imu to estimate position and velocity by integrating the acceleration vector. To do so this I need good info on the sampling rate of the sensor data. Do you think the best way would be importing the time module and tacking on a time stamp for every sample?

  25. WasabiFan commented on Jul 29, 2016

    @WasabiFan
    Member

    @Master-Matt Although I can't help you with the sensor details, I'll warn you that integrating IMUs like that is a very inaccurate way of finding position. You will probably get large drift rates and your position readings will be wildly wrong within a matter of seconds. This is due to the nature of such an operation; I expect that you would need an update rate that is much higher than what the EV3 can provide in software to achieve reliable position tracking with an IMU. Usually, when systems are built that do this, they use a hardware loop or software on a dedicated chip running at very high clock speeds.

  26. rhempel commented on Jul 29, 2016

    @rhempel
    Member

    I'll agree with @WasabiFan here - you need something like a Kalman filter and another way of estimating and correcting position. You'll be integrating twice accel->velocity->position and paradoxically, the faster your sample rate the worse it gets due to round-off and accumulated error.

    On the other hand, this is a great opportunity to learn just how hard it is to make this work - so go ahead and do the experiment but then go back to student mode and read about some of the math involved in getting better results.

  27. Master-Matt commented on Jul 29, 2016

    @Master-Matt
    Author

    Yeah, I have been doing some research into this, and although there are some nice algorithms out there that can do this, It seems like the results wouldn't be very reliable. I might have a way around this by only using this as one part of my position tracking package. My project is an ev3 powered robotic lawn-mower, and I am planning on using the sumoeyes for obstacle detection, and I also have an xv-11 LIDAR that will be used. My plan for the IMU is just to fill in the gaps when the lidar is not in a range that it will provide reliable data. Mainly for the middle parts of a lawn. I also want to keep my integration period at or less than a second, depending on the sample rates I can achieve with the EV3. I might have to switch over to c++ though, since both my Quaternion class I've made and the xv-11 code I've seen is written in that.

  28. Master-Matt commented on Jul 29, 2016

    @Master-Matt
    Author

    I probably should have just spent the extra money and gotten drive motors with Quadrature encoders, but I always like a good challenge!

  29. Master-Matt commented on Jul 29, 2016

    @Master-Matt
    Author

    Quick question. What's the shortest way to check if a button is pressed? I see any, and proccess, but I'm unsure how to use them.
    I've Tried ev3.ButtonBase.check_buttons==True and I keep getting true, I think I'm just checking that check_buttons is an attribute of the ButtonBase class hah...

  30. ddemidov commented on Jul 30, 2016

    @ddemidov
    Member

    This should work:

    btn = ev3.Button()
    if btn.up:
      print("Up button is pressed")

    Also, see http://python-ev3dev.readthedocs.io/en/latest/other.html#button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions