Git Product home page Git Product logo

Comments (2)

centiLinda avatar centiLinda commented on August 9, 2024

I have solved the 2nd question already. In function environment()

def environment(current_step, first_frame, current_vel, semantic_map, k_scope, k_env, k_label_4, F0, device):
ori_step = current_step + first_frame
scope_point = ori_step + torch.sign(current_vel) * k_scope
area = torch.floor(torch.stack((ori_step, scope_point), dim=2)).int()
F2 = torch.zeros_like(F0)
for i in range(F2.shape[0]):
if area[i, 0, 0] == area[i, 0, 1] and area[i, 1, 0] == area[i, 1, 1]:
continue
if area[i, 0, 0] == area[i, 0, 1] and area[i, 1, 0] != area[i, 1, 1]:
environment_vision = semantic_map[area[i, 0, 0],
torch.min(area[i, 1, 0], area[i, 1, 1]): torch.max(area[i, 1, 0], area[i, 1, 1])]
if len(np.argwhere(environment_vision == 5)) == 0:
continue
obstacle = torch.from_numpy(np.mean(np.argwhere(environment_vision == 5), axis=0)).to(device) # 1
if area[i, 1, 0] < area[i, 1, 1]:
dis = torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] = (k_env / dis) * torch.tensor([0, -1]).to(device)
else:
dis = k_scope - torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] = (k_env / dis) * torch.tensor([0, 1]).to(device)
continue
if area[i, 0, 0] != area[i, 0, 1] and area[i, 1, 0] == area[i, 1, 1]:
environment_vision = semantic_map[
torch.min(area[i, 0, 0], area[i, 0, 1]): torch.max(area[i, 0, 0], area[i, 0, 1]),
area[i, 1, 0]]
if len(np.argwhere(environment_vision == 5)) == 0:
continue
obstacle = torch.from_numpy(np.mean(np.argwhere(environment_vision == 5), axis=0)).to(device) # 1
if area[i, 0, 0] < area[i, 0, 1]:
dis = torch.norm(obstacle) + 1
if dis == 0:
continue
F2[i, :] = (k_env / dis) * torch.tensor([-1, 0]).to(device)
else:
dis = k_scope - torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] = (k_env / dis) * torch.tensor([1, 0]).to(device)
continue
environment_vision = semantic_map[
torch.min(area[i, 0, 0], area[i, 0, 1]): torch.max(area[i, 0, 0], area[i, 0, 1]),
torch.min(area[i, 1, 0], area[i, 1, 1]): torch.max(area[i, 1, 0], area[i, 1, 1])]
if len(np.argwhere(environment_vision == 5)) == 0:
continue
obstacle = torch.from_numpy(np.mean(np.argwhere(environment_vision == 5), axis=0)).to(device) # 2
if area[i, 0, 0] < area[i, 0, 1] and area[i, 1, 0] < area[i, 1, 1]:
dis = torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] = -(k_env / dis) * (obstacle / dis)
if area[i, 0, 0] < area[i, 0, 1] and area[i, 1, 0] > area[i, 1, 1]:
dis = torch.norm(obstacle - torch.tensor([0, k_scope]).to(device))
if dis == 0:
continue
F2[i, :] = (k_env / dis) * ((torch.tensor([0, k_scope]).to(device) - obstacle) / dis)
if area[i, 0, 0] > area[i, 0, 1] and area[i, 1, 0] < area[i, 1, 1]:
dis = torch.norm(obstacle - torch.tensor([k_scope, 0]).to(device))
if dis == 0:
continue
F2[i, :] = (k_env / dis) * ((torch.tensor([k_scope, 0]).to(device) - obstacle) / dis)
if area[i, 0, 0] > area[i, 0, 1] and area[i, 1, 0] > area[i, 1, 1]:
dis = torch.norm(obstacle - torch.tensor([k_scope, k_scope]).to(device))
if dis == 0:
continue
F2[i, :] = (k_env / dis) * ((torch.tensor([k_scope, k_scope]).to(device) - obstacle) / dis)
for i in range(F2.shape[0]):
if area[i, 0, 0] == area[i, 0, 1] and area[i, 1, 0] == area[i, 1, 1]:
continue
if area[i, 0, 0] == area[i, 0, 1] and area[i, 1, 0] != area[i, 1, 1]:
environment_vision = semantic_map[area[i, 0, 0],
torch.min(area[i, 1, 0], area[i, 1, 1]): torch.max(area[i, 1, 0], area[i, 1, 1])]
if len(np.argwhere(environment_vision == 3)) == 0:
continue
obstacle = torch.from_numpy(np.mean(np.argwhere(environment_vision == 3), axis=0)).to(device) # 1
if area[i, 1, 0] < area[i, 1, 1]:
dis = torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] += (k_env / dis) * torch.tensor([0, -1]).to(device)
else:
dis = k_scope - torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] += (k_env / dis) * torch.tensor([0, 1]).to(device)
continue
if area[i, 0, 0] != area[i, 0, 1] and area[i, 1, 0] == area[i, 1, 1]:
environment_vision = semantic_map[
torch.min(area[i, 0, 0], area[i, 0, 1]): torch.max(area[i, 0, 0], area[i, 0, 1]),
area[i, 1, 0]]
if len(np.argwhere(environment_vision == 3)) == 0:
continue
obstacle = torch.from_numpy(np.mean(np.argwhere(environment_vision == 3), axis=0)).to(device) # 1
if area[i, 0, 0] < area[i, 0, 1]:
dis = torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] += (k_env / dis) * torch.tensor([-1, 0]).to(device)
else:
dis = k_scope - torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] += (k_env / dis) * torch.tensor([1, 0]).to(device)
continue
environment_vision = semantic_map[
torch.min(area[i, 0, 0], area[i, 0, 1]): torch.max(area[i, 0, 0], area[i, 0, 1]),
torch.min(area[i, 1, 0], area[i, 1, 1]): torch.max(area[i, 1, 0], area[i, 1, 1])]
if len(np.argwhere(environment_vision == 3)) == 0:
continue
obstacle = torch.from_numpy(np.mean(np.argwhere(environment_vision == 3), axis=0)).to(device) # 2
if area[i, 0, 0] < area[i, 0, 1] and area[i, 1, 0] < area[i, 1, 1]:
dis = torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] += -(k_env / dis) * (obstacle / dis)
if area[i, 0, 0] < area[i, 0, 1] and area[i, 1, 0] > area[i, 1, 1]:
dis = torch.norm(obstacle - torch.tensor([0, k_scope]).to(device))
if dis == 0:
continue
F2[i, :] += (k_env / dis) * ((torch.tensor([0, k_scope]).to(device) - obstacle) / dis)
if area[i, 0, 0] > area[i, 0, 1] and area[i, 1, 0] < area[i, 1, 1]:
dis = torch.norm(obstacle - torch.tensor([k_scope, 0]).to(device))
if dis == 0:
continue
F2[i, :] += (k_env / dis) * ((torch.tensor([k_scope, 0]).to(device) - obstacle) / dis)
if area[i, 0, 0] > area[i, 0, 1] and area[i, 1, 0] > area[i, 1, 1]:
dis = torch.norm(obstacle - torch.tensor([k_scope, k_scope]).to(device))
if dis == 0:
continue
F2[i, :] += (k_env / dis) * ((torch.tensor([k_scope, k_scope]).to(device) - obstacle) / dis)
for i in range(F2.shape[0]):
if area[i, 0, 0] == area[i, 0, 1] and area[i, 1, 0] == area[i, 1, 1]:
continue
if area[i, 0, 0] == area[i, 0, 1] and area[i, 1, 0] != area[i, 1, 1]:
environment_vision = semantic_map[area[i, 0, 0],
torch.min(area[i, 1, 0], area[i, 1, 1]): torch.max(area[i, 1, 0], area[i, 1, 1])]
if len(np.argwhere(environment_vision == 4)) == 0:
continue
obstacle = torch.from_numpy(np.mean(np.argwhere(environment_vision == 4), axis=0)).to(device) # 1
if area[i, 1, 0] < area[i, 1, 1]:
dis = torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] += k_label_4 * (k_env / dis) * torch.tensor([0, -1]).to(device)
else:
dis = k_scope - torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] += k_label_4 * (k_env / dis) * torch.tensor([0, 1]).to(device)
continue
if area[i, 0, 0] != area[i, 0, 1] and area[i, 1, 0] == area[i, 1, 1]:
environment_vision = semantic_map[
torch.min(area[i, 0, 0], area[i, 0, 1]): torch.max(area[i, 0, 0], area[i, 0, 1]),
area[i, 1, 0]]
if len(np.argwhere(environment_vision == 4)) == 0:
continue
obstacle = torch.from_numpy(np.mean(np.argwhere(environment_vision == 4), axis=0)).to(device) # 1
if area[i, 0, 0] < area[i, 0, 1]:
dis = torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] += k_label_4 * (k_env / dis) * torch.tensor([-1, 0]).to(device)
else:
dis = k_scope - torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] += k_label_4 * (k_env / dis) * torch.tensor([1, 0]).to(device)
continue
environment_vision = semantic_map[
torch.min(area[i, 0, 0], area[i, 0, 1]): torch.max(area[i, 0, 0], area[i, 0, 1]),
torch.min(area[i, 1, 0], area[i, 1, 1]): torch.max(area[i, 1, 0], area[i, 1, 1])]
if len(np.argwhere(environment_vision == 4)) == 0:
continue
obstacle = torch.from_numpy(np.mean(np.argwhere(environment_vision == 4), axis=0)).to(device) # 2
if area[i, 0, 0] < area[i, 0, 1] and area[i, 1, 0] < area[i, 1, 1]:
dis = torch.norm(obstacle)
if dis == 0:
continue
F2[i, :] += -k_label_4 * (k_env / dis) * (obstacle / dis)
if area[i, 0, 0] < area[i, 0, 1] and area[i, 1, 0] > area[i, 1, 1]:
dis = torch.norm(obstacle - torch.tensor([0, k_scope]).to(device))
if dis == 0:
continue
F2[i, :] += k_label_4 * (k_env / dis) * ((torch.tensor([0, k_scope]).to(device) - obstacle) / dis)
if area[i, 0, 0] > area[i, 0, 1] and area[i, 1, 0] < area[i, 1, 1]:
dis = torch.norm(obstacle - torch.tensor([k_scope, 0]).to(device))
if dis == 0:
continue
F2[i, :] += k_label_4 * (k_env / dis) * ((torch.tensor([k_scope, 0]).to(device) - obstacle) / dis)
if area[i, 0, 0] > area[i, 0, 1] and area[i, 1, 0] > area[i, 1, 1]:
dis = torch.norm(obstacle - torch.tensor([k_scope, k_scope]).to(device))
if dis == 0:
continue
F2[i, :] += k_label_4 * (k_env / dis) * ((torch.tensor([k_scope, k_scope]).to(device) - obstacle) / dis)
return F2

Semantic class 3&5 means unwalkable, class 4 means weakly-repulsive. The rest of the classes mean walkable.

from human-trajectory-prediction-via-neural-social-physics.

centiLinda avatar centiLinda commented on August 9, 2024

For the 1st question, I checked Y-net's repo and it seems like the semantic masks are the manually labelled masks from Y-net. Is it correct?

from human-trajectory-prediction-via-neural-social-physics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.