def makeTurn(linear, angular, channel):
    # Create message with command for
    # # linear and angular velocities
    message = Message()
    robotConfig = RobotConfig()
    robotConfig.speed.linear = linear
    robotConfig.speed.angular = angular
    message.pack(robotConfig)
    message.topic = "RobotGateway.0.SetConfig"
    # Public message
    channel.publish(message)

    t_a = datetime.now()
    t_b = t_a
    t_diff = relativedelta(t_b, t_a)
    while t_diff.seconds < 4:
        t_b = datetime.now()
        t_diff = relativedelta(t_b, t_a)

    robotConfig.speed.linear = 0
    robotConfig.speed.angular = 0
    message.pack(robotConfig)
    message.topic = "RobotGateway.0.SetConfig"
    # Public message
    channel.publish(message)

    t_a = datetime.now()
    t_b = t_a
    t_diff = relativedelta(t_b, t_a)
    while t_diff.seconds < 2:
        t_b = datetime.now()
        t_diff = relativedelta(t_b, t_a)
Exemplo n.º 2
0
 def get_configuration(self, msg, ctx):
     self.config = RobotConfig()
     #self.log.info("Pediu velocidade")
     spd = self.driver.get_speed()
     #self.log.info("Recebeu velocidade")
     self.config.speed.linear = spd.linear
     self.config.speed.angular = spd.angular
     return self.config
def makeMessage(linear, angular):

    message = Message()
    robotConfig = RobotConfig()
    robotConfig.speed.linear = linear
    robotConfig.speed.angular = angular
    message.pack(robotConfig)
    message.topic = "RobotGateway.0.SetConfig"
    # Public message
    channel.publish(message)
Exemplo n.º 4
0
def makeMessage(linear, angular):
    # Create message with command for
    # linear and angular velocities
    message = Message()
    robotConfig = RobotConfig()
    robotConfig.speed.linear = linear
    robotConfig.speed.angular = angular
    message.pack(robotConfig)
    message.topic = "RobotGateway.0.SetConfig"
    # Public message
    channel.publish(message)
Exemplo n.º 5
0
# Inscreve nos topicos que deseja receber mensagem
subscription = Subscription(channel)
subscription.subscribe(pose_topic)
subscription.subscribe(sonar_topic)
ATSPlog.info("SubscriptionsDone")

# Envia mensagem de getConfig
get_req = Message(reply_to=subscription)
# Salva correlation_id do request
cor_id = get_req.correlation_id
# print("cor_id: ", cor_id)
# Broadcast message to anyone interested (subscribed)
channel.publish(message=get_req, topic=service_name + ".GetConfig")

# Envia msg de setConfig
config = RobotConfig()
config.speed.linear = 0.5
config.speed.angular = 0.0
set_req = Message(content=config, reply_to=subscription)
# Broadcast message to anyone interested (subscribed)
channel.publish(topic=service_name + ".SetConfig", message=set_req)

print("Andou!")

time.sleep(3)

print("Parou?")

# Envia msg de setConfig
config = RobotConfig()
config.speed.linear = 0.0
Exemplo n.º 6
0
 def get_config(self, field_selector, ctx):
     robot_config = RobotConfig()
     get_obj(self.driver.get_speed, robot_config.speed)
     return robot_config
from is_wire.core import Channel, Message, Subscription
from is_msgs.robot_pb2 import RobotConfig

#Create a channel to connet to the broker
channel = Channel("amqp://10.10.2.23:30000")

# Create Message
message = Message()

# Create and set Robot Configuration
robotConfig = RobotConfig()
robotConfig.speed.linear = 40.0
robotConfig.speed.angular = 0.3

# Insert Robot Configuration in the Message
message.pack(robotConfig)

# Define message topic
Topic = "Aula2"
message.topic = Topic

# Publish the message
channel.publish(message)