Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Ros2ForUnity asset and add service hanling #343

Merged
merged 5 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions Assets/AWSIM/Scripts/Environments/V2I/V2IRos2Publisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ private void UpdateTrafficSignalArrayMsg(V2I.OutputData data)
//Get bulbData
var trafficLightBulbData = trafficLight.GetBulbData();
//Fill TrafficSignal with bulbData
var trafficLightElementList = new List<autoware_perception_msgs.msg.TrafficLightElement>();
var trafficLightElementList = new List<autoware_perception_msgs.msg.TrafficSignalElement>();
foreach (var bulbData in trafficLightBulbData)
{
if (isBulbTurnOn(bulbData.Status))
{
var trafficLightElementMsg = new autoware_perception_msgs.msg.TrafficLightElement();
var trafficLightElementMsg = new autoware_perception_msgs.msg.TrafficSignalElement();
trafficLightElementMsg.Color = V2IROS2Utility.UnityToRosBulbColor(bulbData.Color);
trafficLightElementMsg.Shape = V2IROS2Utility.UnityToRosBulbShape(bulbData.Type);
trafficLightElementMsg.Status = V2IROS2Utility.UnityToRosBulbStatus(bulbData.Status);
Expand Down
51 changes: 51 additions & 0 deletions Assets/AWSIM/Scripts/ROS/SimulatorROS2Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,32 @@ static void OnTimeSourceChanged()
return node.CreateSubscription<T>(topicName, callback, qos);
}

/// <summary>
/// Create a service
/// </summary>
/// <returns>The service</returns>
/// <param name="topicName">topic under which the service will be requestable</param>
/// <param name="qos">QoS for requests. If no QoS is selected, it will default to reliable, keep 10 last</param>
static public IService<T, S> CreateService<T, S>(string topicName, Func<T, S> callback, QualityOfServiceProfile qos = null)
where T: Message, new()
where S: Message, new()
{
return node.CreateService<T, S>(topicName, callback, qos);
}

/// <summary>
/// Create a client service
/// </summary>
/// <returns>The client</returns>
/// <param name="topicName">topic under which the client will call the service</param>
/// <param name="qos">QoS for requests. If no QoS is selected, it will default to reliable, keep 10 last</param>
static public Client<T, S> CreateClient<T, S>(string topicName, QualityOfServiceProfile qos = null)
where T: Message, new()
where S: Message, new()
{
return node.CreateClient<T, S>(topicName, qos);
}

/// <summary>
/// Update header timestamp
/// </summary>
Expand Down Expand Up @@ -130,6 +156,31 @@ static public void RemoveSubscription<T>(ISubscriptionBase subscription)
}
}

/// <summary>
/// Remove ros2 service
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="service"></param>
static public void RemoveService(IServiceBase service)
{
if (ros2UnityCore.Ok())
{
node.RemoveService(service);
}
}

/// <summary>
/// Remove ros2 client
/// </summary>
/// <param name="client"></param>
static public void RemoveClient(IClientBase client)
{
if (ros2UnityCore.Ok())
{
node.RemoveClient(client);
}
}

/// <summary>
/// Get current time
/// </summary>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Loading
Loading