Commit e6a71d76 authored by levi's avatar levi
Browse files

added launch files for connecting to different hosts

parent ff6287d4
rmq_publisher:
ros__parameters:
server_hostname: "localhost"
rmq_publisher_docker:
ros__parameters:
server_hostname: "rmq-srv" #containername
\ No newline at end of file
from launch import LaunchDescription
import launch_ros.actions
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
return LaunchDescription([
launch_ros.actions.Node(
parameters=[get_package_share_directory(
"rmq_publisher") + '/config/default.yml'],
package='rmq_publisher',
executable='rmq_publisher',
name='rmq_publisher', # name in ros network
output='screen'
)
])
from launch import LaunchDescription
import launch_ros.actions
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
return LaunchDescription([
launch_ros.actions.Node(
parameters=[get_package_share_directory(
"rmq_publisher") + '/config/default.yml'],
package='rmq_publisher',
executable='rmq_publisher',
name='rmq_publisher_docker', # name in ros network
output='screen'
)
])
......@@ -21,10 +21,11 @@ class RabbitMQPublisher(Node):
def __init__(self):
super().__init__("rabbitmq_topic_forwarder")
self.declare_parameter('server_hostname','localhost')
self.init_rabbitmq()
self.config = {"prefix_topic_name": True, "group_values_by_topic": True}
self.forward_this = {
"cmd_simple_control": {"type": Vector3, "fields": ["x", "y", "z"]},
"cmd_vel": {"type": Twist, "fields": ["linear.y", "angular.z"]},
......@@ -115,7 +116,7 @@ class RabbitMQPublisher(Node):
for i in range(5):
try:
self.rmq_connection = pika.BlockingConnection(
pika.ConnectionParameters("localhost")
pika.ConnectionParameters(self.get_parameter('server_hostname').get_parameter_value().string_value)
)
self.rmq_channel = self.rmq_connection.channel()
......
......@@ -13,7 +13,8 @@ setup(
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
(os.path.join(share_path, 'launch'), glob('launch/*.launch.py'))
(os.path.join(share_path, 'launch'), glob('launch/*.launch.py')),
(os.path.join(share_path, 'config'), glob('config/*.yml'))
],
install_requires=['setuptools'],
zip_safe=True,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment