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

Fixes for ROS2ScriptIntegration #63

Merged
merged 2 commits into from
Sep 17, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gems/ROS2ScriptIntegration/Code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
BUILD_DEPENDENCIES
PUBLIC
AZ::AzToolsFramework
$<TARGET_OBJECTS:Gem::${gem_name}.Private.Object>
Gem::${gem_name}.Private.Object
Gem::ROS2.Static
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace ROS2ScriptIntegration
AZ_RTTI(PublisherRequests, "{b8356874-f7ba-4436-8d98-a342d7c720d9}");
static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
virtual void PublishStdMsgsString(const AZStd::string& topicName, const AZStd::string& value) = 0;
virtual void PublishStdMsgString(const AZStd::string& topicName, const AZStd::string& value) = 0;
virtual void PublishStdMsgEmpty(const AZStd::string& topicName) = 0;
virtual void PublishStdMsgUInt32(const AZStd::string& topicName, const uint32_t value) = 0;
virtual void PublishStdMsgInt32(const AZStd::string& topicName, const int32_t value) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace ROS2ScriptIntegration
}

// Publishers overrides ...
void PublisherSystemComponent::PublishStdMsgsString(const AZStd::string& topicName, const AZStd::string& value)
void PublisherSystemComponent::PublishStdMsgString(const AZStd::string& topicName, const AZStd::string& value)
{
std_msgs::msg::String message;
message.data = std::string(value.c_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace ROS2ScriptIntegration

protected:
// ROS2ScriptIntegrationRequestBus::Handler overrides ...
void PublishStdMsgsString(const AZStd::string& topicName, const AZStd::string& value) override;
void PublishStdMsgString(const AZStd::string& topicName, const AZStd::string& value) override;

void PublishStdMsgEmpty(const AZStd::string& topicName) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ namespace ROS2ScriptIntegration
->Attribute(AZ::Script::Attributes::Category, "ROS2")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "ROS2")
->Event(
"PublishStdMsgsString", &PublisherRequestBus::Events::PublishStdMsgsString, { { { "Topic", "" }, { "Value", "" } } })
->Event("PublishStdMsgString", &PublisherRequestBus::Events::PublishStdMsgString, { { { "Topic", "" }, { "Value", "" } } })
->Event("PublishStdMsgEmpty", &PublisherRequestBus::Events::PublishStdMsgEmpty, { { { "Topic", "" } } })
->Event("PublishStdMsgUInt32", &PublisherRequestBus::Events::PublishStdMsgUInt32, { { { "Topic", "" }, { "Value", "" } } })
->Event("PublishStdMsgInt32", &PublisherRequestBus::Events::PublishStdMsgInt32, { { { "Topic", "" }, { "Value", "" } } })
Expand Down
6 changes: 3 additions & 3 deletions Gems/ROS2ScriptIntegration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Let us write a simple publisher using Script Canvas.
The "OnGraphStart" node is called on the component being activated.
It activates a "Heart Beat" node.
The "Heart Beat" node is configured to issue a pulse every 100 milliseconds.
Finally, pulse cause the publication message by node `PublishStdMsgsString`.
Finally, pulse cause the publication message by node `PublishStdMsgString`.

**Note** that the publisher is initialized on the first pulse.
To see your messages, start the simulation and type in the terminal:
Expand All @@ -37,9 +37,9 @@ You should see new messages arriving with a frequency of 10 Hertz.

The message can be published from LUA scripting language using a single call:
```lua
PublisherRequestBus.Broadcast.PublishStdMsgsString("/hello", "Hello world from Lua")
PublisherRequestBus.Broadcast.PublishStdMsgString("/hello", "Hello world from Lua")
```
in which the first parameter is a topic name and the rest of the parameters form the message (only one string in `PublishStdMsgsString` method).
in which the first parameter is a topic name and the rest of the parameters form the message (only one string in `PublishStdMsgString` method).

## Subscriber

Expand Down