fqdemo_nodes.PySubPub module

(This is module-level documentation for PySubPub. This docstring must be inserted before any code in the module.)

Overview

This module contains a single class which creates a ROS2 node.

class fqdemo_nodes.PySubPub.PySubPub(*args: Any, **kwargs: Any)[source]

Bases: Node

Node to simulate a sample filter to an incoming topic, publishing result.

Listens for a message with a number and power. Publishes a message with that number to that power, and to that root. Part of a demonstration of a ROS2 package with supporting quality features.

Node Name: py_node

Topics Subscribed

  • num_power (type NumPwrData)

    Requests from package users to calculate a power and root.

Topics Published

  • power_result (type fqdemo_msgs.msg.NumPwrResult)

    Message is published either in response to an incoming num_power NumPwrResult message, or a message with zeros is published periodically.

static apply_powers(number, exponent)[source]

Given a number and an exponent, calculate its power and root.

Parameters:
  • number (float) – Base value to take to a power or root

  • exponent (float) – Value to use as exponent for power or root

Returns:

Result of (pow(number, exponent), pow(number, 1./exponent))

Return type:

tuple(float, float)

publisher

Publisher for topic power_result type NumPwrResult

run()[source]

main program for the node

subscriber

Subscriber for topic num_power type NumPwrData

topic_callback(msg: fqdemo_msgs.msg.NumPwrData)[source]

callback for subscription to num_power