Jianlin Cao

Week 16: Mechanical Design, Machine Design

• Assignments

This week’s assignments

make a machine, including the end effector
build the passive parts and operate it manually
document the group project and your individual contribution

My main job is that find a way to convert pictures to files that could be read by our drawing machine.

Start with software called ‘StippleGen_2’ to generate .svg file for next step. It solves the classic traveling sales man problem that is almost exactlly what we want.

images images

Then the .svg file is converted to both python code and .csv for drawing machine by the following matlab code.

function csv_gen(file_name,maximum_size)

%file_name='evil_minion'; maximum_size=200;

%read svg to text
[data, result]= readtext(sprintf('%s.svg',file_name),' ');

%read coordinates from text
m=1;
for n=1:result.rows
   if isnumeric(cell2mat(data(n,1))) & ~isempty(cell2mat(data(n,1)))
       if isnumeric(cell2mat(data(n,2))) & ~isempty(cell2mat(data(n,2)))
           coor(m,1)=cell2mat(data(n,1));
           coor(m,2)=cell2mat(data(n,2));
           m=m+1;
       end
   end
end

min_coor=min(coor);
for n=1:length(coor)
    coor_shifted(n,:)=coor(n,:)-min_coor;
end

%re-scale to 200mm size
coor_a=coor_shifted*maximum_size/(max(max(coor_shifted)));

% %convert to relative coordinates
% coor_r=coor_a(1,:);
% for n=2:length(coor_a)
%     coor_r(n,:)=coor_a(n,:)-coor_a(n-1,:);
% end

%generate .csv file
csvwrite(sprintf('%s.csv',file_name),coor_a);
%csvwrite(sprintf('%s_r.csv',file_name),coor_r);

%generate python code in .txt
fid = fopen(sprintf('%s.txt',file_name),'wt'); 
fprintf(fid,'moves = [');
fprintf(fid,'[%d,%d]',coor_a(1,1),coor_a(1,2));
for n=2:length(coor_a)
    fprintf(fid,',[%d,%d]',coor_a(n,1),coor_a(n,2));
end
fprintf(fid,']');
fclose(fid);

% fid = fopen(sprintf('%s_r.txt',file_name),'wt'); 
% fprintf(fid,'moves = [');
% fprintf(fid,'[%d,%d]',coor_r(1,1),coor_r(1,2));
% for n=2:length(coor_a)
%     fprintf(fid,',[%d,%d]',coor_r(n,1),coor_r(n,2));
% end
% fprintf(fid,']');
% fclose(fid);

plot(coor_a);

Bonus

images

Engineer(tape) style pen holder

images

Get the files

You can download the source files directly.