How to implement a semantic camera in ROS + Morse

asked 2018-04-21 23:18:57 -0500

nathliapaula gravatar image

Hi ROS community! :)

I'm a pretty beginner in ROS and I'm trying to implement a semantic camera in ROS + Morse + Blender platform in order to get data from specific objects from Blender scenario. The problem is that we don't a lot of information documented or code as example to follow.

I follow these documentation from Morse: Semantic camera and SemanticCameraPublisher class. Both lists some parameters and also the code to consider on Morse Builder API, but I don't know how or where I could use them in my code.

In builder.py code, I set :

from morse.builder import *
atrv = ATRV() #the robot
atrv.translate(x=2.5, y=3.2, z=0.0) #starting location

#adding a passive object
 table = PassiveObject('props/objects','SmallTable')
 table.setgraspable()
 table.translate(x=0, y=0, z=-5)
 table.properties(Object = True, Graspable = True, Label = "TABLE")

#adding a semantic camera
 camera = SemanticCamera()
 atrv.append(camera)
 camera.translate(x=0.3, z=0.762)
 camera.add_interface('ros',topic='/camera')

Then my goal is that ATVR robot needs to identify the table object, like this article does. In subscriber code, I've tried to define a msg function to print get_local_data(), but I don't know what object I need to declare from import, because the message is a String type (because rospy publishes the data of the semantic camera as JSON in a ROS String message). My current code is like that, but it is not working at all:

import rospy
from std_msgs.msg import String

def callback_semcam(msg): 

   reponse = String.get_local_data()
   tmp = reponse.result()
   print (tmp['visible_objects'])

if __name__=='__main__':

   rospy.init_node("obstacle_check_node")
   rospy.Subscriber('/camera', String, callback_semcam)

   rospy.spin() # this will block untill you hit Ctrl+C

When I run the code above, I get this error:

[ERROR] [WallTime: 1524369527.637321] bad callback: <function callback_semcam at 0x7f9d49691578>
Traceback (most recent call last):
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/topics.py", line 720, in _invoke_callback
    cb(msg)
  File "obstacle_check.py", line 27, in callback_semcam
    reponse = String.get_local_data()
AttributeError: type object 'String' has no attribute 'get_local_data'

Any idea of what we need to take into account when we uses a semantic camera in ROS?

edit retag flag offensive close merge delete

Comments

1

I would start with:

def callback_semcam(msg):
    print (msg)

or maybe:

def callback_semcam(msg):
    print (msg.data)

remove all the rest from callback(msg), it doesn't make any sense (to me).

gvdhoorn gravatar image gvdhoorn  ( 2018-04-22 04:07:03 -0500 )edit