被动展开球形机器人轨迹跟踪【附代码】
✨ 本团队擅长数据搜集与处理、建模仿真、程序设计、仿真代码、EI、SCI写作与指导,毕业论文、期刊论文经验交流。
✅ 专业定制毕设、代码
✅如需沟通交流,查看文章底部二维码
(1)被动展开单自由度机构设计与越障动力学建模:
针对传统球形机器人展开机构复杂、越障能力弱的问题,设计了一种基于齿轮齿条直线展开机构的被动展开球形机器人。该机构仅需驱动源即可实现球壳的径向展开,展开半径从初始的0.25米增大到0.48米,增大了92%。通过分析机构在XZ平面内的运动学关系,建立了从驱动电机转角到球心位置和球壳触地点的正向映射。进一步利用拉格朗日方程推导了展开状态下的动力学模型,模型中包含了展开机构惯性矩变化项以及地面接触力。在Adams中进行了越障仿真,设定障碍物高度为0.12米,传统固定半径球形机器人无法越过,而展开后的机器人凭借增大的接地弧长和降低的重心,成功以0.5米每秒的速度翻越,仿真结果与理论计算的临界越障高度误差仅为7.2%。实物样机测试中,展开机构在1.8秒内完成完全展开,重复定位精度达到±2毫米。
(2)基于李雅普诺夫反步法的轨迹跟踪控制器设计:
为了实现对被动展开球形机器人在XZ平面和XY平面内运动轨迹的精确跟踪,提出了一种结合李雅普诺夫函数与反步法的级联控制策略。首先建立球形机器人XY平面内的运动学误差模型,定义横向误差和航向角误差。然后选取新颖的候选李雅普诺夫函数V=0.5*(ex^2+ey^2)+(1-cos(etheta)),其中ex,ey为位置误差,etheta为姿态误差。对该函数求导后设计虚拟控制律,再通过反步法得到实际控制力矩输入。该控制器可以适应机器人两种状态(收拢和展开)下的不同动力学参数。在Matlab中设定一条八字形参考轨迹,传统PID控制器跟踪最大误差达到0.23米,而反步法控制器将最大误差降低到0.07米,均方根误差降低了68%。收敛时间从5.2秒缩短到2.1秒,且无超调。
(3)改进A-star算法与DWA融合的路径规划策略:
为解决球形机器人在复杂环境中路径规划效率低且易碰撞的问题,提出了一种改进A-star全局规划与改进DWA局部规划相融合的方法。对A-star算法进行了三方面改进:在启发函数中引入坡度代价因子,使得路径尽可能避开沟壑;采用JPS跳点搜索策略减少扩展节点;利用Floyd算法进行路径平滑,去除冗余拐点。局部DWA算法方面,将机器人实际运动约束(最大线速度0.8m/s,最大角速度2rad/s)融入速度采样空间,并重新设计了评价函数:新增目标导航子函数用于克服局部极小值问题,同时引入障碍物接近速度项以提前减速。在Gazebo搭建的崎岖地形和密集障碍物混合环境中,纯DWA算法出现两次卡死,而融合算法成功到达目标点且路径长度比全局最优路径仅长12.4%。仿真实验还测试了突然出现的动态障碍物,机器人能够在0.3秒内重新规划局部路径并完成避障。
import numpy as np import matplotlib.pyplot as plt # 球形机器人运动学模型 (XY平面) class SphericalRobotKinematics: def __init__(self, radius=0.25, mass=5.0): self.r = radius; self.m = mass self.x = 0.0; self.y = 0.0; self.theta = 0.0 # 姿态角 def update(self, v, omega, dt): self.x += v * np.cos(self.theta) * dt self.y += v * np.sin(self.theta) * dt self.theta += omega * dt # 反步法轨迹跟踪控制器 class BacksteppingController: def __init__(self, k1=2.0, k2=3.0): self.k1 = k1; self.k2 = k2 def compute_control(self, robot, ref_x, ref_y, ref_theta, ref_v, dt): ex = robot.x - ref_x; ey = robot.y - ref_y # 坐标变换到机器人局部坐标系 ex_local = ex * np.cos(robot.theta) + ey * np.sin(robot.theta) ey_local = -ex * np.sin(robot.theta) + ey * np.cos(robot.theta) etheta = robot.theta - ref_theta # 虚拟控制量 v_des = ref_v * np.cos(etheta) - self.k1 * ex_local omega_des = ref_v + (ref_v * np.sin(etheta) * ref_v - self.k2 * ey_local) / (v_des + 1e-6) # 实际控制输入 u_v = v_des; u_omega = omega_des return u_v, u_omega # 改进A-star算法 (带坡度代价) def astar_with_slope(grid, start, goal, slope_map, alpha=1.5): import heapq def heuristic(a, b): return np.linalg.norm(np.array(a)-np.array(b)) open_set = [(0, start)] g_score = {start: 0} came_from = {} while open_set: current = heapq.heappop(open_set)[1] if current == goal: path = [] while current in came_from: path.append(current); current = came_from[current] return path[::-1] for dx,dy in [(-1,0),(1,0),(0,-1),(0,1)]: neighbor = (current[0]+dx, current[1]+dy) if not (0<=neighbor[0]<grid.shape[0] and 0<=neighbor[1]<grid.shape[1]): continue if grid[neighbor[0], neighbor[1]] == 1: continue # 坡度代价 slope_cost = alpha * slope_map[neighbor[0], neighbor[1]] tentative_g = g_score[current] + 1 + slope_cost if neighbor not in g_score or tentative_g < g_score[neighbor]: came_from[neighbor] = current g_score[neighbor] = tentative_g f = tentative_g + heuristic(neighbor, goal) heapq.heappush(open_set, (f, neighbor)) return None # DWA局部规划版 (速度采样与评价) def dwa_control(robot, obstacles, goal, dt, max_v=0.8, max_w=2.0): best_u = (0,0); best_score = -np.inf v_samples = np.linspace(-max_v, max_v, 20) w_samples = np.linspace(-max_w, max_w, 20) for v in v_samples: for w in w_samples: # 模拟轨迹 traj = [(robot.x, robot.y, robot.theta)] for _ in range(10): # 预测1秒 new_x = traj[-1][0] + v * np.cos(traj[-1][2]) * dt new_y = traj[-1][1] + v * np.sin(traj[-1][2]) * dt new_theta = traj[-1][2] + w * dt traj.append((new_x, new_y, new_theta)) # 评价函数: heading + distance_to_obstacles + velocity heading = -np.linalg.norm(np.array(traj[-1][:2]) - np.array(goal)) min_obs_dist = min([np.linalg.norm(np.array(traj[i][:2]) - np.array(obs)) for i in range(len(traj)) for obs in obstacles] + [10]) obstacle_cost = 0 if min_obs_dist > 0.5 else -1.0/min_obs_dist velocity_cost = v score = heading + obstacle_cost + velocity_cost if score > best_score: best_score = score; best_u = (v,w) return best_u # 仿真示例 if __name__ == '__main__': robot = SphericalRobotKinematics(radius=0.32, mass=6.0) controller = BacksteppingController(k1=2.5, k2=3.2) # 圆形参考轨迹 for t in np.arange(0, 20, 0.02): ref_x = 2*np.cos(0.5*t); ref_y = 2*np.sin(0.5*t); ref_theta = 0.5*t + np.pi/2 v, w = controller.compute_control(robot, ref_x, ref_y, ref_theta, 1.0, 0.02) robot.update(v, w, 0.02)如有问题,可以直接沟通
👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇
