BB-8 Stabalizer

Hey guys totally new to arduino but not to RC or 3d printing blah blah
My project is a life size bb8. and although there are a few different ways of driving him out there they are all expensive so i am making my own simpler drive system.

It is in simple terms a 2 wheel drive robot inside a ball (i have stabilizing wheels at the front and back but they are not driven wheels)

Ill list my equipment first.....

RC transmitter FlySky 6x 10 ch
FlySky 10 ch receiver.
L298n motor driver (controlling dual motors)
2 servos for the head movement
arduino uno
MPU 6050

I have 2 ways id like to build this picking the easiest way for the final project.

  1. have basically a radio controlled balance bot inside a ball.

However i cant find any balance bot sketch's that are also Radio Controlled using an rc receiver and the l298n & mpu6050.

I have found alot of rc cars Sketches and i have tried them just to test every thing but i need stabilization.

  1. I could use the sketch i already have to drive the robot by radio control. the issue is when you stop he wobbles. so this option would be to stabilize just the head of the robot to give the illusion that he is balanced while the ball wobbles.

The head is controlled by 2 servos to go forward and back left and right. basically a 2 servo gimbal attached to the drive inside the ball. I have also found a sketch (not radio controlled) that does this and it works good. so if i could add 2 servo stabilazation to the current sketch which is rc contolled he would look good

So could someone... A. help me build a RC controlled 2 wheel balance bot or b Add basically a 2 servo gimbal inside the ball to balance the head. using two servos and RC control.

I would prefer #2

I hope this was enough info I know how forums work and i tried to be clear PLEASE HELP.

If the bot already drives as desired but wobbles, all you need to do is to adjust the PID parameters so that it doesn't wobble. Do you have the code for your drive system? If so, please post it.

it does drive and i was not using any pid controls at all i am re working the code but i am horrible at this. right now i have forward left and right but no reverse. its just a rc car code i downloaded
I do understand pid tuning on model aircraft but it is easy with the software i use for that lol
i do apologize posting here with very little knowledge

RC_car.ino (1.83 KB)

Here’s the cleaned up code:

#define rc3 A0  // receiver chanel 3 on pin 9
#define rc4 A1  // receiver chanel 4 on pin 10
#define spd 3   // PWM pin on L298N
#define spd1 11 // PWM pin on L298N
#define pin1 4  // in 1 pin on L298N to pin 4 on ARDUINO
#define pin2 5  // in 2 pin on L298N to pin 3 on ARDUINO
#define pin3 12 // in 3 pin on L298N to pin 12 on ARDUINO
#define pin4 13 // in 4 pin on L298N to pin 13 on ARDUINO


int ch3; // value of chanel 3 of the receiver
int ch4; // value of chanel 4 of the receiver


void setup()
{
  Serial.begin(115200);
  
  pinMode (rc3, INPUT);
  pinMode (rc4, INPUT);
  pinMode (spd, OUTPUT);
  pinMode (spd1, OUTPUT);
  pinMode (pin1, OUTPUT);
  pinMode (pin2, OUTPUT);
  pinMode (pin3, OUTPUT);
  pinMode (pin4, OUTPUT);
  
  digitalWrite(pin1, LOW);
  digitalWrite(pin2, LOW);
  digitalWrite(pin3, LOW);
  digitalWrite(pin4, LOW);
}

void loop()
{
  ch3 = pulseIn(rc3, HIGH);
  ch4 = pulseIn(rc4, HIGH);
  
  if (ch3 > 1700)
  {
    digitalWrite(spd, HIGH);
    digitalWrite(spd1, HIGH);
    digitalWrite(pin1, LOW);
    digitalWrite(pin2, HIGH);
    digitalWrite(pin3, LOW);
    digitalWrite(pin4, HIGH);
  }
  else  if (ch3 < 1400)
  {
    digitalWrite(spd, HIGH);
    digitalWrite(spd1, HIGH);
    digitalWrite(pin1, HIGH);
    digitalWrite(pin2, LOW);
    digitalWrite(pin3, HIGH);
    digitalWrite(pin4, LOW);
  }
  else if (ch4 < 1400)
  {
    digitalWrite(spd, HIGH);
    digitalWrite(spd1, HIGH);
    digitalWrite(pin1, LOW);
    digitalWrite(pin2, HIGH);
    digitalWrite(pin3, LOW);
    digitalWrite(pin4, LOW);
  }
  else  if (ch4 > 1700)
  {
    digitalWrite(spd, HIGH);
    digitalWrite(spd1, HIGH);
    digitalWrite(pin1, LOW);
    digitalWrite(pin2, LOW);
    digitalWrite(pin3, LOW);
    digitalWrite(pin4, HIGH);
  }
  else
  {
    digitalWrite(pin1, LOW);
    digitalWrite(pin2, LOW);
    digitalWrite(pin3, LOW);
    digitalWrite(pin4, LOW);
  }
}

You’ll need some sort of closed loop controller (i.e. PID) where the setpoint is defined by your RC transmitter signal.

Read up on how to implement PID for Arduinos.

Also, I’m having a really hard time visualizing your physical setup. Can you post some pictures of your project?

for sure give me a minute but im going to try and find a different code that has reverse as well as rc controls. then ill post that so please dont waste your time.
i think with the pictures youll realize the other option to stabalize which is the tall 2 servo arm.
i would use the mpu 6050 and two servos which i can find code for but nothing that allows rc control as well
so if i can get what you are trying to help me with work ill be good.
rc control skid steering with a pid loop to stabalize it
oh and ty so much for replying

bb8_hamster_type.jpg

1.jpg

OK SO HERE IS THE BASIC CODE i will be using… drives the way i want with perfect controls. need to add the mpu6050 some how to make it…um…gooder

FF761ALII7PDOCE.ino (9.61 KB)

You know the robot in the movie is mostly CGI? You don't see it wobble because they edit out or paint over that part.

From what I know about the movie prop, your mechanism is more complex than what they used. The head just rides on the magnet inside the ball and is basically uncontrolled when the prop is rolling.

LOL actually the robot is mostly real and controlled in the movie. 10 were made for the movie 2 died from sand while filming in the desert. and when filming wrapped they gave the RC controlled bb8 droid the same applause. Unfortunately since they have released the drive drain images, which costs between 2000-3000 to build yourself as many have done, i have decided it is to much for my budget
Oh and here is some pictures of the two different drive trains. one uses arduinos

d2.jpg

MorganS:
You know the robot in the movie is mostly CGI?

Actually, it isn't.

https://www.google.com/search?q=is+bb8+cgi

I remember reading that same Wired article years ago. The definitive statement in the article is "At least not entirely [CGI]"

I can't be bothered to watch the movie again, but how many times does it stop onscreen? Only 1 or 2 times? Can you be sure that any of those times don't have any CGI hiding the "wobble"?

I think it's a great idea to use an IMU as a stabilizer. I suspect that it's going to take a lot more tuning than a basic 2-wheeled balance bot. I would focus on controlling the decelleration to a stop.

Consider that the derivative of position is speed and the derivative of speed is acceleration. The derivative of acceleration is "jerk" and the derivative of jerk is "snatch". Control jerk so that it doesn't come to a rapid immediate stop with a wobble. Or maybe just control acceleration.