Skip to content

Commit

Permalink
fix rosbot
Browse files Browse the repository at this point in the history
  • Loading branch information
lukicdarkoo committed Dec 27, 2024
1 parent 2188902 commit be11d43
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 39 deletions.
7 changes: 5 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ RUN useradd -d /${DOCKERUSER} -m \
usermod -a -G video ${DOCKERUSER} && \
usermod -a -G dialout ${DOCKERUSER}

RUN apt update && apt install -y wget && \
wget https://github.com/cyberbotics/webots/releases/download/nightly_25_12_2024/webots_2025a_amd64.deb -O /tmp/webots.deb && \
RUN echo $WEBOTS_VERSION | grep -q "nigthly" && export WEBOTS_URL="https://github.com/cyberbotics/webots/releases/download/R${WEBOTS_VERSION}/webots_${WEBOTS_VERSION}_amd64.deb" || export WEBOTS_URL="https://github.com/cyberbotics/webots/releases/download/${WEBOTS_VERSION}_amd64.deb" && \
apt update && apt install -y wget && \
wget ${WEBOTS_URL} -O /tmp/webots.deb && \
apt install -y /tmp/webots.deb && \
rm /tmp/webots.deb

Expand All @@ -36,6 +37,8 @@ RUN apt-get update && apt-get install -y \
ros-${ROS_DISTRO}-kinematics-interface \
ros-${ROS_DISTRO}-kinematics-interface-kdl \
ros-${ROS_DISTRO}-control-toolbox \
ros-${ROS_DISTRO}-robot-localization \
ros-${ROS_DISTRO}-laser-filters \
gdb \
git

Expand Down
10 changes: 5 additions & 5 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build:
echo "ROS_TESTING=${ROS_TESTING}"
docker build ${ROOT_DIR} \
-f ${ROOT_DIR}/docker/Dockerfile \
-t ${BASENAME}-image ${DOCKER_ARGS} \
-t ${BASENAME} ${DOCKER_ARGS} \
--build-arg UID=${UID} \
--build-arg DOCKERUSER=${DOCKERUSER} \
--build-arg DOCKERUSERCOMMENT=${DOCKERUSERCOMMENT} \
Expand All @@ -21,12 +21,12 @@ build:
--build-arg ROS_DISTRO=${ROS_DISTRO}

run:
@docker container rm -f ${BASENAME}-container
@docker container rm -f ${BASENAME}
docker run \
--net=host \
--ipc=host \
--cap-add SYS_ADMIN \
--name ${BASENAME}-container \
--name ${BASENAME} \
--privileged \
--restart unless-stopped \
-e NVIDIA_DRIVER_CAPABILITIES=all ${NVIDIA_GPU} \
Expand All @@ -37,8 +37,8 @@ run:
-v ${ROOT_DIR}:/${DOCKERUSER}/ros2_ws/src/${BASENAME} \
-v /dev:/dev:rw \
--entrypoint bash \
-d -it ${BASENAME}-image
-d -it ${BASENAME}


exec:
docker exec -it ${BASENAME}-container bash
docker exec -it ${BASENAME} bash
5 changes: 5 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ You need to build & run the container only the first time:
ROS_DISTRO=jazzy ROS_TESTING=0 WEBOTS_VERSION=2025a make build run exec
```

if you want to test a nightly build:
```bash
ROS_DISTRO=jazzy ROS_TESTING=0 WEBOTS_VERSION=nightly_25_12_2024/webots_2025a make build run exec
```

After that, you can just attach to the container with:
```bash
make exec
Expand Down
14 changes: 10 additions & 4 deletions scripts/ci_after_init.bash
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ if [[ "${ROS_DISTRO}" != "rolling" ]]; then
fi

# Setup Qt plugins for RViz (can be used once RViz does not randomly crash anymore in GitHub CI).
#export QT_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins
# export QT_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins

# HOTFIX: https://github.com/ros-controls/ros2_control/pull/1960
if [[ "${ROS_DISTRO}" == "humble" ]]; then
wget -O /tmp/hotfix.deb http://snapshots.ros.org/humble/2024-08-28/ubuntu/pool/main/r/ros-humble-hardware-interface/ros-humble-hardware-interface_2.43.0-1jammy.20240823.145349_amd64.deb && \
apt install -y --allow-downgrades /tmp/hotfix.deb && \
rm -f /tmp/hotfix.deb
fi

# Fixes:
# MESA: error: ZINK: failed to choose pdev
# 2024-07-27T19:23:20.1063344Z [webots-4] glx: failed to create drisw screen
if [[ "${ROS_DISTRO}" == "rolling" ]]; then
apt-get install -y libqt5quickcontrols2-5 qtquickcontrols2-5-dev
fi
apt-get install -y mesa-utils libgl1-mesa-dri
export LIBGL_ALWAYS_SOFTWARE=1
export MESA_GL_VERSION_OVERRIDE=3.3
1 change: 1 addition & 0 deletions webots_ros2_husarion/launch/rosbot_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def get_ros2_nodes(*args):
],
remappings=[
('rosbot_base_controller/cmd_vel_unstamped', '/cmd_vel'),
('rosbot_base_controller/cmd_vel', '/cmd_vel'),
('rosbot/laser', '/scan'),
('rosbot/rl_range', '/range/rl'),
('rosbot/rr_range', '/range/rr'),
Expand Down
1 change: 1 addition & 0 deletions webots_ros2_husarion/launch/rosbot_xl_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def get_ros2_nodes(*args):
],
remappings=[
('rosbot_xl_base_controller/cmd_vel_unstamped', '/cmd_vel'),
('rosbot_xl_base_controller/cmd_vel', '/cmd_vel'),
('rosbot_xl/laser', '/scan')
]
)
Expand Down
42 changes: 29 additions & 13 deletions webots_ros2_tests/test/test_system_rosbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from launch.launch_description_sources import PythonLaunchDescriptionSource
import launch_testing.actions
from launch.actions import IncludeLaunchDescription
from geometry_msgs.msg import Twist
from geometry_msgs.msg import Twist, TwistStamped
from sensor_msgs.msg import LaserScan
from ament_index_python.packages import get_package_share_directory
from webots_ros2_tests.utils import TestWebots, initialize_webots_test
Expand Down Expand Up @@ -64,18 +64,34 @@ def setUp(self):
self.__node = rclpy.create_node('driver_tester')

def testMovement(self):
publisher = self.__node.create_publisher(Twist, '/cmd_vel', 1)

def on_position_message_received(message):
twist_message = Twist()
twist_message.linear.x = 0.5
twist_message.angular.z = 0.3
publisher.publish(twist_message)

# ROSbot should move in an arc to check the sensor fusion
if message.pose.pose.position.x > 0.5 and message.pose.pose.orientation.w < 0.9:
return True
return False
use_twist_stamped = 'ROS_DISTRO' in os.environ and (os.environ['ROS_DISTRO'] in ['rolling', 'jazzy'])

publisher = None
if use_twist_stamped:
publisher = self.__node.create_publisher(TwistStamped, '/cmd_vel', 1)

def on_position_message_received(message):
twist_message = TwistStamped()
twist_message.header.stamp = self.__node.get_clock().now().to_msg()
twist_message.twist.linear.x = 0.5
twist_message.twist.angular.z = 0.3
publisher.publish(twist_message)

if message.pose.pose.position.x > 0.5 and message.pose.pose.orientation.w < 0.9:
return True
return False
else:
publisher = self.__node.create_publisher(Twist, '/cmd_vel', 1)

def on_position_message_received(message):
twist_message = Twist()
twist_message.linear.x = 0.5
twist_message.angular.z = 0.3
publisher.publish(twist_message)

if message.pose.pose.position.x > 0.5 and message.pose.pose.orientation.w < 0.9:
return True
return False

self.wait_for_messages(self.__node, Odometry, '/odometry/filtered', condition=on_position_message_received)

Expand Down
46 changes: 31 additions & 15 deletions webots_ros2_tests/test/test_system_rosbot_xl.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from launch.launch_description_sources import PythonLaunchDescriptionSource
import launch_testing.actions
from launch.actions import IncludeLaunchDescription
from geometry_msgs.msg import Twist
from geometry_msgs.msg import Twist, TwistStamped
from sensor_msgs.msg import LaserScan
from ament_index_python.packages import get_package_share_directory
from webots_ros2_tests.utils import TestWebots, initialize_webots_test
Expand Down Expand Up @@ -68,20 +68,36 @@ def setUp(self):
self.__node = rclpy.create_node('driver_tester')

def testMovement(self):
publisher = self.__node.create_publisher(Twist, '/cmd_vel', 1)

def on_position_message_received(message):
twist_message = Twist()
twist_message.linear.x = 0.5
twist_message.angular.z = 0.3
publisher.publish(twist_message)
# ROSbot XL should move in an arc to check the sensor fusion
if message.pose.pose.position.x > 0.5 and message.pose.pose.orientation.w < 0.9:
return True
return False

self.wait_for_messages(
self.__node, Odometry, '/odometry/filtered', condition=on_position_message_received)
use_twist_stamped = 'ROS_DISTRO' in os.environ and (os.environ['ROS_DISTRO'] in ['rolling', 'jazzy'])

publisher = None
if use_twist_stamped:
publisher = self.__node.create_publisher(TwistStamped, '/cmd_vel', 1)

def on_position_message_received(message):
twist_message = TwistStamped()
twist_message.header.stamp = self.__node.get_clock().now().to_msg()
twist_message.twist.linear.x = 0.5
twist_message.twist.angular.z = 0.3
publisher.publish(twist_message)

if message.pose.pose.position.x > 0.5 and message.pose.pose.orientation.w < 0.9:
return True
return False
else:
publisher = self.__node.create_publisher(Twist, '/cmd_vel', 1)

def on_position_message_received(message):
twist_message = Twist()
twist_message.linear.x = 0.5
twist_message.angular.z = 0.3
publisher.publish(twist_message)

if message.pose.pose.position.x > 0.5 and message.pose.pose.orientation.w < 0.9:
return True
return False

self.wait_for_messages(self.__node, Odometry, '/odometry/filtered', condition=on_position_message_received)

def testScan(self):
def on_scan_message_received(message):
Expand Down

0 comments on commit be11d43

Please sign in to comment.