More code on GitHub

Along with my Arlobot ROS packages, I have also been working on a “Metatron” package that I use for some “personalization” of my robot, and a web interface called Arloweb.

I now have Metatron and Arloweb on my GitHub repository, so technically everything I use on my robot is on GitHub now.
In theory, if you follow my build to build the same robot I did, you can install everything from my GitHub repo and have a robot identical to mine.
Certainly more documentation is due, but at least it is all there and being updated as I modify the code.

If there is something in particular you want to do, let me know and I’ll try to document that ASAP.
As it stands now I kind of drift back and forth between documenting things I did months ago and things I’m working on now.

Using an xBox 360 Joystick with ROS

We have an xBox 360, so just like I was able to “borrow” the Kinect from it for initial testing, I am going to “borrow” one of the kid’s xBox controllers for testing! They rarely use all 4 anyway.

To use an xBox controller with a PC (Windows or Linux) you need a receiver, which are fortunately easily obtained.
I purchased this “Wireless PC USB Gaming Receiver for Xbox 360” from Amazon for under $10.

Note: I’m not sure if there is any way to “disassociate” an xBox controller from your xBox. You just connect it to a new device. I found that if I turned on the controller in another room it was far enough away that the xBox did not power on. If the xBox keeps turning on and grabbing your controller just unplug it from the wall so it has no power. Once your associate the controller with the PC adapter it shouldn’t turn on the xBox anymore.
Reconnecting it to the xBox should be as easy, just remember if you want to go back and forth you’ll have to keep doing this.

ROS already has a page about Configuring and Using a Linux-Supported Joystick with ROS. I will just be adding my findings specific for the xBox 360 and my ArloBot.

Before I plug in the adaptor my Ubuntu machine already shows one “js” device:

This appears to be some sort of accelerometer, possible built into the HP Elitebook laptop?!

That is not what I am after now, but it sure seems like I should look into it in the future! Maybe your laptop has one too?!

When I plug the USB adapter for the xBox joystick into my laptop I get four new “js” devices.

I guess since the xBox standard is to support 4 controllers, the USB PC adapter provides 4 devices right up front.

Press the button on the USB adapter and it starts flashing.
Press and hold the small round button on the back of the xBox controller that looks like “O)))” until the lights on top of the controller start to “spin”.

The light on the USB adapter will stop flashing almost immediatly and the lights on the controller will stop spinning and start flashing all together.
This part is confusing, because when the controller is connected to the xBox you get one quadrant lit up to show which controller it is. Instead on the PC I just get all 4 lights flashing at me, which is kind of annoying.

However, if you run sudo jstest /dev/input/js1 you will indeed see that Ubuntu sees the controller and it is the first one!

If your screen scrolls instead of updating the line of input in place try resizing your terminal window.

Clearly we have a LOT of input options here and a lot of cool buttons for doing all sorts of stuff!

It is kind of fun to play with and learn about how the controller works this way! 🙂

So now we carry on with the ROS instructions:

Make sure the js1 device is read/writeable by everyone:

You will need to have ROS running at this point, so if you don’t, start it.
If you don’t know what I mean, just open another terminal window and run roscore so it can be running over there while you carry on over here.

Now make sure your xBox controller is still on and run:

Now start another terminal (yeah, ROS is big on having dozens of terminals open to test things) and run:

It should be quiet as long as you do nothing, and then it should spit out lines like this if you push any button or move any stick:

A button push will give one entry for each up and down.
Moving an analog stick or button will send a lot of them as a stream of the analog output!

Now we know that ROS can see the input from your xBox controller!!!

One nice thing is that the ROS joy node can deal with the controller shutting down. With just jstest it would quit if the controller shut off or went out of range, but the joy node will keep attempting to reconnect, which you can even see in the output:

NEXT: Use the xBox controller and joy node to control ArloBot!

So now how do we make use of this in ArloBot?
Certainly we could write custom code and/or modify code to make use of the amazing arrow of inputs, but ROS already has code for this. Later I may augment this to make use of more of the buttons, but for now I’m going to try to just use what is included in ROS with as little modification as possible.

Don’t follow on with the ROS page we were at before, that was just to make sure we could see the controller in Linux and show us how to debug.
Now we want to find a node that we can use with ArloBot with the least fuss.

The easiest way to do this is to just launch ArloBot’s minimal bringup package and then launch turtlebot’s teleop:

The way this works is that it ONLY sends commands to the robot while the left “shoulder” button is held down. It is labeled “LB”. Hold that down and move the left stick and the robot should respond!
If things get out of hand just let go of the “LB” button and all zeroes will be sent again to make it stop.

And that’s it! It should work.

I will probably do some tweaking and customizing of my own joystick teleop code and include it in the ArloBot github repository soon. Until then though, the TurtleBot code is working fine.

ROS Kinetic Setup

In the last article I explained how to set up an Ubuntu laptop for use by ROS. Here I’m posting my notes about how to get ROS Kinetic up and running on that laptop.

There is now a script to install everything.
Just run:

and you are done!

To update your code just run the same script again and it will pull down and compile anything new without erasing custom settings.

NEXT!
Next we’ll want set up Propeller Code for Arlobot