码迷,mamicode.com
首页 > 移动开发 > 详细

移动机器人的一点简单运动学

时间:2019-08-01 15:57:09      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:class   编码   mod   tor   com   simple   delay   机器人   ram   

原文地址:https://husarion.com/tutorials/ros-tutorials/3-simple-kinematics-for-mobile-robot

代码地址:https://github.com/husarion/hFramework/blob/master/src/rosbot/ROSbot.cpp#L136

核心部分代码:

enc_FR = wheelFR->getDistance();
enc_RR = wheelRR->getDistance();
enc_RL = wheelRL->getDistance();
enc_FL = wheelFL->getDistance();
//四个轮子的弧度
wheel_FL_ang_pos = 2 * 3.14 * enc_FL / enc_res;
wheel_FR_ang_pos = 2 * 3.14 * enc_FR / enc_res;
wheel_RL_ang_pos = 2 * 3.14 * enc_RL / enc_res;
wheel_RR_ang_pos = 2 * 3.14 * enc_RR / enc_res;

//左轮和右轮编码器值 enc_L
= (enc_FL + enc_RL) / (2 * tyre_deflection);
enc_R
= (enc_FR + enc_RR) / (2 * tyre_deflection);
//左轮和右轮角速度 wheel_L_ang_vel
= ((2 * 3.14 * enc_L / enc_res) - wheel_L_ang_pos) / delay_s; wheel_R_ang_vel = ((2 * 3.14 * enc_R / enc_res) - wheel_R_ang_pos) / delay_s; //左轮和右轮弧度 wheel_L_ang_pos = 2 * 3.14 * enc_L / enc_res; wheel_R_ang_pos = 2 * 3.14 * enc_R / enc_res; robot_angular_vel = (((wheel_R_ang_pos - wheel_L_ang_pos) * wheel_radius / (robot_width * diameter_mod)) - robot_angular_pos) / delay_s; robot_angular_pos = (wheel_R_ang_pos - wheel_L_ang_pos) * wheel_radius / (robot_width * diameter_mod); robot_x_vel = (wheel_L_ang_vel * wheel_radius + robot_angular_vel * robot_width / 2) * cos(robot_angular_pos); robot_y_vel = (wheel_L_ang_vel * wheel_radius + robot_angular_vel * robot_width / 2) * sin(robot_angular_pos); robot_x_pos = robot_x_pos + robot_x_vel * delay_s; robot_y_pos = robot_y_pos + robot_y_vel * delay_s; sys.delay(loop_delay);

未完待续

 

移动机器人的一点简单运动学

标签:class   编码   mod   tor   com   simple   delay   机器人   ram   

原文地址:https://www.cnblogs.com/zwb800/p/11283029.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!