Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
2,221 Views

Doing add-ons of the UPM sensor (smartdrive) to javascript and python

Hi guys,

I did this driver ( https://github.com/intel-iot-devkit/upm/blob/master/examples/c%2B%2B/smartdrive.cxx https://github.com/intel-iot-devkit/upm/blob/master/examples/c%2B%2B/smartdrive.cxx) in partnership with driver

 

Oussema Harbi mailto:oussema.elharbi@gmail.com oussema.elharbi@gmail.com

What I need now to do var smart= require('smartdrive') and use smart variable to move windshield motors to left and right in my javascript code?

e.g.: SmartDrive High Current Motor Controller is originally sold with a python software driver to raspberry pi. I worked in last year to solve problems and make the driver works in intel edison

 

(/thread/88007 https://communities.intel.com/thread/88007)
0 Kudos
62 Replies
Highlighted
New Contributor I
8 Views

https://github.com/intel-iot-devkit/upm/issues/461 Doing add-ons of the UPM sensor (smartdrive) to javascript and python · Issue # 461 · intel-iot-devkit/upm · GitHub

0 Kudos
Highlighted
Community Manager
8 Views

Hi Neuberfran,

 

 

Nice driver, I think that the best way to use this on Javascript is creating the code on JS, in that case you need to check the https://github.com/intel-iot-devkit/mraa MRAA repository to see what libraries you can use on Javascript to implement the driver.

 

 

You can also check this documentation: https://nodejs.org/api/addons.html, maybe you can use your driver written on C++ in Javascript.

 

 

I hope this information helps you.

 

 

Regards,

 

-Leonardo
0 Kudos
Highlighted
New Contributor I
8 Views

Hi,

-Leonardo,

What about this links:

https://github.com/intel-iot-devkit/upm/blob/master/src/smartdrive/jsupm_smartdrive.i upm/jsupm_smartdrive.i at master · intel-iot-devkit/upm · GitHub

https://github.com/intel-iot-devkit/upm/commit/7e402ede3495dff5e2a6076d5f59484687013fe6 smartdrive: upm implementation for SmartDrive from openelectronics.com · intel-iot-devkit/upm@7e402ed · GitHub

Just put smartdrive in package.json?

0 Kudos
Highlighted
Community Manager
8 Views

Hi Neuberfran,

 

 

I found another https://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/Interacting-wit... call-compiled-c-c-code-directly-from-javascript guide that you can follow to interact between JavaScript and compiled C or C++, it can be useful if you want to use the driver directly on Javascript.

 

 

About the links, I'm not sure what you want to know, so can you explain me the question?

 

 

I hope the information helps you.

 

 

Regards,

 

-Leonardo
0 Kudos
Highlighted
New Contributor I
8 Views

Hi -Leonardo,

Ok, I'll explain more

according to this video https://www.youtube.com/watch?v=oin6F_b0V8g Intel Software Day Salvador – IOT Rafael Neri - YouTube the developer rafael neri develops upm to sensor hx711

according to his words now we can do var hx711 = require("hx711"). Above image is similar to smartdrive image.

0 Kudos
Highlighted
Community Manager
8 Views

Hi Neuberfran,

 

 

Thank you for explaining your question, the libraries of the sensors are similar. So I think you can use the driver in your Javascript code, check this example: https://github.com/intel-iot-devkit/upm/blob/master/examples/javascript/hx711.js. Try to do the same with the Smartdrive sensor and let us know if it works.

 

 

I hope you find this information useful.

 

 

Regards,

 

-Leonardo
0 Kudos
Highlighted
New Contributor I
8 Views

Hi -Leonardo,

Now I stay trying install smartdrive (c++ version) in new edison with new yocto image (201606061707) and I'm having problems:

CMake Error at CMakeLists.txt:6 (upm_module_init):

Unknown CMake command "upm_module_init"

0 Kudos
Highlighted
Community Manager
8 Views

Hi Neuberfran,

 

 

Can you explain me your issues? Honestly, I'm not sure what are you doing running those commands. So I appreciate if you explain it to me.

 

 

Normally when I use an UPM driver, I don't go into the src directory and I have never used the .cxx files.

 

 

I will be waiting for your explanation to help you.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo

 

0 Kudos
Highlighted
New Contributor I
8 Views

Hi –Leonardo

I will explain better

You need to understand (that from now on) I will go in two ways:

The first is to make the smartdrive driver work and move two motors in a new intel Edison with new yocto image (I'm not getting)

The second (It is the reason of this topic) Where I can make a nodejs app and put require("smartdrive") and control the motors from this app

First of all I must say I have a intel Edison with these characteristics on which the engines are operating normally:

root@neuberfran:~# configure_edison --version

159

root@neuberfran:~# cat /etc/version

weekly-159

root@neuberfran:~# m2ctool scan 6

MRAA Version: v0.8.1-2-gfa772a0

Platform Name: Intel Edison

Scanning devices on bus

0 1 2 3 4 5 6 7 8 9 a b c d e f

00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- 1b -- -- -- --

root@neuberfran:~# alias build_ex='g++ smartdrive.cxx -o testSmartDrive -lupm-smartdrive -I/usr/local/include/upm; LD_LIBRARY_PATH=/usr/local/lib ./testSmartDrive'

root@neuberfran:~# build_ex

is this moment (in edison with oldest image) the motors running.

I need help to do this in edison with new image

0 Kudos
Highlighted
New Contributor I
8 Views

File smartdrive.cxx this in intel edison with oldest image and running OK

http://pastebin.com/4RFjFPKd http://pastebin.com/4RFjFPKd

When I pu this file in new intel Edison I got these errors

root@neuberfran:~/upm/examples/c++# g++ smartdrive.cxx -o testSmartDrive -lupm-smartdrive -I/usr/local/include/upm;

/tmp/ccziaZ1l.o: In function `main':

  1. smartdrive.cxx:(.text+0xcc): undefined reference to `upm::SmartDrive::StopMotor(MotorID_t, MotorAction_t)'
  2. smartdrive.cxx:(.text+0x136): undefined reference to `upm::SmartDrive::ReadTachometerPosition(MotorID_t)'
  3. smartdrive.cxx:(.text+0x17e): undefined reference to `upm::SmartDrive::ReadTachometerPosition(MotorID_t)'
  4. smartdrive.cxx:(.text+0x1d0): undefined reference to `upm::SmartDrive::Run_Seconds(MotorID_t, Direction_t, unsigned char, unsigned int, bool, MotorAction_t)'
  5. smartdrive.cxx:(.text+0x22d): undefined reference to `upm::SmartDrive::ReadTachometerPosition(MotorID_t)'

collect2: error: ld returned 1 exit status

2) File smartdrive.cxx this in intel Edison with new image but don't running

http://pastebin.com/bV0tm3xT http://pastebin.com/bV0tm3xT

When I pu this file in new intel Edison I got these errors

root@neuberfran:~/upm/examples/c++# g++ smartdrive.cxx -o testSmartDrive -lupm-smartdrive -I/usr/local/include/upm;

/usr/lib/gcc/i586-poky-linux/4.9.1/../../../../i586-poky-linux/bin/ld: /tmp/ccoq6w3k.o: undefined reference to symbol 'mraa_i2c_stop'

//usr/local/lib/libmraa.so.1: error adding symbols: DSO missing from command line

collect2: error: ld returned 1 exit status

root@neuberfran:~/upm/examples/c++# g++ smartdrive.cxx -o testSmartDrive -lupm-smartdrive -I/usr/local/include/upm;

/usr/lib/gcc/i586-poky-linux/4.9.1/../../../../i586-poky-linux/bin/ld: /tmp/cc8gE5Cn.o: undefined reference to symbol 'mraa_i2c_stop'

//usr/local/lib/libmraa.so.1: error adding symbols: DSO missing from command line

collect2: error: ld returned 1 exit status

0 Kudos
Highlighted
Community Manager
8 Views

Hi Neuberfran,

Thank you so much for explaining us your issues. Now I will try to answer all your problem that you posted to us. Just to be clear don't compile the codes in the src directory, because they don't contain the main function on it so they don't work.

I tried to compile the C++ example in the latest Image like you, and I got the same errors, it says that it is a MRAA library error so I linked the MRAA llibrary with the following command:

root@Leonardo:~/upm/examples/c++# g++ smartdrive.cxx -o testSmartDrive -lmraa -lupm-smartdrive -I/usr/include/upm

When I did this it compiled without errors, then I ran the testSmartDrive file and I suppose that it works if I have the module. So you can try it and tell me if it works for you. Here is the photo of the results that I got:

About the NodeJS app, I ran the example of the hx711 sensor (https://github.com/intel-iot-devkit/upm/blob/master/examples/javascript/hx711.js https://github.com/intel-iot-devkit/upm/blob/master/examples/javascript/hx711.js), at the beginning it has the line:

var hx711 = require('jsupm_hx711');

So I think that in your case you have to add the following line (It isn't require("smartdrive")):

var smart = require('jsupm_smartdrive');

I recommend you to try to do the same and let me know if it works for you.

I appreciate your patience.

Regards,

 

-Leonardo
0 Kudos
Highlighted
New Contributor I
8 Views

Hi -Leonardo,

Thank's so much. But now I have new errors

0 Kudos
Highlighted
Community Manager
8 Views

Hi Neuberfran,

 

 

It is good to see that it compiled without errors, but now can you explain to me the error that you are getting to assist you in a better way?

 

 

I will be waiting for your reply. Have a nice day.

 

 

Regards,

 

-Leonardo
0 Kudos
Highlighted
New Contributor I
8 Views

Hi -Leonardo,

I have this issue: https://github.com/intel-iot-devkit/upm/issues/461 Doing add-ons of the UPM sensor (smartdrive) to javascript and python · Issue # 461 · intel-iot-devkit/upm · GitHub

where I put:

Please change this code (wrong code) in github: http://pastebin.com/bV0tm3xT http://pastebin.com/bV0tm3xT

to

 

this:

http://pastebin.com/4RFjFPKd http://pastebin.com/4RFjFPKd

 

(this code worked in old intel edison with old image)

above image error: I don't have motor 3 here. I have motor 1 and motor 2 

your code compiled but don't worked.

 

The original developer Oussema Harbi mailto:oussema.elharbi@gmail.com oussema.elharbi@gmail.com,

don't talk more with me.

Today I see third smartdrive.cxx code:

http://pastebin.com/7QVUBxbh onemoresmartdriveCXX - Pastebin.com

and I have new erros:

0 Kudos
Highlighted
Community Manager
8 Views

Hi Neuberfran,

 

 

Did the motors move when you ran the code? https://github.com/intel-iot-devkit/upm/blob/master/examples/c%2B%2B/smartdrive.cxx

 

 

About the motor 3 when you ran the example code, it is fine because if you look to the source code: https://github.com/intel-iot-devkit/upm/blob/922e0cc26b2eb49dbf4454f05e1912c27ea9fc3b/src/smartdrive..., in the line 406 the function PrintMotorStatus prints the motor_id+1.

 

 

Regarding the third code, it is the code from the source and you shouldn't compile it because it doesn't have a main function.

 

 

I hope you find this information useful.

 

 

Regards,

 

-Leonardo
0 Kudos
Highlighted
New Contributor I
8 Views

Hi -Leonardo,

No, the motors don't moved when I compiled this code:

https://github.com/intel-iot-devkit/upm/blob/master/examples/c%2B%2B/smartdrive.cxx upm/smartdrive.cxx at master · intel-iot-devkit/upm · GitHub

I put errors messages in image below:

Today I stay working in transport the project to eclipse IDE in order to facilitate debug of the erros: I start with devkit-launcher.bat but I have path issue:

0 Kudos
Highlighted
New Contributor I
8 Views

Hi -Leonardo,

when buying the smartdrive the mindsensor/openelectronics

https://github.com/neuberfran/SmartDrive-demo GitHub - neuberfran/SmartDrive-demo

0 Kudos
Highlighted
Community Manager
8 Views

Hi Neuberfran,

 

 

That's weird, the code compiled without errors. Are you sure that you are compiling the example code of the repository? https://github.com/intel-iot-devkit/upm/blob/master/examples/c%2B%2B/smartdrive.cxx

 

 

Try to clone the repository again, and compile it. It should work.

 

 

About the Eclipse IDE, let me investigate a little more about it, and I will let you know if I have updates.

 

 

Regarding your last reply, what do you want to know about https://github.com/neuberfran/SmartDrive-demo?

 

 

Have a nice weekend!

 

 

Regards,

 

-Leonardo
0 Kudos