Skip to content

Commit

Permalink
hardware jazzy with namespaces
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Delicat <[email protected]>
  • Loading branch information
delihus committed Jul 26, 2024
1 parent 605b017 commit c6e7c1d
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 51 deletions.
2 changes: 1 addition & 1 deletion rosbot/rosbot_hardware.repos
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories:
husarion_controllers:
type: git
url: https://github.com/husarion/husarion_controllers
version: 217b09830f5f42930098b9992eda41710702b625
version: jazzy
# Waiting for backporting to the humble version
# https://github.com/ros-controls/ros2_controllers/pull/726 and
# https://github.com/ros-controls/ros2_controllers/pull/831
Expand Down
3 changes: 1 addition & 2 deletions rosbot_bringup/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
<exec_depend>launch_ros</exec_depend>
<exec_depend>rosbot_controller</exec_depend>
<exec_depend>robot_localization</exec_depend>
<exec_depend>micro_ros_agent</exec_depend>
<exec_depend>micro_ros_msgs</exec_depend>


<test_depend>python3-pytest</test_depend>
<test_depend>launch</test_depend>
Expand Down
3 changes: 1 addition & 2 deletions rosbot_controller/config/diff_drive_controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
tf_frame_prefix_enable: false
use_namespace_as_sensor_name_prefix: true

sensor_name: imu
sensor_name: <robot_namespace>/imu
frame_id: imu_link
static_covariance_orientation: [1.9e-3, 0.0, 0.0, 0.0, 1.9e-3, 0.0, 0.0, 0.0, 1.9e-3] # Values taken from datasheet
static_covariance_angular_velocity: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0e-3] # Values measured experimentally
Expand Down Expand Up @@ -60,7 +60,6 @@

cmd_vel_timeout: 0.5
#publish_limited_velocity: true
use_stamped_vel: false

# Velocity and acceleration limits
# Whenever a min_* is unspecified, default to -max_*
Expand Down
3 changes: 1 addition & 2 deletions rosbot_controller/config/mecanum_drive_controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
tf_frame_prefix_enable: false
use_namespace_as_sensor_name_prefix: true

sensor_name: imu
sensor_name: <robot_namespace>/imu
frame_id: imu_link
static_covariance_orientation: [1.9e-3, 0.0, 0.0, 0.0, 1.9e-3, 0.0, 0.0, 0.0, 1.9e-3] # Values taken from datasheet
static_covariance_angular_velocity: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0e-3] # Values based on diff_drive
Expand Down Expand Up @@ -59,7 +59,6 @@

cmd_vel_timeout: 0.5
#publish_limited_velocity: true
use_stamped_vel: false

# Velocity and acceleration limits
# Whenever a min_* is unspecified, default to -max_*
Expand Down
15 changes: 12 additions & 3 deletions rosbot_controller/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
)
from launch_ros.actions import Node, SetParameter
from launch_ros.substitutions import FindPackageShare
from nav2_common.launch import ReplaceString


def generate_launch_description():
Expand Down Expand Up @@ -109,26 +110,34 @@ def generate_launch_description():
)
robot_description = {"robot_description": robot_description_content}

robot_controllers = PathJoinSubstitution(
robot_controllers_config = PathJoinSubstitution(
[
FindPackageShare("rosbot_controller"),
"config",
controller_config_name,
]
)

namespaced_robot_controllers_config = ReplaceString(
source_file=robot_controllers_config,
replacements={
"<robot_namespace>": namespace,
"//": "/"
},
)

control_node = Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[
robot_description,
robot_controllers,
namespaced_robot_controllers_config,
],
remappings=[
("imu_sensor_node/imu", "/_imu/data_raw"),
("~/motors_cmd", "/_motors_cmd"),
("~/motors_response", "/_motors_response"),
("rosbot_base_controller/cmd_vel_unstamped", "cmd_vel"),
("rosbot_base_controller/cmd_vel", "cmd_vel"),
("/tf", "tf"),
("/tf_static", "tf_static"),
],
Expand Down
4 changes: 2 additions & 2 deletions rosbot_controller/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<exec_depend>launch</exec_depend>
<exec_depend>launch_ros</exec_depend>
<exec_depend>nav2_common</exec_depend>

<exec_depend>xacro</exec_depend>
<exec_depend>controller_manager</exec_depend>
Expand All @@ -29,8 +30,7 @@
<exec_depend>joint_state_broadcaster</exec_depend>
<exec_depend>imu_sensor_broadcaster</exec_depend>
<exec_depend>diff_drive_controller</exec_depend>
<!-- TODO: @delihus update -->
<!-- <exec_depend>mecanum_drive_controller</exec_depend> -->
<exec_depend>mecanum_drive_controller</exec_depend>

<test_depend>python3-pytest</test_depend>
<test_depend>launch</test_depend>
Expand Down
6 changes: 3 additions & 3 deletions rosbot_description/urdf/rosbot_macro.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

<xacro:if value="$(arg use_sim)">
<xacro:if value="${simulation_engine == 'ignition-gazebo'}">
<plugin>ign_ros2_control/IgnitionSystem</plugin>
<plugin>gz_ros2_control/GazeboSimSystem</plugin>
</xacro:if>
<xacro:if value="${simulation_engine == 'webots'}">
<plugin>webots_ros2_control::Ros2ControlSystem</plugin>
Expand Down Expand Up @@ -121,7 +121,7 @@
<xacro:if value="${use_sim}">
<xacro:if value="${simulation_engine == 'ignition-gazebo'}">
<gazebo>
<plugin filename="ign_ros2_control-system" name="ign_ros2_control::IgnitionROS2ControlPlugin">
<plugin filename="gz_ros2_control-system" name="gz_ros2_control::GazeboSimROS2ControlPlugin">

<xacro:if value="${mecanum}">
<parameters>$(find rosbot_controller)/config/mecanum_drive_controller.yaml</parameters>
Expand All @@ -134,7 +134,7 @@
<xacro:unless value="${namespace == 'None'}">
<namespace>${namespace}</namespace>
</xacro:unless>
<remapping>rosbot_base_controller/cmd_vel_unstamped:=cmd_vel</remapping>
<remapping>rosbot_base_controller/cmd_vel:=cmd_vel</remapping>
<remapping>/tf:=tf</remapping>
</ros>
</plugin>
Expand Down
28 changes: 15 additions & 13 deletions rosbot_description/urdf/wheel.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,21 @@
</inertial>
</link>

<gazebo reference="${side}_wheel_link" xmlns:ignition="http://ignitionrobotics.org/schema">
<collision>
<surface>
<friction>
<ode>
<mu>1.0</mu>
<mu2>0.0</mu2>
<fdir1 ignition:expressed_in="base_link">${fdir}</fdir1>
</ode>
</friction>
</surface>
</collision>
</gazebo>
<xacro:if value="${mecanum}">
<gazebo reference="${side}_wheel_link" xmlns:ignition="http://ignitionrobotics.org/schema">
<collision>
<surface>
<friction>
<ode>
<mu>1.0</mu>
<mu2>0.0</mu2>
<fdir1 ignition:expressed_in="base_link">${fdir}</fdir1>
</ode>
</friction>
</surface>
</collision>
</gazebo>
</xacro:if>

</xacro:macro>
</robot>
27 changes: 14 additions & 13 deletions tools/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ARG ROS_DISTRO=humble
ARG ROS_DISTRO=jazzy
ARG PREFIX=
ARG HUSARION_ROS_BUILD_TYPE=hardware

## =========================== ROS builder ===============================
FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-base AS ros_builder
FROM rosbot-jazzy-rosdep

ARG ROS_DISTRO
ARG PREFIX
Expand All @@ -12,20 +12,21 @@ ARG HUSARION_ROS_BUILD_TYPE
ENV HUSARION_ROS_BUILD_TYPE=${HUSARION_ROS_BUILD_TYPE}

WORKDIR /ros2_ws
RUN mkdir src

COPY ./ src/
RUN mkdir -p src

RUN apt-get update && apt-get install -y \
python3-pip \
stm32flash

RUN vcs import src < src/rosbot/rosbot_hardware.repos && \
if [ "$HUSARION_ROS_BUILD_TYPE" == "simulation" ]; then \
vcs import src < src/rosbot/rosbot_simulation.repos; \
else \
rm -rf src/rosbot_gazebo; \
fi && \
stm32flash python3-periphery python3-ftdi


COPY ./ src/
# RUN vcs import src < src/rosbot/rosbot_hardware.repos && \
# if [ "$HUSARION_ROS_BUILD_TYPE" == "simulation" ]; then \
# vcs import src < src/rosbot/rosbot_simulation.repos; \
# else \
# rm -rf src/rosbot_gazebo; \
# fi && \
RUN rm -rf src/rosbot_gazebo; rm -rf src/rosbot_controllers/mecanum_drive_controller \
rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \
rosdep init && \
rosdep update --rosdistro $ROS_DISTRO && \
Expand Down
41 changes: 31 additions & 10 deletions tools/compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,37 @@ services:
build:
context: ../
dockerfile: tools/Dockerfile.dev
network_mode: host
ipc: host
# privileged: true # GPIO
devices:
- ${SERIAL_PORT:?err}
- /dev/bus/usb/ #FTDI
# devices:
# - ${SERIAL_PORT:?err}
# - /dev/bus/usb/ #FTDI
volumes:
- ../rosbot_utils:/ros2_ws/src/rosbot_utils
command: tail -f /dev/null
# command: >
# ros2 launch rosbot_bringup combined.launch.py
# mecanum:=${MECANUM:-False}
# serial_port:=$SERIAL_PORT
# serial_baudrate:=576000
# namespace:=robot1
# command: tail -f /dev/null
environment:
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
command: >
ros2 launch rosbot_bringup bringup.launch.py
mecanum:=${MECANUM:-False}
namespace:=rosbot
rviz:
image: husarion/rviz2:jazzy-jazzy
# build:
# context: ..
# dockerfile: Dockerfile
network_mode: host
ipc: host
runtime: nvidia
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
# - ./rosbot.rviz:/root/.rviz2/default.rviz
environment:
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
- ROS_DOMAIN_ID
- DISPLAY
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=all
command: >
rviz2 --ros-args -r __ns:=/rosbot -r /tf:=tf -r /tf_static:=tf_static

0 comments on commit c6e7c1d

Please sign in to comment.