Notifications
Clear all

My first robot.

27 Posts
6 Users
4 Reactions
376 Views
robotBuilder
(@robotbuilder)
Member
Joined: 7 years ago
Posts: 2508
 

@lee-g 

I have the car moving with the Pico (using an IR remote). I'm trying to get the comms figured out to use a Playstation 4 controller as the controller for the car.

Let us know how you go. With an RPi I just use a wireless keyboard to type commands or use keys to remote control the robot because I already have that connected to program the RPi (or PC).

I see voice input is easy enough with Python on the RPi.

 



   
Lee G reacted
ReplyQuote
Lee G
(@lee-g)
Member
Joined: 5 years ago
Posts: 109
Topic starter  

@tfmccarthy,

You mentioned in one of your posts that you were looking into using IMU data to help steer your car. I assume that you’re looking at how much ‘yaw’ is in the current direction as opposed to the desired direction (or heading). Could you elaborate on that a little bit?

I have a little (McWhorter’s courses) experience with both the BNO055 and the 6050 IMU’s and was thinking about trying to do something like that with my car. Not quite sure how, yet. Of course, that’ll be another tangent that I’ll go charging off on, rather than sticking to what I already have to do with the thing.  But, what the heck…

I was also interested in your discussion with @robotbuilder about the vision aspects. Eventually, I hope to turn my car into a ‘cat chaser’, using OpenCV and some of the other tools available. But, our cat will probably take one look and go crawl back up in the chair and go back to sleep. Regards, Lee

 



   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 2 years ago
Posts: 513
 

@lee-g 

[I feel like I'm about to bollocks this up.]

You mentioned in one of your posts that you were looking into using IMU data to help steer your car. I assume that you’re looking at how much ‘yaw’ is in the current direction as opposed to the desired direction (or heading). Could you elaborate on that a little bit?

The kit I'm working on is the Elegoo SmartCar v4.0. The kit has a set of tutorial demo sketches that show the basic operation of the various devices and sensors of the kit. It's open source and you can find it on github: (ELEGOO Smart Robot Car Kit V4.0)

As part of my kit review I built and ran all the demo sketches. The the second tutorial set is focused on the motors and moving the car. There are 4 demos and the 4th demo has the MPU corrections. The PDF file document has a reasonable explaination of what the correction is. The driver used is the TB6612, to controls 2 motors.

My understanding of the algorithm is it's divided into 2 parts (3 if you include the calibration)

  1. Convert the raw MPU z-rotation to angular velocity
  2. Adjust the speed of the left and right motors using a differential os the angular velocity.

The first part uses the MPU API getRotationZ and converts it to an angular velocity using the equation:

angular velocity along the Z-axis = (gyro z-axis raw data /131) °/s.

which is expressed in code as

float gyroz = -(gz - gzo) / 131.0 * dt; // Z-axis angular velocity

where

(gz-gzo) is the calibration adjustment of the raw data

131.0 is a known sensitivity factor of the MPU

dt is the derivative time, i.e., the measurement period. The period is ~ every 10 ms

The second part use a differential time a constant to adjust the speed of the motors

// Add the Proportional Constant Kp
int R = (Yaw - yaw_So) * Kp + speed;
if (R > UpperLimit) {
	R = UpperLimit;
} else if (R < 10) {
	R = 10;
}

int L = (yaw_So - Yaw) * Kp + speed;
if (L > UpperLimit) {
	L = UpperLimit;
} else if (L < 10) {
	L = 10;
}

The upper limit is the fastest speed setting. (255).

The new values are then used to set the motors speed

if (direction == Forward) { // Step forward
	AppMotor.DeviceDriverSet_Motor_control(
		direction_just		// direction_A
		, R					// speed_A
		, direction_just	// direction_B
		, L					// speed_B
		, control_enable	// controlED
	);
} else if (direction == Backward) { // Step back
	AppMotor.DeviceDriverSet_Motor_control(
		direction_back		// direction_A
		, L					// speed_A
		, direction_back	// direction_B
		, R					// speed_B
		, control_enable	// controlED
	);
}

I ran the demo successfully and the result was reasonable. Remember that the Arduin UNO has very limited memory so the processing is fairly rough. Still, the car was able to travel about 2-4 feet with a drift of about 1.5 inches. Unfortunately, this drift is cumulative. A more complex algorithm would be able to take the start point into consideration and calculate a straight line as a base. But again, limited memory.

I hope this makes sense. You can look at the code online but I warn you, the published code is, um, quirky. It suffers from language translation issues and takes some getting used to.

I also must mention that due to a problem with the final code, I've replaced the MPU code with the more current library version. The version on github is quite out of date. So I have lots of unit testing to do after I fix the defect that's preventing the code from running. But the tutorial demo still uses the github code.

I was also interested in your discussion with @robotbuilder about the vision aspects. Eventually, I hope to turn my car into a ‘cat chaser’, using OpenCV and some of the other tools available.

Unless I misunderstand OpenCV, you should be able to experiment with the code just using pictures you take on your phone. However, I think it's obvious that you need a full computer (RPi) in order to process the images on "Ruff" the cat-chaser. That's why I want the SmartCar to send the images to a laptop. That's the real reason I got the thing but like every other camera attempt I've made, it doesn't work. I'm crossing my fingers I can get this one to work. I don't want to have to use the phone to do it. But that what seems to be coming out of the codebase, right now.


The one who has the most fun, wins!


   
ReplyQuote
Lee G
(@lee-g)
Member
Joined: 5 years ago
Posts: 109
Topic starter  

@tfmccarthy

OK, thanks. I’ll take a look at the Elegoo code and see if I can make sense of it. I think I understand (in principle) what needs to be done. Your earlier post and this post helps to clear some things up for me. The Sunfounder code has it’s quirks too and it’s taking me some time to convert some of it to micropython. I’m planning for my car to have a RPi on board, along with the Pico for motor control and some of the sensors. The RPi will be there to handle the vision stuff (looking for the cat and keeping her in the ‘bounding box’). Hopefully, by then I’ll have figured out how to take the position of the camera (pan/tilt angle) and use it to turn the car to keep the car going after the cat.  Take care,  Lee



   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 2 years ago
Posts: 513
 

Posted by: @lee-g

I’m planning for my car to have a RPi on board, along with the Pico for motor control and some of the sensors. The RPi will be there to handle the vision stuff (looking for the cat and keeping her in the ‘bounding box’).

How do you plan to have the RPi and Pico talk to each other? Not just the electrical but the command syntax? I'm curious about the division of labor. Will the Pico interpret a command, e.g., "Move left" or perform a command "Set Motor2 speed = 125". Or will this happen on the RPi?


The one who has the most fun, wins!


   
ReplyQuote
Lee G
(@lee-g)
Member
Joined: 5 years ago
Posts: 109
Topic starter  

@tfmccarthy 

That’s part of what I’m working on now. I originally had a UART link and simple commands (forward, reverse, stop), but the mecanum wheels add more complexity (especially when I need to turn or go sideways). I’m still trying to figure out how to make it turn or go sideways. (I need to watch Bill's video again.) Getting the speed right is another problem. But, the BIGGEST problem I’m having right now is that most of my house is carpeted. The mecanum wheels don’t like the carpet. I probably need better motors than the cheapie TT ones I have now (or, just scrap the mecanum wheels altogether).



   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 7 years ago
Posts: 2508
 

@lee-g 

Carpet is not the best surface for wheels.  My robot "slows" down and can stall when it moves from a hard surface to a carpet surface. I can imagine the mecanum wheels getting clogged with fluff over time travelling on carpet.

Ideally your home robot could be used to monitor your home as well as interact with your pets via your iPhone where ever you are. Having a robot to interact with your cat to keep it active seems like a useful addition to a little home security robot.

Commercial robots might be a source of inspiration.

https://keyirobot.com/en-au/blogs/buying-guide/working-late-how-mobile-robots-keep-your-cat-active-while-you-re-away

The Skymee OwlRobot is the same design as that odometry robot the owner added emotions to.

But if you just want to chase cats or other animals away ...

https://developer.nvidia.com/blog/ai-cat-chaser-jetson-tx1-caffe/



   
ReplyQuote
Lee G
(@lee-g)
Member
Joined: 5 years ago
Posts: 109
Topic starter  

@robotbuilder 

That Loona robot is something else! It ‘might’ even keep our cat entertained. My robot barely moves on the carpet, I had to go into the garage (concrete slab) to test it. Not sure what I’m going to do about that. Probably should have read up on the wheels more before jumping into the project. It all seemed ‘so easy’ on paper (but, it never is!). I'll keep plugging along to get the various parts to work together. 



   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 7 years ago
Posts: 2508
 

@lee-g 

That Loona robot is something else!

If you keep looking online you will find it had issues no matter how good it looked including carpet issues!

I’m currently (trying to) building a mecanum-wheeled robot car and am having trouble getting the motors/wheels to turn at the same rated.

So have you enlisted the help of AI? I used it to get my wheels turning at the same rate. You do need to be getting consistent readings. It turned out one of my issues apart from the motors needing slightly different PWM values is that although they turned at the same rate there must have been mechanical issues (home built I guess) which required a trim variable. The working code also used proportional control and that integral thingy.

Maybe you can bump up the baseline motor speeds for carpet?

 

... Sunfounder Zeus car as a present a couple of years ago ...

Looking at the specs for the Sunfounder Zeus car it seems to have everything including an ESP cam !!

And everything neatly arranged and included on a single all in one expansion board.

Maybe just use it on hard surfaces for the time being until you can replace them with conventional wheels.

It seems like a great learning robot. Maybe add an RPi later?

The ELEGOO UNO R3 Smart Robot Car that @tfmccarthy got looks pretty good as well.

 



   
ReplyQuote
Lee G
(@lee-g)
Member
Joined: 5 years ago
Posts: 109
Topic starter  

@tfmccarthy,

So, how goes your Elegoo Smart-car review??

My project is plugging along, I got the car moving (sorta) using the PS4 controller -> ESP32 -> Pico interface. It (the mecanum wheels) sure doesn't like the carpet though, doing all the testing on the (smoother) concrete patio. I’m now working (playing) with it to refine the movements, make it turn in circles, slide sideways, etc., and thinking about where to go next. Probably adding the RPi5 and a camera to get into the vision portion of the project will be next. I’d like to get some FPV working. Converting from the Sunfounder Arduino code to Micropython was easier than I'd thought it would be. Once I got the car moving (from the Arduino code) the rest of it has been my (awful, probably) logic and code.  



   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 2 years ago
Posts: 513
 

Posted by: @lee-g

So, how goes your Elegoo Smart-car review??

Challenging. Very challenging.

I'm very disappointed with the code Elegoo provides for the kit. It doesn't work or at least I haven't gotten it to work. The more I look into it, the less convinced I am that it ever could work. But I haven't found the root cause of the failure yet. What I have found is tons of confused code, undocumented features, misinterpreted functionality, and a lot of inefficient code. Right now it appears that the only viable execution path requires the use of the phone app using the ESP32 WiFi connection.

I went through all the 15 Tutorial demo apps and they all worked, (except the button demo). You can imagine my disappointement when I tried to run the main sketch and didn't work. It doesn't respomd the the IR remote control, although I know it's receiving the signal. I didn't want to try to connect it to my phone until I could review the ESP32 code. But it should respond to the IR Remote. What I'm seeing is a failure to handle a repeat code from the remote.

The current effort is focused on unit testing of the application modules: LED, IRreceiver, Motor, serevos, UltraSound, Optical, and MPU. The Arduino has so little memory and the kit code uses practically all of it, program and data, that I'm forced to try to separate the program logic from the low level hardware interface. The logic code is running under Google Test while the hardware code will run on the Arduino. I have to make an Arduino library of the sensor API code. I have the json and IR tests and I'm working on the LED tests. The LED json strings are undocumented. That was an unpleasant surprise.

And I still have the ESP32 camera code to go through.

I'm becoming convinced that at the end of the day I'm going to have to rewrite the whole thing. I said it would be my summer project, but I wasn't planning to redevelop it.


The one who has the most fun, wins!


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 7 years ago
Posts: 2508
 

@tfmccarthy 

So it is not for the novice wanting to learn how to program what looks like a very complete starter robot base in terms of hardware.  From what you say about memory it seems that a RPi is in order?

I see great reviews on line starting with what I assume is an earlier version covered by Bill.

https://dronebotworkshop.com/building-the-elegoo-smart-robot-car-part-1/

 

 


This post was modified 1 hour ago 2 times by robotBuilder

   
ReplyQuote
Page 2 / 2