Commit 07b88e19 authored by levi's avatar levi
Browse files

added rmq subscriber to launch with compose

parent acc9927f
...@@ -15,7 +15,7 @@ Make sure docker is installed and the user has access to docker service. ...@@ -15,7 +15,7 @@ Make sure docker is installed and the user has access to docker service.
#### Run: #### Run:
```bash ```bash
docker-compose -f terminal.yml -d up docker-compose -f terminal.yml up -d
``` ```
To controlled the robotti attach to the teleop terminal by: To controlled the robotti attach to the teleop terminal by:
```bash ```bash
......
...@@ -13,11 +13,11 @@ services: ...@@ -13,11 +13,11 @@ services:
# - 15672:15672 # - 15672:15672
# - 1883:1883 # - 1883:1883
rmq-publisher: rmq-bridge:
container_name: drobotti-rmq-publisher container_name: drobotti-rmq-bridge
build: build:
context: ./../../ context: ./../../
dockerfile: ./docker/rmq-publisher/rmq_publisher.Dockerfile dockerfile: ./docker/rmq-bridge/rmq_bridge.Dockerfile
restart: unless-stopped restart: unless-stopped
network_mode: "host" network_mode: "host"
# ports: # ports:
......
...@@ -47,4 +47,4 @@ RUN sed --in-place --expression \ ...@@ -47,4 +47,4 @@ RUN sed --in-place --expression \
/ros_entrypoint.sh /ros_entrypoint.sh
# run launch file # run launch file
CMD ["ros2", "launch", "rmq_bridge", "rmq_publisher_docker.launch.py"] CMD ["ros2", "launch", "rmq_bridge", "rmq_bridge_docker.launch.py"]
\ No newline at end of file \ No newline at end of file
...@@ -35,11 +35,11 @@ services: ...@@ -35,11 +35,11 @@ services:
- drobotti - drobotti
stdin_open: true # docker run -i stdin_open: true # docker run -i
tty: true # docker run -t tty: true # docker run -t
rmq_publisher: rmq_bridge:
container_name: rmq-pub container_name: rmq-bridge
build: build:
context: ../ context: ../
dockerfile: ./docker/rmq-publisher/rmq_publisher.Dockerfile dockerfile: ./docker/rmq-bridge/rmq_bridge.Dockerfile
depends_on: depends_on:
- rmq_server - rmq_server
- teleop_terminal - teleop_terminal
......
...@@ -2,6 +2,14 @@ rmq_publisher: ...@@ -2,6 +2,14 @@ rmq_publisher:
ros__parameters: ros__parameters:
server_hostname: "localhost" server_hostname: "localhost"
rmq_subscriber:
ros__parameters:
server_hostname: "localhost"
rmq_publisher_docker: rmq_publisher_docker:
ros__parameters:
server_hostname: "rmq-srv" #containername
rmq_subscriber_docker:
ros__parameters: ros__parameters:
server_hostname: "rmq-srv" #containername server_hostname: "rmq-srv" #containername
\ No newline at end of file
...@@ -12,5 +12,13 @@ def generate_launch_description(): ...@@ -12,5 +12,13 @@ def generate_launch_description():
executable='rmq_publisher', executable='rmq_publisher',
name='rmq_publisher_docker', # name in ros network name='rmq_publisher_docker', # name in ros network
output='screen' output='screen'
) ),
launch_ros.actions.Node(
parameters=[get_package_share_directory(
"rmq_bridge") + '/config/default.yml'],
package='rmq_bridge',
executable='rmq_subscriber',
name='rmq_subscriber_docker', # name in ros network
output='screen'
),
]) ])
...@@ -21,6 +21,8 @@ class RabbitMQSubscriber(Node): ...@@ -21,6 +21,8 @@ class RabbitMQSubscriber(Node):
def __init__(self): def __init__(self):
super().__init__("rabbitmq_subscriber") super().__init__("rabbitmq_subscriber")
self.declare_parameter('server_hostname','localhost')
self.init_rabbitmq() self.init_rabbitmq()
self.forward_this = { self.forward_this = {
...@@ -79,7 +81,7 @@ class RabbitMQSubscriber(Node): ...@@ -79,7 +81,7 @@ class RabbitMQSubscriber(Node):
print("Initializing Connection") print("Initializing Connection")
try: try:
self.rmq_connection = pika.BlockingConnection( self.rmq_connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost') pika.ConnectionParameters(self.get_parameter('server_hostname').get_parameter_value().string_value)
) )
self.rmq_channel = self.rmq_connection.channel() self.rmq_channel = self.rmq_connection.channel()
self.rmq_channel.exchange_declare( self.rmq_channel.exchange_declare(
......
Supports Markdown
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