Skip to content

Commit

Permalink
publish/subscriber base code
Browse files Browse the repository at this point in the history
  • Loading branch information
TiaSinghania committed Oct 23, 2024
1 parent 858196f commit b9c8231
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions rb_ws/src/buggy/buggy/simulator/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
import rclpy
from rclpy.node import Node

from std_msgs.msg import String, Float64
from std_msgs.msg import Float64

class Simulator(Node):
# simulator constants:

def __init__(self):
super().__init__('SC_sim_single')
self.get_logger().info("INITIALIZING")
super().__init__('sim_single')
self.number_publisher = self.create_publisher(Float64, 'numbers', 1)
self.test_publisher = self.create_publisher(String, 'test', 1)
self.i = 0

self.buggy_name = "NONE"

if (self.get_namespace() == "/SC"):
self.buggy_name = "SC"

Expand All @@ -29,12 +26,6 @@ def __init__(self):
self.timer = self.create_timer(timer_period, self.loop)

def loop(self):

self.get_logger().info("LOOPING")

msg = String()
msg.data = self.buggy_name
self.test_publisher.publish(msg)
msg2 = Float64()
msg2.data = float(self.i)
self.number_publisher.publish(msg2)
Expand All @@ -43,7 +34,8 @@ def loop(self):
def main(args=None):
rclpy.init(args=args)
sim = Simulator()
sim.get_logger().info("CREATED NODE")
rclpy.spin(sim)
rclpy.shutdown()


if __name__ == "__main__":
main()

0 comments on commit b9c8231

Please sign in to comment.