diff --git a/.github/workflows/.pylintrc b/.github/workflows/.pylintrc new file mode 100644 index 00000000..05decfd0 --- /dev/null +++ b/.github/workflows/.pylintrc @@ -0,0 +1,10 @@ +[MESSAGES CONTROL] + +disable=all + +enable= + bad-indentation, + trailing-whitespace, + wrong-import-order, + unused-variable, + unused-import diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 00000000..8ccf8a98 --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,35 @@ +name: Pylint + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pylint + - name: Getting changed Python files and Analysing the code with pylint + run: | + git fetch origin ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} + echo CI_COMMIT_SHA=${GITHUB_SHA} + tmp_files=$(git diff --name-only origin/main ${CI_COMMIT_SHA}) + echo "Changed files are $tmp_files" + if [ -z "$(echo "$tmp_files" | grep "\.py")" ]; then exit 0; else echo "Python files are found"; fi + tmp_pfiles=$(echo "$tmp_files" | grep "\.py") + echo "Python files are $tmp_pfiles" + if [[ -z "$tmp_pfiles" ]]; then + echo "No files to lint" + else + echo "Running Linter!" + pylint --rc-file=/home/runner/work/RoboBuggy2/RoboBuggy2/.github/workflows/.pylintrc $tmp_pfiles + fi diff --git a/rb_ws/src/buggy/scripts/visualization/telematics.py b/rb_ws/src/buggy/scripts/visualization/telematics.py index fe99c4fd..2951b6f7 100755 --- a/rb_ws/src/buggy/scripts/visualization/telematics.py +++ b/rb_ws/src/buggy/scripts/visualization/telematics.py @@ -28,14 +28,13 @@ def __init__(self): self.gnss1_fixinfo_publisher = rospy.Publisher("/gnss1/fix_info_republished", String, queue_size=10) self.gnss1_fixinfo_int_publisher = rospy.Publisher("/gnss1/fix_info_republished_int", Int8, queue_size=10) self.gnss1_fixinfo_subscriber = rospy.Subscriber("/gnss1/fix_info", GNSSFixInfo, self.republish_fixinfo, (self.gnss1_fixinfo_publisher, self.gnss1_fixinfo_int_publisher)) - + self.gnss2_fixinfo_publisher = rospy.Publisher("/gnss2/fix_info_republished", String, queue_size=10) self.gnss2_fixinfo_int_publisher = rospy.Publisher("/gnss2/fix_info_republished_int", Int8, queue_size=10) self.gnss2_fixinfo_subscriber = rospy.Subscriber("/gnss2/fix_info", GNSSFixInfo, self.republish_fixinfo, (self.gnss2_fixinfo_publisher, self.gnss2_fixinfo_int_publisher)) - + def convert_odometry_to_navsatfix(self, msg): """Convert Odometry-type to NavSatFix-type for plotting on Foxglove -x` Args: msg (Odometry): odometry as per INS """ @@ -48,7 +47,7 @@ def convert_odometry_to_navsatfix(self, msg): new_msg.longitude = long new_msg.altitude = down self.odom_publisher.publish(new_msg) - + def convert_navsatfix_to_pose_covariance(self, msg, publishers): """Convert NavSatFix-type and related covariance matrix to Pose-type and array respectively for easy visualization in Foxglove. @@ -70,14 +69,14 @@ def convert_navsatfix_to_pose_covariance(self, msg, publishers): round(msg.position_covariance[4], 4), round(msg.position_covariance[8], 4)] publishers[1].publish(covariance) - + def republish_fixinfo(self, msg, publishers): """ convert gnss/fixinfo to a string for visualization in foxglove """ fix_type = msg.fix_type fix_string = "fix type: " - + if (fix_type == 0): fix_string += "FIX_3D" elif (fix_type == 1): @@ -92,17 +91,13 @@ def republish_fixinfo(self, msg, publishers): fix_string += "FIX_RTK_FLOAT" else: fix_string += "FIX_RTK_FIXED" - - fix_string += "\nsbas_used: " + str(msg.sbas_used) + + fix_string += "\nsbas_used: " + str(msg.sbas_used) fix_string += "\ndngss_used: " + str(msg.dngss_used) publishers[0].publish(fix_string) publishers[1].publish(fix_type) - - - if __name__ == "__main__": - rospy.init_node("telematics") - telem = Telematics() - rospy.spin() - + rospy.init_node("telematics") + telem = Telematics() + rospy.spin()