| 24小時(shí)熱門(mén)版塊排行榜 |
| 8 | 1/1 | 返回列表 |
| 查看: 2594 | 回復(fù): 7 | ||
[求助]
雙足機(jī)器人行走棍圖怎么用MATLAB畫(huà)出來(lái)。壳笾。。! 已有1人參與
|
| 雙足機(jī)器人行走棍圖怎么用MATLAB畫(huà)出來(lái)啊?求助啊。! |



鐵蟲(chóng) (小有名氣)

|
嗯 |

鐵蟲(chóng) (初入文壇)
|
The following is a function I wrote to generate a stick diagram of robot motion. Hope it is helpful to you all. function [foot2] = stick(filename,user_frame_per_second,max_step) global robot foot2=[]; mov_traj = load(filename); dt = mov_traj(2,1) - mov_traj(1,1); frame_per_second = fix(1/dt); if user_frame_per_second == 0 show_frame_per_second = frame_per_second; else show_frame_per_second = user_frame_per_second; end capture_frame_per_second = 20; color0 = [0 0 0]; color1 = [0 0 0]; color2 = [0 0 0]; color3 = [1 1 1]*0.5; color4 = [1 1 1]*0.5; width = 2; scrsz = get(0,'ScreenSize'); animation = figure; %hold on xxlim = [-0.8 0.8] yylim = [ 0.0 1.6] set(animation,'name','2D walking','Position',[100 100 450 450]); h_axes = axes('Parent',animation,'Units','Pixels','Position',[50 40 400 400],'Ylim',yylim,'Xlim',xxlim); %tx = text('Parent',h_axes,'Visible','off'); set(h_axes,'visible','on'); ground = line('Parent',h_axes,'Color',[0 0 0],'Visible','off','LineWidth',2); set(ground, 'Parent',h_axes,'Xdata',xxlim,'Ydata', [0 0],'visible','on'); idx =1 ss_flag = 0; step_count = 0; l_ankle_pos = zeros(2,1); l_knee_pos = zeros(2,1); l_hip_pos = zeros(2,1); head_pos = zeros(2,1); r_knee_pos = zeros(2,1); r_ankle_pos = zeros(2,1); r_ankle_pos_b_save = [-1,0]'; base = [0 0]'; for i = 1:size(mov_traj,1) tt = mov_traj(i,1); l_ankle_abs = mov_traj(i,2); l_knee_abs = l_ankle_abs + mov_traj(i,3); l_hip_abs = l_knee_abs + mov_traj(i,4); r_hip_abs = l_hip_abs + mov_traj(i,5); r_knee_abs = r_hip_abs + mov_traj(i,6); % r_knee_abs = r_knee_abs; l_ankle_pos_b =[0 0]'; l_knee_pos_b = [ -robot.calf_length * sin(l_ankle_abs) robot.calf_length* cos(l_ankle_abs)]'; l_hip_pos_b = [l_knee_pos_b(1)-sin(l_knee_abs)*robot.thigh_length l_knee_pos_b(2)+cos(l_knee_abs)*robot.thigh_length ]'; head_pos_b = [l_hip_pos_b(1)-sin(l_hip_abs)*robot.torso_length l_hip_pos_b(2) + cos(l_hip_abs)*robot.torso_length]'; r_knee_pos_b = [l_hip_pos_b(1)+sin(r_hip_abs)*robot.thigh_length l_hip_pos_b(2) - cos(r_hip_abs)*robot.thigh_length]'; r_ankle_pos_b = [r_knee_pos_b(1)+sin(r_knee_abs)*robot.calf_length r_knee_pos_b(2) - cos(r_knee_abs)*robot.calf_length]'; if (r_ankle_pos_b_save(1) > 0 && r_ankle_pos_b(1) < 0) % switch step_count = step_count +1; if step_count >= max_step break end ss_flag = 1; tmp = color0; color0 = color4; color4=tmp; tmp = color1; color1 = color3; color3=tmp; set(l_calf,'Color',color0,'Visible','off'); set(l_thigh,'Color',color1,'Visible','off'); set(torso,'Color',color2,'Visible','off') set(r_thigh,'Color',color3,'Visible','off'); set(r_calf,'Color',color4,'Visible','off'); % hip_travel = hip_travel + r_ankle_pos_b_save(1); % ground_height = ground_height + r_ankle_pos_b_save(2); base = base + r_ankle_pos_b_save; %ground_height =0 ; %set(h_axes,'Ylim',[-0.05+ground_height 1.95+ground_height]); base; r_ankle_pos_b_save; r_ankle_pos_b; %pause end r_ankle_pos_b_save = r_ankle_pos_b; % drift = l_hip_pos(1); % l_ankle_pos(1) = l_ankle_pos(1) - drift; % l_knee_pos(1) = l_knee_pos(1) - drift; % l_hip_pos(1) = l_hip_pos(1) - drift; % head_pos(1) = head_pos(1) - drift; % r_knee_pos(1) = r_knee_pos(1) - drift; % r_ankle_pos(1) = r_ankle_pos(1) - drift; l_ankle_pos = l_ankle_pos_b + base; l_knee_pos = l_knee_pos_b + base; l_hip_pos = l_hip_pos_b + base; head_pos = head_pos_b + base; r_knee_pos = r_knee_pos_b + base; r_ankle_pos = r_ankle_pos_b + base; foot2 = [foot2,r_ankle_pos]; if (mod(i,fix(frame_per_second/show_frame_per_second)) == 1 ) torso = line('Parent',h_axes,'Color',color2,'Visible','off','LineWidth',width); r_thigh = line('Parent',h_axes,'Color',color3,'Visible','off','LineWidth',width); r_calf = line('Parent',h_axes,'Color',color4,'Visible','off','LineWidth',width); l_calf = line('Parent',h_axes,'Color',color0,'Visible','off','LineWidth',width); l_thigh = line('Parent',h_axes,'Color',color1,'Visible','off','LineWidth',width); if mod(step_count,2) == 1 set(l_calf, 'Parent',h_axes,'Xdata',[l_ankle_pos(1) l_knee_pos(1)],'Ydata', [l_ankle_pos(2) l_knee_pos(2)],'visible','on'); set(l_thigh, 'Parent',h_axes,'Xdata',[l_knee_pos(1) l_hip_pos(1)],'Ydata', [l_knee_pos(2) l_hip_pos(2)],'visible','on'); set(torso, 'Parent',h_axes,'Xdata',[l_hip_pos(1) head_pos(1)],'Ydata', [l_hip_pos(2) head_pos(2)],'visible','on'); set(r_thigh, 'Parent',h_axes,'Xdata',[l_hip_pos(1) r_knee_pos(1)],'Ydata', [l_hip_pos(2) r_knee_pos(2)],'visible','on'); set(r_calf, 'Parent',h_axes,'Xdata',[r_knee_pos(1) r_ankle_pos(1)],'Ydata', [r_knee_pos(2) r_ankle_pos(2)],'visible','on'); else set(torso, 'Parent',h_axes,'Xdata',[l_hip_pos(1) head_pos(1)],'Ydata', [l_hip_pos(2) head_pos(2)],'visible','on'); set(r_thigh, 'Parent',h_axes,'Xdata',[l_hip_pos(1) r_knee_pos(1)],'Ydata', [l_hip_pos(2) r_knee_pos(2)],'visible','on'); set(r_calf, 'Parent',h_axes,'Xdata',[r_knee_pos(1) r_ankle_pos(1)],'Ydata', [r_knee_pos(2) r_ankle_pos(2)],'visible','on'); set(l_calf, 'Parent',h_axes,'Xdata',[l_ankle_pos(1) l_knee_pos(1)],'Ydata', [l_ankle_pos(2) l_knee_pos(2)],'visible','on'); set(l_thigh, 'Parent',h_axes,'Xdata',[l_knee_pos(1) l_hip_pos(1)],'Ydata', [l_knee_pos(2) l_hip_pos(2)],'visible','on'); end stime=sprintf('time:%5.2f',tt); %set(tx,'Parent',h_axes,'Position',[l_hip_pos(1),1.8],'String',stime,'visible','on'); %set(h_axes,'Xlim',[l_hip_pos(1)-1.0 l_hip_pos(1)+1.0]); drawnow; end if l_ankle_pos(1) > xxlim(2) break end end xlabel('(m)') ylabel('(m)') |

| 8 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 招收調(diào)劑碩士 +4 | lidianxing 2026-03-19 | 10/500 |
|
|---|---|---|---|---|
|
[考研] 一志愿北京化工大學(xué)0703化學(xué)318分,有科研經(jīng)歷,求調(diào)劑 +3 | 一瓶苯甲酸 2026-03-14 | 3/150 |
|
|
[考研] 287求調(diào)劑 +3 | 晨昏線與星海 2026-03-19 | 4/200 |
|
|
[考研] 346求調(diào)劑[0856] +3 | WayneLim327 2026-03-16 | 6/300 |
|
|
[考研] 328求調(diào)劑,英語(yǔ)六級(jí)551,有科研經(jīng)歷 +3 | 生物工程調(diào)劑 2026-03-17 | 7/350 |
|
|
[考研] 材料專(zhuān)業(yè)求調(diào)劑 +5 | hanamiko 2026-03-18 | 5/250 |
|
|
[考研] 295求調(diào)劑 +3 | 一志愿京區(qū)211 2026-03-18 | 5/250 |
|
|
[考研] 311求調(diào)劑 +6 | 26研0 2026-03-15 | 6/300 |
|
|
[考研] 收復(fù)試調(diào)劑生 +4 | 雨后秋荷 2026-03-18 | 4/200 |
|
|
[考研] 301求調(diào)劑 +9 | yy要上岸呀 2026-03-17 | 9/450 |
|
|
[考研] 334求調(diào)劑 +3 | 志存高遠(yuǎn)意在機(jī)?/a> 2026-03-16 | 3/150 |
|
|
[考研] 293求調(diào)劑 +11 | zjl的號(hào) 2026-03-16 | 16/800 |
|
|
[考研] 301求調(diào)劑 +4 | A_JiXing 2026-03-16 | 4/200 |
|
|
[考研] 材料工程專(zhuān)碩274一志愿211求調(diào)劑 +6 | 薛云鵬 2026-03-15 | 6/300 |
|
|
[考研] 275求調(diào)劑 +4 | 太陽(yáng)花天天開(kāi)心 2026-03-16 | 4/200 |
|
|
[考研] 304求調(diào)劑 +3 | 曼殊2266 2026-03-14 | 3/150 |
|
|
[考研] 0856求調(diào)劑 +3 | 劉夢(mèng)微 2026-03-15 | 3/150 |
|
|
[考研] 材料與化工 323 英一+數(shù)二+物化,一志愿:哈工大 本人本科雙一流 +4 | 自由的_飛翔 2026-03-13 | 5/250 |
|
|
[考研] 中科大材料專(zhuān)碩319求調(diào)劑 +3 | 孟鑫材料 2026-03-13 | 3/150 |
|
|
[考研] 295求調(diào)劑 +3 | 小匕仔汁 2026-03-12 | 3/150 |
|