Rover with arm

I am building a A4WD2 rover with a AL5D arm w/wrist rotate and am using a botboarduino as the micro controller. I will be using a Playstation controller for RC control. The tutorials available only shows the rover/arm configuration using a bot board as the micro controller. I was wondering if there is code available in Arduino’s library for my configuration. Thanks.

Hi,

All of the sample code available for Lynxmotion products is available on our GitHub here. We have a specific repository for rover related projects. Here is an example of using a BotBoarduino with a PS2 controller and an AL5 arm on the rover.

Make sure your connections for the PS2 controller matches the code here. Also, you may want to check where you to wire your servomotors for the arm here and the control for a RC-compatible motor driver (such as a Sabertooth) here.

The code related to the arm is based on a basic 2D inverse-kinematic system.

In the main loop, you can check which controls of the PS2 are assigned to which part of the robot.
Robotic arm controls: the right side joystick is related to the end-effector X/Y position. The left side joystick is controls the wrist angle and the base rotation. The R1 button and R2 button control the the gripper. The L1 button and L2 button control the wrist rotation. The D-pad up button & down button control the speed of execution of the arm moves.
Rover controls: the red/circle button makes the rover turn right. The pink/square button makes the rover turn left. The blue/X button makes reverse motion. The green/triangle button makes forward motion. If no buttons are pressed, the motors are placed in idle instead.

If you want to activate the debug output, uncomment this define.

Sincerely,

Thanks for the great information. I’m a beginner, how do you install the code from github to the botboarduino?

Hi,

You will need to perform a few simple steps to ensure everything works well. Here they are:

]Check your Arduino IDE and make sure you have the latest version. At the time of writing this response, it was 1.8.2. If needed, you can get an up-to-date copy here./:m]
]Install the PS2X library from the Lynxmotion GitHub. Here is a direct link to PS2X_lib.zip. Once downloaded, install it in Arduino IDE using this guide. If you already had a PS2X library installed, please remove it first (in “Documents” > “Arduino” > “libraries”./:m]
]Download the code for the rover (right-click, save as…) from the Lynxmotion GitHub. Double-click the file to open it in the Arduino IDE./:m]
]Go to the Tools menu and choose the right Board (Arduino Duemilanove or Diecimila), Processor ( ATmega328 ) and Port.
2017-05-18 - Using BotBoarduino.png /
:m]
]You can then click the “upload arrow”. The code should compile with no issues and upload the to the BotBoarduino./:m]

If it does not and you get an error message, please go to File > Preferences and activate verbose mode for both compile and upload. Then, try again. If it fails, copy everything in the console at the bottom into a new file (use notepad or similar) and attach this file to your reply (do not copy & paste it into the message directly!). You can attach files in Full Editor mode.

Sincerely,

Thank you for all your help! I’ll be giving it a try soon.

Would not upload. Hopefully I attached the error message correctly.
Error message.txt (12 KB)

Disregard error message, I thought the USB connection would supply the necessary power for the Botboardino but once I turned the battery on code was uploaded fine. My bad. The forward and reverse controls are reversed, not sure why that is, maybe change something in the code? Also, there seems to be a problem with the x/y axis control, when I raise or lower the arm to a certain high or low point the arm will stop responding and go back to the idle position. The base rotate servo jitters around before this happens. I’m pretty sure I assembled the arm properly and the arm rotates with the joystick or manually with the power off just fine. Suggestions?

Hey,

Here are answers to your questions and comments (inline):

Indeed, the error message indicates the microcontroller is unresponsive. This is usually caused by the board being either not connected or not powered properly.

There are a few things you can check and then decide what you wish to change. The first thing to know is that the control from the PS2 > Arduino > Sabertooth > Motor have multiple steps where they can be different than expected.
Let’s start with the simplest part: the physical connection from the Sabertooth to the motors. How you wired the motors to the H-bridges of the Sabertooth will change how they respond. Therefore, you could simply reverse the connections to each motor (+ with -). This would cause the voltage polarity sent to the motors to be reversed.
Another potential problem would be where the RC channels from the Saberbooth are connector to on the Arduino. This is likely not the one you’d want to change, as it does something a bit different than the previous point.
Finally, we have the Arduino code that produces the RC signal. Of course, you can change those values to be different, depending on your needs. We greatly recommend to experiment with those to get a good understanding of how it produces motion. You may want to try one wheel at a time. Also, please note the code uses “mixed mode” by default, so make sure your Sabertooth is in mixed mode too or change the code here.
Therefore, any changes to those parts above will affect the way the driving will work based on the PS2 controls you press.

In this case, the best would be to provide us with a short video showing the arm in action and with the different problems as they happen. You can attach it to your reply directly if it is small enough or share it to us through a video sharing web site, such as Youtube.

Sincerely,

youtu.be/30gvxVCUXFE
Hopefully this gets to you, never done this before.

Hey,

Thanks for the video.

We’ll review this and get back to you.

Sincerely,

Hi,

First, we determined that some fixes were required to the code.
We’ve increased the size of the dead-zone for joysticks, which should eliminate most jitters. You can see the parameter for dead-zone size here.

Also, we’ve added a line that was missing to prevent the processing of invalid gamepad data (such as when the gamepad is not paired).

They two modifications should help greatly. We tested those with an arm using a PS2 V4 and it worked well with no jitters.
That being said, we also noticed a slow down on the base rotation in the clockwise direction.

This was caused by a rounding error in the original code when converted from float to integer. Negative values created a larger delta of rotation than the positive values in some rounding cases.
They should now both work at the same speed since the values are now first fixed using floor/ceiling before been applied.

Please try the new code and let us know if this improves the situation!

Sincerely,

I’ll give it a try this weekend and I’ll let you know the results. Thanks much!!

We are looking forward to see if it helped fix your problem. Feel free to make another video and show off the results (whether good or in need of more help!). :wink:

Here ya go!
youtu.be/y6hEllzqRaE

Hi,

Thanks again for another very useful video!

For the jittering, it seems to simply be an issue with the base motor itself. This we can replace for you at no cost. Someone from our exchange’s department will contact you at the email address you use for the forum shortly.

The “position reset” is most likely a power issue. The code example you are using only ever goes to this position during start-up. What this means it that the BotBoarduino resets.
This can usually happen when the battery does not provide the proper voltage (if it is too discharged) or if there are other electrical issues with the circuit that would cause the BotBoarduino’s voltage input to drop too low, causing a brownout.
Would it be possible to get some clear pictures of the electronics, their wiring and make sure the jumpers and connections are clearly visible.
As for the batteries, could you check their current voltage with a multimeter?

Concerning the wrist rotate, this is due to the way the IK code works and it is normal behavior. By default, the code limits the wrist angle downwards quite a bit (I think the range changes based on the X/Y) position. You can change the to give a larger range.
You can also detach the wrist angle bracket and reattach it with the servo offset a bit, that way you will get a lower minimum angle without having to change the code.

Sincerely,

Here ya go, maybe a bit of overkill but wanted to make sure you could see as much as possible. I checked the 6V battery with a multimeter before charging and it was at 3 volts. Fully charged it registered 6.93 volts. For the heck of it I checked the 12V battery after charging it and it registered 14 volts. So it looks like my batteries are good. I also tried the arm again after charging the battery but still the same problem.








Hey,

Thanks for the amazing pictures! :slight_smile:

They made it easy to spot an issue that is most likely responsible for your power issues / BotBoarduino resetting (see attached image, point 1).

At these two points, you have the jumpers set to 5V (the default position of the jumpers). This makes it so your servomotors are being powered by the on-board 5 V DC regulator (instead of directly from the battery).
Unfortunately, this regulator cannot provide enough power and eventually cuts-off, which resets the BotBoarduino. Simply change those two jumpers to VS, which will power your servomotors from the battery instead of the on-board regulator.

You can read more about these jumpers in the BotBoarduino manual. The jumpers are discussed at point 7. This would very likely resolve the reset issue and allow you to use the arm properly.

Let us know how it goes!

Sincerely,

Success!! Works perfectly, even seems to have taken some of the jitter away from the base rotate servo (BTW, I forgot to thank you for sending the replacement servo, thanks much, it’ll be here tomorrow.)! I overlooked those jumpers somehow and it makes sense why it was causing the problem. You guys really know your stuff! Thanks for your patience and help, it was a great learning experience for me.

If I could just indulge you for a couple more questions :wink:.

  1. Would it be possible to add a pan and tilt to the rover ( I believe there are still two servo pins available) using the D pad to control it instead of controlling the servo speed? I probably couldn’t write the code yet if it can be done, my ultimate goal is to be able to write code and I’m studying it but that’s a ways off.
  2. A future project for me is building a hexapod (AH2 or BH3) and I was wondering if there is example code anywhere for adding an arm to this platform. All I’ve been able to find in GitHub is Phoenix code for just making it walk. Again thanks and have a good one!

That is some great news! We’re glad you got to learn some new stuff on the way too. Robotics is certainly one of the harder things to get into as a hobby since it is multidisciplinary… but if you like challenges it is great fun!

Yes, that is certainly possible! And, it would not be much work/modifications since most of the code you’d need is already there for you if you look at it carefully. If you need a small pan & tilt, we offer the kit RB-Lyn-74 (there is also a beefier version known as RB-Lyn-316).

Here are some pointers to get you started with experimenting:

  1. To control a servomotor channel, you should also define the pin in a header somewhere (instead of typing in numbers directly). That way, when you need to change it, you only change it at one place (and do not forget others elsewhere!). There are examples of those definitions here. According to these, pins 2,3,4,10,11,12 and A2,A3 are in use. That leaves you pins 5,13 and the remaining analog pins. Please note that the Servo library will be driving all of those in software since most of those pins do not have PWM output. Therefore, it may not be as responsive (just a bit) as you add more pins/servos to it. This is one of the reasons the SSC-32U is so helpful :: it offsets all that heavy-lifting off the Arduino.

  2. Next, you will need to add a servo object using the Arduino Servo library, such as is done here.

  3. Afterwards, usually in the Setup() function (so that it is only done once), you will attach your Servo object (initialize earlier at #2) to your channel (defined earlier at #1). Here is an example.

  4. Once the Servo object is attached, you can send a pulse to it by using the writeMicroseconds(value) function. Of course, the value is an integer in µs, usually ranging from 1000-2000 µs for older servomotors and 500-2500 µs for newer ones (usually those that support a full 180 degrees rotation).

  5. Now that you can create and use a Servo object (steps #1-#4), all that’s left is to get your controller to change its values. This can be done by looking at the existing code for using the PS2 controller’s DPad here (up) and here (down). You can simply comment the code in there and add your own instead. Of course, if you want to keep track of your pan & tilt values, you may want to declare 2 new variables (at the top with the others) to hold those values.
    You can then increment / decrement the value and then write it to the motor using the writeMicroseconds(value) mention above. Here is an example of that.

Not that I know of. That being said, it can certainly be done. At this point though, it may max out what an ATmega328P can do, though (the microcontroller chip used in the BotBoarduino). This is where you may want to swap the BotBoarduino for a Raspberry Pi 3 and connect it by USB to the SSC-32U. You could use 18 channels of the SSC-32U for the hexapod and 6 other channels for the robotic arm and still have 6 outputs to spare! Also, if you wish to use analog sensors, such as a IR range finder (such as this or this) you can connect them to the 8 input pins of the SSC-32U (A,B,C,D,E,F,G,H) which can then be read sending the command “Vx” (ex: VA for input A) by the RPi. The value is send back as a 8-bit binary value (0-255 representing 0-5 V DC). Check page 34 of the SSC-32U manual for more details.

Yeah, that would be the only code we really currently offer for these platform. Feel free to use it as a reference, modify it and make a new branch/fork of it on GitHub and make a pull request when you have a new version that works! We are happy to have external contributors.

Good luck with it and let us know how the pan & tilt goes!

As always, interesting and helpful information! Thanks, you guys are awesome! If I try the pan and tilt I will let you know how it goes. Take it easy!