## 3 Wheel Omni PID correction

2 posts / 0 new
Author
Message
```            req_angle=45;
velocity_x=cos(req_angle*val);  velocity_y=sin(req_angle*val);

velocity_1 = - velocity_x*(sin(theta*val))           +    velocity_y*(cos(theta*val)) + radius*omega;
velocity_2 = - velocity_x*(sin((theta + 120)*val))   +    velocity_y*(cos((theta + 120)*val)) + radius*omega;
velocity_3 = - velocity_x*(sin((theta + 240)*val))   +    velocity_y*(cos((theta + 240)*val)) + radius*omega;```

These are my equations for the three wheels of the omni robot. Required angle signifies the angle in which we move with respect to the x axis. Theta stores the orientation of the bot using an imu, which is zero on the x axis. They are correct.

I dont know what do I do with the term omega and on what should I apply my PID correction.

Here is a rough and general code Ive written for PID which ofcourse doesnt run at the moment.

```int pid()
{
//kp, ki, kd store some constant values
int error = target_position - current_position;

int integral = integral + error;
int derivative = error - last_error;
int pwm= (kp * error) + (ki*integral) + (kd*derivative);

if(pwm>255)
pwm=255;
if(pwm<-255)
pwm=-255;

if(pwm>0)
direction=clockwise;
if(pwm<0)
direction=anticlockwwise;
else
brake;

int last_error = error;

}```

Total votes: 0

I'm not an "omni" person, but you might want to just start with well-known PID information to start with.  Doesn't Atmel have an app note?  I've always found https://www.wescottdesign.com/ar... to be useful.

A Google search uncovers information:

http://mate.tue.nl/mate/pdfs/756...

Chapter 6: Implementation in C

...

https://ieeexplore.ieee.org/docu...

https://www.researchgate.net/pub...

... and others

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.
{"ft_lang_label":"__label__en","ft_lang_prob":0.76249635,"math_prob":0.9686522,"size":1720,"snap":"2019-35-2019-39","text_gpt3_token_len":472,"char_repetition_ratio":0.122960374,"word_repetition_ratio":0.0,"special_character_ratio":0.29302326,"punctuation_ratio":0.17630059,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99707156,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-08-22T06:22:06Z\",\"WARC-Record-ID\":\"<urn:uuid:57522b60-ba76-4c9f-9447-222c91492383>\",\"Content-Length\":\"44311\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8198741e-5c83-4a54-9088-96f30231b399>\",\"WARC-Concurrent-To\":\"<urn:uuid:2608ac35-3c5e-4142-8bd3-2783030ebf46>\",\"WARC-IP-Address\":\"50.112.125.251\",\"WARC-Target-URI\":\"https://www.avrfreaks.net/comment/2554586\",\"WARC-Payload-Digest\":\"sha1:UVLDPIVYRMOHLZUJJN7GOCKC6DSSSU4S\",\"WARC-Block-Digest\":\"sha1:4EP7EJQDVNLEX6NNPXI7ISY3T5Y4HBH2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-35/CC-MAIN-2019-35_segments_1566027316783.70_warc_CC-MAIN-20190822042502-20190822064502-00423.warc.gz\"}"}