Skip to content

Commit

Permalink
Merge branch 'ign-launch3' into image_header
Browse files Browse the repository at this point in the history
  • Loading branch information
iche033 committed Apr 15, 2021
2 parents e759e22 + 460cfa8 commit b3acc63
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)
#============================================================================
# Initialize the project
#============================================================================
project(ignition-launch3 VERSION 3.1.1)
project(ignition-launch3 VERSION 3.2.0)

#============================================================================
# Find ignition-cmake
Expand Down
18 changes: 18 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
## Ignition Launch 3.x

### Ignition Launch 3.2.0 (2021-04-12)

1. Support unsubscribing from a topic in the websocket server.
* [Pull request 107](https://github.com/ignitionrobotics/ign-launch/pull/107)

1. Support particle_emitters in the websocket server.
* [Pull request 104](https://github.com/ignitionrobotics/ign-launch/pull/104)

1. Support getting topic names and message types in the websocket server.
* [Pull request 102](https://github.com/ignitionrobotics/ign-launch/pull/102)

1. Image streaming over websocket.
* [Pull request 97](https://github.com/ignitionrobotics/ign-launch/pull/97)

1. Treat IGN_LAUNCH_CONFIG_PATH as a path list.
* [Pull request 93](https://github.com/ignitionrobotics/ign-launch/pull/93)


### Ignition Launch 3.1.1 (2021-01-08)

1. All changes up to and including those in version 2.2.1.
Expand Down
57 changes: 57 additions & 0 deletions plugins/websocket_server/WebsocketServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ int rootCallback(struct lws *_wsi,
igndbg << "LWS_CALLBACK_HTTP\n";
return httpCallback(_wsi, _reason, _user, _in, _len);
break;

// Publish outboud messages
case LWS_CALLBACK_SERVER_WRITEABLE:
{
Expand Down Expand Up @@ -779,6 +780,37 @@ void WebsocketServer::OnMessage(int _socketId, const std::string &_msg)
this->QueueMessage(this->connections[_socketId].get(),
data.c_str(), data.length());
}
/// \todo(nkoeng) Deprecate this in Ignition Fortress, and instruct users
/// to rely on the "scene" message.
else if (frameParts[0] == "particle_emitters")
{
igndbg << "Particle emitter request received for world["
<< frameParts[1] << "]\n";
ignition::msgs::Empty req;
req.set_unused(true);

ignition::msgs::ParticleEmitter_V rep;
bool result;
unsigned int timeout = 2000;

std::string serviceName = std::string("/world/") + frameParts[1] +
"/particle_emitters";

bool executed = this->node.Request(serviceName, req, timeout, rep, result);
if (!executed || !result)
{
ignerr << "Failed to get the particle emitter information for "
<< frameParts[1] << " world.\n";
}

std::string data = BUILD_MSG(this->operations[PUBLISH], frameParts[0],
std::string("ignition.msgs.ParticleEmitter_V"),
rep.SerializeAsString());

// Queue the message for delivery.
this->QueueMessage(this->connections[_socketId].get(),
data.c_str(), data.length());
}
else if (frameParts[0] == "sub")
{
// Store the relation of socketId to subscribed topic.
Expand Down Expand Up @@ -827,7 +859,32 @@ void WebsocketServer::OnMessage(int _socketId, const std::string &_msg)
this->node.Subscribe(frameParts[1],
&WebsocketServer::OnWebsocketSubscribedImageMessage, this);
}
else if (frameParts[0] == "unsub")
{
igndbg << "Unsubscribe request for topic[" << frameParts[1] << "]\n";
std::map<std::string, std::set<int>>::iterator topicConnectionIter =
this->topicConnections.find(frameParts[1]);

if (topicConnectionIter != this->topicConnections.end())
{
// Remove from the topic connections map
topicConnectionIter->second.erase(_socketId);

// Only unsubscribe from the Ignition Transport topic if there are no
// more websocket connections.
if (topicConnectionIter->second.empty())
{
igndbg << "Unsubscribing from Ignition Transport Topic["
<< frameParts[1] << "]\n";
this->node.Unsubscribe(frameParts[1]);
}
}
else
{
ignwarn << "The websocket server is not subscribed to topic["
<< frameParts[1] << "]. Unable to unsubscribe from the topic\n";
}
}
}

//////////////////////////////////////////////////
Expand Down
15 changes: 9 additions & 6 deletions plugins/websocket_server/WebsocketServer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,17 @@ namespace ignition
/// 2. "pub": Publish a message from the Ignition Transport topic in
/// the `topic_name` component,
/// 3. "topics": Get the list of available topics,
/// 3. "topics-types": Get the list of available topics and their
/// message types, and
/// 4. "protos": Get a string containing all the protobuf
/// 4. "topics-types": Get the list of available topics and their
/// message types,
/// 5. "protos": Get a string containing all the protobuf
/// definitions, and
/// 6. "particle_emitters": Get the list of particle emitters.
/// definitions.
/// 7. "unsub": Unsubscribe from the topic in the `topic_name` component
///
/// The `topic_name` component is mandatory for the "sub" and "pub"
/// operations. If present, it must be the name of an Ignition Transport
/// topic.
/// The `topic_name` component is mandatory for the "sub", "pub", and
/// "unsub" operations. If present, it must be the name of an Ignition
/// Transport topic.
///
/// The `message_type` component is mandatory for the "pub" operation. If
/// present it names the Ignition Message type, such as
Expand Down

0 comments on commit b3acc63

Please sign in to comment.