Skip to content

Commit

Permalink
pre-commit: fixed buil dissues
Browse files Browse the repository at this point in the history
  • Loading branch information
borsesaurabh2022 committed Jun 21, 2024
1 parent bb8ed1f commit 93b59e4
Show file tree
Hide file tree
Showing 24 changed files with 107 additions and 67 deletions.
1 change: 1 addition & 0 deletions .LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
1 change: 1 addition & 0 deletions mps_description/launch/machine_base_description.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
1 change: 1 addition & 0 deletions mps_description/launch/machine_cap_description.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
1 change: 1 addition & 0 deletions mps_description/launch/machine_ring_description.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ omnidirectional_controller:
publish_rate: 50.0
odom_frame_id: odom
base_frame_id: base_link
pose_covariance_diagonal : [0.001, 0.001, 0.001, 0.001, 0.001, 0.01]
pose_covariance_diagonal: [0.001, 0.001, 0.001, 0.001, 0.001, 0.01]
twist_covariance_diagonal: [0.001, 0.001, 0.001, 0.001, 0.001, 0.01]
odom_numeric_integration_method: runge_kutta2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Licensed under GPLv2. See LICENSE file. Copyright Carologistics.

#ifndef ROBOTINO_DRIVER_WEBOTS_PLUGIN_HPP
#define ROBOTINO_DRIVER_WEBOTS_PLUGIN_HPP

Expand Down
1 change: 1 addition & 0 deletions robotino_simulation/launch/robotino_cluster.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
1 change: 1 addition & 0 deletions robotino_simulation/launch/robotino_controller.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
1 change: 1 addition & 0 deletions robotino_simulation/launch/robotino_simulation.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
1 change: 1 addition & 0 deletions robotino_simulation/launch/webots_cluster.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
1 change: 1 addition & 0 deletions robotino_simulation/robotino_simulation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
110 changes: 58 additions & 52 deletions robotino_simulation/robotino_simulation/extract_rosbag_data.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
#!/usr/bin/python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
from decimal import Decimal

import matplotlib.pyplot as plt
import pandas as pd
import rclpy
from rclpy.node import Node
from nav_msgs.msg import Path
from tf2_msgs.msg import TFMessage
from rcl_interfaces.msg import Log
from decimal import Decimal
from builtin_interfaces.msg import Time
import pandas as pd
import matplotlib.pyplot as plt
from rclpy.node import Node
from tf2_ros import TransformException
from tf2_ros.buffer import Buffer
from tf2_ros.transform_listener import TransformListener
from PIL import Image


class DataExtractorNode(Node):
def __init__(self):
super().__init__('data_extractor')
super().__init__("data_extractor")
self.declare_parameter("namespace", "robotinobase1")
self.namespace = self.get_parameter("namespace").get_parameter_value().string_value
self.goal_start_time = None
self.goal_end_time = None

# Subscribe to rosout topic
self.rosout_sub = self.create_subscription(Log, '/rosbag_rosout', self.rosout_callback, 10)
self.rosout_sub = self.create_subscription(Log, "/rosbag_rosout", self.rosout_callback, 10)

# Subscribe to namespace plan topic
#self.plan_sub = self.create_subscription(Path, self.namespace+'/plan', self.plan_callback, 10)
# self.plan_sub = self.create_subscription(Path, self.namespace+'/plan', self.plan_callback, 10)

# Call on_timer function every second
self.timer = self.create_timer(0.1, self.on_timer)

# Declare and acquire `target_frame` parameter
self.target_frame = self.namespace +'/base_link'
self.target_frame = self.namespace + "/base_link"
self.tf_buffer = Buffer()
self.tf_listener = TransformListener(self.tf_buffer, self)

# Define the lookup table for the poses
self.machine_pose = {
"C-BS-I": (5.50, 2.50, 90),
"C-BS-O": (5.50, 4.50, 270),
"C-RS2-I": (3.50, 5.50,180),
"C-RS2-O": (5.50, 5.50,0),
"C-CS1-I": (0.50, 5.50,180),
"C-CS1-O": (2.50, 5.50,0),
"C-CS2-I": (0.50, 1.50,180),
"C-CS2-O": (2.50, 1.50,0),
"C-RS2-I": (3.50, 5.50, 180),
"C-RS2-O": (5.50, 5.50, 0),
"C-CS1-I": (0.50, 5.50, 180),
"C-CS1-O": (2.50, 5.50, 0),
"C-CS2-I": (0.50, 1.50, 180),
"C-CS2-O": (2.50, 1.50, 0),
"C-DS-I": (0.50, 0.50, 180),
"C-DS-O": (2.50, 0.50, 0),
"C-RS1-I": (1.50, 4.50, 270),
Expand All @@ -54,12 +52,12 @@ def __init__(self):
"C-SS-O": (4.50, 3.50, 270),
"M-BS-I": (-5.50, 2.50, 90),
"M-BS-O": (-5.50, 4.50, 270),
"M-RS2-I": (-3.50, 5.50,0),
"M-RS2-O": (-5.50, 5.50,180),
"M-CS1-I": (-0.50, 5.50,0),
"M-CS1-O": (-2.50, 5.50,180),
"M-CS2-I": (-0.50, 1.50,0),
"M-CS2-O": (-2.50, 1.50,180),
"M-RS2-I": (-3.50, 5.50, 0),
"M-RS2-O": (-5.50, 5.50, 180),
"M-CS1-I": (-0.50, 5.50, 0),
"M-CS1-O": (-2.50, 5.50, 180),
"M-CS2-I": (-0.50, 1.50, 0),
"M-CS2-O": (-2.50, 1.50, 180),
"M-DS-I": (-0.50, 0.50, 0),
"M-DS-O": (-2.50, 0.50, 180),
"M-RS1-I": (-1.50, 4.50, 270),
Expand All @@ -68,7 +66,17 @@ def __init__(self):
"M-SS-O": (-4.50, 3.50, 270),
}

self.columns = ["pose_start_x", "pose_start_y", "pose_end_x", "pose_end_y", "machine_start", "machine_end", "time_start", "time_end", "time_diff"]
self.columns = [
"pose_start_x",
"pose_start_y",
"pose_end_x",
"pose_end_y",
"machine_start",
"machine_end",
"time_start",
"time_end",
"time_diff",
]
self.table = pd.DataFrame(columns=self.columns)

self.columns_ = ["pose_x", "pose_y"]
Expand All @@ -85,7 +93,7 @@ def __init__(self):
self.record_data = False

def rosout_callback(self, msg):
if msg.name == self.namespace + '.bt_navigator':
if msg.name == self.namespace + ".bt_navigator":
if self.msg_check(msg.msg, "Begin navigating"):
self.goal_start_time = self.get_time(msg)
self.pose_data = self.machine_pose_check(msg.msg)
Expand All @@ -98,14 +106,14 @@ def rosout_callback(self, msg):
"pose_end_y": [self.pose_data[3]],
"machine_start": [self.machine_start],
"machine_end": [self.machine_end],
"time_start": [self.goal_start_time]
"time_start": [self.goal_start_time],
}
self.table = pd.concat([self.table, pd.DataFrame(data_row)], ignore_index=True)

if msg.msg == "Goal succeeded":
self.goal_end_time = self.get_time(msg)
self.table.at[self.counter, "time_end"] = self.goal_end_time
#self.table.at[self.counter, "time_diff"] = self.goal_end_time - self.goal_start_time
# self.table.at[self.counter, "time_diff"] = self.goal_end_time - self.goal_start_time
self.machine_start = self.machine_end
self.counter += 1
if self.counter in [1, 5, 9, 13, 17]:
Expand All @@ -117,10 +125,9 @@ def rosout_callback(self, msg):
# self.table.to_csv(self.namespace+"_pose_data.csv", index=False)
# self.get_logger().info(f'Pose data saved, check rosbag status and shutdown the node')


def msg_check(self, message, check):
words = message.split()
first_two = ' '.join(words[:2])
first_two = " ".join(words[:2])
return first_two == check

def machine_pose_check(self, message):
Expand All @@ -132,7 +139,7 @@ def machine_pose_check(self, message):
for key, value in self.machine_pose.items():
if end_pose_x == value[0] and end_pose_y == value[1]:
machine_end = key
self.get_logger().info(f'machine end: {machine_end}')
self.get_logger().info(f"machine end: {machine_end}")
return [start_pose_x, start_pose_y, end_pose_x, end_pose_y, machine_end]

def get_time(self, msg):
Expand All @@ -141,47 +148,44 @@ def get_time(self, msg):
def on_timer(self):
if self.record_data:
try:
t = self.tf_buffer.lookup_transform('map', self.target_frame, rclpy.time.Time())
t = self.tf_buffer.lookup_transform("map", self.target_frame, rclpy.time.Time())

except TransformException as ex:
self.get_logger().info(
f'Could not transform {self.target_frame} to map: {ex}')
self.get_logger().info(f"Could not transform {self.target_frame} to map: {ex}")
return
self.robot_pose_x.append(t.transform.translation.x)
self.robot_pose_y.append(t.transform.translation.y)

data_row = {
"pose_x": [t.transform.translation.x],
"pose_y": [t.transform.translation.y]
}
data_row = {"pose_x": [t.transform.translation.x], "pose_y": [t.transform.translation.y]}
self.table_ = pd.concat([self.table_, pd.DataFrame(data_row)], ignore_index=True)


if self.plot_data:
quo, rem = divmod(self.counter, 4)

plt.figure(quo)

plt.clf()
plt.plot(self.robot_pose_x, self.robot_pose_y,'-b')
plt.xlabel('X_Position')
plt.ylabel('Y_Position')
plt.title(self.namespace+'_iteration'+str(quo)+'_followed_Path')
plt.plot(self.robot_pose_x, self.robot_pose_y, "-b")
plt.xlabel("X_Position")
plt.ylabel("Y_Position")
plt.title(self.namespace + "_iteration" + str(quo) + "_followed_Path")
plt.grid(True)
plt.xlim(-6, 6)
plt.ylim(0, 6)
plt.gca().set_aspect('equal')
plt.gca().set_aspect("equal")

plt.text(self.robot_pose_x[0], self.robot_pose_y[0], 'Start', fontsize=12, color='green', ha='right')
plt.text(self.robot_pose_x[-1], self.robot_pose_y[-1], 'End', fontsize=12, color='red', ha='right')
plt.text(self.robot_pose_x[0], self.robot_pose_y[0], "Start", fontsize=12, color="green", ha="right")
plt.text(self.robot_pose_x[-1], self.robot_pose_y[-1], "End", fontsize=12, color="red", ha="right")

plt.savefig(self.namespace+'_iteration'+str(quo)+'_followed_path'+'.png') # Save the plot as PNG file
self.table_.to_csv(self.namespace+'_iteration'+str(quo)+'_pose_data.csv', index=False)
plt.savefig(
self.namespace + "_iteration" + str(quo) + "_followed_path" + ".png"
) # Save the plot as PNG file
self.table_.to_csv(self.namespace + "_iteration" + str(quo) + "_pose_data.csv", index=False)

self.columns_ = ["pose_x", "pose_y"]
self.table_ = pd.DataFrame(columns=self.columns_)

self.get_logger().info(f'Plotting followed path data for iteration {quo}')
self.get_logger().info(f"Plotting followed path data for iteration {quo}")

plt.close()

Expand Down Expand Up @@ -221,16 +225,18 @@ def on_timer(self):
# self.plan_pose_x = []
# self.plan_pose_y = []


def main(args=None):
rclpy.init(args=args)
node = DataExtractorNode()
try:
node.get_logger().info('Beginning data extraction node, shut down with CTRL-C')
node.get_logger().info("Beginning data extraction node, shut down with CTRL-C")
rclpy.spin(node)
except KeyboardInterrupt:
node.get_logger().info('Keyboard interrupt, shutting down.\n')
node.get_logger().info("Keyboard interrupt, shutting down.\n")
node.destroy_node()
rclpy.shutdown()

if __name__ == '__main__':

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions robotino_simulation/robotino_simulation/mps_publisher.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
# Author: Saurabh Borse([email protected])
# MIT License
# Copyright (c) 2023 Saurabh Borse
Expand Down
Loading

0 comments on commit 93b59e4

Please sign in to comment.