Joystick and Gamepad
Most PC compatible joysticks and gamepads can be used as a cheap and simple solution for moving a robot. This is useful for quickly teaching positions.
Required are:
- DirectX compatible gamepad or joystick
- PC with CPRog or iRC connected to the robot
Earlier versions of CPRog/iRC have a static button binding. While version 13-030 and later can be configured. This article explains both.
Default button binding
The following button binding is used on versions up to 13-030 and in later versions when no custom bindings are defined: (read the stick assignment as joint/cartesian/platform)
- Left thumb stick horizontal: A1/Y/X; alternative A4/B/X
- Left thumb stick vertical: A2/X/Y; alternative A5/A/Y
- Right thumb stick vertical: A3/Z/Ori; alternative A6/C/Ori
- Right thumb stick horizontal: velocity override (not assigned since V13-030)
- L1 and R1: velocity override (since V13-030)
- L2: Change motion mode (joints, cart base, cart tool, platform)
- R2: Alternative assignment of thumb sticks while pressed
- right buttons:
- top: touch-up (since V13-030)
- right: add joint command
- bottom: add linear command
- left: remove selected command (since V13-030)
- left buttons:
- top: select previous command (since V13-030)
- top: select next command (since V13-030)
Button binding configuration
Since version 13-031 the configuration can be changed via the project configuration file.
The following example represents the standard configuration as described in the previous article:
<Joypad Bias="10.0">
<Button Num="0"><ProgramEdit Change="TouchUp" /></Button>
<Button Num="1"><ProgramEdit Change="AddJoint" /></Button>
<Button Num="2"><ProgramEdit Change="AddLinear" /></Button>
<Button Num="3"><ProgramEdit Change="Remove" /></Button>
<Button Num="4"><Override Change="Lower" /></Button>
<Button Num="5"><Override Change="Higher" /></Button>
<Button Num="6"><JogMode Mode="Next" /></Button>
<Button Num="7"><AltJoints Toggle="False" /></Button>
<Button Num="1000"><ProgramEdit Change="Prev" /></Button>
<Button Num="1002"><ProgramEdit Change="Next" /></Button>
<Analog Num="0" Bias="-1">
<Jog Alternative="False" Joint="0" Cartesian="Y" Platform="X" InvertJoint="True" InvertJointAlt="True" InvertCartesian="True" InvertPlatform="True" />
<Jog Alternative="True" Joint="3" Cartesian="B" Platform="X" InvertJoint="True" InvertJointAlt="True" InvertCartesian="True" InvertPlatform="True" />
</Analog>
<Analog Num="1" Bias="-1">
<Jog Alternative="False" Joint="1" Cartesian="X" Platform="Y" InvertJoint="True" InvertJointAlt="True" InvertCartesian="True" InvertPlatform="True" />
<Jog Alternative="True" Joint="4" Cartesian="A" Platform="Y" InvertJoint="True" InvertJointAlt="True" InvertCartesian="True" InvertPlatform="True" />
</Analog>
<Analog Num="5" Bias="-1">
<Jog Alternative="False" Joint="2" Cartesian="Z" Platform="Rot" InvertJoint="True" InvertJointAlt="True" InvertCartesian="True" InvertPlatform="True" />
<Jog Alternative="True" Joint="5" Cartesian="C" Platform="Rot" InvertJoint="True" InvertJointAlt="True" InvertCartesian="True" InvertPlatform="True" />
</Analog>
</Joypad>
The Button entries describe the digital buttons, identified by a number: <Button Num="0"></Button>
- 0: right buttons, top
- 1: right buttons, right
- 2: right buttons, bottom
- 3: right buttons, left
- 4: L1
- 5: R1
- 6: L2
- 7: R2
- 8: Select
- 9: Start
- 1000: left buttons, top
- 1001: left buttons, right
- 1002: left buttons, bottom,
- 1003: left buttons, left
The Analog entries describe the thumbsticks or joystick, also identified by a number (see below). An individual bias can be set to prevent drift, otherwise the default bias set in the <Joypad Bias="10.0"> entry is used.
- 0: left stick horizontal
- 1: left stick vertical
- 2: right stick horizontal
- 3-4: unused(?)
- 5: right stick vertical
One or more functions can be assigned to each button or analog input. If multiple functions are assigned they will all be executed.
The following actions are available:
- Jog
<Jog Alternative="False" Joint="1" Cartesian="X" Platform="Y" InvertJoint="True" InvertJointAlt="True" InvertCartesian="True" InvertPlatform="True" />
Jogs an axis depending on the selected motion mode (joint, cart base, cart tool, platform). "Alternative" can be set for an alternative set of buttons which is switched by the AlternativeJoints action. First robot joint is 0, first external axis is 6, -1 for none; values for Cartesian are X,Y,Z,A,B,C,None; values for Platform are X,Y,Z,Rot,None
- JogMode
<JogMode Mode="Next" />
Changes the motion mode: joint -> cart base -> cart tool -> platform; Values for Mode are: Next, Prev, Joint, CartBase, CartTool, Platform.
- DOut
<DOut Num="20" Mode="Toggle" />
Changes the digital output specified by the number (DOut1 is number 0 etc). Values for Mode are: Toggle, SetHigh, SetLow, HoldHigh, HoldLow. Hold will reset to the opposite value after the button is released.
- GSig
<GSig Num="0" Mode="Toggle" />
Changes a global signal. see DOut.
- ProgramControl
<ProgramControl Mode="Start" />
Starts, pauses or stops a program. Values for Mode are: Start, Pause, Stop.
- ProgramEdit
<ProgramEdit Change="AddJoint" />
Program editor actions: Values for Change are: First, Last, Next, Prev, TouchUp, AddJoint, AddLinear, Remove, Save. First, last, next and prev change the selected command and thereby the position at which new commands are added. TouchUp updates the selected command. Remove removes the selected command. Save saves the program.
- MissionEdit
<MissionEdit Change="AddPosOri" />
Mission sequence actions: Values for Change are: AddPos, AddPosOri, Remove, Save. The add commands add a waypoint at the current position. Currently no navigation like ProgramEdit is available.
- Override
<Override Change="Higher" />
Changes the velocity override. Values for Change are: Higher, Lower.
- AlternativeJoints
<AltJoints Toggle="False" />
Selects the alternative axis assignment. If toggle is false the standard set is re-selected after the button is released.