Maestro controlled by Joystick

Hi All
I am new to Programming and need help to control the Mini Maestro with my Joystick. I have no idea which Information is need so please ask if more is needed.
All the best
Marcel Jung

Hello, Marcel.

One way to do this is to write a computer program that reads the input from the joystick and sends commands to the Maestro over USB. Please see the documentation of your particular operating system for information about how to do the former. Please see the “Writing PC Software to Control the Maestro” section of the Maestro User’s Guide for information about how to do the latter.

This perl program written by one of our customers might be useful to you, though I have not tried it:

You should also take a look at the RoboRealm software, because it does support both joysticks and Maestros so something might be possible there. We did not create RoboRealm and we cannot support it, but here are some links that might be useful for you:

roborealm.com/help/Pololu_Maestro.php
roborealm.com/help/Joystick.php
roborealm.com/forum/index.php?thread_id=3718

–David

Hi Marcel,

If you are looking for a fast way to make a working applications we have developed a simple ActiveX (Robot Lite) for stand alone app development to give you the consolidated functionality of manipulating Servos/Sensors via the Maestro and also events for Joystick to report Axis movement as well as which Button was pressed (numeric interpetation). This is the shareware version which will allow you to do a prototype but limited to sending only 20 commands to the Maestro but no limit on reporting back Joystick movement etc.

Main Weblink
progwhiz.com/Robot_ActiveX.html

Downlaod Link
progwhiz.com/files/RobotOCXLite.zip

Manual
progwhiz.com/files/Robotlite.pdf

Have Fun

Mark

Your shared link found very helpful for me …!
I really appreciate your effort…!
Keep working…!

I know this is an ancient thread, but since it seems to be such a popular topic throughout this forum I thought I would at least share how I got it working in the simplest way possible(for me). It is not an elegant solution, but it is fairly simple and doesn’t really have and difficult code to contend with. My goal was to get the maestro servo controller to run a couple of wheel motors from gamepad/joystick inputs connected to a linux mint computer using basic sequences pre-scripted in the Maestro Control Center. Ultimately, the intent is to create a better version of internet control for our robot:(see old post: Autohotkey to Mini Maestro 6 for simulatenous servo control)

The previous method using a Windows PC and autohotkey worked, but it was always slow and buggy used over VNC. If you read the previous post you will learn that I have almost no coding or linux experience, and I think this next method will continue show that. Regardless this works!

Hardware:

  • Micro Maestro 6-channel
  • Linux Mint 19 Cinnamon
  • GameSir T1s wireless gamepad, but also tested and works with GameSir G3s. I tried to get an Xbox One controller with wireless PC adapter to work, but Mint failed to recognize the adapter.
  • Our big robot running some PWMs to wheelchair motors, but I also have a tiny robot I am using as a test bed with two continuous rotation mini servos.

Software:

  • Maestro Control Center(MCC) and UscCmd
  • Xboxdrv
  • mono
  • a small bash script to run a mono command to run UscCmd

Before really getting the gamepad to work I followed the Maestro documentation thoroughly to get USB Dual Port configured in Linux, and set within MCC. I then created the basic sequences I need to control our robot, like forward, reverse, turn, etc, and copied those sequences to the maestro’s script. Once that was complete I knew that those sequences could be run from a terminal using the command: mono UscCmd --sub 1 for example.

Here is the maestro script…its a mess I know:


### Sequence subroutines: ###

# Sequence 0
sub Sequence_0
begin
 800 1500 1500 5 5 0 0 frame_0..5 # stop
repeat
  return
# Sequence 1
sub Sequence_1
begin
  800 2000 2000 5 5 0 0 frame_0..5 # forward
repeat
  return
# Sequence 2
sub Sequence_2
begin
  800 6400 6400 5 5 0 0 frame_0..5 # reverse
repeat
  return
# Sequence 3
sub Sequence_3
begin
  800 6000 5600 5 5 0 0 frame_0..5 # turnleft
repeat
  return
# Sequence 4
sub Sequence_4
begin
  800 5600 6000 5 5 0 0 frame_0..5 # turnright
repeat
  return
# Sequence 5
sub Sequence_5
begin
  800 6500 5600 5 5 0 0 frame_0..5 # spinleft
repeat
  return
# Sequence 6
sub Sequence_6
begin
  800 5600 6500 5 5 0 0 frame_0..5 # spinright
repeat
  return
# Sequence 7
sub Sequence_7
begin
  800 5800 5600 5 5 0 0 frame_0..5 # SlightLeft
repeat
  return
# Sequence 8
sub Sequence_8
begin
  800 5600 5800 5 5 0 0 frame_0..5 # SlightRight
repeat
  return
#  Sequence 10
sub Sequence_10
begin
 800 1500 1500 5 5 0 0 frame_0..5 # stop
repeat
  return

sub frame_0..5
  5 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

Working from the other end of this task I decided to get a gamepad working and found my best luck with Xboxdrv. The funny thing is that I would use Mint’s Software Manager to install Ubuntu-Xboxdrv which also installs Xboxdrv, but ultimatley I had to unistall just the Ubuntu-Xboxdrv package to get this working. Jstest only see the gamepad when both are installed, but only Xboxdrv is needed to get this working. After a week of searching and reading I finally figured out the missing links between Xboxdrv and UscCmd. Xboxdrv is capable of running a bash script with a button press. Using a modified default xboxdrv config file(renamed to test.xboxdrv in this case) I am able to execute different bash scripts when gamepad buttons are depressed.

# Default Example
# ===============
#
# This is simply the default xboxdrv configuration, replicated as INI
# file with a few comments

[xboxdrv]
# Debugging output and verbosity
# silent    = false
# verbose   = false
# usb-debug = false

# timeout = 25

# config = otherconfig.xboxdrv
# alt-config = otherconfig.xboxdrv

# busid = 
# devid = 

# Chatpad 
# chatpad         = false
# chatpad-debug   = false
# chatpad-no-init = false

# controller-id = 0
# detach-kernel-driver = true
# device-name = <not implemented>
# evdev = 
# evdev-debug = true
# evdev-grab = true
# extra-devices = true
# extra-events = true
# force-feedback = 

# Headset
# headset = false
# headset-debug = false
# headset-dump = /tmp/out.raw
# headset-play = /tmp/in.raw

# instant-exit = false
# led = -1
# next = true
# next-controller = true
# no-uinput = true
# product-id = -1
# quiet = false
# rumble = false
# rumble-gain = 255
# rumble-l = -1
# rumble-r = -1

# deadzone = 0
# deadzone-trigger = 0
# mimic-xpad = true
# mouse = true
# square-axis = true
# trigger-as-button = true
# trigger-as-zaxis  = true
# dpad-as-button = true
# dpad-only = true
# dpad-rotation = 45
# four-way-restrictor = 
# guitar = true

# vendor-id = -1
# wireless-id = 0

[xboxdrv-daemon]
# detach = true
# on-connect = /home/juser/bin/on-connect.sh
# on-disconnect = /home/juser/bin/on-connect.sh
# pid-file = /var/run/xboxdrv.pid

[autofire]

[axis-sensitivity]

[axismap]

[buttonmap]

[calibration]

[evdev-absmap]

[evdev-keymap]

[modifier]

[relative-axis]

[xboxdrv]
ui-clear = true

[ui-axismap]
X1 = ABS_X
Y1 = ABS_Y

X2 = ABS_RX
Y2 = ABS_RY

LT = ABS_BRAKE
RT = ABS_GAS

DPAD_X = ABS_HAT0X
DPAD_Y = ABS_HAT0Y

[ui-buttonmap]
start  = BTN_START
guide  = BTN_MODE
back   = BTN_SELECT

A = exec:/home/"user"/Documents/maestro-linux/forward_sub_1.sh
B = exec:/home/"user"/Documents/maestro-linux/reverse_sub_2.sh
X = exec:/home/"user"/Documents/maestro-linux/stop_sub_10.sh
Y = BTN_Y

DU = exec:/home/"user"/Documents/maestro-linux/forward_sub_1.sh
DD = exec:/home/"user"/Documents/maestro-linux/reverse_sub_2.sh
Dl = exec:/home/"user"/Documents/maestro-linux/stop_sub_10.sh

LB = BTN_TL
RB = BTN_TR

TL = BTN_THUMBL
TR = BTN_THUMBR

# EOF #

You can see where the A, B, and X are mapped to execute a bash script called forward_sub_1.sh, reverse, stop. I also mapped the d-pad up down and left buttons similarly in a subsequent test. “user” obviously needs to be changed to your username if you want to try this out. I just so happen to have stored all the Maestro files in the Documents folder, but I am sure that location could and probably should be changed to another directory for reasons I am unaware of yet. Next the bash scripts, which are simply mono commands to run the previously recorded sequences or subroutines with UscCmd. Simply mono UscCmd --sub 1 saved as forward_sub_1.sh for example, which is the subroutine to move our robot forward in this case. I have not created all the bash scripts I need at this point, or mapped additional executions of those scripts, but I think you see how easy that should be.

Assuming your Maestro servo controller is already plugged in and running correctly on Dual Port USB, you simply plug in the GameSir wireless usb dongle, turn on the gamepad with it’s mode set to the funny looking X symbol, open a terminal in the path where UscCmd and the bash scripts are stored…in my case /home/"user"/Documents/maestro-linux and run the command

sudo xboxdrv -c /home/"user"/Documents/test.xboxdrv

This command starts xboxdrv and loads the modified config file that has all the button mappings I posted above. Viola, the robot goes forward when a d-pad up is pressed, and stops when d-pad left is pressed. Ugly, but it works :rofl:

My next steps will be to either get the xboxdrv filter called “click-release” to run the stop routine when any button is released or I may focus my efforts on the left joystick where joystick center runs the stop routine. After that, I will probably attempt to separate this setup into two linux computers where one small computer lives onboard our robot (mintbox with 4g facet card), and the other is connected to the gamepad running these commands remotely over vnc or ssh or other. I don’t really know where to make such a split in this chain of wrappers, but my previous experience using autohotkey in windows would suggest that it might be trickier than I hope. If I get lucky and somehow figure that out, I might take a swing at running this on a an android phone connected to the GameSir over bluetooth.

Well, that’s my strange and messy method for all that might need it. If you see things that I did completely wrong, or you think there are simple tweaks that could short-cut or streamline this into a more elegant solution, then please share and have no mercy with me. This is a hack-job and I know it.

One last thing…I think I might have promised a video in the last thread. Unfortunately, at the time this project happened we did not have the Maestro controls working, but we have another project coming up that should benefit from these latest developments.

4 Likes

Hello, jcoco3.

Thanks for returning to the forum to share the details of how your system works!

-Jon