I have had many requests in the past from people making projects who wanted to use MRL, but did not know how to incorporate it in their "already running" projects. 

In the past MRLComm.ino was a sketch which you had to load into your Arduino in order to use MyRobotLab. But now, there is a kinder / gentler MRL !  It's now an Arduino library !

Now how can you use it with your own sketch!  

Here is a very basic example.  It only shows how to use the MRLComm library and get all the functionality which was previously in the MRLComm.ino sketch ..  But wait there's more !  You may want to send some of you sensor data to MRL.  NO PROBLEM (in fact Alessandruino wants to do this from his MPU06050)

I don't have a MPU06050 - so I'll just show you how to get 3 variables from your Arduino sketch into MRL using the MRLComm library (ax ay & az)

 

Setup is pretty easy - create a MRLComm object .. I chose to call my mrl (clever no?)
mrl will want a serial connection - so I gave it my Mega's first serial connection.  

And now to get all the functionality MRLComm.ino had all you have to do is call mrl.process() in the loop.
Typically its very fast.

Now to send 3 variables back to MRL (specifically python).  Here's our Python script ..

 

And thats it !

available in 1.0.57 
https://github.com/MyRobotLab/myrobotlab/releases

caveats :

  • You will need to load the library like all Arduino libraries - this is well documented here -
    The library itself can be found here - https://github.com/MyRobotLab/repo/blob/master/cc.arduino/1.0/MRLComm.z…
  • The skeleton & what is now needed as the "main" MRLComm.ino is in the zip - it has very little code - same as what is posted in the previous pictures.
  • Only ints are currently handled - other data types unsigned longs, longs, byte[], char will be added in the future.
  • There still needs to be a way to pass information from python (or other services) - to the Arduino sketch

kmcgerald

9 years 6 months ago

I would totally pimp this at my next monthly robotics meet up but I'm going to be hanging out with the MRL nation in "the real world."

GroG

9 years 6 months ago

Ya, ok - I'll do a release.. I have a feeling Alessandruino will be testing tomorrow.

Still have a TODO:

1. handle other types besides int. E.g. char, char*, byte[], long, unsigned long or whatever the Arduino can supply.
2. I would want at some point to be able to "send" data to the Arduino via Python - (python --> arduino) for example

arduino.sendMsg(bx, by, bz) - then have the mrl library give me the data in the Arduino sketch.. e.g.

if (mrl.onCustomMsg()){
int bx = mrl.getMsg();
int by = mrl.getMsg();
int bz = mrl.getMsg();
}

or *something* like that....

Alessandruino

9 years 6 months ago

Cool grog :) ya...definetely I want to test it as soon as I m done with work work :) great job o/

AdolphSmith

9 years 6 months ago

Thank you Grog - As our minds grow and our robots the control program MRL is growing. Thanks to you one day we all have real operating robots.

Thank you for all the time and effort you give us and help us. We all learning from the best.

GroG

9 years 6 months ago

Initially its more complex to install, because you have to install an Arduino library ...

I went through the process myself and have tested it using the oscope & a servo .. it worky for me but Masta has problems

kmcgerald

9 years 6 months ago

I updated to 1.0.57 and pushed the library based MRLComm.ino into my mega with Arduino IDE 1.0.3 on my MacBook. Then I fired up MRL and opened my pingdar python script and it worked.

borsaci06

9 years 6 months ago

YAY!!! I was waiting for this... Kudos Grog... Ur my man...

Still trying to get it working though... :) I am sure it will get better...

Mastablasta

9 years 6 months ago

1.0.57 did not work for me. Everything seemed to be normal, added the library to the Arduino (using IDE 1.5) but all servos went crazy. Back on 1.0.56 things work normally again.
Speech was ok but servos not. Even had to disconnect the wires of the omoplate as it was out of control.
E.g. "close hand" he closed 3 fingers.

After I deleted the library my OS deleted all users and I was having a hard time to get back to the roots. No browser, no IDE, no MRL working.

Alessandruino

9 years 6 months ago

I haven t tried controlling a servo get.

The example sketch/script worky for me.
I noticed that if i Include wire.h library in the same sketch, the serial connection is borkeded and the arduino can t connect to mrl

Worky ! For me - mebbe you should send me the current sketch wich is failing for you and I'll try it...

This is what I'm using...

 

/**
*
* @author GroG (at) myrobotlab.org
*
* This file is part of MyRobotLab.
*
* Enjoy !
*
* MRLComm.ino
* -----------------
* Purpose: support servos, sensors, analog & digital polling
* oscope, motors, range sensors, pingdar & steppers.
*
* Requirements: MyRobotLab running on a computer & a serial connection
*
*/
#include "I2Cdev.h"
#include "MPU6050.h"
 
#include "Wire.h"
#include <Servo.h>
#include<MRLComm.h>
 
 
MRLComm mrl = MRLComm();
 
MPU6050 accelgyro;
//MPU6050 accelgyro(0x69); // <-- use for AD0 high
 
int16_t ax, ay, az;
int16_t gx, gy, gz;
 
 
void setup() {
 
  // join I2C bus (I2Cdev library doesn't do this automatically)
    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
        Wire.begin();
    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
        Fastwire::setup(400, true);
    #endif
    
    Serial.begin(57600);
    mrl.setup(&Serial);
    
    accelgyro.initialize();
 
}
 
void loop() {
 
  // process mrl commands
  // servo control, sensor, control send & recieve
  // oscope, analog polling, digital polling etc..
  // mrl messages
  mrl.process();
 
  // example how to
  // send 3 vars to mrl
  /*
  int ax = 28;
  int ay = 583;
  int az = 32767;
 
  mrl.startMsg();
  mrl.append(ax);
  mrl.append(ay);
  mrl.append(az);
  mrl.sendMsg();
  */
 
}

hairygael

9 years 6 months ago

I'm wondering how to proceed now for to do the whole install.
Do we load this into the arduino with the IDE arduino. and then use MRL like before?