Go Back  RCU Forums > RC Cars, Buggies, Trucks, Tanks and more > RC Tanks
Reload this Page >

Custom arduino controls / tracked vehicle driving algorithm (Video)

Notices
RC Tanks Discuss all aspects of rc tank building and driving here!

Custom arduino controls / tracked vehicle driving algorithm (Video)

Old 02-27-2016, 10:29 AM
  #1  
pedzola
Thread Starter
 
Join Date: Dec 2014
Posts: 192
Likes: 0
Received 0 Likes on 0 Posts
Default Custom arduino controls / tracked vehicle driving algorithm (Video)

Hi guys,

I put together an arduino control system for my Torro KV2 a while back, but finally got around to making a video to demonstrate it. The video just demonstrates the driving algorithm - throttle, steering, inertial movement, etc.

Happy to share my code for anyone interested. I think it's a very "realistic" driving algorithm, and also highly precise (at least using the ETO gearboxes). Anyone interested in creating their own electronics for custom projects or etc might find this useful.

https://www.youtube.com/watch?v=VDiT1ozRKQU
My apologies for the very quiet audio track - first time using my new sony action cam and I guess I need to really be speaking right at the camera or have an external mic. You'll have to turn up your speakers.

Anyway let me know if you have any feedback or would like to see the code.

Last edited by pedzola; 02-27-2016 at 11:07 AM.
Old 02-27-2016, 10:56 AM
  #2  
pedzola
Thread Starter
 
Join Date: Dec 2014
Posts: 192
Likes: 0
Received 0 Likes on 0 Posts
Default

Lets see if I can post code.... this is not the complete arduino project but simply the key components of the driving algorithm so you can see how it works...

Code:
    //CONTROLLER INPUT
    throttle=map(CH3, 1065, 1900, 0, 127);    
    steering=map(CH1, 1065, 1900, -127, 127);
    //Throttle: postive forward / negative reverse.  Steering: positive left / negative right.
    //In this example throttle is mapped for the full motion of the stick to be forward, for more precision.
    //For forward/reverse on same stick (center neutral), you'd map -127 to +127 instead.
   
    //INERTIA
    //savedthrottle variable is initialized as 0
    //steermargin is set to 3 (out of 127).
    //The lower the number, the less input variation is required to trigger "smoothing" of the input
    if(abs(throttle-savedthrottle)>steermargin){
      if(throttle>savedthrottle){
        throttle=savedthrottle+steermargin;
        savedthrottle=throttle;
      } else {
        throttle=savedthrottle-steermargin;
        savedthrottle=throttle;
      }
    } else {
      savedthrottle=throttle;
    }
    
    throttle=abs(throttle);
    
    //Map the steering min/max so that it is no greater than the throttle input
    //In other words, the steering is proportional with the throttle
    steermap=map(steering, -127, 127, throttle, -throttle);
    steering=abs(steermap);


    //Set steering left or right, to determine which motor to "brake" in next step  
      if(steering<0){
        steerswitch=1;
      }else{
        steerswitch=-1;
      }
    
    //Depending on left or right, pick which motor to modify.  The other gets the straight throttle input.
    //Inside track braking is simulated by subtracting steering input from the throttle of the inside track. 
    //dirswitch is the forward/reverse switch (+1/-1).  
      if(steerswitch==1){
        ST.motor(2, (throttle-steering)*dirswitch);
        ST.motor(1, throttle*dirswitch);
      }else{
        ST.motor(1, (throttle-steering)*dirswitch);
        ST.motor(2, throttle*dirswitch);
      }
Old 03-01-2016, 06:16 PM
  #3  
ksoc
 
ksoc's Avatar
 
Join Date: Jun 2006
Location: Dana Point, CA
Posts: 1,368
Received 1 Like on 1 Post
Default

Thanks for sharing. Could that module be expanded to include the IR battle system?
Old 03-01-2016, 06:23 PM
  #4  
pedzola
Thread Starter
 
Join Date: Dec 2014
Posts: 192
Likes: 0
Received 0 Likes on 0 Posts
Default

I didnt create any IR battle system but I imagine you could do so using the arduino platform. I have seen some examples of interpreting IR signals. It can be done, but would be a challenge I'm sure.
Old 03-30-2016, 10:27 AM
  #5  
rileyelf
Junior Member
 
Join Date: Jan 2014
Posts: 15
Likes: 0
Received 0 Likes on 0 Posts
Default

I have made a full Tamiya compatible IR battle system using an Arduino processor, I do like your control algorithm, the control looks very smooth! I made my controller so I could create a tank that can battle using brushless motors. It works very well on the low ratio gearboxes but does have a tendency to 'handbrake' turn changing from straight ahead to turn when running at full speed. I'll study your code and see it I can use it to calm my tank down on the turn!
I have since done away with the actual Arduino and made my own board which makes the tank wiring much easier to use.

Drew
Old 03-30-2016, 12:51 PM
  #6  
tankme
 
Join Date: Apr 2006
Location: Elgin, TX
Posts: 1,498
Received 207 Likes on 169 Posts
Default

This looks really cool. I just have no experience at all with Arduino. Wouldn't mind using it in my 1/6th scale KV-2. It runs at 24V for the motors. I guess I'd have to incorporate another lower voltage battery or use a voltage step down circuit to run the Arduino. Maybe a future project once I get some of the other projects done I'm working on.
Old 03-30-2016, 01:37 PM
  #7  
pedzola
Thread Starter
 
Join Date: Dec 2014
Posts: 192
Likes: 0
Received 0 Likes on 0 Posts
Default

Rileyelf, when looking at my code just try to imagine the way a full size tank works.

The inside track is slowed proportional to the throttle and steering inpuTs. And the speed of the outside track is never greater than the throttle input.

The smoothing comes from Comparing each new throttle or steering input to the previous input, and if it is greater than a threshhold (you could call this An inertia factor) then the new input is limited to a certain Level above the last input, and new inputs are generated over time to get you to the actual stick position.

Hope that description helps elucidate the code a bit. The control really is fantastic, very finite, and took several iterations to get there. Would love to see your fInished product.
Old 04-04-2016, 02:18 PM
  #8  
Silverexpress
Member
My Feedback: (1)
 
Join Date: Jul 2004
Location: berkley, MI
Posts: 44
Likes: 0
Received 0 Likes on 0 Posts
Default

Hello Pedzola,

Thank you for sharing. I too am interested in developing my own tank driver.

Dimension Engineering has a youtube channel and they showcase their Kangaroo 2 module for their motor controllers like the sabertooth. You should check it out. It adds PID control. One thing these tanks all need in my opinion.

Are the motors your using have encoders? Hard to tell from the video.

Space is a big consideration for these tanks as well as clean wiring. My tanks have airsoft units, so they extend downwards near to the floor of the hull. Thus, that area must be kept clear. They also have 360 deg turret rotation so wiring must be tucked along side and away or else they'll get yanked.

Currently, I have stock Taigen/HL controllers, a new IBU3, and an Elmod Fusion Pro in my tanks. Of these three control boards, the Elmod was designed to simulate the motion dynamics of a real tank that is coupled to a sound generator, and it does this very well. It even jerks forward during simulated gear changes, and does skid turns like you've programmed.

The worst is the stock electronics, and surprisingly the new IBU3 falls right in the middle, but I'm still getting to know it. It's at firmware rev v0.11 too. I'm hoping down the road the makers focus on the driving dynamics in later revs. But overall these all-in-one boards are great buys.

For my own custom endeavor I'm looking at...Arduino pro minis for R/C -to-motion drives and another for turret controls/video, a Roboclaw motor controller, a Benedini TBS mini for sound, and both a 5.8ghz, and 1.3 ghz fpv system fed from various micro cameras that depict the commander, gunner, and driver views.

It's not going to be cheap! Especially when you compare it to an all-in-one. The only reason I'm taking on this experiment is for the limited space in my smaller tanks - Sherman and Stug III. An all-in-one eats up too much space. In addition, the mcu's are fun to play with and they do simplify the wiring and hardware overall.

Last edited by Silverexpress; 04-14-2016 at 09:26 AM.

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Thread Tools
Search this Thread

Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service -

Copyright © 2024 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.