-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a0fa04
commit ee768cf
Showing
25 changed files
with
668 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#! /bin/bash | ||
|
||
echo -e "Robotic Park install\n" | ||
echo -e "Checking and installing dependencies to build ..." | ||
|
||
cd ../.. | ||
source install/setup.bash | ||
|
||
cd src | ||
|
||
echo -e "\nCrazyflie package:" | ||
|
||
var0="$(ros2 pkg prefix uned_crazyflie_config)" | ||
|
||
if [ -z "$var0" ]; then | ||
echo -e "\tInstalling ..." | ||
git clone -b humble-dev https://github.com/Robotic-Park-Lab/uned_crazyflie_ros_pkg.git | ||
else | ||
echo -e "\tInstalled." | ||
fi | ||
|
||
echo -e "\nVicon package:" | ||
|
||
var0="$(ros2 pkg prefix vicon_receiver)" | ||
|
||
if [ -z "$var0" ]; then | ||
echo -e "\tInstalling ..." | ||
git clone -b main https://github.com/Robotic-Park-Lab/ros2-vicon-receiver.git | ||
else | ||
echo -e "\tInstalled." | ||
fi | ||
|
||
echo -e "\nSwarm package:" | ||
|
||
var0="$(ros2 pkg prefix uned_swarm_config)" | ||
|
||
if [ -z "$var0" ]; then | ||
echo -e "\tInstalling ..." | ||
git clone -b humble-dev https://github.com/Robotic-Park-Lab/uned_swarm_ros_pkg.git | ||
else | ||
echo -e "\tInstalled." | ||
fi | ||
|
||
echo -e "\nKhepera IV package:" | ||
|
||
var0="$(ros2 pkg prefix uned_kheperaiv_config)" | ||
|
||
if [ -z "$var0" ]; then | ||
echo -e "\tInstalling ..." | ||
git clone -b humble-dev https://github.com/Robotic-Park-Lab/uned_kheperaIV_ros_pkg.git | ||
else | ||
echo -e "\tInstalled." | ||
fi | ||
|
||
cd | ||
echo -e "\nCrazyflie-lib-python:" | ||
dirname='Code' | ||
|
||
if [ -d "$dirname" ]; then | ||
cd Code | ||
dirname='crazyflie-lib-python' | ||
if [ -d "$dirname" ]; then | ||
echo -e "\tInstalled." | ||
else | ||
git clone https://github.com/Robotic-Park-Lab/crazyflie-lib-python.git | ||
cd crazyflie-lib-python | ||
pip install -e . | ||
cd | ||
fi | ||
else | ||
mkdir Code | ||
cd Code | ||
git clone https://github.com/Robotic-Park-Lab/crazyflie-lib-python.git | ||
cd crazyflie-lib-python | ||
pip install -e . | ||
cd | ||
fi | ||
|
||
cd ~/roboticpark_ws/ | ||
rosdep update | ||
rosdep install --from-paths src -y --ignore-src | ||
# colcon build --symlink-install | ||
source install/setup.bash | ||
cd ~/roboticpark_ws/src/RoboticPark | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def main(): | ||
print('Hi from mars_supervisor_pkg.') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>mars_supervisor_pkg</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="[email protected]">kiko</maintainer> | ||
<license>TODO: License declaration</license> | ||
|
||
<test_depend>ament_copyright</test_depend> | ||
<test_depend>ament_flake8</test_depend> | ||
<test_depend>ament_pep257</test_depend> | ||
<test_depend>python3-pytest</test_depend> | ||
|
||
<export> | ||
<build_type>ament_python</build_type> | ||
</export> | ||
</package> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[develop] | ||
script_dir=$base/lib/mars_supervisor_pkg | ||
[install] | ||
install_scripts=$base/lib/mars_supervisor_pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from setuptools import find_packages, setup | ||
|
||
package_name = 'mars_supervisor_pkg' | ||
|
||
setup( | ||
name=package_name, | ||
version='0.0.0', | ||
packages=find_packages(exclude=['test']), | ||
data_files=[ | ||
('share/ament_index/resource_index/packages', | ||
['resource/' + package_name]), | ||
('share/' + package_name, ['package.xml']), | ||
], | ||
install_requires=['setuptools'], | ||
zip_safe=True, | ||
maintainer='kiko', | ||
maintainer_email='[email protected]', | ||
description='TODO: Package description', | ||
license='TODO: License declaration', | ||
tests_require=['pytest'], | ||
entry_points={ | ||
'console_scripts': [ | ||
'supervisor_node = mars_supervisor_pkg.supervisor_node:main' | ||
], | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2015 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from ament_copyright.main import main | ||
import pytest | ||
|
||
|
||
# Remove the `skip` decorator once the source file(s) have a copyright header | ||
@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') | ||
@pytest.mark.copyright | ||
@pytest.mark.linter | ||
def test_copyright(): | ||
rc = main(argv=['.', 'test']) | ||
assert rc == 0, 'Found errors' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2017 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from ament_flake8.main import main_with_errors | ||
import pytest | ||
|
||
|
||
@pytest.mark.flake8 | ||
@pytest.mark.linter | ||
def test_flake8(): | ||
rc, errors = main_with_errors(argv=[]) | ||
assert rc == 0, \ | ||
'Found %d code style errors / warnings:\n' % len(errors) + \ | ||
'\n'.join(errors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2015 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from ament_pep257.main import main | ||
import pytest | ||
|
||
|
||
@pytest.mark.linter | ||
@pytest.mark.pep257 | ||
def test_pep257(): | ||
rc = main(argv=['.', 'test']) | ||
assert rc == 0, 'Found code style errors / warnings' |
Empty file.
Binary file added
BIN
+186 Bytes
measure_process_ros2_pkg/measure_process_ros2_pkg/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added
BIN
+3.23 KB
...ure_process_ros2_pkg/measure_process_ros2_pkg/__pycache__/measure_process.cpython-310.pyc
Binary file not shown.
100 changes: 100 additions & 0 deletions
100
measure_process_ros2_pkg/measure_process_ros2_pkg/measure_process.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import rclpy | ||
from rclpy.node import Node | ||
from std_msgs.msg import String, Float64, Float64MultiArray | ||
import psutil | ||
import numpy as np | ||
|
||
class Process(): | ||
def __init__(self, parent, id, topic): | ||
self.id = id | ||
self.value = 0.0 | ||
self.node = parent | ||
self.node.get_logger().warn('Init %s' % (self.id)) | ||
self.pub_process_measure_ = self.node.create_publisher(Float64, topic.replace("-","_"), 10) | ||
|
||
class MeasureProcess(Node): | ||
def __init__(self): | ||
super().__init__('measure_process') | ||
# Params | ||
self.declare_parameter('process_name', 'gzserver') | ||
self.declare_parameter('process_period', 0.5) | ||
|
||
# Subscription | ||
self.status_ = self.create_subscription(String, 'status', self.status_callback, 10) | ||
|
||
# Publisher | ||
self.pub_cpu_measure_ = self.create_publisher(Float64MultiArray, 'cpu_stats', 10) | ||
|
||
# Variables | ||
self.value = 0.0 | ||
|
||
# | ||
self.initialize() | ||
|
||
def initialize(self): | ||
self.get_logger().info('Measure Process::inicialize() ok.') | ||
# Read Params | ||
self.process_name = self.get_parameter('process_name').get_parameter_value().string_value | ||
self.proc_list = self.process_name.split(', ') | ||
print(self.proc_list) | ||
self.process_list = list() | ||
for process in self.proc_list: | ||
proc = Process(self, process, process+'_cpu') | ||
self.process_list.append(proc) | ||
process_period = self.get_parameter('process_period').get_parameter_value().double_value | ||
|
||
self.timer = self.create_timer(process_period, self.iterate) | ||
|
||
def status_callback(self, msg): | ||
self.get_logger().info('Status: "%s"' % msg.data) | ||
|
||
def do_measure(self): | ||
data_list = list() | ||
cpu_count = psutil.cpu_count() | ||
data_list.append(float(cpu_count)) | ||
data_list.append(psutil.cpu_percent(interval=None)) | ||
mem = psutil.virtual_memory() | ||
data_list.append(mem.percent) | ||
load_tuple = psutil.getloadavg() | ||
for load in load_tuple: | ||
percent = (load / cpu_count) * 100 | ||
data_list.append(percent) | ||
|
||
msg = Float64MultiArray() | ||
msg.data = data_list | ||
self.pub_cpu_measure_.publish(msg) | ||
pi = psutil.process_iter() | ||
|
||
# print(psutil.cpu_percent(percpu=True)) | ||
|
||
for proc in pi: | ||
if not proc.name() in self.proc_list: | ||
continue | ||
|
||
value = proc.cpu_percent() | ||
for process in self.process_list: | ||
if proc.name() == process.id: | ||
process.value += value | ||
|
||
msg = Float64() | ||
for process in self.process_list: | ||
msg.data = process.value | ||
process.pub_process_measure_.publish(msg) | ||
self.get_logger().debug('Process %s = %f' % (process.id, msg.data)) | ||
process.value = 0.0 | ||
|
||
|
||
def iterate(self): | ||
self.do_measure() | ||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
measure_process_node = MeasureProcess() | ||
rclpy.spin(measure_process_node) | ||
|
||
measure_process_node.destroy_node() | ||
rclpy.shutdown() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>measure_process_ros2_pkg</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="[email protected]">kiko</maintainer> | ||
<license>TODO: License declaration</license> | ||
|
||
<test_depend>ament_copyright</test_depend> | ||
<test_depend>ament_flake8</test_depend> | ||
<test_depend>ament_pep257</test_depend> | ||
<test_depend>python3-pytest</test_depend> | ||
|
||
<export> | ||
<build_type>ament_python</build_type> | ||
</export> | ||
</package> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[develop] | ||
script_dir=$base/lib/measure_process_ros2_pkg | ||
[install] | ||
install_scripts=$base/lib/measure_process_ros2_pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from setuptools import setup | ||
|
||
package_name = 'measure_process_ros2_pkg' | ||
|
||
setup( | ||
name=package_name, | ||
version='0.0.0', | ||
packages=[package_name], | ||
data_files=[ | ||
('share/ament_index/resource_index/packages', | ||
['resource/' + package_name]), | ||
('share/' + package_name, ['package.xml']), | ||
], | ||
install_requires=['setuptools'], | ||
zip_safe=True, | ||
maintainer='kiko', | ||
maintainer_email='[email protected]', | ||
description='TODO: Package description', | ||
license='TODO: License declaration', | ||
tests_require=['pytest'], | ||
entry_points={ | ||
'console_scripts': [ | ||
'measure_process = measure_process_ros2_pkg.measure_process:main' | ||
], | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2015 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from ament_copyright.main import main | ||
import pytest | ||
|
||
|
||
# Remove the `skip` decorator once the source file(s) have a copyright header | ||
@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') | ||
@pytest.mark.copyright | ||
@pytest.mark.linter | ||
def test_copyright(): | ||
rc = main(argv=['.', 'test']) | ||
assert rc == 0, 'Found errors' |
Oops, something went wrong.