Controlling 3pi Pololu Robot using a Joystick

The place to discuss the Pololu 3pi, m3pi, and Zumo robots and share your code.

Controlling 3pi Pololu Robot using a Joystick

Postby ODVG90E » Sun Feb 27, 2011 1:49 pm

One of my goal projects with the 3pi Pololu Robot is to control it using a Joystick.
I think this is a good idea. I just have a rough concept but any idea will be very welcome.
Using an old joystick, I think to....
1..... scale the X and Y voltages and use them as analog inputs.
2......or scale and digitize those voltages using an ADC converter.

Then I think to replace the 0-255 (0- -255) speed ref values for joystick real variables in the 3pi firmware.

Thanks,
Wilfredo
ODVG90E
 
Posts: 14
Joined: Sun Feb 27, 2011 4:50 am

Re: Controlling 3pi Pololu Robot using a Joystick

Postby Ben » Mon Feb 28, 2011 11:16 am

Hello.

It's certainly possible to control a 3pi using a joystick. I don't see any actual questions in your post, however, so I'm not sure what kind of response you're looking for.

- Ben
User avatar
Ben
Pololu Employee
 
Posts: 3455
Joined: Mon Aug 28, 2006 12:05 pm
Location: Las Vegas, NV

Re: Controlling 3pi Pololu Robot using a Joystick

Postby ODVG90E » Mon Feb 28, 2011 2:53 pm

Thank you for your comment Mr. Ben.
I am trying to make time to start with this "small project" to control the 3pi
wirelessly using a joystick. Because of that, I will appreciate if you (as an expert in the I/O of the 3pi) could
enlighten me about where to start.
I already have created the algorithm using the X & Y ref voltages of a joystick to control two wheel of an ODV.

Best,
Wilfredo
ODVG90E
 
Posts: 14
Joined: Sun Feb 27, 2011 4:50 am

Re: Controlling 3pi Pololu Robot using a Joystick

Postby Ben » Mon Feb 28, 2011 3:00 pm

The simplest approach would probably be to use potentiometers for your joystick axes and feed the result into analog inputs on the 3pi. However, this is not a wireless solution. I think getting a wireless joystick working would be much harder, and the exact implementation will depend heavily on the exact joystick you are using. Can you tell me more about your joystick?

- Ben
User avatar
Ben
Pololu Employee
 
Posts: 3455
Joined: Mon Aug 28, 2006 12:05 pm
Location: Las Vegas, NV

Re: Controlling 3pi Pololu Robot using a Joystick

Postby ODVG90E » Mon Feb 28, 2011 3:16 pm

I am using a Cyber-tech, Inc. Ergo-Grip Dual Axis Hall Effect Joystick Model JS-EG-930.
I have not develop yet the wireless interface but I coincide with you to start wire and
then move to wireless. This joystick requires 5 VDC input and 0.5 to 4.5 VDC output.

Wilfredo
ODVG90E
 
Posts: 14
Joined: Sun Feb 27, 2011 4:50 am

Re: Controlling 3pi Pololu Robot using a Joystick

Postby Ben » Mon Feb 28, 2011 3:26 pm

In that case, you can use analog inputs ADC6 and ADC7 on the 3pi to read your joystick channel voltages. These two pins are jumpered by default to hardware on the robot, but you can remove these jumpers to use the pins for your own inputs. The Pololu AVR Library makes it easy to read analog voltages on arbitrary analog inputs, so that part should be easy. I suggest you start by just trying to read the voltages from your joystick channels (you can display the readings on the LCD for easy feedback).

After that, you need a function to convert the readings into motor voltages. Assuming you want one joystick channel to control throttle (forward/reverse) and the other to control steering (left/right), you will need to mix the channel readings appropriately to get your motor speeds. Typically, this mixing is something like:

motor 1 speed = scale factor * (joystick ch 1 + joystick ch 2)
motor 2 speed = scale factor * (joystick ch 1 - joystick ch 2)

This assumes that joystick channel 1 is throttle and channel 2 is steering. Note that if the steering channel is zero, both motors are set to the same speed (the throttle channel), and if the throttle channel is zero, both motors are set to opposite speeds (set by the steering channel).

Does this make sense? If you have specific questions, please ask. Otherwise, I think you should just start playing around with it and asking questions as you run into trouble or come across things you don't understand how to do.

- Ben
User avatar
Ben
Pololu Employee
 
Posts: 3455
Joined: Mon Aug 28, 2006 12:05 pm
Location: Las Vegas, NV

Re: Controlling 3pi Pololu Robot using a Joystick

Postby ODVG90E » Mon Feb 28, 2011 6:48 pm

Thank you again Ben for your comments. It does make sense to me your explanation.
My Joystick in X and Y goes from 0.5 (Min) to 4.5 (Max). Origin or Average is 2.

I will try your approach that looks easier than mine but here a brief of it:

1. Initialization:

A - SteeringInput (Input X Analog Voltage)
B - SteeringDeadBand 0.1 (For non Zero values when joystick in origin)
C - SteeringMax 4.5
D - SteeringMin 0.5
E - SteeringAvg 2
F - SteeringPercentOutput

G - ThrottleInput (Input Y Analog Voltage)
H - ThrottleDeadBand 0.1 (For non Zero values when joystick in origin)
I - ThrottleMax 4.5
J - ThrottleMin 0.5
K - ThrottleAvg 2
L - ThrottlePercentOutput 0

2. For the Steering Control:
Read A
IF (A >= ( E + B )) THEN
F = ((A - E - B) X 1000 ) / (C - E - B )

IF ((E - B) >= A) THEN
F = ((A - E + B) X 1000) / (D - E + B )

3. Then do the same for the Throttle control.....and so on.
Once I get it work, I will transcribe it in full here.

Godspeed, Wilfredo
ODVG90E
 
Posts: 14
Joined: Sun Feb 27, 2011 4:50 am

Re: Controlling 3pi Pololu Robot using a Joystick

Postby ODVG90E » Wed Jan 11, 2012 2:46 pm

Today, I ran the first successful motion test of my 3pi using an old Quick-Shot joystick tied to the analog inputs ADC6 and ADC7 as Ben suggested. I can do throttle (forward/reverse) and steering (left/right) with speed control. Thanks Ben!
ODVG90E
 
Posts: 14
Joined: Sun Feb 27, 2011 4:50 am

Re: Controlling 3pi Pololu Robot using a Joystick

Postby ODVG90E » Fri Jan 13, 2012 2:43 pm

I wanted to share part of the system settings (code, electrical schematic) and a small video.

Here the electrical schematic:

Image

Here the code:

Code: Select all Expand


An finally the video:

http://www.youtube.com/watch?v=jaNK4LLzp48

Thank you,
Wilfredo
ODVG90E
 
Posts: 14
Joined: Sun Feb 27, 2011 4:50 am

Re: Controlling 3pi Pololu Robot using a Joystick

Postby ODVG90E » Sun Aug 19, 2012 8:37 pm

Hello Pololu gang! I just wanted to share my new project controlling wirelessly a 3pi using a simple X & Y joystick, a MiniMax C2 module, a couple of XBee modules and a laptop running Termite software as a bridge. Here the link of my video.

http://youtu.be/UmourpBmrLQ

My next project pursues to eliminate the laptop as a bridge and use a XBee module with the joystick.

If you want more detail, please, just let me know. Thank you.

Wilfredo
Humble, TX
ODVG90E
 
Posts: 14
Joined: Sun Feb 27, 2011 4:50 am

Re: Controlling 3pi Pololu Robot using a Joystick

Postby Ben » Tue Aug 21, 2012 9:17 am

Very cool; thanks for sharing your video! I look forward to hearing how it goes without the laptop.

- Ben
User avatar
Ben
Pololu Employee
 
Posts: 3455
Joined: Mon Aug 28, 2006 12:05 pm
Location: Las Vegas, NV

Re: Controlling 3pi Pololu Robot using a Joystick

Postby ODVG90E » Sat Aug 25, 2012 9:09 pm

Hello. I finished my project about a wireless control (Via RF using XBee modules) of a 3pi using a 2-axis joystick.
I ride off the laptop that I was using as a bridge and implemented C codes for the MM51C2 and the robot.
The speed control has 128 steps. I have uploaded a small video of my control with a motion test. Feel free to ask questions.
http://youtu.be/hQgoCTfHOzo
ODVG90E
 
Posts: 14
Joined: Sun Feb 27, 2011 4:50 am

Re: Controlling 3pi Pololu Robot using a Joystick

Postby ryantm » Wed Aug 29, 2012 10:17 am

Hello.

I am glad to see you got it working without the computer. Looks like a very cleanly built project. The music in that video is creepy.

- Ryan
User avatar
ryantm
Pololu Employee
 
Posts: 1268
Joined: Mon May 19, 2008 12:00 pm
Location: Las Vegas, NV

Re: Controlling 3pi Pololu Robot using a Joystick

Postby ODVG90E » Sat Sep 01, 2012 2:04 pm

Than you very much for your comments Ryan. My next step is convert 3pi in a soccer robot. I am now developing the control system for his motion in the playground. My first goal is to make the robot to detect and approach to the ball. I have set a camera pointing from the ceiling to the playground (a table) and I am using a vision software to detect and track the robot and the ball's coordinates. I am sending the X and Y coordinates of the robot (X2,Y2) and the ball (X1,Y1) to a microcontroller, where after some "magic calculations", send throttle commands (forward/reverse) and/or steering commands (left/right) to the robot. Then, the robot will be capable of move from his current position (X2,Y2) to the ball (X1,Y1). One of my best approach for the two-points trajectory requires arc-tangent calculations. Sadly the MM51C2 does not handle trigonometry functions. I really would like to find a controller with that capability. DO you know if Pololu has something to help me here. My plan B is to use a brand different from Bipom. Thanks.
ODVG90E
 
Posts: 14
Joined: Sun Feb 27, 2011 4:50 am

Re: Controlling 3pi Pololu Robot using a Joystick

Postby ryantm » Tue Sep 04, 2012 12:10 pm

Many of our programmable controllers can do trigonometry. The controllers using AVRs (Orangutan or Arduino) can do trigonometry. The mbed controllers are quite a bit more capable, so if you need to do a lot of calculations quickly, you might consider them.

- Ryan
User avatar
ryantm
Pololu Employee
 
Posts: 1268
Joined: Mon May 19, 2008 12:00 pm
Location: Las Vegas, NV

Next

Return to 3pi, m3pi, and Zumo Robots

Who is online

Users browsing this forum: No registered users and 1 guest