コード例 #1
0
ファイル: run_simulation.py プロジェクト: braingram/Main
publisher = Publisher(5055)
if controller != None:
    publisher.addToCatalog('yaw_ang_target', controller.getDesiredYawDeg)
    publisher.addToCatalog('pitch_ang_target', controller.getDesiredPitchDeg)
    publisher.addToCatalog('knee_ang_target', controller.getDesiredKneeDeg)
publisher.addToCatalog('yaw_cmd', lambda: commands[0])
publisher.addToCatalog('pitch_cmd', lambda: commands[1])
publisher.addToCatalog('knee_cmd', lambda: commands[2])

d = {'offset': (0, 0, 2.00)}
s = Simulator(dt=5e-3,
              plane=1,
              pave=0,
              graphical=1,
              robot=LegOnColumn,
              robot_kwargs=d,
              start_paused=1,
              render_objs=1,
              draw_contacts=1,
              publish_int=20)

yaw_joint = s.robot.joints['hip_yaw']
pitch_joint = s.robot.joints['hip_pitch']
knee_joint = s.robot.joints['knee_pitch']
yaw_joint_bl = s.robot.joints['hip_yaw_bl']
pitch_joint_bl = s.robot.joints['hip_pitch_bl']
knee_joint_bl = s.robot.joints['knee_pitch_bl']
shock_joint = s.robot.joints['foot_shock']

control_period = 5e-3
last_time = 0.0
コード例 #2
0
ファイル: kick_test.py プロジェクト: ProjectHexapod/Main

import sys
sys.path.append('../..')
import random
from SimulationKit import Simulator
from SimulationKit.Robots import LegOnStand
import time

import StudentControl

d = {'offset': (0, 0, 1.1)}
s = Simulator(dt=1e-3,
              plane=1,
              pave=0,
              graphical=1,
              robot=LegOnStand,
              robot_kwargs=d,
              start_paused=True)

# Put up the goal posts
wickets = []
static_geoms = []
row_n = 6
x_off = .5
y_off = .5
i = 0

# Rack up the pins
for i in range(row_n):
    for j in range(i + 1):
コード例 #3
0
ファイル: run_simulation.py プロジェクト: ProjectHexapod/Main
    update = retval
    controller = None

commands = [0,0,0]

publisher = Publisher(5055)
if controller != None:
    publisher.addToCatalog( 'yaw_ang_target'   , controller.getDesiredYawDeg )
    publisher.addToCatalog( 'pitch_ang_target' , controller.getDesiredPitchDeg )
    publisher.addToCatalog( 'knee_ang_target'  , controller.getDesiredKneeDeg )
publisher.addToCatalog( 'yaw_cmd'          , lambda: commands[0] )
publisher.addToCatalog( 'pitch_cmd'        , lambda: commands[1] )
publisher.addToCatalog( 'knee_cmd'         , lambda: commands[2] )

d = {'offset':(0,0,2.00)}
s = Simulator(dt=5e-3,plane=1,pave=0,graphical=1,robot=LegOnColumn,robot_kwargs=d, start_paused = 1, render_objs=1, draw_contacts=1, publish_int=20)

yaw_joint      = s.robot.joints['hip_yaw']
pitch_joint    = s.robot.joints['hip_pitch']
knee_joint     = s.robot.joints['knee_pitch']
yaw_joint_bl   = s.robot.joints['hip_yaw_bl']
pitch_joint_bl = s.robot.joints['hip_pitch_bl']
knee_joint_bl  = s.robot.joints['knee_pitch_bl']
shock_joint    = s.robot.joints['foot_shock']

control_period = 5e-3
last_time = 0.0

while True:
    s.step()
    time = s.getSimTime()
コード例 #4
0
ファイル: kick_test.py プロジェクト: ifreecarve/Main
import sys
sys.path.append('../..')
import random
from SimulationKit import Simulator
from SimulationKit.Robots import LegOnStand
import time

import StudentControl

d = {'offset':(0,0,1.1)}
s = Simulator(dt=1e-3,plane=1,pave=0,graphical=1,robot=LegOnStand,robot_kwargs=d, start_paused = True)

# Put up the goal posts
wickets = []
static_geoms = []
row_n = 6
x_off = .5
y_off = .5
i = 0

# Rack up the pins
for i in range(row_n):
    for j in range(i+1):
        body, geom = s.createCapsule( mass = 1.0e1, length = 1.0, radius = 0.1, pos = (5.0+i*x_off, y_off*j - i*(y_off/2),0.7) )
        wickets.append(body)
        static_geoms.append(geom)

# Place the ball
ball,g = s.createSphere( mass=1.0e2, radius=0.25, pos=(1.75,random.uniform(-.05,.05),.25))

# Declare the victory condition
コード例 #5
0
from SimulationKit import Simulator
from SimulationKit.Robots import SpiderWHydraulics
from ControlsKit.filters import LowPassFilter
from ControlsKit.time_sources import global_time
from UI import InputServer
import time

input_server = InputServer()
input_server.startListening()

d = {'offset': (0, 0, 1.5)}
s = Simulator(dt=2e-3,
              plane=1,
              pave=0,
              graphical=1,
              ground_grade=0.,
              robot=SpiderWHydraulics,
              robot_kwargs=d,
              render_objs=1,
              draw_contacts=0)
last_t = 0


def toScale(val):
    return float(val) / 128. - 1


try:
    while True:
        s.step()
        global_time.updateTime(s.getSimTime())
コード例 #6
0
ファイル: run_simulation.py プロジェクト: ifreecarve/Main
import sys
sys.path.append('..')
sys.path.append('planners')

from SimulationKit import Simulator
from SimulationKit.Robots import SpiderWHydraulics
from SimulationKit.helpers import *
from ControlsKit.import_planner import importPlanner
from UI import InputServer, logger

# Check command-line arguments to find the planner module
update = importPlanner()


d = {'offset':(0,0,1.0)}
s = Simulator(dt=1e-3,plane=1,pave=0,graphical=1,robot=SpiderWHydraulics,robot_kwargs=d, start_paused = True)
input_server = InputServer()
input_server.startListening()


try:
    last_command = None
    while True:
        s.step()
        if not s.getPaused():
            time = s.getSimTime()+.0001 # FIXME: first time time_delta is called, it returns zero, which means pid commands infinity
            # FIXME: Known bug, getAcceleration returns (0,0,0)
            next_command = input_server.getLastCommand()
            command = next_command if next_command != last_command else None
            last_command = next_command
#            print command[15]
コード例 #7
0
import sys
sys.path.append('..')
from SimulationKit import Simulator
from SimulationKit.Robots import LegOnColumn

d = {'offset': (0, 0, 1.5)}
s = Simulator(dt=2e-3,
              plane=1,
              graphical=1,
              ground_grade=.00,
              robot=LegOnColumn,
              robot_kwargs=d,
              render_objs=1,
              draw_COM=0,
              draw_support=0,
              draw_contacts=0)
while True:
    s.step()
コード例 #8
0
ファイル: run_simulation.py プロジェクト: ProjectHexapod/Main
from SimulationKit.helpers import *
from ControlsKit.import_planner import importPlanner
from UI import InputServer


# Check command-line arguments to find the planner module
retval = importPlanner()
# FIXME: This is to allow backwards compatibility to older versions of importPlanner
if type(retval) == tuple:
    update, controller = retval
else:
    update = retval
    controller = None

d = {'offset': (0, 0, 0.67)}
s = Simulator(dt=1e-3, plane=1, pave=0, graphical=1, robot=LegOnStand, robot_kwargs=d, start_paused=False)
input_server = InputServer()  # TODO: pass along at least a password argument here
input_server.startListening()

yaw_joint = s.robot.members['hip_yaw']
pitch_joint = s.robot.members['hip_pitch']
knee_joint = s.robot.members['knee_pitch']
shock_joint = s.robot.members['foot_shock']
try:
    while True:
        s.step()
        if not s.getPaused():
            time = s.getSimTime()
            command = input_server.getLastCommand()
            lr = update(time, yaw_joint.getAngle(), pitch_joint.getAngle(), knee_joint.getAngle(), shock_joint.getPosition(), command)
            yaw_joint.setLengthRate(lr[0])
コード例 #9
0
ファイル: stompy.py プロジェクト: braingram/Main
import sys
sys.path.append('..')
from SimulationKit import Simulator
from SimulationKit.Robots import SpiderWHydraulics

d = {'offset': (0, 0, 1.5)}

print Simulator

s = Simulator(dt=2e-3,
              plane=1,
              graphical=1,
              ground_grade=.00,
              robot=SpiderWHydraulics,
              robot_kwargs=d,
              render_objs=1,
              draw_COM=1,
              draw_support=1,
              draw_contacts=0,
              height_map=None)

while True:
    s.step()
    s.robot.constantSpeedWalkSmart()
コード例 #10
0
sys.path.append('planners')

from SimulationKit import Simulator
from SimulationKit.Robots import SpiderWHydraulics
from SimulationKit.helpers import *
from ControlsKit.import_planner import importPlanner
from UI import InputServer, logger

# Check command-line arguments to find the planner module
update = importPlanner()

d = {'offset': (0, 0, 1.0)}
s = Simulator(dt=1e-3,
              plane=1,
              pave=0,
              graphical=1,
              robot=SpiderWHydraulics,
              robot_kwargs=d,
              start_paused=True)
input_server = InputServer()
input_server.startListening()

try:
    last_command = None
    while True:
        s.step()
        if not s.getPaused():
            time = s.getSimTime(
            ) + .0001  # FIXME: first time time_delta is called, it returns zero, which means pid commands infinity
            # FIXME: Known bug, getAcceleration returns (0,0,0)
            next_command = input_server.getLastCommand()
コード例 #11
0
from footPositionFromJointAngles import *
from transformations import *

import sys

sys.path.append('../..')
from SimulationKit import Simulator
from SimulationKit.Robots import LegOnStand

d = {'offset': (0, 0, 0.63)}
s = Simulator(dt=1e-3,
              plane=1,
              pave=0,
              graphical=1,
              robot=LegOnStand,
              robot_kwargs=d,
              start_paused=True)

yaw = s.robot.members['hip_yaw']
pitch = s.robot.members['hip_pitch']
knee = s.robot.members['knee_pitch']
foot_shock = s.robot.members['foot_shock']

while True:
    s.step()
    if not s.paused:
        print footPositionFromJointAngles(yaw.getAngle(), pitch.getAngle(),
                                          knee.getAngle(),
                                          foot_shock.getPosition(), s.robot)
コード例 #12
0
from UI import InputServer

# Check command-line arguments to find the planner module
retval = importPlanner()
# FIXME: This is to allow backwards compatibility to older versions of importPlanner
if type(retval) == tuple:
    update, controller = retval
else:
    update = retval
    controller = None

d = {'offset': (0, 0, 0.67)}
s = Simulator(dt=1e-3,
              plane=1,
              pave=0,
              graphical=1,
              robot=LegOnStand,
              robot_kwargs=d,
              start_paused=False)
input_server = InputServer(
)  # TODO: pass along at least a password argument here
input_server.startListening()

yaw_joint = s.robot.members['hip_yaw']
pitch_joint = s.robot.members['hip_pitch']
knee_joint = s.robot.members['knee_pitch']
shock_joint = s.robot.members['foot_shock']
try:
    while True:
        s.step()
        if not s.getPaused():
コード例 #13
0
ファイル: kick_test.py プロジェクト: braingram/Main
#!/usr/bin/env python

import sys
sys.path.append('../..')
import random
from SimulationKit import Simulator
from SimulationKit.Robots import LegOnStand
import time

import StudentControl

d = {'offset': (0, 0, 1.1)}
s = Simulator(dt=1e-3,
              plane=1,
              pave=0,
              graphical=1,
              robot=LegOnStand,
              robot_kwargs=d,
              start_paused=True)

# Put up the goal posts
wickets = []
static_geoms = []
row_n = 6
x_off = .5
y_off = .5
i = 0

# Rack up the pins
for i in range(row_n):
    for j in range(i + 1):
コード例 #14
0
ファイル: gimpy.py プロジェクト: braingram/Main
import sys
sys.path.append('..')
from SimulationKit import Simulator
from SimulationKit.Robots import LegOnStand
from SimulationKit.helpers import *
import time

from math import *

d = {'offset': (0, 0, 0.67)}
s = Simulator(dt=1e-3,
              plane=1,
              pave=0,
              graphical=1,
              robot=LegOnStand,
              robot_kwargs=d,
              start_paused=True)

# Put up the goal posts
wickets = []
static_geoms = []
row_n = 2
x_off = .5
y_off = .5
i = 0
# Rack up the pins
for i in range(row_n):
    for j in range(i + 1):
        body, geom = s.createCapsule(mass=1.0e1,
                                     length=1.0,
                                     radius=0.1,
コード例 #15
0
stick = joystick.Joystick(0)
stick.init()
print "Joystick detected: ", stick.get_name()
print "Axes:              ", stick.get_numaxes()
print "Balls:             ", stick.get_numballs()
print "Hats:              ", stick.get_numhats()
print "Buttons:           ", stick.get_numbuttons()
stick_neutrals = []

d = {'offset': (0, 0, 1.5)}
s = Simulator(dt=2e-3,
              plane=1,
              pave=0,
              graphical=1,
              ground_grade=.00,
              robot=SpiderWHydraulics,
              robot_kwargs=d,
              render_objs=1,
              draw_contacts=0)
last_t = 0
x_low = LowPassFilter(gain=1.0, corner_frequency=1.2)
y_low = LowPassFilter(gain=1.0, corner_frequency=1.2)
z_low = LowPassFilter(gain=1.0, corner_frequency=1.2)
r_low = LowPassFilter(gain=1.0, corner_frequency=1.2)
while True:
    s.step()
    global_time.updateTime(s.getSimTime())
    if s.getSimTime() - last_t > .001:
        x = -(stick.get_axis(1) + .15466)
        if x < 0:
コード例 #16
0
ファイル: stompy_terrain.py プロジェクト: ifreecarve/Main
import sys
sys.path.append('..')
from SimulationKit import Simulator
from SimulationKit.Robots import SpiderWHydraulics

d = {'offset':(0,0,3.5)}
s = Simulator(dt=2e-3,plane=0,graphical=1,ground_grade=.00,robot=SpiderWHydraulics,robot_kwargs=d,\
    render_objs=0, draw_COM=0, draw_support=0, draw_contacts=1,\
    height_map="heightmap.jpg", terrain_scales=(1,1,3))
while True:
    s.step()
    s.robot.constantSpeedWalkSmart()
コード例 #17
0
ファイル: hexy_test.py プロジェクト: braingram/Main
import sys
sys.path.append('..')
from SimulationKit import Simulator
from SimulationKit.Robots import Hexy
import time

d = {'offset': (0, 0, 20e-2)}
s = Simulator(dt=0, plane=1, pave=0, graphical=1, robot=Hexy, robot_kwargs=d)

last_t = time.time()

rad2deg = 180. / 3.14159


def updateServo(j):
    j.servo.setPos(degrees=(j.servo_mult * rad2deg * j.getAngleTarget()) +
                   j.servo_offset)


while True:
    s.step()
    s.robot.constantSpeedWalk()
    if time.time() - last_t > 50e-3:
        updateServo(s.robot.legs[0]['hip_yaw'])
        updateServo(s.robot.legs[0]['hip_pitch'])
        updateServo(s.robot.legs[0]['knee_pitch'])
        updateServo(s.robot.legs[1]['hip_yaw'])
        updateServo(s.robot.legs[1]['hip_pitch'])
        updateServo(s.robot.legs[1]['knee_pitch'])
        updateServo(s.robot.legs[2]['hip_yaw'])
        updateServo(s.robot.legs[2]['hip_pitch'])