Skip to content

Commit 912f68f

Browse files
lukicdarkooomichel
andauthored
Various refactors and improvements (#186)
* Initial refactoring * Fix * Fix * Fix * Fix * Ignore * Better webots_home * Camel-case * Unused * Fix * Fix * Path * Fix * Add rolling ci * Fix camera * Fix euler * Move * Ignore * Update interpolation.py * Update utils.py * Update webots_node.py * Update webots_node.py * Update webots_node.py * Update webots_node.py * Update webots_node.py * Fix home * Visualize download * Change docstring * New line * Update webots_launcher.py * Use Inno Setup on Windows * Changelog * Better handle * Move installation to utils * Escape path * Fix * Escape path * Update webots_ros2_core/webots_ros2_core/utils.py Co-authored-by: Olivier Michel <[email protected]> Co-authored-by: Olivier Michel <[email protected]>
1 parent 9682e06 commit 912f68f

29 files changed

+530
-582
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
env:
1212
- {ROS_DISTRO: foxy, ROS_REPO: testing}
1313
- {ROS_DISTRO: foxy, ROS_REPO: main}
14+
- {ROS_DISTRO: rolling, ROS_REPO: testing}
15+
- {ROS_DISTRO: rolling, ROS_REPO: main}
1416
runs-on: ubuntu-latest
1517
steps:
1618
- uses: actions/checkout@v1

webots_ros2_core/CHANGELOG.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
Changelog for package webots_ros2_core
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5-
1.0.3 (2020-xx-xx)
5+
1.0.4 (2021-xx-xx)
6+
------------------
7+
* Improved performance of camera.
8+
* Replaced `tkinter` by a simple command line tools.
9+
* Fixed usage on Windows.
10+
* Introduced notion of minimum and target Webots versions.
11+
12+
1.0.3 (2020-12-01)
613
------------------
714
* Improved the performance of point cloud publishing by a few times.
815

webots_ros2_core/test/test_flake8.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@
2121
@pytest.mark.flake8
2222
@pytest.mark.linter
2323
def test_flake8():
24-
rc = main(argv=['--linelength', '128', '--exclude', 'webots_ros2_core/math/quaternions.py'])
24+
rc = main(argv=[
25+
'--linelength', '128', '--exclude', 'webots_ros2_core/math/quaternions.py', 'webots_ros2_core/webots_controller.py'
26+
])
2527
assert rc == 0, 'Found errors'

webots_ros2_core/test/test_math_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import unittest
16-
from webots_ros2_core.math_utils import interpolate_lookup_table
16+
from webots_ros2_core.math.interpolation import interpolate_lookup_table
1717

1818

1919
TABLE_DESC = [

webots_ros2_core/test/test_pep257.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
@pytest.mark.linter
2222
@pytest.mark.pep257
2323
def test_pep257():
24-
rc = main(argv=['.', '--exclude', 'webots_ros2_core/math/quaternions.py'])
24+
rc = main(argv=['.', '--exclude', 'webots_ros2_core/math/quaternions.py', 'webots_ros2_core/webots_controller.py'])
2525
assert rc == 0, 'Found code style errors / warnings'

webots_ros2_core/webots_ros2_core/devices/camera_device.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ def step(self):
102102
msg.width = self._wb_device.getWidth()
103103
msg.is_bigendian = False
104104
msg.step = self._wb_device.getWidth() * 4
105-
msg.data = self._wb_device.getImage()
105+
# We pass `data` directly to we avoid using `data` setter.
106+
# Otherwise ROS2 converts data to `array.array` which slows down the simulation as it copies memory internally.
107+
# Both, `bytearray` and `array.array`, implement Python buffer protocol, so we should not see unpredictable
108+
# behavior.
109+
# deepcode ignore W0212: Avoid conversion from `bytearray` to `array.array`.
110+
msg._data = self._wb_device.getImage()
106111
msg.encoding = 'bgra8'
107112
self._image_publisher.publish(msg)
108113
else:

webots_ros2_core/webots_ros2_core/devices/device_manager.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,14 @@
1616

1717
"""Auto discover Webots devices and publish suitable ROS2 topics."""
1818

19-
import sys
2019
from .camera_device import CameraDevice
2120
from .led_device import LEDDevice
2221
from .lidar_device import LidarDevice
2322
from .distance_sensor_device import DistanceSensorDevice
2423
from .light_sensor_device import LightSensorDevice
2524
from .robot_device import RobotDevice
2625
from .imu_device import ImuDevice
27-
from webots_ros2_core.utils import append_webots_python_lib_to_path
28-
try:
29-
append_webots_python_lib_to_path()
30-
from controller import Node
31-
except Exception as e:
32-
sys.stderr.write('"WEBOTS_HOME" is not correctly set.')
33-
raise e
26+
from webots_ros2_core.webots_controller import Node
3427

3528

3629
class DeviceManager:

webots_ros2_core/webots_ros2_core/devices/distance_sensor_device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Webots DistanceSensor device wrapper for ROS2."""
1616

1717
from sensor_msgs.msg import Range
18-
from webots_ros2_core.math_utils import interpolate_lookup_table
18+
from webots_ros2_core.math.interpolation import interpolate_lookup_table
1919
from .sensor_device import SensorDevice
2020

2121

webots_ros2_core/webots_ros2_core/devices/imu_device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Webots Accelerometer, Gyro and InertialUnit devices wrapper for ROS2."""
1616

1717
from sensor_msgs.msg import Imu
18-
from webots_ros2_core.math_utils import interpolate_lookup_table
18+
from webots_ros2_core.math.interpolation import interpolate_lookup_table
1919
from .sensor_device import SensorDevice
2020

2121

webots_ros2_core/webots_ros2_core/devices/light_sensor_device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Webots LightSensor device wrapper for ROS2."""
1616

1717
from sensor_msgs.msg import Illuminance
18-
from webots_ros2_core.math_utils import interpolate_lookup_table
18+
from webots_ros2_core.math.interpolation import interpolate_lookup_table
1919
from .sensor_device import SensorDevice
2020

2121

0 commit comments

Comments
 (0)