Skip to content

Commit

Permalink
Make it possible to switch TF/TF_static publishing for micom from clo…
Browse files Browse the repository at this point in the history
…isim_ros_bringup
  • Loading branch information
hyunseok-yang committed Jun 24, 2024
1 parent 8b72ca9 commit b284ad2
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 198 deletions.
3 changes: 2 additions & 1 deletion cloisim_ros_base/src/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Base::Base(const string node_name, const string namespace_, const rclcpp::NodeOp
, m_node_handle(shared_ptr<rclcpp::Node>(this, [](auto) {}))
, m_static_tf_broadcaster(nullptr)
, m_tf_broadcaster(nullptr)
, enable_tf_publish_(true)
{
get_parameter_or("enable_tf", enable_tf_publish_, bool(true));
}
Expand All @@ -75,7 +76,7 @@ void Base::Start(const bool enable_tf_publish)

Initialize();

DBG_SIM_MSG("enable_tf(%d)", enable_tf_publish_);
DBG_SIM_MSG("node(%s) enable_tf(%d)", get_name(), enable_tf_publish_);

auto callback_static_tf_pub = [this]() -> void
{
Expand Down
9 changes: 9 additions & 0 deletions cloisim_ros_bringup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ Specify target model from simulation
```shell
ros2 launch cloisim_ros_bringup bringup.launch.py single_mode:=True target_model:=cloi0
```

### Enable or disable TF/TF_Static publishing

Currently only support "micom" type in cloisim_ros_bringup.

```shell
ros2 launch cloisim_ros_bringup bringup.launch.py micom.enable_tf:=False
ros2 run cloisim_ros_bringup bringup --ros-args -p single_mode:=True -p micom.enable_tf:=False
```
113 changes: 0 additions & 113 deletions cloisim_ros_bringup/launch/bringup.launch.py

This file was deleted.

1 change: 1 addition & 0 deletions cloisim_ros_bringup/launch/bringup.launch.py
118 changes: 118 additions & 0 deletions cloisim_ros_bringup/launch/bringup_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"""
LGE Advanced Robotics Laboratory
Copyright (c) 2020 LG Electronics Inc., LTD., Seoul, Korea
All Rights are Reserved.
SPDX-License-Identifier: MIT
"""

import launch.actions
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument, SetEnvironmentVariable
from launch.substitutions import LaunchConfiguration
from launch_ros.parameter_descriptions import ParameterValue


def generate_launch_description():

_single_mode = LaunchConfiguration('single_mode')
_target_model = LaunchConfiguration('target_model')
_target_parts_type = LaunchConfiguration('target_parts_type')
_target_parts_name = LaunchConfiguration('target_parts_name')
_enable_tf_micom = LaunchConfiguration('micom.enable_tf')
_scan = LaunchConfiguration('scan')
_cmd_vel = LaunchConfiguration('cmd_vel')
_odom = LaunchConfiguration('odom')
_imu = LaunchConfiguration('imu')
_navsatfix = LaunchConfiguration('navsatfix')

declare_launch_argument_sm = DeclareLaunchArgument(
'single_mode',
default_value='False',
description='whether to use single mode')

declare_launch_argument_tm = DeclareLaunchArgument(
'target_model',
default_value='',
description='specify the target model you want')

declare_launch_argument_tpt = DeclareLaunchArgument(
'target_parts_type',
default_value='',
description='specify the type of target parts you want')

declare_launch_argument_tpn = DeclareLaunchArgument(
'target_parts_name',
default_value='',
description='specify the name of target parts you want')

declare_launch_argument_etm = DeclareLaunchArgument(
'micom.enable_tf',
default_value='True',
description='whether to use tf/tf_static for Micom')

declare_launch_argument_sc = DeclareLaunchArgument(
'scan',
default_value='scan',
description='specify scan topic you want')

declare_launch_argument_cmdvel = DeclareLaunchArgument(
'cmd_vel',
default_value='cmd_vel',
description='specify cmd_vel topic you want')

declare_launch_argument_odom = DeclareLaunchArgument(
'odom',
default_value='odom',
description='specify odom topic you want')

declare_launch_argument_imu = DeclareLaunchArgument(
'imu',
default_value='imu',
description='specify imu/data topic you want')

declare_launch_argument_navsatfix = DeclareLaunchArgument(
'navsatfix',
default_value='navsatfix',
description='specify navsatfix topic you want')

stdout_log_use_stdout_envvar = SetEnvironmentVariable(
'RCUTILS_LOGGING_USE_STDOUT', '1')

stdout_log_buf_stream_envvar = SetEnvironmentVariable(
'RCUTILS_LOGGING_BUFFERED_STREAM', '1')

cloisim_ros_cmd = Node(
package="cloisim_ros_bringup",
executable="bringup",
output='screen',
remappings=[('scan', _scan),
('cmd_vel', _cmd_vel),
('odom', _odom),
('imu', _imu),
('navsatfix', _navsatfix)],
parameters=[{'single_mode': _single_mode,
'target_model': ParameterValue(_target_model, value_type=str),
'target_parts_type': ParameterValue(_target_parts_type, value_type=str),
'target_parts_name': ParameterValue(_target_parts_name, value_type=str),
'micom.enable_tf': _enable_tf_micom}])

# Create the launch description and populate
ld = launch.LaunchDescription()

# Set environment variables
ld.add_action(stdout_log_use_stdout_envvar)
ld.add_action(stdout_log_buf_stream_envvar)
ld.add_action(declare_launch_argument_sm)
ld.add_action(declare_launch_argument_tm)
ld.add_action(declare_launch_argument_tpt)
ld.add_action(declare_launch_argument_tpn)
ld.add_action(declare_launch_argument_sc)
ld.add_action(declare_launch_argument_cmdvel)
ld.add_action(declare_launch_argument_odom)
ld.add_action(declare_launch_argument_imu)
ld.add_action(declare_launch_argument_navsatfix)
ld.add_action(declare_launch_argument_etm)
ld.add_action(cloisim_ros_cmd)

return ld
42 changes: 0 additions & 42 deletions cloisim_ros_bringup/launch/cloisim.launch.py

This file was deleted.

1 change: 1 addition & 0 deletions cloisim_ros_bringup/launch/cloisim.launch.py
43 changes: 43 additions & 0 deletions cloisim_ros_bringup/launch/cloisim_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
LGE Advanced Robotics Laboratory
Copyright (c) 2020 LG Electronics Inc., LTD., Seoul, Korea
All Rights are Reserved.
SPDX-License-Identifier: MIT
"""

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import ExecuteProcess
from launch.substitutions import LaunchConfiguration


def generate_launch_description() -> LaunchDescription:

sim_path = LaunchConfiguration('sim_path')
world = LaunchConfiguration('world')

execute_multi_robot_simulator = ExecuteProcess(
cmd=['./CLOiSim.x86_64', '-world', world],
cwd=[sim_path],
output='screen')

declare_launch_argument_sim_path = DeclareLaunchArgument(
'sim_path',
default_value='',
description='path where the CLOiSim simulator located')

declare_launch_argument_world = DeclareLaunchArgument(
'world',
default_value='',
description='It is World file name. Please check environments before run. [CLOISIM_WORLD_PATH, CLOISIM_MODEL_PATH]')

# Create the launch description and populate
ld = LaunchDescription()

# Add the actions to launch all nodes
ld.add_action(declare_launch_argument_sim_path)
ld.add_action(declare_launch_argument_world)
ld.add_action(execute_multi_robot_simulator)

return ld
Loading

0 comments on commit b284ad2

Please sign in to comment.