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

Simplify prefix #82

Closed
wants to merge 6 commits into from
Closed
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
args: [--pytest-test-first]

- repo: https://github.com/codespell-project/codespell
rev: v1.16.0
rev: v2.2.6
hooks:
- id: codespell
name: codespell
Expand All @@ -26,13 +26,13 @@ repos:
types: [text]

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.1
rev: 0.2.3
hooks:
- id: yamlfmt
files: ^.github|./\.yaml

- repo: https://github.com/psf/black
rev: 23.10.1
rev: 23.11.0
hooks:
- id: black
args: ["--line-length=99", "--experimental-string-processing"]
Expand Down
2 changes: 2 additions & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,5 @@ TODO
delipl
microros
namespaces
rplidar
slamtec
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ black rosbot*
```

## Demo
Bellow you can find demos with ROSbots:
Below you can find demos with ROSbots:
- in [rosbot-docker](https://github.com/husarion/rosbot-docker/tree/ros2) you will find a simple example how to drive ROSbot with `teleop_twist_keyboard`.
- in [rosbot-sensors](https://github.com/husarion/rosbot-sensors) you will find an example how to visualize all ROSbot sensors.
- in [rosbot-mapping](https://github.com/husarion/rosbot-mapping) you will find an example how to use ROSbot with the [slam_toolbox](https://github.com/SteveMacenski/slam_toolbox/).
Expand Down
2 changes: 1 addition & 1 deletion rosbot/rosbot_hardware.repos
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repositories:
ros_components_description:
type: git
url: https://github.com/husarion/ros_components_description.git
version: ros2
version: namespace-suggestions
rosbot_controllers:
type: git
url: https://github.com/husarion/rosbot_controllers
Expand Down
2 changes: 0 additions & 2 deletions rosbot_bringup/config/ekf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
publish_tf: true
publish_acceleration: false

# The odometry topic name is overwritten in launch file due to the namespace argument
odom0: rosbot_base_controller/odom
odom0_config: [false, false, false, # X , Y , Z
false, false, false, # roll , pitch ,yaw
Expand All @@ -31,7 +30,6 @@
odom0_differential: false
odom0_relative: true

# The IMU topic name is overwritten in launch file due to the namespace argument
imu0: imu_broadcaster/imu
imu0_config: [false, false, false, # X , Y , Z
false, false, true, # roll , pitch ,yaw
Expand Down
91 changes: 40 additions & 51 deletions rosbot_bringup/launch/bringup.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,42 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from launch import LaunchDescription
from launch import LaunchDescription, LaunchContext
from launch_ros.actions import Node, SetParameter
from ament_index_python.packages import get_package_share_directory
from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument, OpaqueFunction
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, PythonExpression
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution


def launch_ekf(context: LaunchContext, *args, **kwargs):
rosbot_bringup = get_package_share_directory("rosbot_bringup")
ekf_config = PathJoinSubstitution([rosbot_bringup, "config", "ekf.yaml"])

namespace = context.perform_substitution(LaunchConfiguration("namespace"))
namespace = namespace + "/" if namespace else ""

robot_localization_node = Node(
package="robot_localization",
executable="ekf_node",
name="ekf_filter_node",
output="screen",
parameters=[
ekf_config,
{"map_frame": namespace + "map"},
{"odom_frame": namespace + "odom"},
{"base_link_frame": namespace + "base_link"},
{"world_frame": namespace + "odom"},
],
namespace=namespace,
)

return [robot_localization_node]


def generate_launch_description():
namespace = LaunchConfiguration("namespace")
namespace_tf_prefix = PythonExpression(
["''", " if '", namespace, "' == '' ", "else ", "'", namespace, "_'"]
)

declare_namespace_arg = DeclareLaunchArgument(
"namespace",
default_value="",
Expand Down Expand Up @@ -54,7 +77,6 @@ def generate_launch_description():
)

rosbot_controller = get_package_share_directory("rosbot_controller")
rosbot_bringup = get_package_share_directory("rosbot_bringup")

mecanum = LaunchConfiguration("mecanum")
declare_mecanum_arg = DeclareLaunchArgument(
Expand Down Expand Up @@ -84,48 +106,15 @@ def generate_launch_description():
}.items(),
)

ekf_config = PathJoinSubstitution([rosbot_bringup, "config", "ekf.yaml"])

robot_localization_node = Node(
package="robot_localization",
executable="ekf_node",
name="ekf_filter_node",
output="screen",
parameters=[
ekf_config,
{
"map_frame": LaunchConfiguration(
"ekf_map_frame", default=[namespace_tf_prefix, "map"]
)
},
{
"odom_frame": LaunchConfiguration(
"ekf_odom_frame", default=[namespace_tf_prefix, "odom"]
)
},
{
"base_link_frame": LaunchConfiguration(
"ekf_base_link_frame", default=[namespace_tf_prefix, "base_link"]
)
},
{
"world_frame": LaunchConfiguration(
"ekf_world_frame", default=[namespace_tf_prefix, "odom"]
)
},
],
namespace=namespace,
return LaunchDescription(
[
declare_namespace_arg,
declare_mecanum_arg,
declare_use_sim_arg,
declare_use_gpu_arg,
declare_simulation_engine_arg,
SetParameter(name="use_sim_time", value=use_sim),
controller_launch,
OpaqueFunction(function=launch_ekf),
]
)

actions = [
declare_namespace_arg,
declare_mecanum_arg,
declare_use_sim_arg,
declare_use_gpu_arg,
declare_simulation_engine_arg,
SetParameter(name="use_sim_time", value=use_sim),
controller_launch,
robot_localization_node,
]

return LaunchDescription(actions)
15 changes: 5 additions & 10 deletions rosbot_controller/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ def generate_launch_description():
]
)

namespace_for_controller_name = PythonExpression(
namespace_ext = PythonExpression(
["''", " if '", namespace, "' == '' ", "else ", "'", namespace, "/'"]
)
controller_manager_name = LaunchConfiguration(
"controller_manager_name",
default=[namespace_for_controller_name, controller_manager_type_name],
default=[namespace_ext, controller_manager_type_name],
)

# Get URDF via xacro
robot_description_content = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
Expand All @@ -112,7 +111,7 @@ def generate_launch_description():
use_gpu,
" simulation_engine:=",
simulation_engine,
" tf_prefix:=",
" namespace:=",
namespace,
rafal-gorecki marked this conversation as resolved.
Show resolved Hide resolved
]
)
Expand All @@ -132,11 +131,7 @@ def generate_launch_description():
parameters=[
robot_description,
robot_controllers,
{
"tf_frame_prefix": LaunchConfiguration(
"rosbot_base_tf_frame_prefix", default=[namespace]
)
},
{"tf_frame_prefix": namespace},
],
remappings=[
("imu_sensor_node/imu", "/_imu/data_raw"),
Expand All @@ -151,7 +146,7 @@ def generate_launch_description():
robot_state_pub_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
parameters=[robot_description],
parameters=[robot_description, {"frame_prefix": namespace_ext}],
namespace=namespace,
)

Expand Down
50 changes: 25 additions & 25 deletions rosbot_description/urdf/body.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
<xacro:include filename="$(find rosbot_description)/urdf/components/vl53lox.urdf.xacro" ns="range_sensor" />

<xacro:if value="${tf_prefix == 'None'}">
<xacro:property name="tf_prefix_ext" value="" />
<xacro:property name="prefix" value="" />
</xacro:if>
<xacro:unless value="${tf_prefix == 'None'}">
<xacro:property name="tf_prefix_ext" value="${tf_prefix}_" />
<xacro:property name="prefix" value="${tf_prefix}_" />
</xacro:unless>

<link name="${tf_prefix_ext}base_link" />
<link name="${prefix}base_link" />

<joint name="${tf_prefix_ext}base_to_${tf_prefix_ext}body_joint" type="fixed">
<joint name="${prefix}base_to_${prefix}body_joint" type="fixed">
<origin xyz="0.0 0.0 ${wheel_radius}" rpy="0.0 0.0 0.0" />
<parent link="${tf_prefix_ext}base_link" />
<child link="${tf_prefix_ext}body_link" />
<parent link="${prefix}base_link" />
<child link="${prefix}body_link" />
</joint>

<link name="${tf_prefix_ext}body_link">
<link name="${prefix}body_link">
<visual>
<geometry>
<mesh filename="file://$(find rosbot_description)/meshes/body.stl" scale="0.001 0.001 0.001" />
Expand All @@ -45,17 +45,17 @@
<origin xyz="0.0 0.0 ${0.040 - 0.02}" rpy="0.0 0.0 0.0" />
</inertial>
</link>
<gazebo reference="${tf_prefix_ext}body_link">
<gazebo reference="${prefix}body_link">
<material>Gazebo/White</material>
</gazebo>

<joint name="${tf_prefix_ext}body_to_${tf_prefix_ext}cover_joint" type="fixed">
<joint name="${prefix}body_to_${prefix}cover_joint" type="fixed">
<origin xyz="0.0 0.0 0.0603" rpy="0.0 0.0 0.0" />
<parent link="${tf_prefix_ext}body_link" />
<child link="${tf_prefix_ext}cover_link" />
<parent link="${prefix}body_link" />
<child link="${prefix}cover_link" />
</joint>

<link name="${tf_prefix_ext}cover_link">
<link name="${prefix}cover_link">
<visual>
<geometry>
<mesh filename="file://$(find rosbot_description)/meshes/cover.stl" scale="0.001 0.001 0.001" />
Expand All @@ -65,31 +65,31 @@
<color rgba="0.8 0.0 0.0 1.0" />
</material>
</visual>
<gazebo reference="${tf_prefix_ext}cover_link">
<gazebo reference="${prefix}cover_link">
<material>Gazebo/Red</material>
</gazebo>
</link>

<joint name="${tf_prefix_ext}body_to_${tf_prefix_ext}imu_joint" type="fixed">
<joint name="${prefix}body_to_${prefix}imu_joint" type="fixed">
<origin xyz="0.003 -0.0495 0.04332" rpy="0.0 0.0 0.0" />
<parent link="${tf_prefix_ext}body_link" />
<child link="${tf_prefix_ext}imu_link" />
<parent link="${prefix}body_link" />
<child link="${prefix}imu_link" />
</joint>

<link name="${tf_prefix_ext}imu_link" />
<link name="${prefix}imu_link" />

<joint name="${tf_prefix_ext}body_to_${tf_prefix_ext}camera_joint" type="fixed">
<joint name="${prefix}body_to_${prefix}camera_joint" type="fixed">
<origin xyz="-0.0141 0.0 0.125" rpy="0.0 0.0 0.0" />
<parent link="${tf_prefix_ext}body_link" />
<child link="${tf_prefix_ext}camera_link" />
<parent link="${prefix}body_link" />
<child link="${prefix}camera_link" />
</joint>

<link name="${tf_prefix_ext}camera_link" />
<link name="${prefix}camera_link" />

<xacro:range_sensor.vl53lox parent="${tf_prefix_ext}body_link" xyz="0.0926 0.05 0.015" rpy="0.0 0.0 ${radians(12.5)}" side="fl" tf_prefix="${tf_prefix}" />
<xacro:range_sensor.vl53lox parent="${tf_prefix_ext}body_link" xyz="0.0926 -0.05 0.015" rpy="0.0 0.0 ${radians(-12.5)}" side="fr" tf_prefix="${tf_prefix}" />
<xacro:range_sensor.vl53lox parent="${tf_prefix_ext}body_link" xyz="-0.0926 0.05 0.0115" rpy="0.0 0.0 ${radians(167.5)}" side="rl" tf_prefix="${tf_prefix}" />
<xacro:range_sensor.vl53lox parent="${tf_prefix_ext}body_link" xyz="-0.0926 -0.05 0.0115" rpy="0.0 0.0 ${radians(192.5)}" side="rr" tf_prefix="${tf_prefix}" />
<xacro:range_sensor.vl53lox parent="${prefix}body_link" xyz="0.0926 0.05 0.015" rpy="0.0 0.0 ${radians(12.5)}" side="fl" tf_prefix="${tf_prefix}" />
<xacro:range_sensor.vl53lox parent="${prefix}body_link" xyz="0.0926 -0.05 0.015" rpy="0.0 0.0 ${radians(-12.5)}" side="fr" tf_prefix="${tf_prefix}" />
<xacro:range_sensor.vl53lox parent="${prefix}body_link" xyz="-0.0926 0.05 0.0115" rpy="0.0 0.0 ${radians(167.5)}" side="rl" tf_prefix="${tf_prefix}" />
<xacro:range_sensor.vl53lox parent="${prefix}body_link" xyz="-0.0926 -0.05 0.0115" rpy="0.0 0.0 ${radians(192.5)}" side="rr" tf_prefix="${tf_prefix}" />

</xacro:macro>
</robot>
18 changes: 9 additions & 9 deletions rosbot_description/urdf/components/vl53lox.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
<xacro:macro name="vl53lox" params="parent xyz rpy side tf_prefix">

<xacro:if value="${tf_prefix == 'None'}">
<xacro:property name="tf_prefix_ext" value="" />
<xacro:property name="prefix" value="" />
</xacro:if>
<xacro:unless value="${tf_prefix == 'None'}">
<xacro:property name="tf_prefix_ext" value="${tf_prefix}_" />
<xacro:property name="prefix" value="${tf_prefix}_" />
</xacro:unless>

<joint name="${parent.rstrip('_link')}_${tf_prefix_ext}${side}_range_joint" type="fixed">
<joint name="${parent.rstrip('_link')}_${prefix}${side}_range_joint" type="fixed">
<origin xyz="${xyz}" rpy="${rpy}" />
<parent link="${parent}" />
<child link="${tf_prefix_ext}${side}_range" />
<child link="${prefix}${side}_range" />
</joint>

<link name="${tf_prefix_ext}${side}_range" />
<link name="${prefix}${side}_range" />

<!-- an IR sensor or a sonar are not implemented yet
https://github.com/gazebosim/gz-sensors/issues/19 -->
<xacro:if value="${simulation_engine == 'ignition-gazebo'}">
<gazebo reference="${tf_prefix_ext}${side}_range">
<sensor name="${tf_prefix_ext}${side}_range" type='gpu_lidar'>
<gazebo reference="${prefix}${side}_range">
<sensor name="${prefix}${side}_range" type='gpu_lidar'>

<topic>/range/${side}</topic>
<frame_id>${tf_prefix_ext}${side}_range</frame_id>
<ignition_frame_id>${tf_prefix_ext}${side}_range</ignition_frame_id>
<frame_id>${prefix}${side}_range</frame_id>
<ignition_frame_id>${prefix}${side}_range</ignition_frame_id>

<update_rate>5.0</update_rate>
<ray>
Expand Down
Loading