Showing posts with label Robot. Show all posts
Showing posts with label Robot. Show all posts

Saturday, November 19, 2016

Raspian ROS on Raspberry PI B+ with Downloadable Image

I wanted to share my image of ROS Indigo for a Raspberry Pi B+. When I tried a couple of images I found online, none of them seemed to work, so I had to make my own. I will warn you that it is pretty slow, but ROS is installed. I was originally going to use this onboard a turtlebot, but I decided against it after seeing how slow it was. As far as I know it would work, but the extent of my testing was launching roscore. Here is the process I went through to create the image.

  1. Install Raspian Jessie with Pixel version September 2016
  2. Follow instructions on the ROS wiki for the ROS-Comm version on Indigo
  3. Pull Image using Win32DiskImager

Download the image here: Raspian_PiBPlus_ROS_Indigo_11_17_2016.7z


Notes:

  • It would probably be better to use the minimal version of Raspian. Like I commented above, it is pretty slow
  • I had issues building the catkin workspace. I think it was RAM related as the wiki suggests. I ended up closing everything that was open and running with the default -j4 option, and it worked.
  • Contrary to seemingly popular belief, ROS can be installed on an original Raspberry Pi. It is just painful. My install took several hours.
  • The image is 2.287 Gb compressed and 31.260 Gb uncompressed. 
I hope this is useful to someone.
-Matthew

Friday, September 13, 2013

Arduino Inverse Kinematics for 2 DoF Robot Arm

In this post I will discuss inverse kinematics. Before I do, I should begin with a disclaimer. I will be using high school trig in this post. I am not a mathematician, and I have never been taught anything about inverse kinematics. Everything here is very simple, and should not be taken as cutting edge science.

So what is inverse kinematics? If you have found this, I suspect you already know. If you don't know, go HERE and read all about it. Basically, if you were normally controlling this arm, you would turn some knobs and change the angles. That would give you the position of the end of the arm. Controlling the arm using inverse kinematics in this case means that you tell the end of the arm where you want it to be, and the joints calculate their angles and move there based on that.

Now this can lead to problems. As every good trigonometry student knows, the trig functions are cyclical. This means you can get multiple answers for given equations. Determining which one is the right one is the trick. How do you do that? I have no idea! (Ok, I have a general idea, but not something I am willing to post on the internet). My arm is simple enough that it avoids the whole problem.

My arm is a simple 2 degree of freedom arm made from 9 gram servos. If you have not seen it, you should check it out HERE. It has 2 joints and that is about it. I am using my custom hackduino to control it. You may be able to get away with an Arduino Uno or Mega and a sensor shield, but I would be wary of maxing out the regulator on it. If you have issues, try an external 5V supply.

Anyway, HERE is the code for the basic inverse kinematics. It just moves the arm to the what ever point you enter. The rest is up to you. I have commented it pretty fully, so you shouldn't have too many problems using it, but I will go into a few things.

First, there will be values your arm can't reach. I would say a safe bet is to just make sure all your x,y values are positive. You probably remember from high school that arccos and arcsin have certain domains. Outside of those domains, they are undefined.

Now if I had done my due diligence I would be able to tell you what values will cause these errors. The problem is, I did all my trig in a hurry one night and threw away the sheet. I now have neither the time nor the interest to go back and figure out where it will error. If you figure it out, let me know. The important thing is that those values should be outside what your arm can physically reach anyway.

Second, the coordinates of the point are in centimeters. I did this so I could use decimals easier. There are also a number of correction factors built in. There is one angle correction for each joint plus one for each axis so you can translate the origin to a convenient point. Theta is also a correction factor but it is a variable calculated automatically based on your inputs. Also note that the arm section lengths are measured from joint to joint. The pivots are the corner of the triangle.

Now the fun stuff. We are going to draw a circle with the arm! HERE is the code. Basically, it is the exact same as the other code except the (x,y) points are determined based on the parametric equation of a circle!

It did take a few tries for me to get the center of the circle in a spot where my arm would physically reach it. A more carefully constructed arm would have less problems with that. When I did get it draw a circle the results were this video! Look at that circle. Just tape a sharpie to it and go to town. I will note that the circle is a little rough. Several factors play into this. The base is shaky. The tape holding the pen on is shaky. The servos lack resolution and are slightly under powered, and the pen is not in the correct location. The tip of it needs to be on the corner of the triangle




Of course, you could draw about anything with it if you had the time. I briefly looked into getting some old code from a plotter and adapting it, so I could write words with it. I never got there, but maybe you will!

So there it is. This post has been done many times by many different people, but I hope mine was useful to you. Both the sketches from this post are HERE. If you do create something cool using code or ideas from here, post a link in the comments.

-Matthew

Monday, September 2, 2013

Simple Arduino Robot Arm from 9 gram servos

Greetings once again. I just wanted to take the opportunity to introduce you to my new robot arm. It doesn't have a name, but it is made from house insulation foam and 9 gram servos. I won't do a full tutorial on this because frankly it isn't required. There are tons of this sort of thing out there. Use mine as a starting point for your own design based on what you have sitting around. This is just one example of something that works.


For this project you will need a few things.

The first is an Arduino or other microcontroller. I suppose you could use an RC receiver or some other sort of signal generator, but I will be using an Arduino Mega2560 r3.

Next you will need two HXT900 9gram servos (or similar). These can be purchased  from hobbyking.com (what I recommend), or you can search for 9 gram servos on Ebay. They are common and cheap. I will say that the one's from HobbyKing are pretty decent quality (for a $3 servo). They aren't without fault, but you could do much worse.

For the arm's physical construction I will be using half inch house insulation foam. It is also cheap, but you will probably need to buy a full 4x8 sheet of it. You might be able to use styrofoam or foam board as well. Just make sure it is light. These servos aren't very big.

Last you will need some sort of hinge bracket. I use a part off some old plastic blinds for the base and then just a plain screw for the elbow.

First, cut two lengths of foam about 6.5" x 1". This is about the maximum length that I would use. Beyond that the servos start to get overtaxed when fully extended. Next cut the center cross beam. It is about 1.25" x 1". Basically, make it big enough that your servo and hinge will fit in between the first two pieces.

Next we are going to glue it together. Make sure your servo horn is pointed in the right direction, and hot glue it in place as shown. I use the servo itself along with the plastic blinds bracket as the joint. Again, if you are using a bracket completely dissimilar to mine, you may need to modify this. The spirit of this arm is use what you have.


Next we are going to make the other arm segment. This is about 5" x 1". I cut two of them and then glued them together to make one solid arm.

Next I screwed a screw into the center of the arm about a half inch from the end. This works as my other hinge. The metal on foam is actually pretty fluid.



Next we need to mount the elbow servo in the 1st arm segment. I cut a nice slot in the arm and slid it in. A little hot glue, and it was secured. This is a good time to go ahead and make sure your elbow servo horn is in the correct position. This is important. It will be hard to change later. Place the horn to achieve the desired range of motion.



Now cut a hole in the 1st segment opposite of the servo to create the other side of the hinge. Insert the screw of the 2nd segment and glue the horn in place once you get it straight. You should now have a completed arm without a base.

Go ahead and cut a base. I used a 5" x 5" slab of the same foam. Now just hot glue the servo of the first joint to the base, and you are good to go. Your arm is now done!

The keen eyed observer may not that this arm can't really do much. It can't rotate or pick up things. About the only useful thing I have done with it is tape a sharpie to the end. That is not the point. The point was to build a tool with which I could explore inverse kinematics. That goal is achieved.

Inverse Kinematics is another post; however, you can test your arm with either the sweep or knob example programs. Note that if you have problems, try powering the servos from an external power supply. It is entirely possible that your Arduino just isn't providing enough current.


Maybe this post inspired you. Maybe it didn't. If not, wait around for inverse kinematics(now HERE). That will be more interesting.
-Matthew

Tuesday, August 27, 2013

Introduction to myrobotlab (MRL)

First, let me say that I am a user of myrobotlab. Not a developer. With that in mind, it is also safe to say that I really know very little about the software. This post is just a collection of things I have learned and observations I have made from a user's perspective.

For a while I have been wanting to do a little vision processing, and being a FIRST robotics alumni I had seen a bit of this done. While I had never been actively a part of the programming, I also knew that FIRST teams get a "free" copy of roborealm with their kit every year, and that is what many teams use for vision processing. Well that is all well and good, but I like free. I began looking for a free version of roborealm and found myrobotlab.

Well for those that may be coming from the land of Arduino (like me) MRL is completely foreign. At first glance, it looks all GUI and friendly, then you discover a hidden underworld of features that can only be found by someone who already knows where they are. Regardless, after getting it installed, getting OpenCV (a widely used computer vision library. See HERE) up and running is pretty simple. You can have your camera finding your face in a matter of seconds. Now, doing something with that data is more tricky.

Now like I said, I am in no way a trusted source on this, but this is my take on how MRL works. You have a set of services running within a Java infrastructure. These services can do just about anything. At the time of this writing the main way you link these services together is by a Python service. From there you can set up the links from service outputs to service inputs. There's just one problem. How do you know what each service can input and output?

Well that is where not being a real programmer is a real pain. Basically, play around with stuff. Look at the examples on each service page and HERE. If you encounter a problem, post on the forum or in the chat and ask a developer. With features progressing so quickly, sometimes examples get left behind. One useful forum topic on this is found HERE. In it GroG discusses several ways to look at the various methods for communicating with each service.

That's about all I can say about it. I have been playing around with it, and as someone who learned to "program" on an Arduino less than a year ago I can say that the fog does lift. Play with some examples and ask questions, and you will figure it out. Of course, if you already know Java or are a real programmer, I'm sure you will have no problems with it.

I have been playing around with the serial, keyboard, and opencv services mostly. Hopefully I will be able to post some cool projects with them in the very near future. Until then, check out myrobotlab. Such opensource projects are always neat to check out even if you aren't going to use them. The people on there are always nice, and I'm sure there's room for one more user.

-Matthew

Monday, February 18, 2013

Differential Steer Robot: Wiring

Greetings once again. I said I would post some more details about wiring up the robot. Well this shouldn't take to long so here it goes.

The first place I started was the servos. Like I said last time, these are continuous rotation servos (now that I've modified them). They have three wires. Depending on what brand of servos you have, they will be different colors, I'll assume you have Futaba servos like me, but if you don't its not too hard to figure out.



  • Red: Power. These servos like 4.8-6V. These are based off of the nominal voltage for NiMh (or Ni-Cd)  batteries. So a 5 cell works fine even though its actually higher than that hot off the charger. Don't try to run them directly off the Arduino. 40mA per pin isn't a lot.
  • Black: Ground. This goes to the negative side of the battery. One important note. You must tie the negative side of the battery back into the GND port on the Arduino board. You will beat your head against the wall until you do this. I know this from experience..
  • White: Signal. This wire will go to a PWM enabled digital IO pin. By using the built in servo library you can transmit PWM signals to the servos. Different pulse widths correspond to different angles. The servo will attempt to turn to that position. This is how our servos work. We have disabled the potentiometer so that no matter how much the servo turns, it never thinks it has reached its destination. Some people claim that servos actually run on PPM. I don't really know which is correct, and it hasn't been worth my time to figure it out. The servo library works. If you want to see the servo wave form, Google it.
So I used my extensions to connect my servos so I could leave my servos mostly intact. White went to one of my PWM pins. Then I connected Red to the positive rail on my breadboard. Black went to the negative rail. I connected my 6V battery to the same rails. Then I tried it out! It jittered around and didn't work. After several hours of frustration I realized my stupidity. You MUST wire in a common ground. ie, connect your ground rail on the breadboard to the GND pin on the Arduino. I knew this but forgot and wasted lots of time chasing a problem that should have never existed. Anyway, the picture to the right should clarify if you're confused as to what colors are equivalent.

A quick note, I have been experiencing some odd fluctuations in my servos. A servo will stop until I tap it.Then it will come back on. I have not yet had time to track down the root of these problems. I believe it is a flaky connector somewhere. I have also considered that I need to filter some noise on them. If you know how to do this and wish to, then go ahead. At the moment, I have bigger fish to fry. I doubt that this is the problem anyway.

Ok. Servos are wired. The Arduino itself is much easier. Get a connector and solder it on as dictated HERE.  I scavenged one off of a old power supply, but if you find a good source for these cheap, feel free to email me or post in comments.

Now the ultra sonic sensors. These are pretty straightforward as well. Wire them as written on the board. I use the sensor shield and my female jumpers. Power (5V. Arduino power, not servo battery). Ground. One IO pin to trigger signal. One IO pin to listen for response.

That's about it. I also have the other rail of my breadboard wired in to 5V. This gives me a 6V rail for servos, LEDs and other high current draw stuff and a 5V rail for logic stuff. Be sure to tie all the grounds everywhere together.

That's about it for today I think. I had planned to begin with videos of object avoidance after this, but I have been met with a bit of a tragedy. I'll talk more about that later. Lets just say, stuff happens. Its not a bad idea to have an extra $20 Arduino sitting around. I may try to work around that. We'll have to see. I've got some tests early this week, but maybe towards the end I'll have time to write again. I will say this, I have gotten some ATtinys and am pretty excited about playing with them. Unfortunately they are at the end of a long list of things to do (including type this post).

With that, I think I shall end. If you have any questions, comments, rants, praises, or large sums of money for to give me, post in the comments or send me an email. If not, just follow so as not to miss out on the latest exciting installment! 

Until later,
Matthew

Saturday, February 9, 2013

Differential Steer Robot: Overview

     Greetings. Its been a while. For that I apologize. Today I decided to take a break from Calculus to type up a new post. So here it is! Anyway, you may have been wondering, "What could he have done with that Arduino?" Well I did something no other person in the world has ever done. Guinness is on his way. I made a differential steer robot. I know. One of a kind. No one else has ever thought of that. And there it is!

     Actually, that is not what it currently looks like. That is what it looked like a month or so ago. It now is sporting 5 more sensors and a real time clock module, but that will come later.

     So what are we looking at? Well its pretty simple really. In the middle we have the Arduino Mega previously mentioned. It is wearing the v4 sensor shield.

     To the left of the Arduino is a solderless breadboard. I got mine off of ebay and I haven't seen one cheaper anywhere else. Mine was called "Mini Solderless Breadboard Bread Board 400 Contacts Available Test Develop DIY." Really, just make it has the rails on the side. This one was $3.22. Radio Shack is more than that, but China takes a while. I just order in advance

     Above and below the breadboard we have two ultra sonic range finders (pictured on the left). Now you can buy these for $30ish at places like robotshop, but these two came from ebay as well. HC-SR04, they cost about $2 each. Mine worked flawlessly. They are a great introduction to thinking like a computer. They work like sonar and are pretty good. They don't like angles all that much, but this is a learning  process. We'll move on to the $2000 LIDAR module later (as soon as a reader buys me one).



     To the right of the Arduino we have the batteries. Now these batteries are pretty up for grabs. I used what I had. They are pictured to the right. The big one is a 7 cell NiMh battery made to go in a Traxxas Stampede RC Truck. It is powering the Arduino. Needless to say, it will power it for a long time. It provides 8.4V to the Arduino voltage regulator. I also put a switch in the circuit because that makes things much more convenient. I ordered these switches as well as some limit switches(and LEDs, etc) I used later from Pololu.com. I think they were 50 cents or something. Since then I have discovered BGmicro.com which also has cheap stuff, but I have never ordered from there and am getting off topic.
     The one below the large battery is a 5 cell NiMh that powers the servo motors. Long story short, the Arduino can't provide enough power through a digital IO pin to power them so we wire in external power through the breadboard. Hobby servos like 4.8v or 6.0v (nominal) so this is perfect. The battery is one I got from Hobbypartz.com. Its a China importer based in California( I think). Shipping is faster than China. The connectors are Deans (T-connectors) and Traxxas connectors from Hobbyking. Connectors like that are one of the things you have to buy from there. I've found that even if I only use 2 or 3 of them, I'll break even with the hobby shop. Find Deans HERE, Traxxas HERE. If you are using dedicated batteries for this project feel free to use whatever connector you want. Tamiya, EC3, XT60, etc. But I will say that Deans are easy to solder. If you want, you could even use rechargeable AA batteries. I already had these and the charger from my previous rc plane endeavors so this is what I used. I kept the Traxxas connectors so the big battery will still fit in the truck.

     Below deck is a set of fps-148 Futaba servos modified for continuous rotation. How to do this? I used instructions HERE. Its a 60 second procedure. Google search it. I also had these servos sitting around. If I had to buy everything I would probably go with servos from HobbyKing. I've used some of the HXT servos before for planes, and they work well. I'd go with THESE most likely, but do what you wish. I haven't researched it all that extensively. You want something with a futaba spline if you are going to use the wheels I did.

     Speaking of which.. The wheels came from Pololu as well. I got the ones found HERE. They screw on just like a servo horn. Easy as can be. While I'm at it, the front ball caster also came from there. I got the .75" version found HERE. Alternatively you could search for ball transfers on a site like McMaster-Carr.


      The white thing on the side is just part of an old computer I put on there for its switches and LEDs. We'll get into that later.

     Assembly is quite straight forward. Wood glue, hot glue, and some machine screws. My total dimensions are 8" x 11". The ultra sonic sensors are mounted on a little block that cradles it (mine is balsa because it was easy to shape) and a tab that rotates.
    The Arduino is held on with some little dowel rods that I made to fit the holes and a few metal standoffs. If you use metal standoffs, be sure to put some sort of insulator between the metal and the board. I used homemade washers made from a cereal box.


Other things you'll want:

  • female-->female jumpers. Get these on ebay. Search for dupont connectors. 40pcs for $3.
  • jumper wire: any 22 awg solid wire will do.
  • Resistors: again, I like ebay. I got 400 metal film resistors in assorted sizes for < $5.
  • *optional* THESE. They make connecting the servos more tidy.
  • Other stuff: Electrical tape, heat shrink, etc. 
  • Basic Tools: Soldering Iron, Wire Strippers, Digital Multimeter (Must have some variation of all these things. You just do.)
  • X-Acto Knife: These are dirt cheap at hobbyking. 50 cents. I have many of THESE. And extra blades HERE.

 
     Ok. Well this post is getting pretty long so I better wrap it up. I hope this has inspired you to greatness. If you have any questions, comment or send me an email. I would encourage you to check out Jeremy Blum's YouTube channel too(HERE). He has some great tutorials for Arduino and knows much more about electronics than I do. I have learned a lot from his videos.

     If you want to go ahead and stock up for the future, order some IR LEDs, IR photodiodes, and 2.54mm male headers from Ebay and some of THESE too. Next post I 'll try to get into more details of wiring this thing up. I'll start throwing out some free code soon too. See you later!

Have Fun!
Matthew