From 2a1fcf08319219ca9192293e7ea57b4bcc0debc6 Mon Sep 17 00:00:00 2001
From: Shubham Gawande <37308273+ShubhamGawande191@users.noreply.github.com>
Date: Wed, 20 Dec 2023 15:50:54 +0100
Subject: [PATCH 1/9] setup ros2 workflow

---
 .github/workflows/ros2_ci.yml | 48 +++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 .github/workflows/ros2_ci.yml

diff --git a/.github/workflows/ros2_ci.yml b/.github/workflows/ros2_ci.yml
new file mode 100644
index 0000000..33bd344
--- /dev/null
+++ b/.github/workflows/ros2_ci.yml
@@ -0,0 +1,48 @@
+name: ROS2 CI
+
+on:
+  push:
+    branches: [ main ]
+  pull_request:
+    branches: [ main ]
+
+jobs:
+  build-and-test:
+    runs-on: ubuntu-latest
+
+    container:
+      image: osrf/ros:humble-desktop
+
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v3
+
+    - name: Import ROS2 apt key
+      run: |
+        sudo apt update
+        sudo apt install -y curl gnupg lsb-release
+        curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o ros.key
+        sudo apt-key add ros.key
+
+    - name: Install ROS2 Humble dependencies
+      run: |
+        sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'
+        sudo apt update
+        sudo apt install -y python3-colcon-common-extensions python3-rosdep python3-vcstool
+        sudo rosdep init
+        rosdep update
+
+    - name: Install package dependencies
+      run: |
+        rosdep install --from-paths src --ignore-src --rosdistro humble -y
+
+    - name: Build the package
+      run: |
+        source /opt/ros/humble/setup.bash
+        colcon build --symlink-install
+
+    - name: Run tests
+      run: |
+        source /opt/ros/humble/setup.bash
+        colcon test
+        colcon test-result --verbose

From 71504946d0163fad3889ed057a28f97cbcc1c6cd Mon Sep 17 00:00:00 2001
From: Shubham Gawande <37308273+ShubhamGawande191@users.noreply.github.com>
Date: Wed, 20 Dec 2023 15:56:17 +0100
Subject: [PATCH 2/9] Update ros2_ci.yml

---
 .github/workflows/ros2_ci.yml | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/ros2_ci.yml b/.github/workflows/ros2_ci.yml
index 33bd344..1a368bc 100644
--- a/.github/workflows/ros2_ci.yml
+++ b/.github/workflows/ros2_ci.yml
@@ -17,19 +17,29 @@ jobs:
     - name: Checkout repository
       uses: actions/checkout@v3
 
-    - name: Import ROS2 apt key
+    - name: Install system dependencies
       run: |
         sudo apt update
         sudo apt install -y curl gnupg lsb-release
-        curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o ros.key
-        sudo apt-key add ros.key
 
-    - name: Install ROS2 Humble dependencies
+    - name: Import ROS2 apt key
+      run: |
+        curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.key | sudo apt-key add -
+
+    - name: Setup sources.list
       run: |
         sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'
+
+    - name: Install ROS2 Humble dependencies
+      run: |
         sudo apt update
         sudo apt install -y python3-colcon-common-extensions python3-rosdep python3-vcstool
-        sudo rosdep init
+
+    - name: Initialize rosdep
+      run: |
+        if [ ! -f /etc/ros/rosdep/sources.list.d/20-default.list ]; then
+          sudo rosdep init
+        fi
         rosdep update
 
     - name: Install package dependencies

From 69b175d8f99fb802beeba999db93bcaf2bbaff0a Mon Sep 17 00:00:00 2001
From: Shubham Gawande <37308273+ShubhamGawande191@users.noreply.github.com>
Date: Wed, 20 Dec 2023 16:02:25 +0100
Subject: [PATCH 3/9] Update ros2_ci.yml

---
 .github/workflows/ros2_ci.yml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/ros2_ci.yml b/.github/workflows/ros2_ci.yml
index 1a368bc..9f2a9b7 100644
--- a/.github/workflows/ros2_ci.yml
+++ b/.github/workflows/ros2_ci.yml
@@ -2,7 +2,7 @@ name: ROS2 CI
 
 on:
   push:
-    branches: [ main ]
+    branches: [ main, unittest ]
   pull_request:
     branches: [ main ]
 
@@ -44,15 +44,18 @@ jobs:
 
     - name: Install package dependencies
       run: |
-        rosdep install --from-paths src --ignore-src --rosdistro humble -y
+        cd robile_safety
+        rosdep install --from-paths . --ignore-src --rosdistro humble -y
 
     - name: Build the package
       run: |
+        cd robile_safety
         source /opt/ros/humble/setup.bash
         colcon build --symlink-install
 
     - name: Run tests
       run: |
+        cd robile_safety
         source /opt/ros/humble/setup.bash
         colcon test
         colcon test-result --verbose

From ce806b4471724a63af9a45ca8a67f83bd7acf547 Mon Sep 17 00:00:00 2001
From: Shubham Gawande <37308273+ShubhamGawande191@users.noreply.github.com>
Date: Wed, 20 Dec 2023 16:07:22 +0100
Subject: [PATCH 4/9] Update ros2_ci.yml

---
 .github/workflows/ros2_ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/ros2_ci.yml b/.github/workflows/ros2_ci.yml
index 9f2a9b7..315ad20 100644
--- a/.github/workflows/ros2_ci.yml
+++ b/.github/workflows/ros2_ci.yml
@@ -52,6 +52,7 @@ jobs:
         cd robile_safety
         source /opt/ros/humble/setup.bash
         colcon build --symlink-install
+      shell: bash
 
     - name: Run tests
       run: |

From ba315b20f6726cd87ea80a8ef1c52d9de0736946 Mon Sep 17 00:00:00 2001
From: Shubham Gawande <37308273+ShubhamGawande191@users.noreply.github.com>
Date: Wed, 20 Dec 2023 16:11:28 +0100
Subject: [PATCH 5/9] Update ros2_ci.yml

---
 .github/workflows/ros2_ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/ros2_ci.yml b/.github/workflows/ros2_ci.yml
index 315ad20..ab508a1 100644
--- a/.github/workflows/ros2_ci.yml
+++ b/.github/workflows/ros2_ci.yml
@@ -60,3 +60,4 @@ jobs:
         source /opt/ros/humble/setup.bash
         colcon test
         colcon test-result --verbose
+      shell: bash

From 3b25788587ec2b1be51f113d78987b2765885c48 Mon Sep 17 00:00:00 2001
From: ShubhamGawande191 <shubhamgawande191@gmail.com>
Date: Wed, 20 Dec 2023 17:37:18 +0100
Subject: [PATCH 6/9] added tests for SMACH

---
 .../safety_monitoring_SMACH.cpython-310.pyc   | Bin 4172 -> 4201 bytes
 robile_safety/safety_monitoring_SMACH.py      |  11 +--
 run_tests.py                                  |   5 ++
 setup.py                                      |   4 +-
 test/__init__.py                              |   0
 test/__pycache__/__init__.cpython-310.pyc     | Bin 0 -> 151 bytes
 .../test_SMACH.cpython-310-pytest-6.2.5.pyc   | Bin 0 -> 3283 bytes
 test/__pycache__/test_SMACH.cpython-310.pyc   | Bin 0 -> 3090 bytes
 .../test_behaviors.cpython-310.pyc            | Bin 0 -> 909 bytes
 test/__pycache__/test_bt.cpython-310.pyc      | Bin 0 -> 150 bytes
 .../test_copyright.cpython-310.pyc            | Bin 0 -> 546 bytes
 test/__pycache__/test_flake8.cpython-310.pyc  | Bin 0 -> 515 bytes
 test/__pycache__/test_pep257.cpython-310.pyc  | Bin 0 -> 457 bytes
 test/test_SMACH.py                            |  83 ++++++++++++++++++
 14 files changed, 96 insertions(+), 7 deletions(-)
 create mode 100644 run_tests.py
 create mode 100644 test/__init__.py
 create mode 100644 test/__pycache__/__init__.cpython-310.pyc
 create mode 100644 test/__pycache__/test_SMACH.cpython-310-pytest-6.2.5.pyc
 create mode 100644 test/__pycache__/test_SMACH.cpython-310.pyc
 create mode 100644 test/__pycache__/test_behaviors.cpython-310.pyc
 create mode 100644 test/__pycache__/test_bt.cpython-310.pyc
 create mode 100644 test/__pycache__/test_copyright.cpython-310.pyc
 create mode 100644 test/__pycache__/test_flake8.cpython-310.pyc
 create mode 100644 test/__pycache__/test_pep257.cpython-310.pyc
 create mode 100644 test/test_SMACH.py

diff --git a/robile_safety/__pycache__/safety_monitoring_SMACH.cpython-310.pyc b/robile_safety/__pycache__/safety_monitoring_SMACH.cpython-310.pyc
index 6dcf7591f00b53ff9f12ceee412af637865f20ec..785f3719e06c5bd588942de9d31fcc3959b47ce4 100644
GIT binary patch
delta 330
zcmX@3@KS*{pO=@50SMNMH>V!i$g9IF6QQ4xpPQ<ml$x4Tm6}wVq+gU@Y!qK!tY2J|
zyg88hFAE<FP(3pcI|FgC)#Mlsb%_#&W`<hk8ip+91uQkp3mF+1Qka7oG+8Fk<uIOn
zlfzh5lch)+sJuu6NZjHsDbFk}i7zfmEGoIh1>@uwOqS<VWnyF5?8d3j$QUrWj4OpZ
z9jG1*iX0|C<PsAx2XcxmK!hoXumlpClX*GS7(*wka0iOo1Nr_yT+9X}I2bq>d030=
zC*Nn2VJfnlyn?%tF>bOJPdJ+uP`1c=ayySQW76c+JeG{Ho1gM*V`OxgJcrMX(SGt{
qzF@|*$>#jaMZqcsLCQfU7U_cs`^lgA{kSEB__#PZ<hU4F{sRC8?M}h~

delta 289
zcmaE<a7KYQpO=@50SK}g15^7p^6D^4gy?7F=cei>rKaXor6!do=@;b}8^xCwZw_Vt
z%QAU27cZmD<OB|NsTAfKrYy#IrW%GU<^?P@ObZzq8B$n+88lfZ&*v~^dk!*{Ve)wn
zGscyZrMT55+i?mqaWHQV<kV+m^q<_wmBL<R4pdR(IQavYn5YGaX$c}sL4*~Eu${bt
zN1QQavLkn(r~^>I4~UD|fCL8v2O|$_k;CNW+_H@JlaF#YGR97J=Lu)C21*v$OkTpH
z%$PX&1dk<S%w{IuZH$bLlXvpDF*;1*4`xiA9Kyd`6s%AXq#9&ikv@oUm@FXR$1N_z
N$HmDZ$HmC<9{{q&LTUg2

diff --git a/robile_safety/safety_monitoring_SMACH.py b/robile_safety/safety_monitoring_SMACH.py
index 882fd5f..0cfb3b7 100755
--- a/robile_safety/safety_monitoring_SMACH.py
+++ b/robile_safety/safety_monitoring_SMACH.py
@@ -63,16 +63,17 @@ def __init__(self, node):
     def execute(self, userdata):
         """Rotates the base for 5 seconds
         """
-        twist = Twist()
-        twist.angular.z = 0.5
-        self.cmd_vel_pub.publish(twist)
+        twist_start = Twist()
+        twist_start.angular.z = 0.5
+        self.cmd_vel_pub.publish(twist_start)
 
         # rotate for 5 seconds
         time.sleep(5)
 
         # stop rotating
-        twist.angular.z = 0.0
-        self.cmd_vel_pub.publish(twist)
+        # twist.angular.z = 0.0
+        twist_stop = Twist()
+        self.cmd_vel_pub.publish(twist_stop)
         return 'rotated'
 
 class Stop(smach.State):
diff --git a/run_tests.py b/run_tests.py
new file mode 100644
index 0000000..49e54f1
--- /dev/null
+++ b/run_tests.py
@@ -0,0 +1,5 @@
+import unittest
+
+if __name__ == "__main__":
+    testsuite = unittest.TestLoader().discover('test', pattern='test_*.py')
+    unittest.TextTestRunner(verbosity=2).run(testsuite)
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 463babd..95894f6 100644
--- a/setup.py
+++ b/setup.py
@@ -14,18 +14,18 @@
         ('share/' + package_name, ['package.xml']),
         (os.path.join('share/', package_name, 'launch'), glob('launch/*.py')),
     ],
-    install_requires=['setuptools'],
+    install_requires=['setuptools', 'py_trees', 'rclpy'],
     zip_safe=True,
     maintainer='beelzebub',
     maintainer_email='shubhamgawande191@gmail.com',
     description='TODO: Package description',
     license='TODO: License declaration',
     tests_require=['pytest'],
+    test_suite='test',
     entry_points={
         'console_scripts': [
         'safety_monitoring_bt = robile_safety.safety_monitoring_BT:main',
         'safety_monitoring_smach = robile_safety.safety_monitoring_SMACH:main',
-        'behaviors = robile_safety.behaviors:main',
         ],
     },
 )
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/test/__pycache__/__init__.cpython-310.pyc b/test/__pycache__/__init__.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..9601f3bbf4521a7e3c4c36e0b1deda6f818d34e6
GIT binary patch
literal 151
zcmd1j<>g`k0ztm!R1p0bL?8o3AjbiSi&=m~3PUi1CZpd<h9ZzKg7{^npOK%Ns-Kja
znp2gURGOq;lwWKVUtX+VT$BuCCuQcO#uq21rIu9cm!uY#=*P!r=4F<|$LkeT-r}&y
S%}*)KNwou+S<D0^SQr4}T_PU<

literal 0
HcmV?d00001

diff --git a/test/__pycache__/test_SMACH.cpython-310-pytest-6.2.5.pyc b/test/__pycache__/test_SMACH.cpython-310-pytest-6.2.5.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..5f2c0fb84476fd248b75ac362a24ce9288ea72e8
GIT binary patch
literal 3283
zcmbVO&2QX96!+L(uh;9%$0kibpcEpt$U<zOk$|E?(xyN`BnJW)3(4|&rkic;^)lma
z$Z9#IN6Lu{oDy#RQ@C*9#9S*O_1qg5cyDZPvgvLQjO6E;_ukCB`Mr;sw9#-hXxAEt
z><{QY#lh)j!eA3V@iP#rQ4(uDQGY!#bd6|<=~qZDv3v_8dR$Fx-%e_Nt>8Pp1AHT{
zC$8@*o*6fiIe$*|EAf1?;4dVL{$kSfo5_;DM6}N|YSHQ=jaHd;fBDex&#@J1KhXJI
zW*wbBhJ7j7Ri9UT29{|%o-Ql>FpKu2xt&H2JR+-~#%Y+XUx#k(%TO@B8-+d3l$W;C
zUN=km?J&z2Ke*MSTWK73MK|q9=c_aeGj<!)rMa7>eQAD9V;12Sr&|REoA8MrfiMM$
zuQP)Zsz1^WiEl#Rpr-0qXoXsjGytbcZTMH2O>2h)sB=hYow}$6b85h8DE=IsrwfmD
zx=5Ra%mLXFXfM-qYRx)~ORW`pUh!NyzpHr{<nq@{WV_)#mK_u)?e;nm0Yl4%eI33n
z_@28!GVO>cP_<p{2~k+`DDEFfvkOo?A<~Fq@kHZ`p!?6wwY@Z9Yi-8jA!`rXYdjU#
zgMG0kcm(}+H)erQ+plF{i6X)7_N}eEEm+YJEc>Rv6^BA#<UL0_Tzz<Dn$fKj-I@0D
zIxN8P5T4E(@RPRK8)P)y@9}vQq0KpIqO_5*klz8RGGPvd%Rq*!Qw^9<e!&I<CL)I7
z0uaQIl4CN`0zEShHTatp@bvT@SwkR#UP_r)$&IW>oI#)|o-|RyaWy%YK=20rK^p>c
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;aUw$%--uzACii`${=!h1Oyh_gt))Of|
z;bNT2^~t1}9L-3fy#A{)qM{q)LE0F6Tlh9d-1rUTnFz%+Y^8lOcj3qQeiis?Th$hb
R4RE^T0%_{@hb}Sy{SS{$bLId5

literal 0
HcmV?d00001

diff --git a/test/__pycache__/test_SMACH.cpython-310.pyc b/test/__pycache__/test_SMACH.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..2e881be942c58cc37cae1a6764938c082a7dc445
GIT binary patch
literal 3090
zcma)8&2Jk;6yMoh+w1j595+p&qAe7Pv=>KeK&Vn7Z9_khNQ6k?u$R$#XW}^B^_rP+
z(^&4wy@m@XI3+#NKZP?V=7dxUspsA}0PoG(`KnVfmfz0Kdo%Oq_ul)>X0@7cL0h>n
z=08;|>m|M%Z!Wytg1`I`1hW`PtPr1eLQ*@lQzvv%H*`s^D})8mIY}`sg(WlQCSF<&
z%cfsQ{In8Q(rQ>W@5Q8+*28)_7tW=Pu#wJ(^TfJuu@dv1S<K_sc6026=lB9EKeEML
zZtb5xuwW+HF#o`R1wL8pfujrkNX1*aycTu3@mdx?(rz3jNkDYzUXn#>`8ssVUq_OQ
zjX3HBwk|x}=}M(b-}6{yVmWa2#kH*0h5nsLDK2(z_t<KdBwg9fdfNXsQ<36#U;*uJ
zsI0HuuUNuk-2ZqxL~9F1xfK#-g*JB>VfHg?OhOm>4s%VvzzVGR%nFP7dBYO-Sb0pC
z&niY=W>r=Lz0c}w4xSazH`qLD?%C`dTQD|NHosv7=k>xvF4ab~$<^-U6y07YCdXXE
zz779X_`j}#P}V*%Xj&WA3$l)oh&bu*YPSn8ydc_%6Zygt3t;>A&84j@<x6eOlOb;p
z+Djsn*XfR2k|KtFyPI$-&Gt(QJTZc9tleIH(1I0x$<=rL)g+P<Qp|ddepKz@m03==
zj%?5LU({g%F$W^BMFSq%lUoDDvYno2q6&S^#d*}$6pzH0pfxVwJaGZU@ajwlP8h%8
zg98&0Ly7w$hKwALkwt9=I0p8*E+YW6moX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Ul$EvT+iid-_$RAT%%NV(d|
zn7~U%U|owVC_X@e=^&O+V2+8;QQSsxbk&<4-uI#g0_ja&1mRh>?Gqb#z;iqYxxu^Q
z)%{|f7&~+?jk-NbgGKEP;L`__TGyt%7Q&Nnj{(Rl%6xNFrD8~0vW3iLcymtjp3DrD
z<)elq=Q|ueo|M=<vOX%wYya!o%-PzMyh&n=r}i+jR*^gLz~T;$xp<aYplI)Aj{O(-
aB`6VN&su;at-`NC-XTrf`>IOZfByr`ITwup

literal 0
HcmV?d00001

diff --git a/test/__pycache__/test_behaviors.cpython-310.pyc b/test/__pycache__/test_behaviors.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..5c74fe711fd24f946f592f19ce9a4c39fa159737
GIT binary patch
literal 909
zcmZuv&u`N(6n@T+F74VLIyfP&NV&8UXEY5)g^*AWw5MDwr}nm#q#3q5v}#;nXD&#b
z+av#yublW75E8tXOj9Co<S+hS?DxLsFXdp+0~}v}e^TE(fFDGfBS3P3(;Op6kSvFU
z-d@fMFYy?>0_n@(7G$7c<$v~*K!q}V=jq1^cAY&iJTtFm-1&()U=}miP1S|C%1UjP
z6lx9>Q5SrG3k3<2ka&_w?-mkY`g4c_H(DrT-<DQb_2Mqkk~NZ04ibKf(|kd&uw#4p
z$ZlZg-LRE!VZ~O#9_8OfLJ1AlX|aPAi(0JPV!akSY_WdLBwz<@77sLubi;NR?ob$`
zw4J`+h}?ySI&{7H;`w6AU%z}absa18xw0-4>+@XUj!UJa>&i^4rOnE<>*m5(ZnFZ<
zRm*x~y{>l;tN8tq*mHqV`I%$schDnL_3LDEQ5I^FDwS_lx=AOxG*9^lGckIJ>om(1
zH{wj$>xo4tD&Y5)jxVp>5yg47&TJ;~Y%54xNN$j;5gV~#>lv}_lYc!O|0l@|?T<KL
zi$ZbkdYl)f+@Kup`kd3P)n7E#shVlP5ygB2`Zo+g1btRTC}$zEHRthxi#Dj6YP(0R
wX2&g78yJ!7Q-P*YV*L=o1(c~#m+n+kaTh(S<sQ@DYWfJIVB|%^J`4W*1qem%j{pDw

literal 0
HcmV?d00001

diff --git a/test/__pycache__/test_bt.cpython-310.pyc b/test/__pycache__/test_bt.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..401adec721a7e4e6400ae62444db2a3beb64cace
GIT binary patch
literal 150
zcmd1j<>g`k0`A{UsUZ3>h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o6vKKO;XkRX-^;
zHK!^ysWeHyD8JY!zPwn!xF{LOPRh(ljW142OD(C?FG(#f0Tb~_C3*#ww>WHa^HWN5
OQtd!S7Bc|}76t%6W+KS|

literal 0
HcmV?d00001

diff --git a/test/__pycache__/test_copyright.cpython-310.pyc b/test/__pycache__/test_copyright.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..d908e76ab0737ef06973cdbd2c7054f068f0075d
GIT binary patch
literal 546
zcmYjO!A=`75cN3D63P;!Dj#6=#${LPxk4bM9#EAFw_GA;J!F^cu2<s?C=tCtuY3r<
z!Dsl&slUL9air3WHBU2R>&=_7J3js**s}B&z7B+Vi^;wXIXP$dXAD+Ys6_)afEdeK
z&Lqm)!L70btDa#O4|kZ@p-ujXCx~ZuVCA(qJ^0HU;st_gOw~@e7gMJT*KMd;mc1^~
zSR`E<uNR1|?rKw@)m5we67>>WB-3-jyEPT4Z>k!zQwRy6@vbc*^*;j+co=cX?!Phg
zEZoYaw1a2(EgpnbE9p<JgdIM?BUr)Wl4*b}s2+XKtjf^xjv~)C{pr@N)kx&XljIWL
zODbLj9dh!1o|mq{oHf^5T&x#4Isbir?{iND#|zdu_vQxsO&-a2F#jAo>o#E=>;Fp=
zX7!3;tR_H5vEe98OoQ#-qb#nF;*cTfHjyB1l~zIdRn>*V&jul>tF~wLk!YuQ58~g4
Y(T~R2b&Y3nT%R(e;}N7Pfdsz72kI-0)Bpeg

literal 0
HcmV?d00001

diff --git a/test/__pycache__/test_flake8.cpython-310.pyc b/test/__pycache__/test_flake8.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..2e0498221345bff812871953c2bd621162592290
GIT binary patch
literal 515
zcmYjO!AiqG5Z&3NvBtJ2f_ltFB$r0SgNTYCco6a8tq39Mu5H>)Qg*kNN_(+h{Rchz
zOMCU?FL=?}M!|u3%*@WbH_VpJrccn?jccwQLOyKr-&{=2(bYZzBMbz|p#xxJDrkpt
zI&cQ=5^Kz1?lW1y0y-X}w<N56;uHzNtmjEq#FI?-V=iSW)lJvF{29fdhJJyr4iPlz
zq1FrB(K(sJ47G+-?OYM&XqX}Y7GdryoxvMyquvuRV%2U?$xUSMK>~6-?p>DSf(5%Q
z=$4EJN>2q3D)}G^CW$PvqNk311Agd8yMu8AFN`}Vvm&I1%C7OM{&yl*@%`&G>X$i>
zQqILAPseE_OLY)WRHS4V<1`aIR>?ir(@1lrmk{5JWXO-&qp4Z5#ov4r`BVd;<@n%3
z9q4!cTdrXtTrnF-&Wpd!wmn|8pEsIX3ghO992&1;HlD}|jf>jh<(~h*ey^#Y<Ru#m
RerE5YY^l+zgXeg#4nLu~epmni

literal 0
HcmV?d00001

diff --git a/test/__pycache__/test_pep257.cpython-310.pyc b/test/__pycache__/test_pep257.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..ec0d6b589c682712385365996120378df00302e3
GIT binary patch
literal 457
zcmYjNO-sW-5Z&3Nv1;oF`U65e^^!<Iyr>9*2a#U9^-_}TSkvZ<-PDqz7wgp@(!Z3e
zC;x&cXM%+e%wyiL@6FES-R_>C@H&rpW(o1lWIJpkx0L3bKnVqjNMQuPwM^tlqMTY&
zyTO*Sl>I4Iu!51J<df*Pen=(OP}^w`XTyluCV&c>DDEgtkDw%XB_~o@U+^y8gtBMS
z96kuuTEPb>L4MA#2CueDG-aPm13h`w?6d6M=krXtQLfN6WtE_dTIbrhzPku?7H1Qq
zB|RjS)X`e#Hj&?J|0Pe+4-u0khV#(ZxfzTX#y2{mI*bz>o8TGC%IA>{j0-FV7nfd9
z)%)E1=O^T6_*e(lDQLcFf2TeUQp`3lJU)Tujccc<Sjtz?v)W1GtVB)S#<>wU|J#CH
YmbI_aT+I`_;gt=~=p3}cu^c#pKf&>9ZU6uP

literal 0
HcmV?d00001

diff --git a/test/test_SMACH.py b/test/test_SMACH.py
new file mode 100644
index 0000000..9fe4e97
--- /dev/null
+++ b/test/test_SMACH.py
@@ -0,0 +1,83 @@
+import unittest
+from unittest.mock import patch, MagicMock, call
+import rclpy
+from std_msgs.msg import Float32
+from sensor_msgs.msg import LaserScan
+from geometry_msgs.msg import Twist, Vector3
+from robile_safety.safety_monitoring_SMACH import MonitorBatteryAndCollision, RotateBase, Stop, Idle
+
+class TestSafetyMonitoring(unittest.TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        rclpy.init()
+
+    @classmethod
+    def tearDownClass(cls):
+        rclpy.shutdown()
+
+    def setUp(self):
+        self.node = rclpy.create_node('test_node')
+
+    def tearDown(self):
+        self.node.destroy_node()
+
+    @patch('robile_safety.safety_monitoring_SMACH.MonitorBatteryAndCollision.execute')
+    def test_monitor_battery_and_collision(self, mock_execute):
+        monitor_state = MonitorBatteryAndCollision(self.node)
+
+        # Set up the mock for the execute method
+        mock_execute.side_effect = [
+            'idle',  
+            'low_battery',  
+            'idle', 
+            'collision_detected'
+        ]
+
+        # Simulate battery callback with a battery level above the threshold
+        battery_msg = Float32(data=25.0)
+        monitor_state.battery_callback(battery_msg)
+        self.assertEqual(mock_execute(None), 'idle')
+
+        # Simulate battery callback with a battery level below the threshold
+        battery_msg.data = 15.0
+        monitor_state.battery_callback(battery_msg)
+        self.assertEqual(mock_execute(None), 'low_battery')
+
+        # Simulate scan callback with no collision detected
+        laser_msg = LaserScan(ranges=[0.6, 0.7, 0.8])
+        monitor_state.scan_callback(laser_msg)
+        self.assertEqual(mock_execute(None), 'idle')
+
+        # Simulate scan callback with a collision detected
+        laser_msg.ranges = [0.4, 0.3, 0.2]
+        monitor_state.scan_callback(laser_msg)
+        self.assertEqual(mock_execute(None), 'collision_detected')
+   
+    def test_rotate_base(self):
+        rotate_state = RotateBase(self.node)
+        rotate_state.cmd_vel_pub = MagicMock()  # Mock the publisher
+        rotate_state.execute(None)
+        
+        # Create the expected calls
+        expected_calls = [
+            call(Twist(angular=Vector3(z=0.5))),  # Expected start rotation call
+            call(Twist())  # Expected stop rotation call
+        ]
+        
+        # Verify that the calls were made with the expected arguments
+        rotate_state.cmd_vel_pub.publish.assert_has_calls(expected_calls, any_order=False)
+
+    def test_stop(self):
+        stop_state = Stop(self.node)
+        stop_state.cmd_vel_pub = MagicMock()  # Set up the mock publisher
+        self.assertEqual(stop_state.execute(None), 'stopped')
+        stop_state.cmd_vel_pub.publish.assert_called_once()
+
+    @patch('time.sleep', return_value=None)
+    def test_idle(self, mock_sleep):
+        idle_state = Idle(self.node)
+        self.assertEqual(idle_state.execute(None), 'idle')
+
+if __name__ == '__main__':
+    unittest.main()

From 52dc4965aa6d5988b0698044c569e03f22826705 Mon Sep 17 00:00:00 2001
From: ShubhamGawande191 <shubhamgawande191@gmail.com>
Date: Wed, 20 Dec 2023 17:48:39 +0100
Subject: [PATCH 7/9] fixed trailing whitespace in test_SMACH.py

---
 test/test_SMACH.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test_SMACH.py b/test/test_SMACH.py
index 9fe4e97..0d43b3c 100644
--- a/test/test_SMACH.py
+++ b/test/test_SMACH.py
@@ -53,7 +53,7 @@ def test_monitor_battery_and_collision(self, mock_execute):
         laser_msg.ranges = [0.4, 0.3, 0.2]
         monitor_state.scan_callback(laser_msg)
         self.assertEqual(mock_execute(None), 'collision_detected')
-   
+
     def test_rotate_base(self):
         rotate_state = RotateBase(self.node)
         rotate_state.cmd_vel_pub = MagicMock()  # Mock the publisher

From dcc082fde2334944ffa7b879a44ab7b070ac09c1 Mon Sep 17 00:00:00 2001
From: ShubhamGawande191 <shubhamgawande191@gmail.com>
Date: Wed, 20 Dec 2023 17:55:38 +0100
Subject: [PATCH 8/9] fixed trailing whitespace in test_SMACH.py

---
 test/test_SMACH.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test_SMACH.py b/test/test_SMACH.py
index 0d43b3c..440821c 100644
--- a/test/test_SMACH.py
+++ b/test/test_SMACH.py
@@ -58,7 +58,7 @@ def test_rotate_base(self):
         rotate_state = RotateBase(self.node)
         rotate_state.cmd_vel_pub = MagicMock()  # Mock the publisher
         rotate_state.execute(None)
-        
+
         # Create the expected calls
         expected_calls = [
             call(Twist(angular=Vector3(z=0.5))),  # Expected start rotation call

From 38088e2445d38cf27fce2c0c498f45634798a8f2 Mon Sep 17 00:00:00 2001
From: ShubhamGawande191 <shubhamgawande191@gmail.com>
Date: Wed, 20 Dec 2023 17:58:37 +0100
Subject: [PATCH 9/9] fixed trailing whitespace in test_SMACH.py

---
 test/test_SMACH.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test_SMACH.py b/test/test_SMACH.py
index 440821c..dbbd0d0 100644
--- a/test/test_SMACH.py
+++ b/test/test_SMACH.py
@@ -64,7 +64,7 @@ def test_rotate_base(self):
             call(Twist(angular=Vector3(z=0.5))),  # Expected start rotation call
             call(Twist())  # Expected stop rotation call
         ]
-        
+
         # Verify that the calls were made with the expected arguments
         rotate_state.cmd_vel_pub.publish.assert_has_calls(expected_calls, any_order=False)