diff --git a/Videos/Balance_Video.webm b/Videos/Balance_Video.webm new file mode 100644 index 0000000..bca0d11 Binary files /dev/null and b/Videos/Balance_Video.webm differ diff --git a/Videos/DoubleInverted_Video.webm b/Videos/DoubleInverted_Video.webm new file mode 100644 index 0000000..a4f6fc7 Binary files /dev/null and b/Videos/DoubleInverted_Video.webm differ diff --git a/Videos/SwingUp_Video.webm b/Videos/SwingUp_Video.webm new file mode 100644 index 0000000..3eb815a Binary files /dev/null and b/Videos/SwingUp_Video.webm differ diff --git a/double_inverted/build/COLCON_IGNORE b/double_inverted/build/COLCON_IGNORE new file mode 100644 index 0000000..e69de29 diff --git a/double_inverted/build/double_inverted/build/lib/double_inverted/__init__.py b/double_inverted/build/double_inverted/build/lib/double_inverted/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/double_inverted/build/double_inverted/build/lib/double_inverted/double_inverted_dyanamics.py b/double_inverted/build/double_inverted/build/lib/double_inverted/double_inverted_dyanamics.py new file mode 100644 index 0000000..fe00916 --- /dev/null +++ b/double_inverted/build/double_inverted/build/lib/double_inverted/double_inverted_dyanamics.py @@ -0,0 +1,82 @@ +import rclpy +from rclpy.node import Node +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +class DoubleInvertedPendulumSimulator(Node): + def __init__(self): + super().__init__("double_inverted_pendulum_simulator") + + # Initialize pendulum parameters + self.length1 = 1.0 # Length of the first pendulum + self.length2 = 1.0 # Length of the second pendulum + self.mass1 = 1.0 # Mass of the first pendulum + self.mass2 = 1.0 # Mass of the second pendulum + self.gravity = 9.81 # Acceleration due to gravity + + # Initial state [theta1, omega1, theta2, omega2] + self.state = np.array([np.pi / 2, 0, np.pi / 2, 0]) + + # Time step for the simulation + self.dt = 0.01 + + # Setup the figure and axis for visualization + self.fig, self.ax = plt.subplots() + self.line, = self.ax.plot([], [], 'o-', lw=2) + self.ax.set_xlim(-2, 2) + self.ax.set_ylim(-2, 2) + self.ax.grid() + + self.ani = animation.FuncAnimation(self.fig, self.update_plot, interval=50, blit=True) + plt.show() + + def equations_of_motion(self, state): + theta1, omega1, theta2, omega2 = state + + delta = theta2 - theta1 + + denom1 = (self.mass1 + self.mass2) * self.length1 - self.mass2 * self.length1 * np.cos(delta) * np.cos(delta) + denom2 = (self.length2 / self.length1) * denom1 + + a1 = (self.mass2 * self.length1 * omega1 * omega1 * np.sin(delta) * np.cos(delta) + + self.mass2 * self.gravity * np.sin(theta2) * np.cos(delta) + + self.mass2 * self.length2 * omega2 * omega2 * np.sin(delta) - + (self.mass1 + self.mass2) * self.gravity * np.sin(theta1)) / denom1 + + a2 = (- self.mass2 * self.length2 * omega2 * omega2 * np.sin(delta) * np.cos(delta) + + (self.mass1 + self.mass2) * self.gravity * np.sin(theta1) * np.cos(delta) - + (self.mass1 + self.mass2) * self.length1 * omega1 * omega1 * np.sin(delta) - + (self.mass1 + self.mass2) * self.gravity * np.sin(theta2)) / denom2 + + return np.array([omega1, a1, omega2, a2]) + + def step(self): + self.state += self.equations_of_motion(self.state) * self.dt + + def update_plot(self, frame): + self.step() + + theta1, _, theta2, _ = self.state + + x1 = self.length1 * np.sin(theta1) + y1 = -self.length1 * np.cos(theta1) + x2 = x1 + self.length2 * np.sin(theta2) + y2 = y1 - self.length2 * np.cos(theta2) + + self.line.set_data([0, x1, x2], [0, y1, y2]) + return self.line, + +def main(args=None): + rclpy.init(args=args) + node = DoubleInvertedPendulumSimulator() + try: + rclpy.spin(node) + except KeyboardInterrupt: + pass + finally: + node.destroy_node() + rclpy.shutdown() + +if __name__ == "__main__": + main() diff --git a/double_inverted/build/double_inverted/colcon_build.rc b/double_inverted/build/double_inverted/colcon_build.rc new file mode 100644 index 0000000..573541a --- /dev/null +++ b/double_inverted/build/double_inverted/colcon_build.rc @@ -0,0 +1 @@ +0 diff --git a/double_inverted/build/double_inverted/colcon_command_prefix_setup_py.sh b/double_inverted/build/double_inverted/colcon_command_prefix_setup_py.sh new file mode 100644 index 0000000..f9867d5 --- /dev/null +++ b/double_inverted/build/double_inverted/colcon_command_prefix_setup_py.sh @@ -0,0 +1 @@ +# generated from colcon_core/shell/template/command_prefix.sh.em diff --git a/double_inverted/build/double_inverted/colcon_command_prefix_setup_py.sh.env b/double_inverted/build/double_inverted/colcon_command_prefix_setup_py.sh.env new file mode 100644 index 0000000..df39a06 --- /dev/null +++ b/double_inverted/build/double_inverted/colcon_command_prefix_setup_py.sh.env @@ -0,0 +1,57 @@ +AMENT_PREFIX_PATH=/opt/ros/galactic +COLCON=1 +COLORTERM=truecolor +DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus,guid=76d3d2a54a87fb7fcc1215e866556bb3 +DBUS_STARTER_ADDRESS=unix:path=/run/user/1000/bus,guid=76d3d2a54a87fb7fcc1215e866556bb3 +DBUS_STARTER_BUS_TYPE=session +DESKTOP_SESSION=ubuntu +DISPLAY=:0 +GDMSESSION=ubuntu +GNOME_DESKTOP_SESSION_ID=this-is-deprecated +GNOME_SHELL_SESSION_MODE=ubuntu +GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/25509364_879c_490d_a838_26e8c09adf24 +GNOME_TERMINAL_SERVICE=:1.643 +GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1 +GTK_MODULES=gail:atk-bridge +HOME=/home/aryan +IM_CONFIG_PHASE=1 +INVOCATION_ID=685ce25ff4a54ba8a5f8e9295eb0a1ac +JOURNAL_STREAM=8:45890 +LANG=en_IN +LANGUAGE=en_IN:en +LD_LIBRARY_PATH=/opt/ros/galactic/opt/yaml_cpp_vendor/lib:/opt/ros/galactic/opt/rviz_ogre_vendor/lib:/opt/ros/galactic/lib/x86_64-linux-gnu:/opt/ros/galactic/lib +LESSCLOSE=/usr/bin/lesspipe %s %s +LESSOPEN=| /usr/bin/lesspipe %s +LOGNAME=aryan +LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36: +MANAGERPID=1509 +PATH=/opt/ros/galactic/bin:/home/aryan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin +PWD=/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted +PYTHONPATH=/opt/ros/galactic/lib/python3.8/site-packages +QT_ACCESSIBILITY=1 +QT_IM_MODULE=ibus +ROS_DISTRO=galactic +ROS_LOCALHOST_ONLY=0 +ROS_PYTHON_VERSION=3 +ROS_VERSION=2 +SESSION_MANAGER=local/aryan-Vivobook-ASUSLaptop-X1502ZA-X1502ZA:@/tmp/.ICE-unix/1647,unix/aryan-Vivobook-ASUSLaptop-X1502ZA-X1502ZA:/tmp/.ICE-unix/1647 +SHELL=/bin/bash +SHLVL=1 +SSH_AGENT_PID=1607 +SSH_AUTH_SOCK=/run/user/1000/keyring/ssh +TERM=xterm-256color +USER=aryan +USERNAME=aryan +VTE_VERSION=6003 +WINDOWPATH=2 +XAUTHORITY=/run/user/1000/gdm/Xauthority +XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg +XDG_CURRENT_DESKTOP=ubuntu:GNOME +XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop +XDG_MENU_PREFIX=gnome- +XDG_RUNTIME_DIR=/run/user/1000 +XDG_SESSION_CLASS=user +XDG_SESSION_DESKTOP=ubuntu +XDG_SESSION_TYPE=x11 +XMODIFIERS=@im=ibus +_=/usr/bin/colcon diff --git a/double_inverted/build/double_inverted/double_inverted.egg-info/PKG-INFO b/double_inverted/build/double_inverted/double_inverted.egg-info/PKG-INFO new file mode 100644 index 0000000..2029d33 --- /dev/null +++ b/double_inverted/build/double_inverted/double_inverted.egg-info/PKG-INFO @@ -0,0 +1,10 @@ +Metadata-Version: 1.2 +Name: double-inverted +Version: 0.0.0 +Summary: TODO: Package description +Home-page: UNKNOWN +Maintainer: aryan +Maintainer-email: aryankay1234@gmail.com +License: TODO: License declaration +Description: UNKNOWN +Platform: UNKNOWN diff --git a/double_inverted/build/double_inverted/double_inverted.egg-info/SOURCES.txt b/double_inverted/build/double_inverted/double_inverted.egg-info/SOURCES.txt new file mode 100644 index 0000000..414b498 --- /dev/null +++ b/double_inverted/build/double_inverted/double_inverted.egg-info/SOURCES.txt @@ -0,0 +1,16 @@ +package.xml +setup.cfg +setup.py +build/double_inverted/double_inverted.egg-info/PKG-INFO +build/double_inverted/double_inverted.egg-info/SOURCES.txt +build/double_inverted/double_inverted.egg-info/dependency_links.txt +build/double_inverted/double_inverted.egg-info/entry_points.txt +build/double_inverted/double_inverted.egg-info/requires.txt +build/double_inverted/double_inverted.egg-info/top_level.txt +build/double_inverted/double_inverted.egg-info/zip-safe +double_inverted/__init__.py +double_inverted/double_inverted_dyanamics.py +resource/double_inverted +test/test_copyright.py +test/test_flake8.py +test/test_pep257.py \ No newline at end of file diff --git a/double_inverted/build/double_inverted/double_inverted.egg-info/dependency_links.txt b/double_inverted/build/double_inverted/double_inverted.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/double_inverted/build/double_inverted/double_inverted.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/double_inverted/build/double_inverted/double_inverted.egg-info/entry_points.txt b/double_inverted/build/double_inverted/double_inverted.egg-info/entry_points.txt new file mode 100644 index 0000000..9a6c5bf --- /dev/null +++ b/double_inverted/build/double_inverted/double_inverted.egg-info/entry_points.txt @@ -0,0 +1,3 @@ +[console_scripts] +dyanamics = double_inverted.double_inverted_dyanamics:main + diff --git a/double_inverted/build/double_inverted/double_inverted.egg-info/requires.txt b/double_inverted/build/double_inverted/double_inverted.egg-info/requires.txt new file mode 100644 index 0000000..49fe098 --- /dev/null +++ b/double_inverted/build/double_inverted/double_inverted.egg-info/requires.txt @@ -0,0 +1 @@ +setuptools diff --git a/double_inverted/build/double_inverted/double_inverted.egg-info/top_level.txt b/double_inverted/build/double_inverted/double_inverted.egg-info/top_level.txt new file mode 100644 index 0000000..b224df2 --- /dev/null +++ b/double_inverted/build/double_inverted/double_inverted.egg-info/top_level.txt @@ -0,0 +1 @@ +double_inverted diff --git a/double_inverted/build/double_inverted/double_inverted.egg-info/zip-safe b/double_inverted/build/double_inverted/double_inverted.egg-info/zip-safe new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/double_inverted/build/double_inverted/double_inverted.egg-info/zip-safe @@ -0,0 +1 @@ + diff --git a/double_inverted/build/double_inverted/install.log b/double_inverted/build/double_inverted/install.log new file mode 100644 index 0000000..062c5c2 --- /dev/null +++ b/double_inverted/build/double_inverted/install.log @@ -0,0 +1,14 @@ +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/double_inverted_dyanamics.py +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__init__.py +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__pycache__/double_inverted_dyanamics.cpython-38.pyc +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__pycache__/__init__.cpython-38.pyc +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index/packages/double_inverted +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/package.xml +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/PKG-INFO +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/entry_points.txt +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/dependency_links.txt +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/SOURCES.txt +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/requires.txt +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/zip-safe +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/top_level.txt +/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/double_inverted/dyanamics diff --git a/double_inverted/build/double_inverted/prefix_override/__pycache__/sitecustomize.cpython-38.pyc b/double_inverted/build/double_inverted/prefix_override/__pycache__/sitecustomize.cpython-38.pyc new file mode 100644 index 0000000..68dd60c Binary files /dev/null and b/double_inverted/build/double_inverted/prefix_override/__pycache__/sitecustomize.cpython-38.pyc differ diff --git a/double_inverted/build/double_inverted/prefix_override/sitecustomize.py b/double_inverted/build/double_inverted/prefix_override/sitecustomize.py new file mode 100644 index 0000000..9a35321 --- /dev/null +++ b/double_inverted/build/double_inverted/prefix_override/sitecustomize.py @@ -0,0 +1,3 @@ +import sys +sys.real_prefix = sys.prefix +sys.prefix = sys.exec_prefix = '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted' diff --git a/double_inverted/double_inverted/__init__.py b/double_inverted/double_inverted/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/double_inverted/double_inverted/__pycache__/double_inverted_dyanamics.cpython-38.pyc b/double_inverted/double_inverted/__pycache__/double_inverted_dyanamics.cpython-38.pyc new file mode 100644 index 0000000..1727752 Binary files /dev/null and b/double_inverted/double_inverted/__pycache__/double_inverted_dyanamics.cpython-38.pyc differ diff --git a/double_inverted/double_inverted/double_inverted_dyanamics.py b/double_inverted/double_inverted/double_inverted_dyanamics.py new file mode 100644 index 0000000..d4a6b19 --- /dev/null +++ b/double_inverted/double_inverted/double_inverted_dyanamics.py @@ -0,0 +1,172 @@ +import numpy as np +import matplotlib.pyplot as plt +import time +from math import sin, cos + +import rclpy +from rclpy.node import Node + +from builtin_interfaces.msg import Duration +from visualization_msgs.msg import Marker +from geometry_msgs.msg import Point + +from custom_msgs.msg import TorqueInput, States + +class Double_Inverted_Pendulum(Node): + + # Initialise States : + theta_1_init = np.pi - (np.random.rand() - 0.5) / 2 + theta_2_init = np.pi / 3 + + theta1_dot_init = 0.0 + theta2_dot_init = 0.0 + + # Param/s + mass1 = 1.0 # grams + mass2 = 0.1 # grams + l1 = 1.0 # metres + l2 = 1.0 # metres + a = 0.05 # metres + g = 9.81 # m / sec ^ 2 + + state_update_frequency = 500 + state_update_timeperiod = 1 / state_update_frequency + + feedback_frequency = 50 + + def __init__ (self) : + super().__init__('main') + + # Timers : + update_states_timer = self.create_timer(1 / self.state_update_frequency, self.Update_Pendulum_States) + feedback_timer = self.create_timer(1 / self.feedback_frequency, self.Feedback) + + # Publishers : + self.visualizer1 = self.create_publisher(Marker, '/pendulum_viz1', 1) + self.visualizer2 = self.create_publisher(Marker, '/pendulum_viz2', 1) + + self.feedback_pub1 = self.create_publisher(States, '/state_feedback1', 1) + self.feedback_pub2 = self.create_publisher(States, '/state_feedback2', 1) + + # Attributes : + self.t_start = time.time() + self.t_prev = time.time() - 0.0001 + self.obj_id = 0 + + # States : + self.theta1 = self.theta_1_init + self.theta2 = self.theta_2_init + + self.theta1_dot = self.theta1_dot_init + self.theta2_dot = self.theta2_dot_init + + def Update_Pendulum_States(self) : + dt = time.time() - self.t_prev + self.t_prev = time.time() + + #Calculation of angular accelerations :) + Theta1_DoubleDot = (-self.g * (2 * self.mass1 + self.mass2) * np.sin(self.theta1) + - self.mass2 * self.g * np.sin(self.theta1 - 2 * self.theta2) + - 2 * np.sin(self.theta1 - self.theta2) * self.mass2 * (self.theta2_dot**2 * self.l2 + self.theta1_dot**2 * self.l1 * np.cos(self.theta1 - self.theta2))) / (self.l1 * (2 * self.mass1 + self.mass2 - self.mass2 * np.cos(2 * self.theta1 - 2 * self.theta2))) + + Theta2_DoubleDot = (2 * np.sin(self.theta1 - self.theta2) * + (self.theta1_dot**2 * self.l1 * (self.mass1 + self.mass2) + + self.g * (self.mass1 + self.mass2) * np.cos(self.theta1) + + self.theta2_dot**2 * self.l2 * self.mass2 * np.cos(self.theta1 - self.theta2))) / (self.l2 * (2 * self.mass1 + self.mass2 - self.mass2 * np.cos(2 * self.theta1 - 2 * self.theta2))) + + # Incrementing omegas + self.theta1_dot += Theta1_DoubleDot * dt + self.theta2_dot += Theta2_DoubleDot * dt + + # Incrementing thetas + self.theta1 += self.theta1_dot * dt + self.theta2 += self.theta2_dot * dt + + self.visualise_pendulum() + + return + + def Feedback(self): + states_msg1 = States() + states_msg1.theta = self.theta1 + states_msg1.theta_dot = self.theta1_dot + + states_msg2 = States() + states_msg2.theta = self.theta2 + states_msg2.theta_dot = self.theta2_dot + + self.feedback_pub1.publish(states_msg1) + self.feedback_pub2.publish(states_msg2) + + return + + + def visualise_pendulum(self): + pendulum_marker1 = Marker() + pendulum_marker1.header.frame_id = "map" + pendulum_marker1.id = self.obj_id + pendulum_marker1.type = Marker.LINE_STRIP + pendulum_marker1.action = Marker.ADD + pendulum_marker1.pose.orientation.w = 1.0 + pendulum_marker1.scale.x = 0.05 # Line width + + # Set points + point_1 = Point() + point_1.x = 0.0 + point_1.y = 0.0 + point_1.z = 0.0 + + point_2 = Point() + point_2.x = self.l1 * sin(self.theta1) + point_2.y = - self.l1 * cos(self.theta1) + point_2.z = 0.0 + pendulum_marker1.points = [point_1, + point_2 + ] + + pendulum_marker2 = Marker() + pendulum_marker2.header.frame_id = "map" + pendulum_marker2.id = self.obj_id + pendulum_marker2.type = Marker.LINE_STRIP + pendulum_marker2.action = Marker.ADD + pendulum_marker2.pose.orientation.w = 1.0 + pendulum_marker2.scale.x = 0.05 # Line width + + point_3 = Point() + point_3.x = point_2.x + (self.l2 * sin(self.theta2)) + point_3.y = point_2.y + (self.l2 * cos(self.theta2)) + point_3.z = 0.0 + pendulum_marker2.points = [point_2, + point_3 + ] + pendulum_marker1.color.b = 1.0 + pendulum_marker1.color.g = 1.0 + pendulum_marker1.color.a = 1.0 # Alpha value + Duration_of_pendulum_marker = Duration() + Duration_of_pendulum_marker.sec = 0 + Duration_of_pendulum_marker.nanosec = int(self.state_update_timeperiod * 1e+9) + pendulum_marker1.lifetime = Duration_of_pendulum_marker # Permanent pendulum_marker + self.visualizer1.publish(pendulum_marker1) + + pendulum_marker2.color.g = 1.0 + pendulum_marker1.color.r = 1.0 + pendulum_marker2.color.a = 1.0 # Alpha value + Duration_of_pendulum_marker = Duration() + Duration_of_pendulum_marker.sec = 0 + Duration_of_pendulum_marker.nanosec = int(self.state_update_timeperiod * 1e+9) + pendulum_marker2.lifetime = Duration_of_pendulum_marker # Permanent pendulum_marker + self.visualizer2.publish(pendulum_marker2) + + self.obj_id += 1 + +def main(args = None): + + rclpy.init(args = args) + pendulum = Double_Inverted_Pendulum() + rclpy.spin(pendulum) + + pendulum.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() diff --git a/double_inverted/install/COLCON_IGNORE b/double_inverted/install/COLCON_IGNORE new file mode 100644 index 0000000..e69de29 diff --git a/double_inverted/install/_local_setup_util_ps1.py b/double_inverted/install/_local_setup_util_ps1.py new file mode 100644 index 0000000..83abe63 --- /dev/null +++ b/double_inverted/install/_local_setup_util_ps1.py @@ -0,0 +1,407 @@ +# Copyright 2016-2019 Dirk Thomas +# Licensed under the Apache License, Version 2.0 + +import argparse +from collections import OrderedDict +import os +from pathlib import Path +import sys + + +FORMAT_STR_COMMENT_LINE = '# {comment}' +FORMAT_STR_SET_ENV_VAR = 'Set-Item -Path "Env:{name}" -Value "{value}"' +FORMAT_STR_USE_ENV_VAR = '$env:{name}' +FORMAT_STR_INVOKE_SCRIPT = '_colcon_prefix_powershell_source_script "{script_path}"' +FORMAT_STR_REMOVE_LEADING_SEPARATOR = '' +FORMAT_STR_REMOVE_TRAILING_SEPARATOR = '' + +DSV_TYPE_APPEND_NON_DUPLICATE = 'append-non-duplicate' +DSV_TYPE_PREPEND_NON_DUPLICATE = 'prepend-non-duplicate' +DSV_TYPE_PREPEND_NON_DUPLICATE_IF_EXISTS = 'prepend-non-duplicate-if-exists' +DSV_TYPE_SET = 'set' +DSV_TYPE_SET_IF_UNSET = 'set-if-unset' +DSV_TYPE_SOURCE = 'source' + + +def main(argv=sys.argv[1:]): # noqa: D103 + parser = argparse.ArgumentParser( + description='Output shell commands for the packages in topological ' + 'order') + parser.add_argument( + 'primary_extension', + help='The file extension of the primary shell') + parser.add_argument( + 'additional_extension', nargs='?', + help='The additional file extension to be considered') + parser.add_argument( + '--merged-install', action='store_true', + help='All install prefixes are merged into a single location') + args = parser.parse_args(argv) + + packages = get_packages(Path(__file__).parent, args.merged_install) + + ordered_packages = order_packages(packages) + for pkg_name in ordered_packages: + if _include_comments(): + print( + FORMAT_STR_COMMENT_LINE.format_map( + {'comment': 'Package: ' + pkg_name})) + prefix = os.path.abspath(os.path.dirname(__file__)) + if not args.merged_install: + prefix = os.path.join(prefix, pkg_name) + for line in get_commands( + pkg_name, prefix, args.primary_extension, + args.additional_extension + ): + print(line) + + for line in _remove_ending_separators(): + print(line) + + +def get_packages(prefix_path, merged_install): + """ + Find packages based on colcon-specific files created during installation. + + :param Path prefix_path: The install prefix path of all packages + :param bool merged_install: The flag if the packages are all installed + directly in the prefix or if each package is installed in a subdirectory + named after the package + :returns: A mapping from the package name to the set of runtime + dependencies + :rtype: dict + """ + packages = {} + # since importing colcon_core isn't feasible here the following constant + # must match colcon_core.location.get_relative_package_index_path() + subdirectory = 'share/colcon-core/packages' + if merged_install: + # return if workspace is empty + if not (prefix_path / subdirectory).is_dir(): + return packages + # find all files in the subdirectory + for p in (prefix_path / subdirectory).iterdir(): + if not p.is_file(): + continue + if p.name.startswith('.'): + continue + add_package_runtime_dependencies(p, packages) + else: + # for each subdirectory look for the package specific file + for p in prefix_path.iterdir(): + if not p.is_dir(): + continue + if p.name.startswith('.'): + continue + p = p / subdirectory / p.name + if p.is_file(): + add_package_runtime_dependencies(p, packages) + + # remove unknown dependencies + pkg_names = set(packages.keys()) + for k in packages.keys(): + packages[k] = {d for d in packages[k] if d in pkg_names} + + return packages + + +def add_package_runtime_dependencies(path, packages): + """ + Check the path and if it exists extract the packages runtime dependencies. + + :param Path path: The resource file containing the runtime dependencies + :param dict packages: A mapping from package names to the sets of runtime + dependencies to add to + """ + content = path.read_text() + dependencies = set(content.split(os.pathsep) if content else []) + packages[path.name] = dependencies + + +def order_packages(packages): + """ + Order packages topologically. + + :param dict packages: A mapping from package name to the set of runtime + dependencies + :returns: The package names + :rtype: list + """ + # select packages with no dependencies in alphabetical order + to_be_ordered = list(packages.keys()) + ordered = [] + while to_be_ordered: + pkg_names_without_deps = [ + name for name in to_be_ordered if not packages[name]] + if not pkg_names_without_deps: + reduce_cycle_set(packages) + raise RuntimeError( + 'Circular dependency between: ' + ', '.join(sorted(packages))) + pkg_names_without_deps.sort() + pkg_name = pkg_names_without_deps[0] + to_be_ordered.remove(pkg_name) + ordered.append(pkg_name) + # remove item from dependency lists + for k in list(packages.keys()): + if pkg_name in packages[k]: + packages[k].remove(pkg_name) + return ordered + + +def reduce_cycle_set(packages): + """ + Reduce the set of packages to the ones part of the circular dependency. + + :param dict packages: A mapping from package name to the set of runtime + dependencies which is modified in place + """ + last_depended = None + while len(packages) > 0: + # get all remaining dependencies + depended = set() + for pkg_name, dependencies in packages.items(): + depended = depended.union(dependencies) + # remove all packages which are not dependent on + for name in list(packages.keys()): + if name not in depended: + del packages[name] + if last_depended: + # if remaining packages haven't changed return them + if last_depended == depended: + return packages.keys() + # otherwise reduce again + last_depended = depended + + +def _include_comments(): + # skipping comment lines when COLCON_TRACE is not set speeds up the + # processing especially on Windows + return bool(os.environ.get('COLCON_TRACE')) + + +def get_commands(pkg_name, prefix, primary_extension, additional_extension): + commands = [] + package_dsv_path = os.path.join(prefix, 'share', pkg_name, 'package.dsv') + if os.path.exists(package_dsv_path): + commands += process_dsv_file( + package_dsv_path, prefix, primary_extension, additional_extension) + return commands + + +def process_dsv_file( + dsv_path, prefix, primary_extension=None, additional_extension=None +): + commands = [] + if _include_comments(): + commands.append(FORMAT_STR_COMMENT_LINE.format_map({'comment': dsv_path})) + with open(dsv_path, 'r') as h: + content = h.read() + lines = content.splitlines() + + basenames = OrderedDict() + for i, line in enumerate(lines): + # skip over empty or whitespace-only lines + if not line.strip(): + continue + # skip over comments + if line.startswith('#'): + continue + try: + type_, remainder = line.split(';', 1) + except ValueError: + raise RuntimeError( + "Line %d in '%s' doesn't contain a semicolon separating the " + 'type from the arguments' % (i + 1, dsv_path)) + if type_ != DSV_TYPE_SOURCE: + # handle non-source lines + try: + commands += handle_dsv_types_except_source( + type_, remainder, prefix) + except RuntimeError as e: + raise RuntimeError( + "Line %d in '%s' %s" % (i + 1, dsv_path, e)) from e + else: + # group remaining source lines by basename + path_without_ext, ext = os.path.splitext(remainder) + if path_without_ext not in basenames: + basenames[path_without_ext] = set() + assert ext.startswith('.') + ext = ext[1:] + if ext in (primary_extension, additional_extension): + basenames[path_without_ext].add(ext) + + # add the dsv extension to each basename if the file exists + for basename, extensions in basenames.items(): + if not os.path.isabs(basename): + basename = os.path.join(prefix, basename) + if os.path.exists(basename + '.dsv'): + extensions.add('dsv') + + for basename, extensions in basenames.items(): + if not os.path.isabs(basename): + basename = os.path.join(prefix, basename) + if 'dsv' in extensions: + # process dsv files recursively + commands += process_dsv_file( + basename + '.dsv', prefix, primary_extension=primary_extension, + additional_extension=additional_extension) + elif primary_extension in extensions and len(extensions) == 1: + # source primary-only files + commands += [ + FORMAT_STR_INVOKE_SCRIPT.format_map({ + 'prefix': prefix, + 'script_path': basename + '.' + primary_extension})] + elif additional_extension in extensions: + # source non-primary files + commands += [ + FORMAT_STR_INVOKE_SCRIPT.format_map({ + 'prefix': prefix, + 'script_path': basename + '.' + additional_extension})] + + return commands + + +def handle_dsv_types_except_source(type_, remainder, prefix): + commands = [] + if type_ in (DSV_TYPE_SET, DSV_TYPE_SET_IF_UNSET): + try: + env_name, value = remainder.split(';', 1) + except ValueError: + raise RuntimeError( + "doesn't contain a semicolon separating the environment name " + 'from the value') + try_prefixed_value = os.path.join(prefix, value) if value else prefix + if os.path.exists(try_prefixed_value): + value = try_prefixed_value + if type_ == DSV_TYPE_SET: + commands += _set(env_name, value) + elif type_ == DSV_TYPE_SET_IF_UNSET: + commands += _set_if_unset(env_name, value) + else: + assert False + elif type_ in ( + DSV_TYPE_APPEND_NON_DUPLICATE, + DSV_TYPE_PREPEND_NON_DUPLICATE, + DSV_TYPE_PREPEND_NON_DUPLICATE_IF_EXISTS + ): + try: + env_name_and_values = remainder.split(';') + except ValueError: + raise RuntimeError( + "doesn't contain a semicolon separating the environment name " + 'from the values') + env_name = env_name_and_values[0] + values = env_name_and_values[1:] + for value in values: + if not value: + value = prefix + elif not os.path.isabs(value): + value = os.path.join(prefix, value) + if ( + type_ == DSV_TYPE_PREPEND_NON_DUPLICATE_IF_EXISTS and + not os.path.exists(value) + ): + comment = f'skip extending {env_name} with not existing ' \ + f'path: {value}' + if _include_comments(): + commands.append( + FORMAT_STR_COMMENT_LINE.format_map({'comment': comment})) + elif type_ == DSV_TYPE_APPEND_NON_DUPLICATE: + commands += _append_unique_value(env_name, value) + else: + commands += _prepend_unique_value(env_name, value) + else: + raise RuntimeError( + 'contains an unknown environment hook type: ' + type_) + return commands + + +env_state = {} + + +def _append_unique_value(name, value): + global env_state + if name not in env_state: + if os.environ.get(name): + env_state[name] = set(os.environ[name].split(os.pathsep)) + else: + env_state[name] = set() + # append even if the variable has not been set yet, in case a shell script sets the + # same variable without the knowledge of this Python script. + # later _remove_ending_separators() will cleanup any unintentional leading separator + extend = FORMAT_STR_USE_ENV_VAR.format_map({'name': name}) + os.pathsep + line = FORMAT_STR_SET_ENV_VAR.format_map( + {'name': name, 'value': extend + value}) + if value not in env_state[name]: + env_state[name].add(value) + else: + if not _include_comments(): + return [] + line = FORMAT_STR_COMMENT_LINE.format_map({'comment': line}) + return [line] + + +def _prepend_unique_value(name, value): + global env_state + if name not in env_state: + if os.environ.get(name): + env_state[name] = set(os.environ[name].split(os.pathsep)) + else: + env_state[name] = set() + # prepend even if the variable has not been set yet, in case a shell script sets the + # same variable without the knowledge of this Python script. + # later _remove_ending_separators() will cleanup any unintentional trailing separator + extend = os.pathsep + FORMAT_STR_USE_ENV_VAR.format_map({'name': name}) + line = FORMAT_STR_SET_ENV_VAR.format_map( + {'name': name, 'value': value + extend}) + if value not in env_state[name]: + env_state[name].add(value) + else: + if not _include_comments(): + return [] + line = FORMAT_STR_COMMENT_LINE.format_map({'comment': line}) + return [line] + + +# generate commands for removing prepended underscores +def _remove_ending_separators(): + # do nothing if the shell extension does not implement the logic + if FORMAT_STR_REMOVE_TRAILING_SEPARATOR is None: + return [] + + global env_state + commands = [] + for name in env_state: + # skip variables that already had values before this script started prepending + if name in os.environ: + continue + commands += [ + FORMAT_STR_REMOVE_LEADING_SEPARATOR.format_map({'name': name}), + FORMAT_STR_REMOVE_TRAILING_SEPARATOR.format_map({'name': name})] + return commands + + +def _set(name, value): + global env_state + env_state[name] = value + line = FORMAT_STR_SET_ENV_VAR.format_map( + {'name': name, 'value': value}) + return [line] + + +def _set_if_unset(name, value): + global env_state + line = FORMAT_STR_SET_ENV_VAR.format_map( + {'name': name, 'value': value}) + if env_state.get(name, os.environ.get(name)): + line = FORMAT_STR_COMMENT_LINE.format_map({'comment': line}) + return [line] + + +if __name__ == '__main__': # pragma: no cover + try: + rc = main() + except RuntimeError as e: + print(str(e), file=sys.stderr) + rc = 1 + sys.exit(rc) diff --git a/double_inverted/install/_local_setup_util_sh.py b/double_inverted/install/_local_setup_util_sh.py new file mode 100644 index 0000000..ff31198 --- /dev/null +++ b/double_inverted/install/_local_setup_util_sh.py @@ -0,0 +1,407 @@ +# Copyright 2016-2019 Dirk Thomas +# Licensed under the Apache License, Version 2.0 + +import argparse +from collections import OrderedDict +import os +from pathlib import Path +import sys + + +FORMAT_STR_COMMENT_LINE = '# {comment}' +FORMAT_STR_SET_ENV_VAR = 'export {name}="{value}"' +FORMAT_STR_USE_ENV_VAR = '${name}' +FORMAT_STR_INVOKE_SCRIPT = 'COLCON_CURRENT_PREFIX="{prefix}" _colcon_prefix_sh_source_script "{script_path}"' +FORMAT_STR_REMOVE_LEADING_SEPARATOR = 'if [ "$(echo -n ${name} | head -c 1)" = ":" ]; then export {name}=${{{name}#?}} ; fi' +FORMAT_STR_REMOVE_TRAILING_SEPARATOR = 'if [ "$(echo -n ${name} | tail -c 1)" = ":" ]; then export {name}=${{{name}%?}} ; fi' + +DSV_TYPE_APPEND_NON_DUPLICATE = 'append-non-duplicate' +DSV_TYPE_PREPEND_NON_DUPLICATE = 'prepend-non-duplicate' +DSV_TYPE_PREPEND_NON_DUPLICATE_IF_EXISTS = 'prepend-non-duplicate-if-exists' +DSV_TYPE_SET = 'set' +DSV_TYPE_SET_IF_UNSET = 'set-if-unset' +DSV_TYPE_SOURCE = 'source' + + +def main(argv=sys.argv[1:]): # noqa: D103 + parser = argparse.ArgumentParser( + description='Output shell commands for the packages in topological ' + 'order') + parser.add_argument( + 'primary_extension', + help='The file extension of the primary shell') + parser.add_argument( + 'additional_extension', nargs='?', + help='The additional file extension to be considered') + parser.add_argument( + '--merged-install', action='store_true', + help='All install prefixes are merged into a single location') + args = parser.parse_args(argv) + + packages = get_packages(Path(__file__).parent, args.merged_install) + + ordered_packages = order_packages(packages) + for pkg_name in ordered_packages: + if _include_comments(): + print( + FORMAT_STR_COMMENT_LINE.format_map( + {'comment': 'Package: ' + pkg_name})) + prefix = os.path.abspath(os.path.dirname(__file__)) + if not args.merged_install: + prefix = os.path.join(prefix, pkg_name) + for line in get_commands( + pkg_name, prefix, args.primary_extension, + args.additional_extension + ): + print(line) + + for line in _remove_ending_separators(): + print(line) + + +def get_packages(prefix_path, merged_install): + """ + Find packages based on colcon-specific files created during installation. + + :param Path prefix_path: The install prefix path of all packages + :param bool merged_install: The flag if the packages are all installed + directly in the prefix or if each package is installed in a subdirectory + named after the package + :returns: A mapping from the package name to the set of runtime + dependencies + :rtype: dict + """ + packages = {} + # since importing colcon_core isn't feasible here the following constant + # must match colcon_core.location.get_relative_package_index_path() + subdirectory = 'share/colcon-core/packages' + if merged_install: + # return if workspace is empty + if not (prefix_path / subdirectory).is_dir(): + return packages + # find all files in the subdirectory + for p in (prefix_path / subdirectory).iterdir(): + if not p.is_file(): + continue + if p.name.startswith('.'): + continue + add_package_runtime_dependencies(p, packages) + else: + # for each subdirectory look for the package specific file + for p in prefix_path.iterdir(): + if not p.is_dir(): + continue + if p.name.startswith('.'): + continue + p = p / subdirectory / p.name + if p.is_file(): + add_package_runtime_dependencies(p, packages) + + # remove unknown dependencies + pkg_names = set(packages.keys()) + for k in packages.keys(): + packages[k] = {d for d in packages[k] if d in pkg_names} + + return packages + + +def add_package_runtime_dependencies(path, packages): + """ + Check the path and if it exists extract the packages runtime dependencies. + + :param Path path: The resource file containing the runtime dependencies + :param dict packages: A mapping from package names to the sets of runtime + dependencies to add to + """ + content = path.read_text() + dependencies = set(content.split(os.pathsep) if content else []) + packages[path.name] = dependencies + + +def order_packages(packages): + """ + Order packages topologically. + + :param dict packages: A mapping from package name to the set of runtime + dependencies + :returns: The package names + :rtype: list + """ + # select packages with no dependencies in alphabetical order + to_be_ordered = list(packages.keys()) + ordered = [] + while to_be_ordered: + pkg_names_without_deps = [ + name for name in to_be_ordered if not packages[name]] + if not pkg_names_without_deps: + reduce_cycle_set(packages) + raise RuntimeError( + 'Circular dependency between: ' + ', '.join(sorted(packages))) + pkg_names_without_deps.sort() + pkg_name = pkg_names_without_deps[0] + to_be_ordered.remove(pkg_name) + ordered.append(pkg_name) + # remove item from dependency lists + for k in list(packages.keys()): + if pkg_name in packages[k]: + packages[k].remove(pkg_name) + return ordered + + +def reduce_cycle_set(packages): + """ + Reduce the set of packages to the ones part of the circular dependency. + + :param dict packages: A mapping from package name to the set of runtime + dependencies which is modified in place + """ + last_depended = None + while len(packages) > 0: + # get all remaining dependencies + depended = set() + for pkg_name, dependencies in packages.items(): + depended = depended.union(dependencies) + # remove all packages which are not dependent on + for name in list(packages.keys()): + if name not in depended: + del packages[name] + if last_depended: + # if remaining packages haven't changed return them + if last_depended == depended: + return packages.keys() + # otherwise reduce again + last_depended = depended + + +def _include_comments(): + # skipping comment lines when COLCON_TRACE is not set speeds up the + # processing especially on Windows + return bool(os.environ.get('COLCON_TRACE')) + + +def get_commands(pkg_name, prefix, primary_extension, additional_extension): + commands = [] + package_dsv_path = os.path.join(prefix, 'share', pkg_name, 'package.dsv') + if os.path.exists(package_dsv_path): + commands += process_dsv_file( + package_dsv_path, prefix, primary_extension, additional_extension) + return commands + + +def process_dsv_file( + dsv_path, prefix, primary_extension=None, additional_extension=None +): + commands = [] + if _include_comments(): + commands.append(FORMAT_STR_COMMENT_LINE.format_map({'comment': dsv_path})) + with open(dsv_path, 'r') as h: + content = h.read() + lines = content.splitlines() + + basenames = OrderedDict() + for i, line in enumerate(lines): + # skip over empty or whitespace-only lines + if not line.strip(): + continue + # skip over comments + if line.startswith('#'): + continue + try: + type_, remainder = line.split(';', 1) + except ValueError: + raise RuntimeError( + "Line %d in '%s' doesn't contain a semicolon separating the " + 'type from the arguments' % (i + 1, dsv_path)) + if type_ != DSV_TYPE_SOURCE: + # handle non-source lines + try: + commands += handle_dsv_types_except_source( + type_, remainder, prefix) + except RuntimeError as e: + raise RuntimeError( + "Line %d in '%s' %s" % (i + 1, dsv_path, e)) from e + else: + # group remaining source lines by basename + path_without_ext, ext = os.path.splitext(remainder) + if path_without_ext not in basenames: + basenames[path_without_ext] = set() + assert ext.startswith('.') + ext = ext[1:] + if ext in (primary_extension, additional_extension): + basenames[path_without_ext].add(ext) + + # add the dsv extension to each basename if the file exists + for basename, extensions in basenames.items(): + if not os.path.isabs(basename): + basename = os.path.join(prefix, basename) + if os.path.exists(basename + '.dsv'): + extensions.add('dsv') + + for basename, extensions in basenames.items(): + if not os.path.isabs(basename): + basename = os.path.join(prefix, basename) + if 'dsv' in extensions: + # process dsv files recursively + commands += process_dsv_file( + basename + '.dsv', prefix, primary_extension=primary_extension, + additional_extension=additional_extension) + elif primary_extension in extensions and len(extensions) == 1: + # source primary-only files + commands += [ + FORMAT_STR_INVOKE_SCRIPT.format_map({ + 'prefix': prefix, + 'script_path': basename + '.' + primary_extension})] + elif additional_extension in extensions: + # source non-primary files + commands += [ + FORMAT_STR_INVOKE_SCRIPT.format_map({ + 'prefix': prefix, + 'script_path': basename + '.' + additional_extension})] + + return commands + + +def handle_dsv_types_except_source(type_, remainder, prefix): + commands = [] + if type_ in (DSV_TYPE_SET, DSV_TYPE_SET_IF_UNSET): + try: + env_name, value = remainder.split(';', 1) + except ValueError: + raise RuntimeError( + "doesn't contain a semicolon separating the environment name " + 'from the value') + try_prefixed_value = os.path.join(prefix, value) if value else prefix + if os.path.exists(try_prefixed_value): + value = try_prefixed_value + if type_ == DSV_TYPE_SET: + commands += _set(env_name, value) + elif type_ == DSV_TYPE_SET_IF_UNSET: + commands += _set_if_unset(env_name, value) + else: + assert False + elif type_ in ( + DSV_TYPE_APPEND_NON_DUPLICATE, + DSV_TYPE_PREPEND_NON_DUPLICATE, + DSV_TYPE_PREPEND_NON_DUPLICATE_IF_EXISTS + ): + try: + env_name_and_values = remainder.split(';') + except ValueError: + raise RuntimeError( + "doesn't contain a semicolon separating the environment name " + 'from the values') + env_name = env_name_and_values[0] + values = env_name_and_values[1:] + for value in values: + if not value: + value = prefix + elif not os.path.isabs(value): + value = os.path.join(prefix, value) + if ( + type_ == DSV_TYPE_PREPEND_NON_DUPLICATE_IF_EXISTS and + not os.path.exists(value) + ): + comment = f'skip extending {env_name} with not existing ' \ + f'path: {value}' + if _include_comments(): + commands.append( + FORMAT_STR_COMMENT_LINE.format_map({'comment': comment})) + elif type_ == DSV_TYPE_APPEND_NON_DUPLICATE: + commands += _append_unique_value(env_name, value) + else: + commands += _prepend_unique_value(env_name, value) + else: + raise RuntimeError( + 'contains an unknown environment hook type: ' + type_) + return commands + + +env_state = {} + + +def _append_unique_value(name, value): + global env_state + if name not in env_state: + if os.environ.get(name): + env_state[name] = set(os.environ[name].split(os.pathsep)) + else: + env_state[name] = set() + # append even if the variable has not been set yet, in case a shell script sets the + # same variable without the knowledge of this Python script. + # later _remove_ending_separators() will cleanup any unintentional leading separator + extend = FORMAT_STR_USE_ENV_VAR.format_map({'name': name}) + os.pathsep + line = FORMAT_STR_SET_ENV_VAR.format_map( + {'name': name, 'value': extend + value}) + if value not in env_state[name]: + env_state[name].add(value) + else: + if not _include_comments(): + return [] + line = FORMAT_STR_COMMENT_LINE.format_map({'comment': line}) + return [line] + + +def _prepend_unique_value(name, value): + global env_state + if name not in env_state: + if os.environ.get(name): + env_state[name] = set(os.environ[name].split(os.pathsep)) + else: + env_state[name] = set() + # prepend even if the variable has not been set yet, in case a shell script sets the + # same variable without the knowledge of this Python script. + # later _remove_ending_separators() will cleanup any unintentional trailing separator + extend = os.pathsep + FORMAT_STR_USE_ENV_VAR.format_map({'name': name}) + line = FORMAT_STR_SET_ENV_VAR.format_map( + {'name': name, 'value': value + extend}) + if value not in env_state[name]: + env_state[name].add(value) + else: + if not _include_comments(): + return [] + line = FORMAT_STR_COMMENT_LINE.format_map({'comment': line}) + return [line] + + +# generate commands for removing prepended underscores +def _remove_ending_separators(): + # do nothing if the shell extension does not implement the logic + if FORMAT_STR_REMOVE_TRAILING_SEPARATOR is None: + return [] + + global env_state + commands = [] + for name in env_state: + # skip variables that already had values before this script started prepending + if name in os.environ: + continue + commands += [ + FORMAT_STR_REMOVE_LEADING_SEPARATOR.format_map({'name': name}), + FORMAT_STR_REMOVE_TRAILING_SEPARATOR.format_map({'name': name})] + return commands + + +def _set(name, value): + global env_state + env_state[name] = value + line = FORMAT_STR_SET_ENV_VAR.format_map( + {'name': name, 'value': value}) + return [line] + + +def _set_if_unset(name, value): + global env_state + line = FORMAT_STR_SET_ENV_VAR.format_map( + {'name': name, 'value': value}) + if env_state.get(name, os.environ.get(name)): + line = FORMAT_STR_COMMENT_LINE.format_map({'comment': line}) + return [line] + + +if __name__ == '__main__': # pragma: no cover + try: + rc = main() + except RuntimeError as e: + print(str(e), file=sys.stderr) + rc = 1 + sys.exit(rc) diff --git a/double_inverted/install/double_inverted/lib/double_inverted/dyanamics b/double_inverted/install/double_inverted/lib/double_inverted/dyanamics new file mode 100644 index 0000000..7e72561 --- /dev/null +++ b/double_inverted/install/double_inverted/lib/double_inverted/dyanamics @@ -0,0 +1,12 @@ +#!/usr/bin/python3 +# EASY-INSTALL-ENTRY-SCRIPT: 'double-inverted==0.0.0','console_scripts','dyanamics' +__requires__ = 'double-inverted==0.0.0' +import re +import sys +from pkg_resources import load_entry_point + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) + sys.exit( + load_entry_point('double-inverted==0.0.0', 'console_scripts', 'dyanamics')() + ) diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/PKG-INFO b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/PKG-INFO new file mode 100644 index 0000000..2029d33 --- /dev/null +++ b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/PKG-INFO @@ -0,0 +1,10 @@ +Metadata-Version: 1.2 +Name: double-inverted +Version: 0.0.0 +Summary: TODO: Package description +Home-page: UNKNOWN +Maintainer: aryan +Maintainer-email: aryankay1234@gmail.com +License: TODO: License declaration +Description: UNKNOWN +Platform: UNKNOWN diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/SOURCES.txt b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/SOURCES.txt new file mode 100644 index 0000000..414b498 --- /dev/null +++ b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/SOURCES.txt @@ -0,0 +1,16 @@ +package.xml +setup.cfg +setup.py +build/double_inverted/double_inverted.egg-info/PKG-INFO +build/double_inverted/double_inverted.egg-info/SOURCES.txt +build/double_inverted/double_inverted.egg-info/dependency_links.txt +build/double_inverted/double_inverted.egg-info/entry_points.txt +build/double_inverted/double_inverted.egg-info/requires.txt +build/double_inverted/double_inverted.egg-info/top_level.txt +build/double_inverted/double_inverted.egg-info/zip-safe +double_inverted/__init__.py +double_inverted/double_inverted_dyanamics.py +resource/double_inverted +test/test_copyright.py +test/test_flake8.py +test/test_pep257.py \ No newline at end of file diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/dependency_links.txt b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/entry_points.txt b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/entry_points.txt new file mode 100644 index 0000000..9a6c5bf --- /dev/null +++ b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/entry_points.txt @@ -0,0 +1,3 @@ +[console_scripts] +dyanamics = double_inverted.double_inverted_dyanamics:main + diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/requires.txt b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/requires.txt new file mode 100644 index 0000000..49fe098 --- /dev/null +++ b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/requires.txt @@ -0,0 +1 @@ +setuptools diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/top_level.txt b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/top_level.txt new file mode 100644 index 0000000..b224df2 --- /dev/null +++ b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/top_level.txt @@ -0,0 +1 @@ +double_inverted diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/zip-safe b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/zip-safe new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info/zip-safe @@ -0,0 +1 @@ + diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__init__.py b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__pycache__/__init__.cpython-38.pyc b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..e376436 Binary files /dev/null and b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__pycache__/__init__.cpython-38.pyc differ diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__pycache__/double_inverted_dyanamics.cpython-38.pyc b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__pycache__/double_inverted_dyanamics.cpython-38.pyc new file mode 100644 index 0000000..7be8788 Binary files /dev/null and b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__pycache__/double_inverted_dyanamics.cpython-38.pyc differ diff --git a/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/double_inverted_dyanamics.py b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/double_inverted_dyanamics.py new file mode 100644 index 0000000..fe00916 --- /dev/null +++ b/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/double_inverted_dyanamics.py @@ -0,0 +1,82 @@ +import rclpy +from rclpy.node import Node +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation + +class DoubleInvertedPendulumSimulator(Node): + def __init__(self): + super().__init__("double_inverted_pendulum_simulator") + + # Initialize pendulum parameters + self.length1 = 1.0 # Length of the first pendulum + self.length2 = 1.0 # Length of the second pendulum + self.mass1 = 1.0 # Mass of the first pendulum + self.mass2 = 1.0 # Mass of the second pendulum + self.gravity = 9.81 # Acceleration due to gravity + + # Initial state [theta1, omega1, theta2, omega2] + self.state = np.array([np.pi / 2, 0, np.pi / 2, 0]) + + # Time step for the simulation + self.dt = 0.01 + + # Setup the figure and axis for visualization + self.fig, self.ax = plt.subplots() + self.line, = self.ax.plot([], [], 'o-', lw=2) + self.ax.set_xlim(-2, 2) + self.ax.set_ylim(-2, 2) + self.ax.grid() + + self.ani = animation.FuncAnimation(self.fig, self.update_plot, interval=50, blit=True) + plt.show() + + def equations_of_motion(self, state): + theta1, omega1, theta2, omega2 = state + + delta = theta2 - theta1 + + denom1 = (self.mass1 + self.mass2) * self.length1 - self.mass2 * self.length1 * np.cos(delta) * np.cos(delta) + denom2 = (self.length2 / self.length1) * denom1 + + a1 = (self.mass2 * self.length1 * omega1 * omega1 * np.sin(delta) * np.cos(delta) + + self.mass2 * self.gravity * np.sin(theta2) * np.cos(delta) + + self.mass2 * self.length2 * omega2 * omega2 * np.sin(delta) - + (self.mass1 + self.mass2) * self.gravity * np.sin(theta1)) / denom1 + + a2 = (- self.mass2 * self.length2 * omega2 * omega2 * np.sin(delta) * np.cos(delta) + + (self.mass1 + self.mass2) * self.gravity * np.sin(theta1) * np.cos(delta) - + (self.mass1 + self.mass2) * self.length1 * omega1 * omega1 * np.sin(delta) - + (self.mass1 + self.mass2) * self.gravity * np.sin(theta2)) / denom2 + + return np.array([omega1, a1, omega2, a2]) + + def step(self): + self.state += self.equations_of_motion(self.state) * self.dt + + def update_plot(self, frame): + self.step() + + theta1, _, theta2, _ = self.state + + x1 = self.length1 * np.sin(theta1) + y1 = -self.length1 * np.cos(theta1) + x2 = x1 + self.length2 * np.sin(theta2) + y2 = y1 - self.length2 * np.cos(theta2) + + self.line.set_data([0, x1, x2], [0, y1, y2]) + return self.line, + +def main(args=None): + rclpy.init(args=args) + node = DoubleInvertedPendulumSimulator() + try: + rclpy.spin(node) + except KeyboardInterrupt: + pass + finally: + node.destroy_node() + rclpy.shutdown() + +if __name__ == "__main__": + main() diff --git a/double_inverted/install/double_inverted/share/ament_index/resource_index/packages/double_inverted b/double_inverted/install/double_inverted/share/ament_index/resource_index/packages/double_inverted new file mode 100644 index 0000000..e69de29 diff --git a/double_inverted/install/double_inverted/share/colcon-core/packages/double_inverted b/double_inverted/install/double_inverted/share/colcon-core/packages/double_inverted new file mode 100644 index 0000000..e69de29 diff --git a/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.dsv b/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.dsv new file mode 100644 index 0000000..79d4c95 --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.dsv @@ -0,0 +1 @@ +prepend-non-duplicate;AMENT_PREFIX_PATH; diff --git a/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.ps1 b/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.ps1 new file mode 100644 index 0000000..26b9997 --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.ps1 @@ -0,0 +1,3 @@ +# generated from colcon_powershell/shell/template/hook_prepend_value.ps1.em + +colcon_prepend_unique_value AMENT_PREFIX_PATH "$env:COLCON_CURRENT_PREFIX" diff --git a/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.sh b/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.sh new file mode 100644 index 0000000..f3041f6 --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.sh @@ -0,0 +1,3 @@ +# generated from colcon_core/shell/template/hook_prepend_value.sh.em + +_colcon_prepend_unique_value AMENT_PREFIX_PATH "$COLCON_CURRENT_PREFIX" diff --git a/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.dsv b/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.dsv new file mode 100644 index 0000000..84dbc4c --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.dsv @@ -0,0 +1 @@ +prepend-non-duplicate;PYTHONPATH;lib/python3.8/site-packages diff --git a/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.ps1 b/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.ps1 new file mode 100644 index 0000000..12877ef --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.ps1 @@ -0,0 +1,3 @@ +# generated from colcon_powershell/shell/template/hook_prepend_value.ps1.em + +colcon_prepend_unique_value PYTHONPATH "$env:COLCON_CURRENT_PREFIX\lib/python3.8/site-packages" diff --git a/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.sh b/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.sh new file mode 100644 index 0000000..ed8efd9 --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.sh @@ -0,0 +1,3 @@ +# generated from colcon_core/shell/template/hook_prepend_value.sh.em + +_colcon_prepend_unique_value PYTHONPATH "$COLCON_CURRENT_PREFIX/lib/python3.8/site-packages" diff --git a/double_inverted/install/double_inverted/share/double_inverted/package.bash b/double_inverted/install/double_inverted/share/double_inverted/package.bash new file mode 100644 index 0000000..b65fe64 --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/package.bash @@ -0,0 +1,31 @@ +# generated from colcon_bash/shell/template/package.bash.em + +# This script extends the environment for this package. + +# a bash script is able to determine its own path if necessary +if [ -z "$COLCON_CURRENT_PREFIX" ]; then + # the prefix is two levels up from the package specific share directory + _colcon_package_bash_COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${BASH_SOURCE[0]}"`/../.." > /dev/null && pwd)" +else + _colcon_package_bash_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX" +fi + +# function to source another script with conditional trace output +# first argument: the path of the script +# additional arguments: arguments to the script +_colcon_package_bash_source_script() { + if [ -f "$1" ]; then + if [ -n "$COLCON_TRACE" ]; then + echo "# . \"$1\"" + fi + . "$@" + else + echo "not found: \"$1\"" 1>&2 + fi +} + +# source sh script of this package +_colcon_package_bash_source_script "$_colcon_package_bash_COLCON_CURRENT_PREFIX/share/double_inverted/package.sh" + +unset _colcon_package_bash_source_script +unset _colcon_package_bash_COLCON_CURRENT_PREFIX diff --git a/double_inverted/install/double_inverted/share/double_inverted/package.dsv b/double_inverted/install/double_inverted/share/double_inverted/package.dsv new file mode 100644 index 0000000..93a272c --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/package.dsv @@ -0,0 +1,6 @@ +source;share/double_inverted/hook/pythonpath.ps1 +source;share/double_inverted/hook/pythonpath.dsv +source;share/double_inverted/hook/pythonpath.sh +source;share/double_inverted/hook/ament_prefix_path.ps1 +source;share/double_inverted/hook/ament_prefix_path.dsv +source;share/double_inverted/hook/ament_prefix_path.sh diff --git a/double_inverted/install/double_inverted/share/double_inverted/package.ps1 b/double_inverted/install/double_inverted/share/double_inverted/package.ps1 new file mode 100644 index 0000000..f1121fc --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/package.ps1 @@ -0,0 +1,116 @@ +# generated from colcon_powershell/shell/template/package.ps1.em + +# function to append a value to a variable +# which uses colons as separators +# duplicates as well as leading separators are avoided +# first argument: the name of the result variable +# second argument: the value to be prepended +function colcon_append_unique_value { + param ( + $_listname, + $_value + ) + + # get values from variable + if (Test-Path Env:$_listname) { + $_values=(Get-Item env:$_listname).Value + } else { + $_values="" + } + $_duplicate="" + # start with no values + $_all_values="" + # iterate over existing values in the variable + if ($_values) { + $_values.Split(";") | ForEach { + # not an empty string + if ($_) { + # not a duplicate of _value + if ($_ -eq $_value) { + $_duplicate="1" + } + if ($_all_values) { + $_all_values="${_all_values};$_" + } else { + $_all_values="$_" + } + } + } + } + # append only non-duplicates + if (!$_duplicate) { + # avoid leading separator + if ($_all_values) { + $_all_values="${_all_values};${_value}" + } else { + $_all_values="${_value}" + } + } + + # export the updated variable + Set-Item env:\$_listname -Value "$_all_values" +} + +# function to prepend a value to a variable +# which uses colons as separators +# duplicates as well as trailing separators are avoided +# first argument: the name of the result variable +# second argument: the value to be prepended +function colcon_prepend_unique_value { + param ( + $_listname, + $_value + ) + + # get values from variable + if (Test-Path Env:$_listname) { + $_values=(Get-Item env:$_listname).Value + } else { + $_values="" + } + # start with the new value + $_all_values="$_value" + # iterate over existing values in the variable + if ($_values) { + $_values.Split(";") | ForEach { + # not an empty string + if ($_) { + # not a duplicate of _value + if ($_ -ne $_value) { + # keep non-duplicate values + $_all_values="${_all_values};$_" + } + } + } + } + # export the updated variable + Set-Item env:\$_listname -Value "$_all_values" +} + +# function to source another script with conditional trace output +# first argument: the path of the script +# additional arguments: arguments to the script +function colcon_package_source_powershell_script { + param ( + $_colcon_package_source_powershell_script + ) + # source script with conditional trace output + if (Test-Path $_colcon_package_source_powershell_script) { + if ($env:COLCON_TRACE) { + echo ". '$_colcon_package_source_powershell_script'" + } + . "$_colcon_package_source_powershell_script" + } else { + Write-Error "not found: '$_colcon_package_source_powershell_script'" + } +} + + +# a powershell script is able to determine its own path +# the prefix is two levels up from the package specific share directory +$env:COLCON_CURRENT_PREFIX=(Get-Item $PSCommandPath).Directory.Parent.Parent.FullName + +colcon_package_source_powershell_script "$env:COLCON_CURRENT_PREFIX\share/double_inverted/hook/pythonpath.ps1" +colcon_package_source_powershell_script "$env:COLCON_CURRENT_PREFIX\share/double_inverted/hook/ament_prefix_path.ps1" + +Remove-Item Env:\COLCON_CURRENT_PREFIX diff --git a/double_inverted/install/double_inverted/share/double_inverted/package.sh b/double_inverted/install/double_inverted/share/double_inverted/package.sh new file mode 100644 index 0000000..e157970 --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/package.sh @@ -0,0 +1,87 @@ +# generated from colcon_core/shell/template/package.sh.em + +# This script extends the environment for this package. + +# function to prepend a value to a variable +# which uses colons as separators +# duplicates as well as trailing separators are avoided +# first argument: the name of the result variable +# second argument: the value to be prepended +_colcon_prepend_unique_value() { + # arguments + _listname="$1" + _value="$2" + + # get values from variable + eval _values=\"\$$_listname\" + # backup the field separator + _colcon_prepend_unique_value_IFS=$IFS + IFS=":" + # start with the new value + _all_values="$_value" + # workaround SH_WORD_SPLIT not being set in zsh + if [ "$(command -v colcon_zsh_convert_to_array)" ]; then + colcon_zsh_convert_to_array _values + fi + # iterate over existing values in the variable + for _item in $_values; do + # ignore empty strings + if [ -z "$_item" ]; then + continue + fi + # ignore duplicates of _value + if [ "$_item" = "$_value" ]; then + continue + fi + # keep non-duplicate values + _all_values="$_all_values:$_item" + done + unset _item + # restore the field separator + IFS=$_colcon_prepend_unique_value_IFS + unset _colcon_prepend_unique_value_IFS + # export the updated variable + eval export $_listname=\"$_all_values\" + unset _all_values + unset _values + + unset _value + unset _listname +} + +# since a plain shell script can't determine its own path when being sourced +# either use the provided COLCON_CURRENT_PREFIX +# or fall back to the build time prefix (if it exists) +_colcon_package_sh_COLCON_CURRENT_PREFIX="/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted" +if [ -z "$COLCON_CURRENT_PREFIX" ]; then + if [ ! -d "$_colcon_package_sh_COLCON_CURRENT_PREFIX" ]; then + echo "The build time path \"$_colcon_package_sh_COLCON_CURRENT_PREFIX\" doesn't exist. Either source a script for a different shell or set the environment variable \"COLCON_CURRENT_PREFIX\" explicitly." 1>&2 + unset _colcon_package_sh_COLCON_CURRENT_PREFIX + return 1 + fi + COLCON_CURRENT_PREFIX="$_colcon_package_sh_COLCON_CURRENT_PREFIX" +fi +unset _colcon_package_sh_COLCON_CURRENT_PREFIX + +# function to source another script with conditional trace output +# first argument: the path of the script +# additional arguments: arguments to the script +_colcon_package_sh_source_script() { + if [ -f "$1" ]; then + if [ -n "$COLCON_TRACE" ]; then + echo "# . \"$1\"" + fi + . "$@" + else + echo "not found: \"$1\"" 1>&2 + fi +} + +# source sh hooks +_colcon_package_sh_source_script "$COLCON_CURRENT_PREFIX/share/double_inverted/hook/pythonpath.sh" +_colcon_package_sh_source_script "$COLCON_CURRENT_PREFIX/share/double_inverted/hook/ament_prefix_path.sh" + +unset _colcon_package_sh_source_script +unset COLCON_CURRENT_PREFIX + +# do not unset _colcon_prepend_unique_value since it might be used by non-primary shell hooks diff --git a/double_inverted/install/double_inverted/share/double_inverted/package.xml b/double_inverted/install/double_inverted/share/double_inverted/package.xml new file mode 100644 index 0000000..d449295 --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/package.xml @@ -0,0 +1,18 @@ + + + + double_inverted + 0.0.0 + TODO: Package description + aryan + TODO: License declaration + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/double_inverted/install/double_inverted/share/double_inverted/package.zsh b/double_inverted/install/double_inverted/share/double_inverted/package.zsh new file mode 100644 index 0000000..ac54d6c --- /dev/null +++ b/double_inverted/install/double_inverted/share/double_inverted/package.zsh @@ -0,0 +1,42 @@ +# generated from colcon_zsh/shell/template/package.zsh.em + +# This script extends the environment for this package. + +# a zsh script is able to determine its own path if necessary +if [ -z "$COLCON_CURRENT_PREFIX" ]; then + # the prefix is two levels up from the package specific share directory + _colcon_package_zsh_COLCON_CURRENT_PREFIX="$(builtin cd -q "`dirname "${(%):-%N}"`/../.." > /dev/null && pwd)" +else + _colcon_package_zsh_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX" +fi + +# function to source another script with conditional trace output +# first argument: the path of the script +# additional arguments: arguments to the script +_colcon_package_zsh_source_script() { + if [ -f "$1" ]; then + if [ -n "$COLCON_TRACE" ]; then + echo "# . \"$1\"" + fi + . "$@" + else + echo "not found: \"$1\"" 1>&2 + fi +} + +# function to convert array-like strings into arrays +# to workaround SH_WORD_SPLIT not being set +colcon_zsh_convert_to_array() { + local _listname=$1 + local _dollar="$" + local _split="{=" + local _to_array="(\"$_dollar$_split$_listname}\")" + eval $_listname=$_to_array +} + +# source sh script of this package +_colcon_package_zsh_source_script "$_colcon_package_zsh_COLCON_CURRENT_PREFIX/share/double_inverted/package.sh" +unset convert_zsh_to_array + +unset _colcon_package_zsh_source_script +unset _colcon_package_zsh_COLCON_CURRENT_PREFIX diff --git a/double_inverted/install/local_setup.bash b/double_inverted/install/local_setup.bash new file mode 100644 index 0000000..03f0025 --- /dev/null +++ b/double_inverted/install/local_setup.bash @@ -0,0 +1,121 @@ +# generated from colcon_bash/shell/template/prefix.bash.em + +# This script extends the environment with all packages contained in this +# prefix path. + +# a bash script is able to determine its own path if necessary +if [ -z "$COLCON_CURRENT_PREFIX" ]; then + _colcon_prefix_bash_COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)" +else + _colcon_prefix_bash_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX" +fi + +# function to prepend a value to a variable +# which uses colons as separators +# duplicates as well as trailing separators are avoided +# first argument: the name of the result variable +# second argument: the value to be prepended +_colcon_prefix_bash_prepend_unique_value() { + # arguments + _listname="$1" + _value="$2" + + # get values from variable + eval _values=\"\$$_listname\" + # backup the field separator + _colcon_prefix_bash_prepend_unique_value_IFS="$IFS" + IFS=":" + # start with the new value + _all_values="$_value" + _contained_value="" + # iterate over existing values in the variable + for _item in $_values; do + # ignore empty strings + if [ -z "$_item" ]; then + continue + fi + # ignore duplicates of _value + if [ "$_item" = "$_value" ]; then + _contained_value=1 + continue + fi + # keep non-duplicate values + _all_values="$_all_values:$_item" + done + unset _item + if [ -z "$_contained_value" ]; then + if [ -n "$COLCON_TRACE" ]; then + if [ "$_all_values" = "$_value" ]; then + echo "export $_listname=$_value" + else + echo "export $_listname=$_value:\$$_listname" + fi + fi + fi + unset _contained_value + # restore the field separator + IFS="$_colcon_prefix_bash_prepend_unique_value_IFS" + unset _colcon_prefix_bash_prepend_unique_value_IFS + # export the updated variable + eval export $_listname=\"$_all_values\" + unset _all_values + unset _values + + unset _value + unset _listname +} + +# add this prefix to the COLCON_PREFIX_PATH +_colcon_prefix_bash_prepend_unique_value COLCON_PREFIX_PATH "$_colcon_prefix_bash_COLCON_CURRENT_PREFIX" +unset _colcon_prefix_bash_prepend_unique_value + +# check environment variable for custom Python executable +if [ -n "$COLCON_PYTHON_EXECUTABLE" ]; then + if [ ! -f "$COLCON_PYTHON_EXECUTABLE" ]; then + echo "error: COLCON_PYTHON_EXECUTABLE '$COLCON_PYTHON_EXECUTABLE' doesn't exist" + return 1 + fi + _colcon_python_executable="$COLCON_PYTHON_EXECUTABLE" +else + # try the Python executable known at configure time + _colcon_python_executable="/usr/bin/python3" + # if it doesn't exist try a fall back + if [ ! -f "$_colcon_python_executable" ]; then + if ! /usr/bin/env python3 --version > /dev/null 2> /dev/null; then + echo "error: unable to find python3 executable" + return 1 + fi + _colcon_python_executable=`/usr/bin/env python3 -c "import sys; print(sys.executable)"` + fi +fi + +# function to source another script with conditional trace output +# first argument: the path of the script +_colcon_prefix_sh_source_script() { + if [ -f "$1" ]; then + if [ -n "$COLCON_TRACE" ]; then + echo "# . \"$1\"" + fi + . "$1" + else + echo "not found: \"$1\"" 1>&2 + fi +} + +# get all commands in topological order +_colcon_ordered_commands="$($_colcon_python_executable "$_colcon_prefix_bash_COLCON_CURRENT_PREFIX/_local_setup_util_sh.py" sh bash)" +unset _colcon_python_executable +if [ -n "$COLCON_TRACE" ]; then + echo "$(declare -f _colcon_prefix_sh_source_script)" + echo "# Execute generated script:" + echo "# <<<" + echo "${_colcon_ordered_commands}" + echo "# >>>" + echo "unset _colcon_prefix_sh_source_script" +fi +eval "${_colcon_ordered_commands}" +unset _colcon_ordered_commands + +unset _colcon_prefix_sh_source_script + +unset _colcon_prefix_bash_COLCON_CURRENT_PREFIX diff --git a/double_inverted/install/local_setup.ps1 b/double_inverted/install/local_setup.ps1 new file mode 100644 index 0000000..6f68c8d --- /dev/null +++ b/double_inverted/install/local_setup.ps1 @@ -0,0 +1,55 @@ +# generated from colcon_powershell/shell/template/prefix.ps1.em + +# This script extends the environment with all packages contained in this +# prefix path. + +# check environment variable for custom Python executable +if ($env:COLCON_PYTHON_EXECUTABLE) { + if (!(Test-Path "$env:COLCON_PYTHON_EXECUTABLE" -PathType Leaf)) { + echo "error: COLCON_PYTHON_EXECUTABLE '$env:COLCON_PYTHON_EXECUTABLE' doesn't exist" + exit 1 + } + $_colcon_python_executable="$env:COLCON_PYTHON_EXECUTABLE" +} else { + # use the Python executable known at configure time + $_colcon_python_executable="/usr/bin/python3" + # if it doesn't exist try a fall back + if (!(Test-Path "$_colcon_python_executable" -PathType Leaf)) { + if (!(Get-Command "python3" -ErrorAction SilentlyContinue)) { + echo "error: unable to find python3 executable" + exit 1 + } + $_colcon_python_executable="python3" + } +} + +# function to source another script with conditional trace output +# first argument: the path of the script +function _colcon_prefix_powershell_source_script { + param ( + $_colcon_prefix_powershell_source_script_param + ) + # source script with conditional trace output + if (Test-Path $_colcon_prefix_powershell_source_script_param) { + if ($env:COLCON_TRACE) { + echo ". '$_colcon_prefix_powershell_source_script_param'" + } + . "$_colcon_prefix_powershell_source_script_param" + } else { + Write-Error "not found: '$_colcon_prefix_powershell_source_script_param'" + } +} + +# get all commands in topological order +$_colcon_ordered_commands = & "$_colcon_python_executable" "$(Split-Path $PSCommandPath -Parent)/_local_setup_util_ps1.py" ps1 + +# execute all commands in topological order +if ($env:COLCON_TRACE) { + echo "Execute generated script:" + echo "<<<" + $_colcon_ordered_commands.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries) | Write-Output + echo ">>>" +} +if ($_colcon_ordered_commands) { + $_colcon_ordered_commands.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries) | Invoke-Expression +} diff --git a/double_inverted/install/local_setup.sh b/double_inverted/install/local_setup.sh new file mode 100644 index 0000000..6251240 --- /dev/null +++ b/double_inverted/install/local_setup.sh @@ -0,0 +1,137 @@ +# generated from colcon_core/shell/template/prefix.sh.em + +# This script extends the environment with all packages contained in this +# prefix path. + +# since a plain shell script can't determine its own path when being sourced +# either use the provided COLCON_CURRENT_PREFIX +# or fall back to the build time prefix (if it exists) +_colcon_prefix_sh_COLCON_CURRENT_PREFIX="/home/aryan/Inverted-pendulum-problems/double_inverted/install" +if [ -z "$COLCON_CURRENT_PREFIX" ]; then + if [ ! -d "$_colcon_prefix_sh_COLCON_CURRENT_PREFIX" ]; then + echo "The build time path \"$_colcon_prefix_sh_COLCON_CURRENT_PREFIX\" doesn't exist. Either source a script for a different shell or set the environment variable \"COLCON_CURRENT_PREFIX\" explicitly." 1>&2 + unset _colcon_prefix_sh_COLCON_CURRENT_PREFIX + return 1 + fi +else + _colcon_prefix_sh_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX" +fi + +# function to prepend a value to a variable +# which uses colons as separators +# duplicates as well as trailing separators are avoided +# first argument: the name of the result variable +# second argument: the value to be prepended +_colcon_prefix_sh_prepend_unique_value() { + # arguments + _listname="$1" + _value="$2" + + # get values from variable + eval _values=\"\$$_listname\" + # backup the field separator + _colcon_prefix_sh_prepend_unique_value_IFS="$IFS" + IFS=":" + # start with the new value + _all_values="$_value" + _contained_value="" + # iterate over existing values in the variable + for _item in $_values; do + # ignore empty strings + if [ -z "$_item" ]; then + continue + fi + # ignore duplicates of _value + if [ "$_item" = "$_value" ]; then + _contained_value=1 + continue + fi + # keep non-duplicate values + _all_values="$_all_values:$_item" + done + unset _item + if [ -z "$_contained_value" ]; then + if [ -n "$COLCON_TRACE" ]; then + if [ "$_all_values" = "$_value" ]; then + echo "export $_listname=$_value" + else + echo "export $_listname=$_value:\$$_listname" + fi + fi + fi + unset _contained_value + # restore the field separator + IFS="$_colcon_prefix_sh_prepend_unique_value_IFS" + unset _colcon_prefix_sh_prepend_unique_value_IFS + # export the updated variable + eval export $_listname=\"$_all_values\" + unset _all_values + unset _values + + unset _value + unset _listname +} + +# add this prefix to the COLCON_PREFIX_PATH +_colcon_prefix_sh_prepend_unique_value COLCON_PREFIX_PATH "$_colcon_prefix_sh_COLCON_CURRENT_PREFIX" +unset _colcon_prefix_sh_prepend_unique_value + +# check environment variable for custom Python executable +if [ -n "$COLCON_PYTHON_EXECUTABLE" ]; then + if [ ! -f "$COLCON_PYTHON_EXECUTABLE" ]; then + echo "error: COLCON_PYTHON_EXECUTABLE '$COLCON_PYTHON_EXECUTABLE' doesn't exist" + return 1 + fi + _colcon_python_executable="$COLCON_PYTHON_EXECUTABLE" +else + # try the Python executable known at configure time + _colcon_python_executable="/usr/bin/python3" + # if it doesn't exist try a fall back + if [ ! -f "$_colcon_python_executable" ]; then + if ! /usr/bin/env python3 --version > /dev/null 2> /dev/null; then + echo "error: unable to find python3 executable" + return 1 + fi + _colcon_python_executable=`/usr/bin/env python3 -c "import sys; print(sys.executable)"` + fi +fi + +# function to source another script with conditional trace output +# first argument: the path of the script +_colcon_prefix_sh_source_script() { + if [ -f "$1" ]; then + if [ -n "$COLCON_TRACE" ]; then + echo "# . \"$1\"" + fi + . "$1" + else + echo "not found: \"$1\"" 1>&2 + fi +} + +# get all commands in topological order +_colcon_ordered_commands="$($_colcon_python_executable "$_colcon_prefix_sh_COLCON_CURRENT_PREFIX/_local_setup_util_sh.py" sh)" +unset _colcon_python_executable +if [ -n "$COLCON_TRACE" ]; then + echo "_colcon_prefix_sh_source_script() { + if [ -f \"\$1\" ]; then + if [ -n \"\$COLCON_TRACE\" ]; then + echo \"# . \\\"\$1\\\"\" + fi + . \"\$1\" + else + echo \"not found: \\\"\$1\\\"\" 1>&2 + fi + }" + echo "# Execute generated script:" + echo "# <<<" + echo "${_colcon_ordered_commands}" + echo "# >>>" + echo "unset _colcon_prefix_sh_source_script" +fi +eval "${_colcon_ordered_commands}" +unset _colcon_ordered_commands + +unset _colcon_prefix_sh_source_script + +unset _colcon_prefix_sh_COLCON_CURRENT_PREFIX diff --git a/double_inverted/install/local_setup.zsh b/double_inverted/install/local_setup.zsh new file mode 100644 index 0000000..b648710 --- /dev/null +++ b/double_inverted/install/local_setup.zsh @@ -0,0 +1,134 @@ +# generated from colcon_zsh/shell/template/prefix.zsh.em + +# This script extends the environment with all packages contained in this +# prefix path. + +# a zsh script is able to determine its own path if necessary +if [ -z "$COLCON_CURRENT_PREFIX" ]; then + _colcon_prefix_zsh_COLCON_CURRENT_PREFIX="$(builtin cd -q "`dirname "${(%):-%N}"`" > /dev/null && pwd)" +else + _colcon_prefix_zsh_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX" +fi + +# function to convert array-like strings into arrays +# to workaround SH_WORD_SPLIT not being set +_colcon_prefix_zsh_convert_to_array() { + local _listname=$1 + local _dollar="$" + local _split="{=" + local _to_array="(\"$_dollar$_split$_listname}\")" + eval $_listname=$_to_array +} + +# function to prepend a value to a variable +# which uses colons as separators +# duplicates as well as trailing separators are avoided +# first argument: the name of the result variable +# second argument: the value to be prepended +_colcon_prefix_zsh_prepend_unique_value() { + # arguments + _listname="$1" + _value="$2" + + # get values from variable + eval _values=\"\$$_listname\" + # backup the field separator + _colcon_prefix_zsh_prepend_unique_value_IFS="$IFS" + IFS=":" + # start with the new value + _all_values="$_value" + _contained_value="" + # workaround SH_WORD_SPLIT not being set + _colcon_prefix_zsh_convert_to_array _values + # iterate over existing values in the variable + for _item in $_values; do + # ignore empty strings + if [ -z "$_item" ]; then + continue + fi + # ignore duplicates of _value + if [ "$_item" = "$_value" ]; then + _contained_value=1 + continue + fi + # keep non-duplicate values + _all_values="$_all_values:$_item" + done + unset _item + if [ -z "$_contained_value" ]; then + if [ -n "$COLCON_TRACE" ]; then + if [ "$_all_values" = "$_value" ]; then + echo "export $_listname=$_value" + else + echo "export $_listname=$_value:\$$_listname" + fi + fi + fi + unset _contained_value + # restore the field separator + IFS="$_colcon_prefix_zsh_prepend_unique_value_IFS" + unset _colcon_prefix_zsh_prepend_unique_value_IFS + # export the updated variable + eval export $_listname=\"$_all_values\" + unset _all_values + unset _values + + unset _value + unset _listname +} + +# add this prefix to the COLCON_PREFIX_PATH +_colcon_prefix_zsh_prepend_unique_value COLCON_PREFIX_PATH "$_colcon_prefix_zsh_COLCON_CURRENT_PREFIX" +unset _colcon_prefix_zsh_prepend_unique_value +unset _colcon_prefix_zsh_convert_to_array + +# check environment variable for custom Python executable +if [ -n "$COLCON_PYTHON_EXECUTABLE" ]; then + if [ ! -f "$COLCON_PYTHON_EXECUTABLE" ]; then + echo "error: COLCON_PYTHON_EXECUTABLE '$COLCON_PYTHON_EXECUTABLE' doesn't exist" + return 1 + fi + _colcon_python_executable="$COLCON_PYTHON_EXECUTABLE" +else + # try the Python executable known at configure time + _colcon_python_executable="/usr/bin/python3" + # if it doesn't exist try a fall back + if [ ! -f "$_colcon_python_executable" ]; then + if ! /usr/bin/env python3 --version > /dev/null 2> /dev/null; then + echo "error: unable to find python3 executable" + return 1 + fi + _colcon_python_executable=`/usr/bin/env python3 -c "import sys; print(sys.executable)"` + fi +fi + +# function to source another script with conditional trace output +# first argument: the path of the script +_colcon_prefix_sh_source_script() { + if [ -f "$1" ]; then + if [ -n "$COLCON_TRACE" ]; then + echo "# . \"$1\"" + fi + . "$1" + else + echo "not found: \"$1\"" 1>&2 + fi +} + +# get all commands in topological order +_colcon_ordered_commands="$($_colcon_python_executable "$_colcon_prefix_zsh_COLCON_CURRENT_PREFIX/_local_setup_util_sh.py" sh zsh)" +unset _colcon_python_executable +if [ -n "$COLCON_TRACE" ]; then + echo "$(declare -f _colcon_prefix_sh_source_script)" + echo "# Execute generated script:" + echo "# <<<" + echo "${_colcon_ordered_commands}" + echo "# >>>" + echo "unset _colcon_prefix_sh_source_script" +fi +eval "${_colcon_ordered_commands}" +unset _colcon_ordered_commands + +unset _colcon_prefix_sh_source_script + +unset _colcon_prefix_zsh_COLCON_CURRENT_PREFIX diff --git a/double_inverted/install/setup.bash b/double_inverted/install/setup.bash new file mode 100644 index 0000000..85a3fd5 --- /dev/null +++ b/double_inverted/install/setup.bash @@ -0,0 +1,31 @@ +# generated from colcon_bash/shell/template/prefix_chain.bash.em + +# This script extends the environment with the environment of other prefix +# paths which were sourced when this file was generated as well as all packages +# contained in this prefix path. + +# function to source another script with conditional trace output +# first argument: the path of the script +_colcon_prefix_chain_bash_source_script() { + if [ -f "$1" ]; then + if [ -n "$COLCON_TRACE" ]; then + echo "# . \"$1\"" + fi + . "$1" + else + echo "not found: \"$1\"" 1>&2 + fi +} + +# source chained prefixes +# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script +COLCON_CURRENT_PREFIX="/opt/ros/galactic" +_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/local_setup.bash" + +# source this prefix +# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script +COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)" +_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/local_setup.bash" + +unset COLCON_CURRENT_PREFIX +unset _colcon_prefix_chain_bash_source_script diff --git a/double_inverted/install/setup.ps1 b/double_inverted/install/setup.ps1 new file mode 100644 index 0000000..538f397 --- /dev/null +++ b/double_inverted/install/setup.ps1 @@ -0,0 +1,29 @@ +# generated from colcon_powershell/shell/template/prefix_chain.ps1.em + +# This script extends the environment with the environment of other prefix +# paths which were sourced when this file was generated as well as all packages +# contained in this prefix path. + +# function to source another script with conditional trace output +# first argument: the path of the script +function _colcon_prefix_chain_powershell_source_script { + param ( + $_colcon_prefix_chain_powershell_source_script_param + ) + # source script with conditional trace output + if (Test-Path $_colcon_prefix_chain_powershell_source_script_param) { + if ($env:COLCON_TRACE) { + echo ". '$_colcon_prefix_chain_powershell_source_script_param'" + } + . "$_colcon_prefix_chain_powershell_source_script_param" + } else { + Write-Error "not found: '$_colcon_prefix_chain_powershell_source_script_param'" + } +} + +# source chained prefixes +_colcon_prefix_chain_powershell_source_script "/opt/ros/galactic\local_setup.ps1" + +# source this prefix +$env:COLCON_CURRENT_PREFIX=(Split-Path $PSCommandPath -Parent) +_colcon_prefix_chain_powershell_source_script "$env:COLCON_CURRENT_PREFIX\local_setup.ps1" diff --git a/double_inverted/install/setup.sh b/double_inverted/install/setup.sh new file mode 100644 index 0000000..14f404b --- /dev/null +++ b/double_inverted/install/setup.sh @@ -0,0 +1,45 @@ +# generated from colcon_core/shell/template/prefix_chain.sh.em + +# This script extends the environment with the environment of other prefix +# paths which were sourced when this file was generated as well as all packages +# contained in this prefix path. + +# since a plain shell script can't determine its own path when being sourced +# either use the provided COLCON_CURRENT_PREFIX +# or fall back to the build time prefix (if it exists) +_colcon_prefix_chain_sh_COLCON_CURRENT_PREFIX=/home/aryan/Inverted-pendulum-problems/double_inverted/install +if [ ! -z "$COLCON_CURRENT_PREFIX" ]; then + _colcon_prefix_chain_sh_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX" +elif [ ! -d "$_colcon_prefix_chain_sh_COLCON_CURRENT_PREFIX" ]; then + echo "The build time path \"$_colcon_prefix_chain_sh_COLCON_CURRENT_PREFIX\" doesn't exist. Either source a script for a different shell or set the environment variable \"COLCON_CURRENT_PREFIX\" explicitly." 1>&2 + unset _colcon_prefix_chain_sh_COLCON_CURRENT_PREFIX + return 1 +fi + +# function to source another script with conditional trace output +# first argument: the path of the script +_colcon_prefix_chain_sh_source_script() { + if [ -f "$1" ]; then + if [ -n "$COLCON_TRACE" ]; then + echo "# . \"$1\"" + fi + . "$1" + else + echo "not found: \"$1\"" 1>&2 + fi +} + +# source chained prefixes +# setting COLCON_CURRENT_PREFIX avoids relying on the build time prefix of the sourced script +COLCON_CURRENT_PREFIX="/opt/ros/galactic" +_colcon_prefix_chain_sh_source_script "$COLCON_CURRENT_PREFIX/local_setup.sh" + + +# source this prefix +# setting COLCON_CURRENT_PREFIX avoids relying on the build time prefix of the sourced script +COLCON_CURRENT_PREFIX="$_colcon_prefix_chain_sh_COLCON_CURRENT_PREFIX" +_colcon_prefix_chain_sh_source_script "$COLCON_CURRENT_PREFIX/local_setup.sh" + +unset _colcon_prefix_chain_sh_COLCON_CURRENT_PREFIX +unset _colcon_prefix_chain_sh_source_script +unset COLCON_CURRENT_PREFIX diff --git a/double_inverted/install/setup.zsh b/double_inverted/install/setup.zsh new file mode 100644 index 0000000..4122da9 --- /dev/null +++ b/double_inverted/install/setup.zsh @@ -0,0 +1,31 @@ +# generated from colcon_zsh/shell/template/prefix_chain.zsh.em + +# This script extends the environment with the environment of other prefix +# paths which were sourced when this file was generated as well as all packages +# contained in this prefix path. + +# function to source another script with conditional trace output +# first argument: the path of the script +_colcon_prefix_chain_zsh_source_script() { + if [ -f "$1" ]; then + if [ -n "$COLCON_TRACE" ]; then + echo "# . \"$1\"" + fi + . "$1" + else + echo "not found: \"$1\"" 1>&2 + fi +} + +# source chained prefixes +# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script +COLCON_CURRENT_PREFIX="/opt/ros/galactic" +_colcon_prefix_chain_zsh_source_script "$COLCON_CURRENT_PREFIX/local_setup.zsh" + +# source this prefix +# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script +COLCON_CURRENT_PREFIX="$(builtin cd -q "`dirname "${(%):-%N}"`" > /dev/null && pwd)" +_colcon_prefix_chain_zsh_source_script "$COLCON_CURRENT_PREFIX/local_setup.zsh" + +unset COLCON_CURRENT_PREFIX +unset _colcon_prefix_chain_zsh_source_script diff --git a/double_inverted/launch/double.launch.py b/double_inverted/launch/double.launch.py new file mode 100644 index 0000000..e5d958d --- /dev/null +++ b/double_inverted/launch/double.launch.py @@ -0,0 +1,28 @@ +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration +from launch_ros.actions import Node +import os + +def generate_launch_description(): + + package_dir = os.path.dirname(os.path.abspath(__file__)) + rviz_config_file = os.path.join(package_dir, '..', 'config', 'config.rviz') + + visualizer = Node( + package = 'rviz2', + executable = 'rviz2', + # name='rviz2', + arguments = ['-d', rviz_config_file] + + ) + + dynamics = Node( + package = 'double_inverted', + executable = 'dyanamics' + ) + + return LaunchDescription([ + visualizer, + dynamics + ]) \ No newline at end of file diff --git a/double_inverted/log/COLCON_IGNORE b/double_inverted/log/COLCON_IGNORE new file mode 100644 index 0000000..e69de29 diff --git a/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/command.log b/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/command.log new file mode 100644 index 0000000..5f859ea --- /dev/null +++ b/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/command.log @@ -0,0 +1,2 @@ +Invoking command in '/home/aryan/Inverted-pendulum-problems/double_inverted': PYTHONPATH=/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/prefix_override:/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages:${PYTHONPATH} /usr/bin/python3 -W ignore:setup.py install is deprecated setup.py egg_info --egg-base build/double_inverted build --build-base /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build install --record /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log --single-version-externally-managed install_data +Invoked command in '/home/aryan/Inverted-pendulum-problems/double_inverted' returned '0': PYTHONPATH=/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/prefix_override:/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages:${PYTHONPATH} /usr/bin/python3 -W ignore:setup.py install is deprecated setup.py egg_info --egg-base build/double_inverted build --build-base /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build install --record /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log --single-version-externally-managed install_data diff --git a/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/stderr.log b/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/stderr.log new file mode 100644 index 0000000..e69de29 diff --git a/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/stdout.log b/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/stdout.log new file mode 100644 index 0000000..b37a75f --- /dev/null +++ b/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/stdout.log @@ -0,0 +1,35 @@ +running egg_info +creating build/double_inverted/double_inverted.egg-info +writing build/double_inverted/double_inverted.egg-info/PKG-INFO +writing dependency_links to build/double_inverted/double_inverted.egg-info/dependency_links.txt +writing entry points to build/double_inverted/double_inverted.egg-info/entry_points.txt +writing requirements to build/double_inverted/double_inverted.egg-info/requires.txt +writing top-level names to build/double_inverted/double_inverted.egg-info/top_level.txt +writing manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt' +reading manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt' +writing manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt' +running build +running build_py +creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build +creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib +creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted +copying double_inverted/double_inverted_dyanamics.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted +copying double_inverted/__init__.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted +running install +running install_lib +creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted +copying /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted/double_inverted_dyanamics.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted +copying /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted/__init__.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted +byte-compiling /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/double_inverted_dyanamics.py to double_inverted_dyanamics.cpython-38.pyc +byte-compiling /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__init__.py to __init__.cpython-38.pyc +running install_data +creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index +creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index +creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index/packages +copying resource/double_inverted -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index/packages +copying package.xml -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted +running install_egg_info +Copying build/double_inverted/double_inverted.egg-info to /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info +running install_scripts +Installing dyanamics script to /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/double_inverted +writing list of installed files to '/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log' diff --git a/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/stdout_stderr.log b/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/stdout_stderr.log new file mode 100644 index 0000000..b37a75f --- /dev/null +++ b/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/stdout_stderr.log @@ -0,0 +1,35 @@ +running egg_info +creating build/double_inverted/double_inverted.egg-info +writing build/double_inverted/double_inverted.egg-info/PKG-INFO +writing dependency_links to build/double_inverted/double_inverted.egg-info/dependency_links.txt +writing entry points to build/double_inverted/double_inverted.egg-info/entry_points.txt +writing requirements to build/double_inverted/double_inverted.egg-info/requires.txt +writing top-level names to build/double_inverted/double_inverted.egg-info/top_level.txt +writing manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt' +reading manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt' +writing manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt' +running build +running build_py +creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build +creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib +creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted +copying double_inverted/double_inverted_dyanamics.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted +copying double_inverted/__init__.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted +running install +running install_lib +creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted +copying /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted/double_inverted_dyanamics.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted +copying /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted/__init__.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted +byte-compiling /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/double_inverted_dyanamics.py to double_inverted_dyanamics.cpython-38.pyc +byte-compiling /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__init__.py to __init__.cpython-38.pyc +running install_data +creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index +creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index +creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index/packages +copying resource/double_inverted -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index/packages +copying package.xml -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted +running install_egg_info +Copying build/double_inverted/double_inverted.egg-info to /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info +running install_scripts +Installing dyanamics script to /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/double_inverted +writing list of installed files to '/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log' diff --git a/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/streams.log b/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/streams.log new file mode 100644 index 0000000..5345f37 --- /dev/null +++ b/double_inverted/log/build_2024-05-28_12-57-24/double_inverted/streams.log @@ -0,0 +1,37 @@ +[0.345s] Invoking command in '/home/aryan/Inverted-pendulum-problems/double_inverted': PYTHONPATH=/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/prefix_override:/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages:${PYTHONPATH} /usr/bin/python3 -W ignore:setup.py install is deprecated setup.py egg_info --egg-base build/double_inverted build --build-base /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build install --record /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log --single-version-externally-managed install_data +[0.456s] running egg_info +[0.456s] creating build/double_inverted/double_inverted.egg-info +[0.456s] writing build/double_inverted/double_inverted.egg-info/PKG-INFO +[0.456s] writing dependency_links to build/double_inverted/double_inverted.egg-info/dependency_links.txt +[0.456s] writing entry points to build/double_inverted/double_inverted.egg-info/entry_points.txt +[0.456s] writing requirements to build/double_inverted/double_inverted.egg-info/requires.txt +[0.456s] writing top-level names to build/double_inverted/double_inverted.egg-info/top_level.txt +[0.457s] writing manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt' +[0.475s] reading manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt' +[0.475s] writing manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt' +[0.475s] running build +[0.475s] running build_py +[0.475s] creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build +[0.475s] creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib +[0.475s] creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted +[0.476s] copying double_inverted/double_inverted_dyanamics.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted +[0.476s] copying double_inverted/__init__.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted +[0.476s] running install +[0.476s] running install_lib +[0.476s] creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted +[0.476s] copying /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted/double_inverted_dyanamics.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted +[0.477s] copying /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted/__init__.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted +[0.477s] byte-compiling /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/double_inverted_dyanamics.py to double_inverted_dyanamics.cpython-38.pyc +[0.478s] byte-compiling /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__init__.py to __init__.cpython-38.pyc +[0.478s] running install_data +[0.478s] creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index +[0.478s] creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index +[0.478s] creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index/packages +[0.478s] copying resource/double_inverted -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index/packages +[0.478s] copying package.xml -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted +[0.478s] running install_egg_info +[0.479s] Copying build/double_inverted/double_inverted.egg-info to /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info +[0.479s] running install_scripts +[0.488s] Installing dyanamics script to /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/double_inverted +[0.488s] writing list of installed files to '/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log' +[0.499s] Invoked command in '/home/aryan/Inverted-pendulum-problems/double_inverted' returned '0': PYTHONPATH=/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/prefix_override:/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages:${PYTHONPATH} /usr/bin/python3 -W ignore:setup.py install is deprecated setup.py egg_info --egg-base build/double_inverted build --build-base /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build install --record /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log --single-version-externally-managed install_data diff --git a/double_inverted/log/build_2024-05-28_12-57-24/events.log b/double_inverted/log/build_2024-05-28_12-57-24/events.log new file mode 100644 index 0000000..373b54b --- /dev/null +++ b/double_inverted/log/build_2024-05-28_12-57-24/events.log @@ -0,0 +1,47 @@ +[0.000000] (-) TimerEvent: {} +[0.000086] (double_inverted) JobQueued: {'identifier': 'double_inverted', 'dependencies': OrderedDict()} +[0.000545] (double_inverted) JobStarted: {'identifier': 'double_inverted'} +[0.099951] (-) TimerEvent: {} +[0.200365] (-) TimerEvent: {} +[0.300730] (-) TimerEvent: {} +[0.343258] (double_inverted) Command: {'cmd': ['/usr/bin/python3', '-W', 'ignore:setup.py install is deprecated', 'setup.py', 'egg_info', '--egg-base', 'build/double_inverted', 'build', '--build-base', '/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build', 'install', '--record', '/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log', '--single-version-externally-managed', 'install_data'], 'cwd': '/home/aryan/Inverted-pendulum-problems/double_inverted', 'env': {'LESSOPEN': '| /usr/bin/lesspipe %s', 'LANGUAGE': 'en_IN:en', 'USER': 'aryan', 'SSH_AGENT_PID': '1607', 'XDG_SESSION_TYPE': 'x11', 'SHLVL': '1', 'LD_LIBRARY_PATH': '/opt/ros/galactic/opt/yaml_cpp_vendor/lib:/opt/ros/galactic/opt/rviz_ogre_vendor/lib:/opt/ros/galactic/lib/x86_64-linux-gnu:/opt/ros/galactic/lib', 'HOME': '/home/aryan', 'DESKTOP_SESSION': 'ubuntu', 'ROS_PYTHON_VERSION': '3', 'GNOME_SHELL_SESSION_MODE': 'ubuntu', 'GTK_MODULES': 'gail:atk-bridge', 'MANAGERPID': '1509', 'DBUS_STARTER_BUS_TYPE': 'session', 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus,guid=76d3d2a54a87fb7fcc1215e866556bb3', 'COLORTERM': 'truecolor', 'IM_CONFIG_PHASE': '1', 'ROS_DISTRO': 'galactic', 'LOGNAME': 'aryan', 'JOURNAL_STREAM': '8:45890', '_': '/usr/bin/colcon', 'ROS_VERSION': '2', 'XDG_SESSION_CLASS': 'user', 'USERNAME': 'aryan', 'TERM': 'xterm-256color', 'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated', 'ROS_LOCALHOST_ONLY': '0', 'WINDOWPATH': '2', 'PATH': '/opt/ros/galactic/bin:/home/aryan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'SESSION_MANAGER': 'local/aryan-Vivobook-ASUSLaptop-X1502ZA-X1502ZA:@/tmp/.ICE-unix/1647,unix/aryan-Vivobook-ASUSLaptop-X1502ZA-X1502ZA:/tmp/.ICE-unix/1647', 'INVOCATION_ID': '685ce25ff4a54ba8a5f8e9295eb0a1ac', 'XDG_MENU_PREFIX': 'gnome-', 'GNOME_TERMINAL_SCREEN': '/org/gnome/Terminal/screen/25509364_879c_490d_a838_26e8c09adf24', 'XDG_RUNTIME_DIR': '/run/user/1000', 'DISPLAY': ':0', 'LANG': 'en_IN', 'XDG_CURRENT_DESKTOP': 'ubuntu:GNOME', 'XMODIFIERS': '@im=ibus', 'XDG_SESSION_DESKTOP': 'ubuntu', 'XAUTHORITY': '/run/user/1000/gdm/Xauthority', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:', 'GNOME_TERMINAL_SERVICE': ':1.643', 'SSH_AUTH_SOCK': '/run/user/1000/keyring/ssh', 'AMENT_PREFIX_PATH': '/opt/ros/galactic', 'SHELL': '/bin/bash', 'QT_ACCESSIBILITY': '1', 'GDMSESSION': 'ubuntu', 'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'GPG_AGENT_INFO': '/run/user/1000/gnupg/S.gpg-agent:0:1', 'QT_IM_MODULE': 'ibus', 'PWD': '/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted', 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-ubuntu:/etc/xdg', 'DBUS_STARTER_ADDRESS': 'unix:path=/run/user/1000/bus,guid=76d3d2a54a87fb7fcc1215e866556bb3', 'XDG_DATA_DIRS': '/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop', 'PYTHONPATH': '/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/prefix_override:/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages:/opt/ros/galactic/lib/python3.8/site-packages', 'COLCON': '1', 'VTE_VERSION': '6003'}, 'shell': False} +[0.400921] (-) TimerEvent: {} +[0.456369] (double_inverted) StdoutLine: {'line': b'running egg_info\n'} +[0.456610] (double_inverted) StdoutLine: {'line': b'creating build/double_inverted/double_inverted.egg-info\n'} +[0.456681] (double_inverted) StdoutLine: {'line': b'writing build/double_inverted/double_inverted.egg-info/PKG-INFO\n'} +[0.456837] (double_inverted) StdoutLine: {'line': b'writing dependency_links to build/double_inverted/double_inverted.egg-info/dependency_links.txt\n'} +[0.456904] (double_inverted) StdoutLine: {'line': b'writing entry points to build/double_inverted/double_inverted.egg-info/entry_points.txt\n'} +[0.456936] (double_inverted) StdoutLine: {'line': b'writing requirements to build/double_inverted/double_inverted.egg-info/requires.txt\n'} +[0.456966] (double_inverted) StdoutLine: {'line': b'writing top-level names to build/double_inverted/double_inverted.egg-info/top_level.txt\n'} +[0.457447] (double_inverted) StdoutLine: {'line': b"writing manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt'\n"} +[0.475216] (double_inverted) StdoutLine: {'line': b"reading manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt'\n"} +[0.475830] (double_inverted) StdoutLine: {'line': b"writing manifest file 'build/double_inverted/double_inverted.egg-info/SOURCES.txt'\n"} +[0.475900] (double_inverted) StdoutLine: {'line': b'running build\n'} +[0.475936] (double_inverted) StdoutLine: {'line': b'running build_py\n'} +[0.475966] (double_inverted) StdoutLine: {'line': b'creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build\n'} +[0.475995] (double_inverted) StdoutLine: {'line': b'creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib\n'} +[0.476023] (double_inverted) StdoutLine: {'line': b'creating /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted\n'} +[0.476050] (double_inverted) StdoutLine: {'line': b'copying double_inverted/double_inverted_dyanamics.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted\n'} +[0.476081] (double_inverted) StdoutLine: {'line': b'copying double_inverted/__init__.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted\n'} +[0.476110] (double_inverted) StdoutLine: {'line': b'running install\n'} +[0.476428] (double_inverted) StdoutLine: {'line': b'running install_lib\n'} +[0.476971] (double_inverted) StdoutLine: {'line': b'creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted\n'} +[0.477042] (double_inverted) StdoutLine: {'line': b'copying /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted/double_inverted_dyanamics.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted\n'} +[0.477078] (double_inverted) StdoutLine: {'line': b'copying /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build/lib/double_inverted/__init__.py -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted\n'} +[0.477230] (double_inverted) StdoutLine: {'line': b'byte-compiling /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/double_inverted_dyanamics.py to double_inverted_dyanamics.cpython-38.pyc\n'} +[0.478329] (double_inverted) StdoutLine: {'line': b'byte-compiling /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted/__init__.py to __init__.cpython-38.pyc\n'} +[0.478400] (double_inverted) StdoutLine: {'line': b'running install_data\n'} +[0.478435] (double_inverted) StdoutLine: {'line': b'creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index\n'} +[0.478465] (double_inverted) StdoutLine: {'line': b'creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index\n'} +[0.478493] (double_inverted) StdoutLine: {'line': b'creating /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index/packages\n'} +[0.478520] (double_inverted) StdoutLine: {'line': b'copying resource/double_inverted -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/ament_index/resource_index/packages\n'} +[0.478547] (double_inverted) StdoutLine: {'line': b'copying package.xml -> /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted\n'} +[0.478576] (double_inverted) StdoutLine: {'line': b'running install_egg_info\n'} +[0.479301] (double_inverted) StdoutLine: {'line': b'Copying build/double_inverted/double_inverted.egg-info to /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages/double_inverted-0.0.0-py3.8.egg-info\n'} +[0.479587] (double_inverted) StdoutLine: {'line': b'running install_scripts\n'} +[0.488828] (double_inverted) StdoutLine: {'line': b'Installing dyanamics script to /home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/double_inverted\n'} +[0.488899] (double_inverted) StdoutLine: {'line': b"writing list of installed files to '/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log'\n"} +[0.499375] (double_inverted) CommandEnded: {'returncode': 0} +[0.501024] (-) TimerEvent: {} +[0.504529] (double_inverted) JobEnded: {'identifier': 'double_inverted', 'rc': 0} +[0.505049] (-) EventReactorShutdown: {} diff --git a/double_inverted/log/build_2024-05-28_12-57-24/logger_all.log b/double_inverted/log/build_2024-05-28_12-57-24/logger_all.log new file mode 100644 index 0000000..ac9e566 --- /dev/null +++ b/double_inverted/log/build_2024-05-28_12-57-24/logger_all.log @@ -0,0 +1,89 @@ +[0.104s] DEBUG:colcon:Command line arguments: ['/usr/bin/colcon', 'build'] +[0.104s] DEBUG:colcon:Parsed command line arguments: Namespace(allow_overriding=[], ament_cmake_args=None, base_paths=['.'], build_base='build', catkin_cmake_args=None, catkin_skip_building_tests=False, cmake_args=None, cmake_clean_cache=False, cmake_clean_first=False, cmake_force_configure=False, cmake_target=None, cmake_target_skip_unavailable=False, continue_on_error=False, event_handlers=None, executor='parallel', ignore_user_meta=False, install_base='install', log_base=None, log_level=None, main=>, merge_install=False, metas=['./colcon.meta'], packages_above=None, packages_above_and_dependencies=None, packages_above_depth=None, packages_end=None, packages_ignore=None, packages_ignore_regex=None, packages_select=None, packages_select_build_failed=False, packages_select_by_dep=None, packages_select_regex=None, packages_select_test_failures=False, packages_skip=None, packages_skip_build_finished=False, packages_skip_by_dep=None, packages_skip_regex=None, packages_skip_test_passed=False, packages_skip_up_to=None, packages_start=None, packages_up_to=None, packages_up_to_regex=None, parallel_workers=16, paths=None, symlink_install=False, test_result_base=None, verb_extension=, verb_name='build', verb_parser=) +[0.184s] Level 1:colcon.colcon_core.package_discovery:discover_packages(colcon_meta) check parameters +[0.185s] Level 1:colcon.colcon_core.package_discovery:discover_packages(recursive) check parameters +[0.185s] Level 1:colcon.colcon_core.package_discovery:discover_packages(ignore) check parameters +[0.185s] Level 1:colcon.colcon_core.package_discovery:discover_packages(path) check parameters +[0.185s] Level 1:colcon.colcon_core.package_discovery:discover_packages(colcon_meta) discover +[0.185s] Level 1:colcon.colcon_core.package_discovery:discover_packages(recursive) discover +[0.185s] INFO:colcon.colcon_core.package_discovery:Crawling recursively for packages in '/home/aryan/Inverted-pendulum-problems/double_inverted' +[0.185s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extensions ['ignore', 'ignore_ament_install'] +[0.185s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'ignore' +[0.185s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'ignore_ament_install' +[0.185s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extensions ['colcon_pkg'] +[0.185s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'colcon_pkg' +[0.185s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extensions ['colcon_meta'] +[0.185s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'colcon_meta' +[0.185s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extensions ['ros'] +[0.185s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'ros' +[0.192s] DEBUG:colcon.colcon_core.package_identification:Package '.' with type 'ros.ament_python' and name 'double_inverted' +[0.196s] Level 1:colcon.colcon_core.package_discovery:discover_packages(recursive) using defaults +[0.196s] Level 1:colcon.colcon_core.package_discovery:discover_packages(ignore) discover +[0.196s] Level 1:colcon.colcon_core.package_discovery:discover_packages(ignore) using defaults +[0.196s] Level 1:colcon.colcon_core.package_discovery:discover_packages(path) discover +[0.196s] Level 1:colcon.colcon_core.package_discovery:discover_packages(path) using defaults +[0.204s] Level 1:colcon.colcon_core.package_discovery:discover_packages(prefix_path) check parameters +[0.204s] Level 1:colcon.colcon_core.package_discovery:discover_packages(prefix_path) discover +[0.205s] DEBUG:colcon.colcon_installed_package_information.package_discovery:Found 270 installed packages in /opt/ros/galactic +[0.212s] Level 1:colcon.colcon_core.package_discovery:discover_packages(prefix_path) using defaults +[0.243s] Level 5:colcon.colcon_core.verb:set package 'double_inverted' build argument 'cmake_args' from command line to 'None' +[0.243s] Level 5:colcon.colcon_core.verb:set package 'double_inverted' build argument 'cmake_target' from command line to 'None' +[0.243s] Level 5:colcon.colcon_core.verb:set package 'double_inverted' build argument 'cmake_target_skip_unavailable' from command line to 'False' +[0.243s] Level 5:colcon.colcon_core.verb:set package 'double_inverted' build argument 'cmake_clean_cache' from command line to 'False' +[0.243s] Level 5:colcon.colcon_core.verb:set package 'double_inverted' build argument 'cmake_clean_first' from command line to 'False' +[0.243s] Level 5:colcon.colcon_core.verb:set package 'double_inverted' build argument 'cmake_force_configure' from command line to 'False' +[0.243s] Level 5:colcon.colcon_core.verb:set package 'double_inverted' build argument 'ament_cmake_args' from command line to 'None' +[0.243s] Level 5:colcon.colcon_core.verb:set package 'double_inverted' build argument 'catkin_cmake_args' from command line to 'None' +[0.243s] Level 5:colcon.colcon_core.verb:set package 'double_inverted' build argument 'catkin_skip_building_tests' from command line to 'False' +[0.243s] DEBUG:colcon.colcon_core.verb:Building package 'double_inverted' with the following arguments: {'ament_cmake_args': None, 'build_base': '/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted', 'catkin_cmake_args': None, 'catkin_skip_building_tests': False, 'cmake_args': None, 'cmake_clean_cache': False, 'cmake_clean_first': False, 'cmake_force_configure': False, 'cmake_target': None, 'cmake_target_skip_unavailable': False, 'install_base': '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted', 'merge_install': False, 'path': '/home/aryan/Inverted-pendulum-problems/double_inverted', 'symlink_install': False, 'test_result_base': None} +[0.243s] INFO:colcon.colcon_core.executor:Executing jobs using 'parallel' executor +[0.244s] DEBUG:colcon.colcon_parallel_executor.executor.parallel:run_until_complete +[0.244s] INFO:colcon.colcon_ros.task.ament_python.build:Building ROS package in '/home/aryan/Inverted-pendulum-problems/double_inverted' with build type 'ament_python' +[0.244s] Level 1:colcon.colcon_core.shell:create_environment_hook('double_inverted', 'ament_prefix_path') +[0.245s] INFO:colcon.colcon_core.plugin_system:Skipping extension 'colcon_core.shell.bat': Not used on non-Windows systems +[0.245s] INFO:colcon.colcon_core.shell:Creating environment hook '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.ps1' +[0.245s] INFO:colcon.colcon_core.shell:Creating environment descriptor '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.dsv' +[0.246s] INFO:colcon.colcon_core.shell:Creating environment hook '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/hook/ament_prefix_path.sh' +[0.246s] INFO:colcon.colcon_core.shell:Skip shell extension 'powershell' for command environment: Not usable outside of PowerShell +[0.246s] DEBUG:colcon.colcon_core.shell:Skip shell extension 'dsv' for command environment +[0.371s] INFO:colcon.colcon_core.task.python.build:Building Python package in '/home/aryan/Inverted-pendulum-problems/double_inverted' +[0.371s] INFO:colcon.colcon_core.shell:Skip shell extension 'powershell' for command environment: Not usable outside of PowerShell +[0.371s] DEBUG:colcon.colcon_core.shell:Skip shell extension 'dsv' for command environment +[0.589s] DEBUG:colcon.colcon_core.event_handler.log_command:Invoking command in '/home/aryan/Inverted-pendulum-problems/double_inverted': PYTHONPATH=/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/prefix_override:/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages:${PYTHONPATH} /usr/bin/python3 -W ignore:setup.py install is deprecated setup.py egg_info --egg-base build/double_inverted build --build-base /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build install --record /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log --single-version-externally-managed install_data +[0.743s] DEBUG:colcon.colcon_core.event_handler.log_command:Invoked command in '/home/aryan/Inverted-pendulum-problems/double_inverted' returned '0': PYTHONPATH=/home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/prefix_override:/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages:${PYTHONPATH} /usr/bin/python3 -W ignore:setup.py install is deprecated setup.py egg_info --egg-base build/double_inverted build --build-base /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/build install --record /home/aryan/Inverted-pendulum-problems/double_inverted/build/double_inverted/install.log --single-version-externally-managed install_data +[0.744s] Level 1:colcon.colcon_core.environment:checking '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted' for CMake module files +[0.745s] Level 1:colcon.colcon_core.environment:checking '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted' for CMake config files +[0.745s] Level 1:colcon.colcon_core.environment:checking '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib' +[0.745s] Level 1:colcon.colcon_core.environment:checking '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/bin' +[0.745s] Level 1:colcon.colcon_core.environment:checking '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/pkgconfig/double_inverted.pc' +[0.745s] Level 1:colcon.colcon_core.environment:checking '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/lib/python3.8/site-packages' +[0.745s] Level 1:colcon.colcon_core.shell:create_environment_hook('double_inverted', 'pythonpath') +[0.746s] INFO:colcon.colcon_core.shell:Creating environment hook '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.ps1' +[0.746s] INFO:colcon.colcon_core.shell:Creating environment descriptor '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.dsv' +[0.746s] INFO:colcon.colcon_core.shell:Creating environment hook '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/hook/pythonpath.sh' +[0.746s] Level 1:colcon.colcon_core.environment:checking '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/bin' +[0.746s] Level 1:colcon.colcon_core.environment:create_environment_scripts_only(double_inverted) +[0.746s] INFO:colcon.colcon_core.shell:Creating package script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/package.ps1' +[0.747s] INFO:colcon.colcon_core.shell:Creating package descriptor '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/package.dsv' +[0.747s] INFO:colcon.colcon_core.shell:Creating package script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/package.sh' +[0.747s] INFO:colcon.colcon_core.shell:Creating package script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/package.bash' +[0.748s] INFO:colcon.colcon_core.shell:Creating package script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/double_inverted/package.zsh' +[0.748s] Level 1:colcon.colcon_core.environment:create_file_with_runtime_dependencies(/home/aryan/Inverted-pendulum-problems/double_inverted/install/double_inverted/share/colcon-core/packages/double_inverted) +[0.748s] DEBUG:colcon.colcon_parallel_executor.executor.parallel:closing loop +[0.748s] DEBUG:colcon.colcon_parallel_executor.executor.parallel:loop closed +[0.748s] DEBUG:colcon.colcon_parallel_executor.executor.parallel:run_until_complete finished with '0' +[0.748s] DEBUG:colcon.colcon_core.event_reactor:joining thread +[0.752s] INFO:colcon.colcon_core.plugin_system:Skipping extension 'colcon_notification.desktop_notification.terminal_notifier': Not used on non-Darwin systems +[0.752s] INFO:colcon.colcon_core.plugin_system:Skipping extension 'colcon_notification.desktop_notification.win32': Not used on non-Windows systems +[0.752s] INFO:colcon.colcon_notification.desktop_notification:Sending desktop notification using 'notify2' +[0.766s] DEBUG:colcon.colcon_core.event_reactor:joined thread +[0.766s] INFO:colcon.colcon_core.shell:Creating prefix script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/local_setup.ps1' +[0.767s] INFO:colcon.colcon_core.shell:Creating prefix util module '/home/aryan/Inverted-pendulum-problems/double_inverted/install/_local_setup_util_ps1.py' +[0.767s] INFO:colcon.colcon_core.shell:Creating prefix chain script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/setup.ps1' +[0.768s] INFO:colcon.colcon_core.shell:Creating prefix script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/local_setup.sh' +[0.768s] INFO:colcon.colcon_core.shell:Creating prefix util module '/home/aryan/Inverted-pendulum-problems/double_inverted/install/_local_setup_util_sh.py' +[0.768s] INFO:colcon.colcon_core.shell:Creating prefix chain script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/setup.sh' +[0.769s] INFO:colcon.colcon_core.shell:Creating prefix script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/local_setup.bash' +[0.769s] INFO:colcon.colcon_core.shell:Creating prefix chain script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/setup.bash' +[0.769s] INFO:colcon.colcon_core.shell:Creating prefix script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/local_setup.zsh' +[0.770s] INFO:colcon.colcon_core.shell:Creating prefix chain script '/home/aryan/Inverted-pendulum-problems/double_inverted/install/setup.zsh' diff --git a/double_inverted/package.xml b/double_inverted/package.xml new file mode 100644 index 0000000..d449295 --- /dev/null +++ b/double_inverted/package.xml @@ -0,0 +1,18 @@ + + + + double_inverted + 0.0.0 + TODO: Package description + aryan + TODO: License declaration + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/double_inverted/resource/double_inverted b/double_inverted/resource/double_inverted new file mode 100644 index 0000000..e69de29 diff --git a/double_inverted/setup.cfg b/double_inverted/setup.cfg new file mode 100644 index 0000000..2daf2b6 --- /dev/null +++ b/double_inverted/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/double_inverted +[install] +install_scripts=$base/lib/double_inverted diff --git a/double_inverted/setup.py b/double_inverted/setup.py new file mode 100644 index 0000000..ee8bcb9 --- /dev/null +++ b/double_inverted/setup.py @@ -0,0 +1,32 @@ +from setuptools import setup +import os +from glob import glob + +package_name = 'double_inverted' + +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']), + (os.path.join('share', package_name, 'launch/'), + glob('launch/*launch.[pxy][yma]*')), + (os.path.join('share', package_name, 'config/'), + glob('config/**')) + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='aryan', + maintainer_email='aryankay1234@gmail.com', + description='TODO: Package description', + license='TODO: License declaration', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + 'dyanamics = double_inverted.double_inverted_dyanamics:main' + ], + }, +) diff --git a/double_inverted/test/test_copyright.py b/double_inverted/test/test_copyright.py new file mode 100644 index 0000000..cc8ff03 --- /dev/null +++ b/double_inverted/test/test_copyright.py @@ -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_copyright.main import main +import pytest + + +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/double_inverted/test/test_flake8.py b/double_inverted/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/double_inverted/test/test_flake8.py @@ -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) diff --git a/double_inverted/test/test_pep257.py b/double_inverted/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/double_inverted/test/test_pep257.py @@ -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' diff --git a/single_inverted/launch/single_inverted_pendulum.launch.py b/single_inverted/launch/single_inverted_pendulum.launch.py index 0e7c01b..0eedd27 100644 --- a/single_inverted/launch/single_inverted_pendulum.launch.py +++ b/single_inverted/launch/single_inverted_pendulum.launch.py @@ -22,7 +22,25 @@ def generate_launch_description(): executable = 'dynamics_sim' ) + interface = Node( + package = 'single_inverted', + executable = 'interface' + ) + + balance = Node( + package = 'single_inverted', + executable = 'balancer' + ) + + swingup = Node( + package = 'single_inverted', + executable = 'swingup' + ) + return LaunchDescription([ visualizer, - dynamics - ]) \ No newline at end of file + dynamics, + #interface, + #balance, + swingup + ]) diff --git a/single_inverted/setup.py b/single_inverted/setup.py index d02acd7..c16557a 100644 --- a/single_inverted/setup.py +++ b/single_inverted/setup.py @@ -26,7 +26,10 @@ tests_require=['pytest'], entry_points={ 'console_scripts': [ - 'dynamics_sim = single_inverted.dynamics_sim:main' + 'dynamics_sim = single_inverted.dynamics_sim:main', + 'balancer = single_inverted.Single_Inverted_Balance:main', + 'interface = single_inverted.Single_Inverted_Interface:main', + 'swingup = single_inverted.Single_Inverted_SwingUp:main' ], }, ) diff --git a/single_inverted/single_inverted/Single_Inverted_Balance.py b/single_inverted/single_inverted/Single_Inverted_Balance.py new file mode 100644 index 0000000..7950d9b --- /dev/null +++ b/single_inverted/single_inverted/Single_Inverted_Balance.py @@ -0,0 +1,120 @@ +import rclpy +from rclpy.node import Node +from rclpy.time import Time +import numpy as np +from math import pi +import matplotlib.pyplot as plt +from custom_msgs.msg import States, TorqueInput + +class Single_Inverted(Node): + + # Param/s + mass = 1.0 + g = 9.81 + l = 1.0 + state_update_frequency = 3000 + state_update_timeperiod = 1 / state_update_frequency + + feedback_frequency = 50 + # feedback_timeperiod = 1 / feedback_frequency + + inertia = mass * l * l + + def __init__(self): + super().__init__('Pendulum_Node') + self.subscription = self.create_subscription( + States, + '/state_feedback', + self.talker_callback, + 10 + ) + + self.publisher = self.create_publisher( + TorqueInput, + '/torque_input', + 10 + ) + + # PID gains + self.kp = 0.15 + self.ki = 0.002 + self.kd = 4.0 + + # Initialize PID controller state + self.integral_error = 0.0 + self.previous_error = 0.0 + self.prev_time = self.get_clock().now() + + # Initialize lists to store theta and time data for plotting + self.theta_data = [] + self.time_data = [] + + def Time_Diff(self, t1: Time, t2: Time) -> float: + t1_msg = t1.to_msg() + t2_msg = t2.to_msg() + sec_diff = t1_msg.sec - t2_msg.sec + nanosec_diff = t1_msg.nanosec - t2_msg.nanosec + return sec_diff + nanosec_diff / 1e9 + + def talker_callback(self, msg: States): + Theta_Meas = abs(msg.theta) + curr_time = self.get_clock().now() + + # Compute error terms + error = np.pi - Theta_Meas + self.integral_error += error + self.derivative_error = (error - self.previous_error) / self.Time_Diff(curr_time, self.prev_time) + + # Compute the control torque + control_torque = ( + self.kp * error + + self.ki * self.integral_error + + self.kd * self.derivative_error + ) + + # Updating errors + self.previous_error = error + self.prev_time = curr_time + + # Store theta and time data for plotting + self.theta_data.append(Theta_Meas) + self.time_data.append(curr_time.seconds_nanoseconds()[0] + curr_time.seconds_nanoseconds()[1] / 1e9) + + # Publish the control torque + Torque_msg = TorqueInput() + + Torque_msg.torque_value = control_torque + Theta_Meas + if msg.theta < 0 : Torque_msg.torque_value *= -1 + + # Setting limits on Torque value + if Torque_msg.torque_value > 5 : Torque_msg.torque_value = 5.0 + if Torque_msg.torque_value < -5 : Torque_msg.torque_value = -5.0 + self.publisher.publish(Torque_msg) + + def plot_theta_vs_time(self): + plt.plot(self.time_data, self.theta_data, label='Theta vs Time') + plt.xlabel('Time (seconds)') + plt.ylabel('Theta (radians)') + plt.title('Theta vs Time') + plt.legend() + plt.grid(True) + plt.show() + +def main(args=None): + rclpy.init(args=args) + + Pendulum_Node = Single_Inverted() + try: + rclpy.spin(Pendulum_Node) + except KeyboardInterrupt: + pass + + # Plot theta vs time after shutting down the node + Pendulum_Node.plot_theta_vs_time() + + Pendulum_Node.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() + diff --git a/single_inverted/single_inverted/Single_Inverted_Interface.py b/single_inverted/single_inverted/Single_Inverted_Interface.py new file mode 100644 index 0000000..ae265a3 --- /dev/null +++ b/single_inverted/single_inverted/Single_Inverted_Interface.py @@ -0,0 +1,60 @@ +import rclpy +from rclpy.node import Node +from rclpy.time import Time +import numpy as np +from math import pi +import matplotlib.pyplot as plt +from custom_msgs.msg import States, TorqueInput + +class Single_Inverted(Node): + + # Param/s + mass = 1.0 + g = 9.81 + l = 1.0 + state_update_frequency = 3000 + state_update_timeperiod = 1 / state_update_frequency + + feedback_frequency = 50 + # feedback_timeperiod = 1 / feedback_frequency + + inertia = mass * l * l + + def __init__(self): + super().__init__('Pendulum_Node') + self.subscription = self.create_subscription( + States, + '/state_feedback', + self.talker_callback, + 10 + ) + + self.publisher = self.create_publisher( + TorqueInput, + '/torque_input', + 10 + ) + + def talker_callback(self, msg: States): + Theta_Meas = abs(msg.theta) + + # Publish the control torque + Torque_msg = TorqueInput() + + if Theta_Meas > 0 : Torque_msg.torque_value = 1.0 * self.inertia + else : Torque_msg.torque_value = -1.0 + + self.publisher.publish(Torque_msg) + +def main(args=None): + rclpy.init(args=args) + + Pendulum_Node = Single_Inverted() + rclpy.spin(Pendulum_Node) + + Pendulum_Node.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() + diff --git a/single_inverted/single_inverted/Single_Inverted_SwingUp.py b/single_inverted/single_inverted/Single_Inverted_SwingUp.py new file mode 100644 index 0000000..3c51d40 --- /dev/null +++ b/single_inverted/single_inverted/Single_Inverted_SwingUp.py @@ -0,0 +1,96 @@ +from typing import List + +import rclpy +from rclpy.node import Node +from rclpy.time import Time +import numpy as np +import time + +from custom_msgs.msg import States, TorqueInput + +class Single_Inverted_Swing_Up(Node): + + # Setting Limits + Target_Value = np.pi + Torque_Max = 5.0 + + # Setting terms for errors + Theta_prev = 0.0 + Torque_prev = Torque_Max + + # Setting terms for PID + prev_error = 0.0 + Integral_Total = 0.0 + + def __init__(self): + super().__init__("swing_up_pendulum") + + self.create_subscription( + States, + "/state_feedback", + self.handle_state_msg, + 10 + ) + self.torque_publisher = self.create_publisher( + TorqueInput, + "/torque_input", + 10 + ) + + self.prev_time = time.time() + + def handle_state_msg(self, msg: States): + Theta_meas = abs(msg.theta) + curr_time = time.time() + + Torque_msg = TorqueInput() + error = self.Target_Value - Theta_meas + + Kp = 0.15 + Ki = 0.002 + Kd = 4.0 + + # If the chnage i angle is greater than 0.1 radian, Troque = 0 + if abs(Theta_meas - self.Theta_prev) >= 0.1: + Torque_msg.torque_value = 0.0 + + # If absolute angle is less than 135 deg, and change in angle is less than 0.001 rad, Reverse Torque + elif abs(Theta_meas) < 3 * np.pi / 4: + if abs(Theta_meas - self.Theta_prev) < 0.001: + self.Torque_prev *= -1 + + Torque_msg.torque_value = self.Torque_prev + + # Else PID :) + else: + dt = curr_time - self.prev_time + + self.Integral_Total += error + derivative = (error - self.prev_error) / dt + + PIDvalue = Kp * error + Ki * self.Integral_Total + Kd * derivative + + Torque_msg.torque_value = Theta_meas + PIDvalue + if msg.theta < 0: + Torque_msg.torque_value *= -1 + + self.torque_publisher.publish(Torque_msg) + + # Set all current values to previous for next error calculations + self.Theta_prev = Theta_meas + self.prev_error = error + self.prev_time = curr_time + + +def main(args=None): + rclpy.init(args=args) + + node = Single_Inverted_Swing_Up() + rclpy.spin(node) + node.destroy_node() + + rclpy.shutdown() + + +if __name__ == "__main__": + main()