Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 92cb95c7 authored by Daniel Dugas's avatar Daniel Dugas
Browse files

working agents viz

parent e46850e5
No related branches found
No related tags found
No related merge requests found
using UnityEngine;
using System.Collections.Generic;
namespace RosSharp.RosBridgeClient
{
public class ETHCrowdSubscriber : Subscriber<Messages.crowdbotsim.TwistArrayStamped>
{
private bool isMessageReceived;
public Vector3[] crowd_pose;
protected override void Start()
{
int length = GameObject.FindGameObjectsWithTag("VirtualHumanActive").Length;
crowd_pose = new Vector3[length+1]; // + 1 for robot
for(int i = 0; i < length+1; i++)
{
crowd_pose[i] = new Vector3(0,0,0);
}
base.Start();
}
protected override void ReceiveMessage(Messages.crowdbotsim.TwistArrayStamped message)
{
for(int i = 0; i < message.twist.Length; i++){
if (i < crowd_pose.Length)
{
crowd_pose[i] = ProcessMessage(message.twist[i]);
}
else
{
print("Mismatch in crowd message an number of agents");
}
}
isMessageReceived = true;
}
private Vector3 ProcessMessage(Messages.Geometry.Twist agent)
{
Vector3 new_pos = new Vector3();
new_pos.x = agent.linear.x;
new_pos.y = agent.linear.z;
new_pos.z = agent.linear.y;
return new_pos;
}
public void GetAgents(List<Vector3> to_fill)
{
for(int i = 0; i < crowd_pose.Length; i++)
{
to_fill.Add(crowd_pose[i]);
}
return;
}
}
}
fileFormatVersion: 2
guid: 1ac1538dde393b86eb689a2625f68e79
folderAsset: yes
DefaultImporter:
guid: 3af2312059c51a4bdbd028e7f6cd5b87
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -15,7 +15,7 @@ public class Viz_ExternalTrialManager : MonoBehaviour, TrialManager {
public RosConnector ros_connector;
List<Publisher> Ros_Publishers;
// List<Subscriber> Ros_Subscribers;
public CrowdStampedSubscriber crowdsub;
public ETHCrowdSubscriber crowdsub;
private bool player_in_sim;
......@@ -100,17 +100,19 @@ public class Viz_ExternalTrialManager : MonoBehaviour, TrialManager {
}
GameObject[] my_robots = GameObject.FindGameObjectsWithTag("Robot");
foreach(GameObject r in my_robots)
{
}
GameObject[] humans = GameObject.FindGameObjectsWithTag("VirtualHumanActive");
int i = 0;
foreach (GameObject a in my_robots)
{
Vector3 temp = new Vector3(a.transform.position.x+(float)0.01, 0, 0);
a.transform.position = temp;
if (i < all_agents_pos.Count ){
a.transform.position = all_agents_pos[i];
}
i++;
}
foreach (GameObject a in humans)
{
Vector3 temp = new Vector3(a.transform.position.x+(float)0.01, 0, 0);
a.transform.position = temp;
// print(temp);
if (i < all_agents_pos.Count ){
a.transform.position = all_agents_pos[i];
}
......
This diff is collapsed.
fileFormatVersion: 2
guid: 1e432a42083055c3b93cdb7cbed99318
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment