G33kDude / pyev3

A thin python wrapper library for ev3dev following the official API specification
MIT License
17 stars 7 forks source link

Rcx control by ev3 #1

Open ameysutavani opened 9 years ago

ameysutavani commented 9 years ago

Hello, I liked your idea to control rcx by ev3

I have few questions though...

  1. Can you use serial tower by using serial to usb interface instead of usb tower ?
  2. Can you elaborate on packet protocol of rcx and how it is implemented in your code ?
  3. Can the tower.send work for sending custom int values to RCX Lejos?
G33kDude commented 9 years ago
  1. I know it's possible to use a serial tower, but I'm not sure if my code would just "work" on it. In theory, you could just point my code to /dev/ttyAMA0 (or wherever it shows up as) and everything would work as normal, but on a serial tower.
  2. The RCX packet protocol is still a bit sketchy to me, but there's a short writeup here: http://www.mralligator.com/rcx/protocol.html
    As for the opcodes it's sending to the RCX, those are defined here http://www.mralligator.com/rcx/opcodes.html
    The code 2185 sends the opcode 0x21, meaning "turn on or off motors" with the argument 0x80 | 0x1 | 0x4, which means "turn on A and C"
  3. I'm sure it's possible, but I've never used LeJOS for RCX.
G33kDude commented 9 years ago

Also, here are some videos of my RCX controlling code at work:

https://www.youtube.com/watch?v=t4EUzCGEUEI

https://www.youtube.com/watch?v=AtdG0gXhS0A

ameysutavani commented 9 years ago

I wish to make an arduino based bluetooth to ir relay (bidirectional if possible) for rcx....mainly for following reasons

  1. It will be possible to connect rcx to ev3 or nxt or an android phone via bluetooth 2.Eg Rcx can act as locomotion base for an android phone doing object tracking and other heavy lifting tasks
  2. It will be cool and challenging project!!!

Any thoughts??

Very thanks

G33kDude commented 9 years ago

In my experience the RCX is not well suited to precise or difficult tasks. The motors have no tachometers in them for positional or correctional feedback, which often results in very inaccurate movements. Also the motors are not well suited to heavy tasks, they have very little torque unless you gear them down to a quite slow speed. You might try a worm gear. The LEGO building bricks don't hold together well under heavy weight, but good building technique can help avoid this problem.

The RCX doesn't work too well at long-range from the IR tower, so attaching the tower to the bot may be required for best accuracy. I have put my phone onto the RCX before, with a live-streaming IP camera app on it. It worked pretty well, actually, but for some reason my phone appears to emit a constant "0xFF" from its IR blaster as of android 4.4.4, and it was interfering with the RCX. If your phone has a working IR blaster, you might experiment with controlling the RCX with it, though I can't say for sure if the IR blaster on a phone can generate the required frequency of flashes.

ameysutavani commented 9 years ago

All good points

the relay will always be in front of rcx..just like the tower you mounted on the robot. Yes, rcx does not have tacho, but android smartphone has plethora of imu sensors like gyros and accelerometers which can be used to get the current heading and acceleration

The only paramater that has to be passed to rcx is the speed of both the motors and polarity (eg for a single motor ranging from -100% to 100%)...here -ve sign indicates reversed polarity

for a pair of motors forward is (100,100) backward is (-100,-100) left is (-100,100) arc left(-50,100) and so on

these parameters can be given by an android app which implements PID controller based on its imu sensors

G33kDude commented 9 years ago

I'm not quite sure how well the feedback thing would actually work, since as far as my tests have gone there's a slight "cooldown" period between when it allows you to send commands..

The "Set motor power" opcode only allows you to set power as values 0 through 7. 13050203 would

  1. set the power of 13
  2. motors A and C 05
  3. to the value of 02
  4. 3 03