Skip to content

Commit

Permalink
Robot driver wrapper update.
Browse files Browse the repository at this point in the history
  • Loading branch information
samyarsadat committed Sep 9, 2024
1 parent 67b0e26 commit 9d0e0eb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ros_robot_driver_wrapper</name>
<version>2024.8.25</version>
<version>2024.9.3</version>
<description>The ROS Robot Project: ROS 2 wrapper for robot hardware driver.</description>
<maintainer email="samyarsadat@gigawhat.net">Samyar Sadat Akhavi</maintainer>
<license>GPL-3.0-only</license>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https: www.gnu.org/licenses/>.

PROGRAM_VERSION = "2024.8.25"
PROGRAM_VERSION = "2024.9.3"
from rclpy.qos import QoSProfile, ReliabilityPolicy, HistoryPolicy, LivelinessPolicy
import sys


# ---- Program Info ----
class ProgramInfoConfig:
VERSION = PROGRAM_VERSION
VERSION_DATE = "2024/08/25 @ 09:05PM UTC"
VERSION_DATE = "2024/08/03 @ 15:32PM UTC"


class ProgramConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def micro_switches_callback() -> None:
msg.min_range = ros_robot_interface.micro_switches[i].get_trigger_distance()
msg.radiation_type = Range.INFRARED # Not actually infrared, just a normal micro switches.
msg.field_of_view = 90.0
msg.range = (float("inf") if ros_robot_interface.micro_switches[i].get_latest_state() else float("-inf"))
msg.range = (float("-inf") if ros_robot_interface.micro_switches[i].get_latest_state() else float("inf"))
msg.header.frame_id = RosFrameIds.MICRO_SW_SENS_BASE_FRAME_ID.format(get_ros_node().micro_switch_pubs[i].topic.split("/")[2])
msg.header.stamp.sec, msg.header.stamp.nanosec = ros_robot_interface.micro_switches[i].get_last_timestamp()
get_ros_node().micro_switch_pubs[i].publish(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ def main():
try:
while True:
if not wrapper_ros_thread.is_alive():
print("The driver wrapper thread has died. Terminating program.")
if is_ros_node_initialized():
get_ros_node().get_logger().fatal("The driver wrapper thread has died. Terminating program.")
else:
print("The driver wrapper thread has died. Terminating program.")
RosRobotDriverThread.stop_ros_thread(True)
sys.exit(1)

if not RosRobotDriverThread.is_alive():
if is_ros_node_initialized():
get_ros_node().get_logger().fatal("The robot driver thread has died. Terminating program.")

else:
print("The robot driver thread has died. Terminating program.")
stop_wrapper_ros_thread = True
wrapper_ros_thread.join()
sys.exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def __init__(self, context: rclpy.Context):
self.ultrasonic_sens_pubs.append(self.create_publisher(Range, f"range_sens/ultrasonic/{name}", qos_profile=RosConfig.QOS_RELIABLE, callback_group=self._reentrant_cb_group))

for i in range(0, 4):
name = ros_robot_interface.front_cliff_sensors[i].get_id().split("_")[2:5]
name = ros_robot_interface.front_cliff_sensors[i].get_id().split("_")[2:4]
self.cliff_sens_pubs.append(self.create_publisher(Range, f"range_sens/cliff/{'_'.join(name)}", qos_profile=RosConfig.QOS_RELIABLE, callback_group=self._reentrant_cb_group))

for i in range(0, 4):
name = ros_robot_interface.back_cliff_sensors[i].get_id().split("_")[2:5]
name = ros_robot_interface.back_cliff_sensors[i].get_id().split("_")[2:4]
self.cliff_sens_pubs.append(self.create_publisher(Range, f"range_sens/cliff/{'_'.join(name)}", qos_profile=RosConfig.QOS_RELIABLE, callback_group=self._reentrant_cb_group))

@staticmethod
Expand Down

0 comments on commit 9d0e0eb

Please sign in to comment.