我正在尝试绘制一个控制块,但在将两个输入连接到一个块时遇到了问题
如何能在不绘制估算器块的情况下从 u1 到估算器画一条线?
这是我尝试过的
\tikzstyle{block} = [draw, rectangle,
minimum height=1cm, minimum width=2cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{arrow}=[draw, -latex]
\tikzstyle{pinstyle} = [pin edge={latex-, black}]
\tikzstyle{sum} = [draw, circle, node distance=1cm]
% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
% We start by placing the blocks
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (controller) {Controller};
\node [block, right of=controller, node distance=3cm] (system) {System};
\node [output, right of=system] (output) {};
%Connect
\draw [arrow] (input) -- node {$y_{_1ref}$} (sum);
\draw [arrow] (sum) -- node [name=y_err_one] {$e_{_1}$} (controller);
\draw [arrow] (controller) -- node [name=u_one] {$u_{_1}$} (system);
\draw [arrow] (system) -- node [name=y_one] {$y_{_1}$} (output);
%Second leader
\node [block, below of=u_one] (estimator_one) {Estimator};
%\node [block, left of=estimator_one, node distance=3cm] (cs_to_js_one) {CS2JS};
%\node [block, left of=cs_to_js_one] (for_kin) {Forward Kinematics};
%Connect
\draw [arrow] (y_one) |- (estimator_one);
\draw [arrow] (u_one) |- (estimator_one);
\draw [arrow] (estimator_one) -| node[pos=0.99] {$-$}
node [near end, name=y_est_one] {$y_{_1est}$} (sum);
\end{tikzpicture}
答案1
下面的代码主要做了一些修改
\path [arrow] (u_one) -- ($(estimator_one.north)+(0,.5)$)
-| ($(estimator_one.east)+(1,1)$)
-| ($(estimator_one.east)+(1,0)$)
--(estimator_one.east);
这需要\usetikzlibrary{calc}
我还将其更改tikstyle=
为tikzset
,如应该使用 \tikzset 还是 \tikzstyle 来定义 TikZ 样式?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,calc}
\tikzset{
block/.style = {draw, rectangle,
minimum height=1cm,
minimum width=2cm},
input/.style = {coordinate},
output/.style = {coordinate},
arrow/.style={draw, -latex},
pinstyle/.style = {pin edge={latex-, black}},
sum/.style = {draw, circle, node distance=1cm}
}
\begin{document}
% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
% We start by placing the blocks
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (controller) {Controller};
\node [block, right of=controller, node distance=3cm] (system) {System};
\node [output, right of=system] (output) {};
%Connect
\draw [arrow] (input) -- node {$y_{_1ref}$} (sum);
\draw [arrow] (sum) -- node [name=y_err_one] {$e_{_1}$} (controller);
\draw [arrow] (controller) -- node [name=u_one] {$u_{_1}$} (system);
\draw [arrow] (system) -- node [name=y_one] {$y_{_1}$} (output);
%Second leader
\node [block, below of=u_one] (estimator_one) {Estimator};
%\node [block, left of=estimator_one, node distance=3cm] (cs_to_js_one) {CS2JS};
%\node [block, left of=cs_to_js_one] (for_kin) {Forward Kinematics};
%Connect
\draw [arrow] (y_one) |- (estimator_one);
\path [arrow] (u_one) -- ($(estimator_one.north)+(0,.5)$) -| ($(estimator_one.east)+(1,1)$)-| ($(estimator_one.east)+(1,0)$)--(estimator_one.east);
\draw [arrow] (estimator_one) -| node[pos=0.99] {$-$}
node [near end, name=y_est_one] {$y_{_1est}$} (sum);
\end{tikzpicture}
\end{document}