c# code for Maplin USB Robot arm. :)
Uses the LibUsbDotNet lib with a bug fix. I'm going to create a WinForms app and then create a web page for it all. Just wanted to post this so others can play with it over xmas. ;) Go get your robot arms, only £30 and fun!
Robot Arm If you're using prebuilt bin you'll need to use the LibMonoUsb code, if you have the LibUsbDotNet source and want to use that then you'll need to fix the MonoUsbControlSetup.SetData function with the following code. Code:
//Fixed function. The robot arm takes three bytes. first two bytes is for the motors. The last one, set to 1 for light on. Set all to zero for all off. First byte Gripper close == 0x01 Gripper open == 0x02 Wrist Up == 0x04 Wrist Down == 0x08 Elbow up == 0x10 Elbow down == 0x20 Shoulder up == 0x40 Shoulder down == 0x80 Second byte Base rotate right == 0x01 Base rotate left == 0x02 Third byte Light on == 0x01 :) Code:
using System; |
Certainly looks very interesting however with most people on here being Linux users, I doubt many will program (or at least choose program) in c#.
|
I've now created a binary and a project page on google code.
http://code.google.com/p/maplin-robot-arm-for-linux/ You'll need mono runtime. I'm using version 2.6.7 |
Quote:
c# offers easy internet integration as well as better bug resistance. Anyway having in the past few years been coming a Linux advocate I looked into Mono as a way for the current applications they have to run on Linux. And as it turns out c# is outstanding in allowing cross platform integration. I've spent years maintaining code that works on many platforms, not just Linux and Windows. c# just makes that work go away. Really, if you've not, go check it out. It wont fulfill the hardcore coders needs but it will allow you to create one binary that will run on all systems. |
off topic...
does mono work ok? I'm a staunch freeBSD perl c/c++ vi/make man - but unfortunately in my job i need to learn c# asp.NET. (that or quit and go scrabbling about for occasional perl contracts again). sad but rent needs to be paid. |
Quote:
Hi Richard, I've no luck using the code. :( dmesg recognises a usb device, but doesn't try to load any drivers or anything: Code:
[ 3822.512183] usb 5-1: new low speed USB device using uhci_hcd and address 2 Where am I going wrong? I'm using ubuntu lucid, kernel 2.6.32-25, mono version 2.4.4. Cheers! EDIT (might have been an idea to include some errors haha): Here's the output of the program when I load it and press every button. Maybe I'm missing a mono library? Code:
Stacktrace: |
Sorted!
just found this, solved all my problems! Now programming my robot arm in C!
http://notbrainsurgery.livejournal.com/38622.html |
Quote:
I was where you are now 8 months ago. Now unless i'm hacking, i'll use c#. Just so much more productive. |
Quote:
Good to here you got it running in C. The main reason I did mine in C# was to see how easy it was to do C# code and power USB devices. There are two possible issues that may have cause your problems. Did you have libusb-1.0 installed? Also the libusbdotnet c# lib is buggy, it's using unmanaged memory incorrectly causing it to misbehave on 64bit systems. |
Hi guys, your details have been very useful to me. I've got this working in Python using your command structure etc. This is part of my "teach myself Python properly" plan as its something I wanted / need to do, rather than just dabbling in yet another language. I'm planning that it will evolve from a very basic program to a simple module, and then I'll add some other features too! I'm also hoping to use this as a test for the deployment tools and possible wxpython to wrap a pretty user interface around it. So I've registered a little blog python-poly at blogspot (I can't include a link as its my first post) to track the progress! I'll start by adding the basic module tomorrow night (if anyone is desperate for it you can email me and I'll send you the "ugly" version).
|
OK I've added some very rudimentary python code (http://python-poly.blogspot.com/2011...lest-code.html). It only needs about eleven lines of code - so this might be quite attractive to anyone new to programming or new to USB!
Here's the simplest prog I've done, but do pop over to the blog for more detailed versions or "documentation" and explanation of what I'm trying to do etc! Code:
# Minimalist version of USB arm control to show how simple it could be! (c) N Polwart, 2011 |
Robot arm control ported to Ruby
I realise this thread has gone quite a while back, but for the sake of sharing examples here is another port of the USB control code (this time in Ruby).
Please note that this is still a work in progress; however, it does work and should act as a good starting point for working with Ruby and USB. Code:
require 'rubygems' |
Arm not supported?
Quote:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/libusb-0.3.4-x86-mingw32/lib/libusb/constants.rb:56:in `raise_error': LIBUSB::ERROR_NOT_SUPPORTED in libusb_open (LIBUSB::ERROR_NOT_SUPPORTED) from C:/Ruby200/lib/ruby/gems/2.0.0/gems/libusb-0.3.4-x86-mingw32/lib/libusb/device.rb:58:in `open' from D:/MyName/Google Drive/Programs/Ruby/RobotArmCode.rb:36:in `<main>' I have tried the arm with the program that comes with it and it works, and I have installed the 'ffi' and 'libusb' gems. I have tried using a Windows 7 64 bit OS and a Windows XP 32 OS, but neither have worked. Any idea why? |
Quote:
https://www.ruby-forum.com/topic/3961426 The code I posted was tested on Ruby 1.8.7 and should probably have worked with 1.9 too, but I have no idea what sort of changes Ruby 2 requires; it's still really new and I don't know anyone who's adopted it yet. |
All times are GMT -5. The time now is 03:30 AM. |