Skip to content

Commit 29943a4

Browse files
Merge pull request #43 from kzorina/hpp_test_code
Initial demo setup for HPP pick and place plan
2 parents 7d87ae5 + deed387 commit 29943a4

40 files changed

+242379
-0
lines changed

agimus_demo_04_visual_servoing/.exists

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cmake_minimum_required(VERSION 3.22.1)
2+
3+
#
4+
# Project definition
5+
#
6+
project(agimus_demo_05_pick_and_place LANGUAGES CXX)
7+
8+
#
9+
# Handle dependencies by reading the package.xml
10+
#
11+
find_package(ament_cmake_auto REQUIRED)
12+
ament_auto_find_build_dependencies()
13+
14+
#
15+
# Build Python package.
16+
#
17+
ament_python_install_package(${PROJECT_NAME})
18+
install(PROGRAMS scripts/pick_and_place_node DESTINATION lib/${PROJECT_NAME})
19+
20+
#
21+
# Unit tests
22+
#
23+
include(CTest)
24+
if(BUILD_TESTING)
25+
find_package(ament_lint_auto REQUIRED)
26+
ament_auto_find_test_dependencies()
27+
# Integration test of the roscontrol controller with simulation on Talos.
28+
# add_rostest(tests/test_integration.py)
29+
endif()
30+
31+
#
32+
# Installation
33+
#
34+
ament_auto_package(INSTALL_TO_SHARE config launch urdf srdf)
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
AGIMUS demo 05 pick and place
2+
-----------------------------
3+
4+
The purpose of this demo is to use the AGIMUS architecture to unbox some objects.
5+
Expected behaviors:
6+
- The robot goes over a box of object.
7+
- The robot start approaching one object.
8+
- The robot goes to grasp an object.
9+
- The robot move the object above a desired location.
10+
- The robot drops the object.
11+
12+
## Install dependencies and build.
13+
14+
```bash
15+
vcs import src < src/agimus-demos/agimus_demo_05_pick_and_place/dependencies.repos
16+
rosdep update --rosdistro $ROS_DISTRO
17+
rosdep install -y -i --from-paths src --rosdistro $ROS_DISTRO --skip-keys libfranka
18+
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug --symlink-install
19+
source install/setup.bash
20+
```
21+
22+
## Start the demo in simulation using the Panda robot.
23+
```bash
24+
cd workspace
25+
reset && source install/setup.bash && ros2 launch agimus_demo_05_pick_and_place bringup.launch.py use_gazebo:=true
26+
```
27+
After the xterm terminal is opened, type there `o.pick_and_place('obj_26')`.
28+
29+
## Start the demo on hardware using the Panda robot.
30+
```bash
31+
ros2 launch agimus_demo_05_pick_and_place bringup_hw.launch.py arm_id:=fer robot_ip:=<fci-ip>
32+
```

agimus_demo_05_pick_and_place/agimus_demo_05_pick_and_place/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from copy import deepcopy
2+
3+
import rclpy
4+
from rclpy.node import Node
5+
from rclpy.task import Future
6+
from rclpy.qos import qos_profile_system_default, QoSProfile
7+
from rclpy.qos_overriding_options import QoSOverridingOptions
8+
9+
10+
class AsyncSubscriber:
11+
def __init__(
12+
self,
13+
node: Node,
14+
message_type: type,
15+
topic_name: str,
16+
qos_profile: QoSProfile = qos_profile_system_default,
17+
) -> None:
18+
self._node = node
19+
20+
# Joint states subscriber
21+
self._subscription = self._node.create_subscription(
22+
message_type,
23+
topic_name,
24+
self._message_cb,
25+
qos_profile=qos_profile,
26+
qos_overriding_options=QoSOverridingOptions.with_default_policies(),
27+
)
28+
29+
self._future = Future()
30+
# Initialize the future to be already in state `Done`
31+
self._future.set_result(None)
32+
33+
def _message_cb(self, msg):
34+
"""Callback function to latest value of the message."""
35+
# Complete the future if it was waiting
36+
if not self._future.done():
37+
self._future.set_result(msg)
38+
39+
def wait_for_future(self):
40+
"""Blocks until a new joint state is received."""
41+
self._future = Future() # Reset future for next call
42+
rclpy.spin_until_future_complete(self._node, self._future)
43+
return deepcopy(self._future.result())

0 commit comments

Comments
 (0)