Exemplo n.º 1
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''

import nengo
import numpy as np

import Arm; reload(Arm)

run_in_GUI = True 

# set the initial position of the arm
arm = Arm.Arm2Link(dt=1e-3)
arm.reset(q=[np.pi/5.5, np.pi/1.7], dq=[0, 0])

"""Generate the Nengo model that will control the arm."""
model = nengo.Network()

with model: 
    
    # create input nodes
    def arm_func(t, x):
        u = x[:2]
        arm.apply_torque(u) 
        data = np.hstack([arm.q0, arm.q1, arm.dq0, arm.dq1, arm.x]) # data returned from node to model

        # visualization code -----------------------------------------------------
        scale = 15