Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SafetyObserverCodeGeneration #34

Open
darkobozhinoski opened this issue May 19, 2020 · 3 comments
Open

SafetyObserverCodeGeneration #34

darkobozhinoski opened this issue May 19, 2020 · 3 comments
Assignees

Comments

@darkobozhinoski
Copy link

These are the topics to which the observer needs to subsbscirbe:

topics = [("/odom", Odometry), ("/imu/data", Imu), ("/d_obstacle", Float32)]
The code to the observer is here

@chcorbato
Copy link
Member

Just for information, who is publishing /d_obstacle? @darkobozhinoski @marioney

@marioney
Copy link
Member

Just for information, who is publishing /d_obstacle? @darkobozhinoski @marioney

There's a node called https://github.com/rosin-project/metacontrol_sim/blob/MVP_world/scripts/safety_distance_publisher.py

It uses filtered laser data to get the closest distance

@ipa-nhg
Copy link
Member

ipa-nhg commented May 19, 2020

@darkobozhinoski Thanks for the information!

Solved by: rosin-project/rosin-experiments#5

The resulted auto-generated model file fits perfectly to the observer code:

PackageSet { package { 
  CatkinPackage rosgraph_monitor { artifact {
    Artifact my_observer {
      node Node { name /my_observer
        publisher { 
          Publisher { name '/diagnostics' message 'diagnostic_msgs.DiagnosticArray'}}
        subscriber {
          Subscriber { name '/d_obstacle' message 'std_msgs.Float32'},
          Subscriber { name '/odom' message 'nav_msgs.Odometry'},
          Subscriber { name 'imu/data' message 'sensor_msgs.Imu'}}}}}}}}

and the autogenerated python code looks:

from rosgraph_monitor.observer import TopicObserver
from std_msgs.msg import Float32
from nav_msgs.msg import Odometry
from sensor_msgs.msg import Imu
from diagnostic_msgs.msg import DiagnosticStatus, KeyValue


class Myobserver(TopicObserver):
    def __init__(self, name):
    	
        topics = [
        ("/d_obstacle", Float32),
        ("/odom", Odometry),
        ("imu/data", Imu)
        ]

        super(Myobserver, self).__init__(
            name, 10, topics)

    def calculate_attr(self, msgs):
        status_msg = DiagnosticStatus()
        
        #Write here your code (or uncomment the following lines)
        #if len(msgs) < 2:
        #    print("Incorrect number of messages")
        #    return status_msg
        
        #...

        #attr = msgs[0].data + msgs[1].data
        #print("{0} + {1}".format(msgs[0].data, msgs[1].data))

        status_msg = DiagnosticStatus()
        status_msg.level = DiagnosticStatus.OK
        status_msg.name = self._id
        # Set here your name attribute
        status_msg.values.append(
            KeyValue("KeyName", attr))
        status_msg.message = "QA status"

        return status_msg

this confirms that the observer generator works fine and the global RosSystem model is correct! 🎉 🎉

NOTE: I had to add two new nodes that correspond to gazebo plugins (the simulation of the base controllers and the imu sensor), but I think that make sense to have both there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants