Skip to content

Commit ba3664e

Browse files
amalnanavatiTaylor Kessler Faulkner
and
Taylor Kessler Faulkner
authored
Add some system configuration (#189)
* Add lovelace configuration * Add cyclonedds configuration * Fixed filepath to configure_lovelace.sh * Update README.md * Final cleaup * Formatting --------- Co-authored-by: Taylor Kessler Faulkner <[email protected]>
1 parent 6845a0d commit ba3664e

File tree

10 files changed

+49
-5
lines changed

10 files changed

+49
-5
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,20 @@ This README is the definitive source for downloading, installing, and running th
4747
- [`pyrealsense2` is not released for ARM systems](https://github.com/IntelRealSense/librealsense/issues/6449#issuecomment-650784066), so ARM users will have to [build from source](https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/readme.md#building-from-source). You may have to add the `-DPYTHON_EXECUTABLE=/usr/bin/python3` flag to the `cmake` command. When running `sudo make install`, pay close attention to which path `pyrealsense2` is installed to and add *that path* to the `PYTHONPATH` -- it should be `/use/local/lib` but may be `/usr/local/OFF`.
4848
4949
7. Install the JACO SDK (real robot only). All SDKs are listed [here](https://www.kinovarobotics.com/resources?r=79301&s); PRL currently uses the [Gen2 SDK v1.5.1](https://drive.google.com/file/d/1UEQAow0XLcVcPCeQfHK9ERBihOCclkJ9/view). Note that although the latest version of that SDK is for Ubuntu 16.04, it still works on Ubuntu 22.04 (only for x86 systems, not ARM system).
50-
8. (Optional): We recommend using [FastRTPS](https://docs.ros.org/en/humble/Installation/DDS-Implementations/Working-with-eProsima-Fast-DDS.html) as ROS middleware, as [CycloneDDS unnecessarily sends packets over the network](https://github.com/ros2/rmw_cyclonedds/issues/489). Install it with `sudo apt install ros-humble-rmw-fastrtps-cpp`. Then, add the following line to your `~/bashrc`: `export RMW_IMPLEMENTATION=rmw_fastrtps_cpp`. Note that you have to [rebuild your workspace from scratch after doing this](https://docs.ros.org/en/humble/How-To-Guides/Working-with-multiple-RMW-implementations.html#adding-rmw-implementations-to-your-workspace).
51-
8. Build your workspace:
50+
8. (Optional): We recommend using CycloneDDS as your ROS2 midleware, with a custom configuration file that enables multicast on loopback and prioritizes loopback. Install it with `sudo apt install ros-humble-rmw-cyclonedds-cpp`. Then, add the following lines to your `~/bashrc`: `export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp; export CYCLONEDDS_URI=~/colcon_ws/src/ada_feeding/cyclonedds.xml`.
51+
- Note that you may have to change the name of the fallback interface that CycloneDDS uses if `lo` does not work for that transmission. To do so, run `ifconfig` and either use the name of your ethernet network or WiFi network, depending on how your computer is connected to the internet.
52+
- Note that you have to [rebuild your workspace from scratch after doing this](https://docs.ros.org/en/humble/How-To-Guides/Working-with-multiple-RMW-implementations.html#adding-rmw-implementations-to-your-workspace).
53+
9. Build your workspace:
5254
5355
cd ~/colcon_ws
5456
colcon build --symlink-install # if sim-only, add '--packages-skip ada_hardware'
5557
58+
### Setup (System Configuration)
59+
60+
Our system includes two computers, `lovelace` (Lenovo Legion 5i) and `nano` (Nvidia Jetson Nano), where the former runs camera code and the latter runs everything else. This repository includes some system-specific bash scripts to configure those computers. Specifically, move `start_nano.sh`, `start_nano.py`, and `run_camera.sh` to the home directory of `nano`. On `lovelace`, add a cronjob to run `configure_lovelace.sh` on reboot (e.g., `sudo crontab -e`, then add the line `@reboot <path/to/ada_feeding>/configure_lovelace.sh`).
61+
62+
Note that these scripts will likely need to be changed for your setup's computers; however, perhaps the commands in these scripts can provide you inspiration.
63+
5664
### Setup (Robot Hardware)
5765
5866
If you change the e-stop button, the e-stop button's adapter(s), and/or the device this code is being run on, you may have to change several device-specific parameters for the e-stop to work. Read the long comment above `amixer_configuration_name` in `ada_feeding/config/ada_watchdog.yaml` for detailed instructions on changing these parameters.

ada_feeding/ada_feeding/watchdog/estop_condition.py

+4
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,10 @@ def __audio_callback(
770770

771771
# Convert the data to a numpy array
772772
self.curr_data_arr = np.frombuffer(data, dtype=np.int16)
773+
self._node.get_logger().debug(
774+
f"Data min: {np.min(self.curr_data_arr)}, max: {np.max(self.curr_data_arr)}, "
775+
f"mean: {np.mean(self.curr_data_arr)}, median: {np.median(self.curr_data_arr)}"
776+
)
773777

774778
# Check if the e-stop button has been pressed
775779
if EStopCondition.rising_edge_detector(

ada_feeding/config/ada_watchdog.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ ada_watchdog:
119119
amixer_mic_control_names:
120120
- "'Mic',0"
121121
amixer_mic_control_percentages:
122-
- 100
122+
- 40
123123
is_usb: true
124124
udev_id: 'usb-Plugable_Plugable_USB_Audio_Device_000000000000-00'
125125
device_name: 'Plugable USB Audio Device'

ada_feeding/scripts/create_action_servers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# Standard imports
88
import collections.abc
9+
import multiprocessing
910
import os
1011
import threading
1112
import traceback
@@ -932,7 +933,7 @@ def main(args: List = None) -> None:
932933
create_action_servers = CreateActionServers()
933934

934935
# Use a MultiThreadedExecutor to enable processing goals concurrently
935-
executor = MultiThreadedExecutor()
936+
executor = MultiThreadedExecutor(num_threads=multiprocessing.cpu_count() * 2)
936937

937938
# pylint: disable=broad-exception-caught
938939
# All exceptions need printing at shutdown

ada_feeding_perception/ada_feeding_perception/segment_from_point.py

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(self) -> None:
6363

6464
# Check if cuda is available
6565
self.device = "cuda" if torch.cuda.is_available() else "cpu"
66+
self.get_logger().info(f"Using device {self.device}")
6667

6768
# Read the parameters
6869
# NOTE: These parameters are only read once. Any changes after the node

ada_planning_scene/config/ada_planning_scene.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ada_planning_scene:
2323
namespaces:
2424
- seated
2525
- bedside
26-
namespace_to_use: bedside # seated
26+
namespace_to_use: seated # bedside #
2727

2828
############################################################################
2929
# Parameters related to the PlanningSceneInitializer class

configure_lovelace.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
# export LOCAL_USER=ada
3+
ifconfig lo multicast
4+
route add -net 224.0.0.0 netmask 240.0.0.0 dev lo
5+
setfacl -m u:ada:rw /dev/snd/*

cyclonedds.xml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<CycloneDDS
3+
xmlns="https://cdds.io/config"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="https://cdds.io/config https://raw.githubusercontent.com/eclipse-cyclonedds/cyclonedds/master/etc/cyclonedds.xsd"
6+
>
7+
<Domain Id="any">
8+
<General>
9+
<Interfaces>
10+
<NetworkInterface name="lo" priority="default" multicast="true"/>
11+
<NetworkInterface name="wlp0s20f3" priority="default" multicast="true"/>
12+
</Interfaces>
13+
</General>
14+
</Domain>
15+
16+
</CycloneDDS>

run_camera.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
source ~/ros2_humble/install/local_setup.bash
3+
source ~/Workspace/camera_ros2/install/setup.bash
4+
export ROS_DOMAIN_ID=42
5+
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
6+
ros2 launch realsense2_camera rs_launch.py rgb_camera.profile:=640,480,15 depth_module.profile:=640,480,15 align_depth.enable:=true initial_reset:=true publish_tf:=false
7+
8+

start.py

+1
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ async def main(args: argparse.Namespace, pwd: str) -> None:
269269
f"ros2 launch ada_planning_scene ada_moveit_launch.xml use_rviz:={'true' if args.dev else 'false'}",
270270
],
271271
"feeding": [
272+
"sudo ./src/ada_feeding/configure_lovelace.sh",
272273
(
273274
"ros2 launch ada_feeding ada_feeding_launch.xml "
274275
f"use_estop:={'false' if args.dev else 'true'} run_web_bridge:=false"

0 commit comments

Comments
 (0)