Skip to content

Commit

Permalink
updated default configuration to ROS2 Foxy, added ros2 launch to app.…
Browse files Browse the repository at this point in the history
…sh and blocking_app.sh, fix command generation (#6)

Signed-off-by: gabrik <gabriele.baldoni@gmail.com>
  • Loading branch information
gabrik authored Jul 27, 2020
1 parent 7c51623 commit b70d01d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 49 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ before_install:
- docker exec build bash -c "cd /root/ && git clone https://github.com/atolab/zenoh-c -b 0.3.0 --depth 1 && cd zenoh-c && make && make install"
- docker exec build bash -c "cd /root/ && git clone https://github.com/atolab/zenoh-python -b 0.3.0 --depth 1 && cd zenoh-python && python3 setup.py install"
- docker exec build bash -c "cd /root/ && git clone https://github.com/atolab/yaks-python -b 0.3.0 --depth 1 && cd yaks-python && make install"
- docker exec build bash -c "cd /root/ && git clone https://github.com/eclipse-fog05/sdk-python -b master --depth 1 && cd sdk-python && make && make install"
- docker exec build bash -c "cd /root/ && git clone https://github.com/eclipse-fog05/api-python -b master --depth 1 && cd api-python && make install"
- docker exec build bash -c "cd /root/ && git clone https://github.com/eclipse-fog05/sdk-python -b 0.2.x --depth 1 && cd sdk-python && make && make install"
- docker exec build bash -c "cd /root/ && git clone https://github.com/eclipse-fog05/api-python -b 0.2.x --depth 1 && cd api-python && make install"
# copying repo inside container
- docker cp ../plugin-fdu-ros2 build:/root/
script:
- docker exec build bash -c "mkdir /root/build && cd /root && cp -r plugin-fdu-ros2 build/fog05-plugin-fdu-ros2-0.2 && cd build/fog05-plugin-fdu-ros2-0.2 && rm -rf .git && make clean && cd .. && tar -czvf fog05-plugin-fdu-ros2-0.2.tar.gz fog05-plugin-fdu-ros2-0.2"
- docker exec build bash -c "export DEBEMAIL=\"info@adlink-labs.tech\" && export DEBFULLNAME=\"ATO Labs\" && cd /root/build/fog05-plugin-fdu-ros2-0.2 && dh_make -f ../fog05-plugin-fdu-ros2-0.2.tar.gz -s -y"
- docker exec build bash -c 'cd /root/build/fog05-plugin-fdu-ros2-0.2 && printf "override_dh_auto_install:\n\tmkdir -p \$\$(pwd)/debian/fog05-plugin-fdu-native/usr/bin/\n\tmkdir -p \$\$(pwd)/debian/fog05-plugin-fdu-ros2/lib/systemd/system/\n\t\$(MAKE) ros2_PLUGIN_DIR=\$\$(pwd)/debian/fog05-plugin-fdu-ros2/etc/fos/plugins/plugin-fdu-ros2 SYSTEMD_DIR=\$\$(pwd)/debian/fog05-plugin-fdu-ros2/lib/systemd/system/ BIN_DIR=\$\$(pwd)/debian/fog05-plugin-fdu-native/usr/bin install">> debian/rules'
- docker exec build bash -c "cd /root/build/fog05-plugin-fdu-ros2-0.2 && debuild --preserve-envvar PATH -us -uc && ls -l"
- docker exec build bash -c "cd /root/build/ && dpkg -I fog05-plugin-fdu-ros2_0.2-1_amd64.deb"
- docker exec build bash -c "mkdir /root/build && cd /root && cp -r plugin-fdu-ros2 build/fog05-plugin-fdu-ros2-0.2.1 && cd build/fog05-plugin-fdu-ros2-0.2.1 && rm -rf .git && make clean && cd .. && tar -czvf fog05-plugin-fdu-ros2-0.2.1.tar.gz fog05-plugin-fdu-ros2-0.2.1"
- docker exec build bash -c "export DEBEMAIL=\"info@adlink-labs.tech\" && export DEBFULLNAME=\"ATO Labs\" && cd /root/build/fog05-plugin-fdu-ros2-0.2.1 && dh_make -f ../fog05-plugin-fdu-ros2-0.2.1.tar.gz -s -y"
- docker exec build bash -c 'cd /root/build/fog05-plugin-fdu-ros2-0.2.1 && printf "override_dh_auto_install:\n\tmkdir -p \$\$(pwd)/debian/fog05-plugin-fdu-native/usr/bin/\n\tmkdir -p \$\$(pwd)/debian/fog05-plugin-fdu-ros2/lib/systemd/system/\n\t\$(MAKE) ros2_PLUGIN_DIR=\$\$(pwd)/debian/fog05-plugin-fdu-ros2/etc/fos/plugins/plugin-fdu-ros2 SYSTEMD_DIR=\$\$(pwd)/debian/fog05-plugin-fdu-ros2/lib/systemd/system/ BIN_DIR=\$\$(pwd)/debian/fog05-plugin-fdu-native/usr/bin install">> debian/rules'
- docker exec build bash -c "cd /root/build/fog05-plugin-fdu-ros2-0.2.1 && debuild --preserve-envvar PATH -us -uc && ls -l"
- docker exec build bash -c "cd /root/build/ && dpkg -I fog05-plugin-fdu-ros2_0.2.1-1_amd64.deb"
10 changes: 5 additions & 5 deletions ros2_plugin
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class ROS2(RuntimePluginFDU):
if real_intf_name is None:
raise ValueError("phy_face cannot be none")
if self.os.get_intf_type(real_intf_name) in ['ethernet']:
self.logger.error('configure_fdu()', 'ROS2 FDU Plugin - Creating macvlan interface')
self.logger.info('configure_fdu()', 'ROS2 FDU Plugin - Creating macvlan interface')
mac = intf.get('mac_address', self.__generate_random_mac())
intf.update({'mac_address': mac})

Expand All @@ -248,7 +248,7 @@ class ROS2(RuntimePluginFDU):
fdu.virtual_interfaces.append({'internal':intf_info.get('internal'), 'external':None})

elif self.os.get_intf_type(real_intf_name) in ['wireless']:
self.logger.error('configure_fdu()', 'ROS2 FDU Plugin - Creating moving wireless interface to namespace')
self.logger.info('configure_fdu()', 'ROS2 FDU Plugin - Creating moving wireless interface to namespace')
intf_info = self.nm.move_interface_in_namespace(real_intf_name, fdu.namespace)
self.nm.rename_virtual_interface_in_namespace(real_intf_name, intf_name, fdu.namespace)
intf_info.update({"name":intf_name})
Expand All @@ -273,7 +273,7 @@ class ROS2(RuntimePluginFDU):
# adding to the list of interfaces
fdu.virtual_interfaces.append({'internal':intf_info.get('internal'), 'external':intf_info.get('external')})
else:
self.logger.error('configure_fdu()', 'ROS2 FDU Plugin creating interface attached to connection point')
self.logger.info('configure_fdu()', 'ROS2 FDU Plugin creating interface attached to connection point')
mac = intf.get('mac_address', self.__generate_random_mac())
intf.update({'mac_address': mac})
intf_info = self.nm.create_virtual_interface_in_namespace(intf_name, fdu.namespace)
Expand Down Expand Up @@ -407,7 +407,7 @@ class ROS2(RuntimePluginFDU):
self.os.store_file(app_sh, os.path.join(self.BASE_DIR, self.STORE_DIR, fdu_uuid),'run_{}.sh'.format(instance_uuid) )
chmod_cmd = 'chmod +x {}'.format(path)
self.os.execute_command(chmod_cmd, blocking=True, external=False)
cmd = 'sudo fos_ros_isolate /var/run/netns/{} {} bash -c "{} {} {} {} {}"'.format(fdu.namespace, child_pid_path, path, fdu.app_path, fdu.name, fdu.cmd, ' '.join(fdu.args))
cmd = 'sudo fos_ros_isolate /var/run/netns/{} {} bash -c \"{} {} {} {} {}\"'.format(fdu.namespace, child_pid_path, path, fdu.app_path, fdu.name, fdu.cmd, ' '.join(fdu.args))
outfile = open(fdu.outfile,'w')
p = psutil.Popen(cmd, shell=True, stdout=outfile, stderr=outfile,stdin=PIPE, executable='/bin/bash', env=dict(os.environ,**env))
fdu.on_start(p.pid)
Expand Down Expand Up @@ -449,7 +449,7 @@ class ROS2(RuntimePluginFDU):
self.os.store_file(app_sh, os.path.join(self.BASE_DIR, self.STORE_DIR, fdu_uuid),'run_{}.sh'.format(instance_uuid) )
chmod_cmd = 'chmod +x {}'.format(path)
self.os.execute_command(chmod_cmd, blocking=True, external=False)
cmd = 'sudo fos_ros_isolate /var/run/netns/{} {} bash -c "{} {} {} {} {}"'.format(fdu.namespace, child_pid_path, path, fdu.app_path, fdu.name, fdu.cmd, ' '.join(fdu.args))
cmd = 'sudo fos_ros_isolate /var/run/netns/{} {} bash -c \"{} {} {} {} {}\"'.format(fdu.namespace, child_pid_path, path, fdu.app_path, fdu.name, fdu.cmd, ' '.join(fdu.args))
outfile = open(fdu.outfile,'w')
p = psutil.Popen(cmd, shell=True, stdout=outfile, stderr=outfile,stdin=PIPE, executable='/bin/bash', env=dict(os.environ,**env))
fdu.on_start(p.pid)
Expand Down
20 changes: 2 additions & 18 deletions templates/app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,10 @@ echo "--- Entry Point = $ROS_ENTRY_POINT ---"
echo "--- ROS2 Distribution = $ROSDISTRO ---"
echo "--- RMW Implementation = $RMW_IMPLEMENTATION ---"

# echo "=== Kill old screens ==="
# screen -S {{ id }} -X quit


# echo "=== Build ROS2 Application ==="
# sudo rosdep install -i --from-path . --rosdistro $ROSDISTRO -y
# colcon build --packages-select $ROS_APP_NAME


echo "=== Run ROS2 Application ==="
#source $CYCLONE

source install/setup.bash

ros2 run $ROS_APP_NAME $ROS_ENTRY_POINT $@

# CMD="ros2 run $ROS_APP_NAME $ROS_ENTRY_POINT $@"
# screen -S {{ id }} -dm $CMD
# while [ True ];
# do
# NOW=$(date '+%F_%H:%M:%S')
# echo "=== Still running at $NOW ==="
# sleep 1
# done
ros2 launch $ROS_APP_NAME $ROS_ENTRY_POINT $@
21 changes: 2 additions & 19 deletions templates/blocking_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ trap cleanup 1 2 3 6

cleanup(){
echo "=== Kill ROS2 Application ==="
# screen -S {{ id }} -X quit
echo "=== Bye ==="
exit 0
}
Expand All @@ -48,25 +47,9 @@ echo "--- Entry Point = $ROS_ENTRY_POINT ---"
echo "--- ROS2 Distribution = $ROSDISTRO ---"
echo "--- RMW Implementation = $RMW_IMPLEMENTATION ---"

# echo "=== Kill old screens ==="
# screen -S {{ id }} -X quit


# echo "=== Build ROS2 Application ==="
# sudo rosdep install -i --from-path . --rosdistro $ROSDISTRO -y
# colcon build --packages-select $ROS_APP_NAME


echo "=== Run ROS2 Application ==="
#source $CYCLONE

source install/setup.bash
ros2 run $ROS_APP_NAME $ROS_ENTRY_POINT $@
# CMD="ros2 run $ROS_APP_NAME $ROS_ENTRY_POINT $@"
# $CMD
# screen -S {{ id }} -dm $CMD
# while [ True ];
# do
# NOW=$(date '+%F_%H:%M:%S')
# echo "=== Still running at $NOW ==="
# sleep 1
# done
ros2 launch $ROS_APP_NAME $ROS_ENTRY_POINT $@

0 comments on commit b70d01d

Please sign in to comment.