コード例 #1
0
def test_mavo_obs_vis():
    mavo = MultiAgentVelocityObstacle()
    mavo.register_agent("tata", Position(2, 2), Position(4, 5))
    mavo.register_obstacle(2, 3.14, Position(2, 3))
    mavo.register_obstacle(2, -3.14, Position(2, 10))
    mavo.run_simulation()
    mavo.visualize("toto", 10, 10)
コード例 #2
0
ファイル: test_nmpc.py プロジェクト: ramonpereira/pymapf
def test_sim_obstacles():
    nmpc = MultiAgentNMPC()
    nmpc.register_agent("toto", Position(1, 2), Position(4, 5))
    nmpc.register_agent("tata", Position(2, 2), Position(7, 5))
    nmpc.register_agent("titi", Position(2, 3), Position(4, 8))
    nmpc.register_obstacle(2, 3.14, Position(2, 3))
    nmpc.register_obstacle(2, -3.14, Position(10, 7))
    nmpc.run_simulation()
コード例 #3
0
def test_mavo_no_obs_vis():
    mavo = MultiAgentVelocityObstacle()
    mavo.register_agent("toto", Position(2, 5), Position(4, 10))
    mavo.register_agent("tata", Position(4, 2), Position(4, 1))
    mavo.register_agent("titi", Position(10, 2), Position(0, 5))
    mavo.run_simulation()
    mavo.visualize("tata", 10, 10)
コード例 #4
0
ファイル: test_nmpc.py プロジェクト: ramonpereira/pymapf
def test_visualize_no_obs():
    nmpc = MultiAgentNMPC()
    nmpc.register_agent("toto", Position(1, 2), Position(4, 5))
    nmpc.register_agent("tata", Position(2, 2), Position(7, 5))
    nmpc.register_agent("titi", Position(2, 3), Position(4, 8))
    nmpc.run_simulation()
    nmpc.visualize("toto", 10, 10)
コード例 #5
0
ファイル: test_position.py プロジェクト: ramonpereira/pymapf
def test_position_str():
    pos = Position(4, 5)
    assert str(pos) == "[4 ; 5]"
コード例 #6
0
ファイル: test_position.py プロジェクト: ramonpereira/pymapf
def test_position():
    pos = Position(2, 4)
    assert pos.x == 2 and pos.y == 4
コード例 #7
0
from os import path
import sys

sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from pymapf.decentralized.nmpc.nmpc import MultiAgentNMPC
from pymapf.decentralized.position import Position
import numpy as np
import time

runtimes = []
global_runtimes_per_agents = []

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 10), Position(20, 10), vmin=0)
sim.register_agent("2", Position(20, 10), Position(0, 10), vmin=0)
stamp = time.time()
sim.run_simulation()
runtimes_per_agents = {}
for key, agent in sim.agents.items():
    runtimes_per_agents[key] = agent.total_computation_runtime
global_runtimes_per_agents.append(runtimes_per_agents)
runtimes.append((time.time() - stamp, 2))

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 10), Position(20, 10), vmin=0)
sim.register_agent("2", Position(20, 10), Position(0, 10), vmin=0)
sim.register_agent("3", Position(10, 20), Position(20, 0), vmin=0)
sim.register_agent("4", Position(20, 0), Position(10, 20), vmin=0)
stamp = time.time()
sim.run_simulation()
runtimes_per_agents = {}
コード例 #8
0
from os import path
import sys

sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from pymapf.decentralized.nmpc.nmpc import MultiAgentNMPC
from pymapf.decentralized.position import Position
import numpy as np
import time

runtimes = []
global_runtimes_per_agents = []

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 5), Position(10, 5), vmin=0)
sim.register_agent("2", Position(10, 5), Position(0, 5), vmin=0)
sim.register_agent("3", Position(5, 10), Position(5, 0), vmin=0)
sim.register_agent("4", Position(5, 0), Position(5, 10), vmin=0)
stamp = time.time()
sim.run_simulation()
runtimes_per_agents = {}
for key, agent in sim.agents.items():
    runtimes_per_agents[key] = agent.total_computation_runtime
global_runtimes_per_agents.append(runtimes_per_agents)
runtimes.append((time.time() - stamp, 100))

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 6), Position(12, 6), vmin=0)
sim.register_agent("2", Position(12, 6), Position(0, 6), vmin=0)
sim.register_agent("3", Position(6, 12), Position(6, 0), vmin=0)
sim.register_agent("4", Position(6, 0), Position(6, 12), vmin=0)
stamp = time.time()
コード例 #9
0
def test_nmpc_agent():
    agent = VelocityAgent("toto", Position(2, 2), Position(4, 6), 15, 0.1)
    assert agent.current_state.all() == np.array([2, 2]).all()
    assert agent.vmax > agent.vmin
コード例 #10
0
def test_mavo_obstacles():
    mavo = MultiAgentVelocityObstacle()
    mavo.register_obstacle(2, 3.14, Position(2, 3))
    assert len(mavo.obstacles_objects) == 1
コード例 #11
0
def test_mavo_agents():
    mavo = MultiAgentVelocityObstacle()
    mavo.register_agent("toto", Position(2, 2), Position(10, 5))
    mavo.register_agent("tata", Position(2, 5), Position(1, 5))
    mavo.register_agent("titi", Position(2, 9), Position(8, 5))
    assert len(mavo.agents) == 3
コード例 #12
0
from os import path
import sys

sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from pymapf.decentralized.nmpc.nmpc import MultiAgentNMPC
from pymapf.decentralized.position import Position
import numpy as np
import time

runtimes = []

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 5), Position(10, 5), vmin=0)
sim.register_agent("2", Position(10, 5), Position(0, 5), vmin=0)
stamp = time.time()
sim.run_simulation()
runtimes.append((time.time() - stamp, 2))

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 5), Position(10, 5), vmin=0)
sim.register_agent("2", Position(10, 5), Position(0, 5), vmin=0)
sim.register_agent("3", Position(5, 10), Position(5, 0), vmin=0)
sim.register_agent("4", Position(5, 0), Position(5, 10), vmin=0)
stamp = time.time()
sim.run_simulation()
runtimes.append((time.time() - stamp, 4))

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 5), Position(10, 5), vmin=0)
sim.register_agent("2", Position(10, 5), Position(0, 5), vmin=0)
sim.register_agent("3", Position(5, 10), Position(5, 0), vmin=0)
コード例 #13
0
ファイル: test_nmpc.py プロジェクト: ramonpereira/pymapf
def test_nmpc_obstacles():
    nmpc = MultiAgentNMPC()
    nmpc.register_obstacle(2, 3.14, Position(2, 3))
    assert len(nmpc.obstacles_objects) == 1
コード例 #14
0
ファイル: test_nmpc.py プロジェクト: ramonpereira/pymapf
def test_nmpc_agents():
    nmpc = MultiAgentNMPC()
    nmpc.register_agent("toto", Position(1, 2), Position(4, 5))
    nmpc.register_agent("tata", Position(2, 2), Position(7, 5))
    nmpc.register_agent("titi", Position(2, 3), Position(4, 8))
    assert len(nmpc.agents) == 3
コード例 #15
0
from os import path
import sys

sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from pymapf.decentralized.nmpc.nmpc import MultiAgentNMPC
from pymapf.decentralized.position import Position
import numpy as np

sim = MultiAgentNMPC()
sim.register_agent("r2d2", Position(0, 3), Position(10, 7), vmin=0)
sim.register_agent("bb8", Position(0, 7), Position(5, 10), vmin=0)
sim.register_agent("c3po", Position(10, 7), Position(5, 0), vmin=0)
sim.register_agent("r4d4", Position(10, 3), Position(0, 3), vmin=0)
sim.register_agent("wally", Position(5, 10), Position(0, 7), vmin=0)
sim.register_agent("spot", Position(5, 0), Position(10, 3), vmin=0)
sim.run_simulation()
sim.visualize("switch_positions_nmpc", 10, 10)