Proximity Sensor¶
Distance sensor to detect nearby objects.
This sensor can be used to determine which other objects are within a certain radius of the sensor. It performs its test based only on distance. The type of tracked objects can be specified using the Track property.
Configuration parameters for Proximity Sensor¶
You can set these properties in your scripts with <component>.properties(<property1>=..., <property2>=...)
.
Range
(float, default:100
)- The distance, in meters beyond which this sensor is unable to locate other robots.
Track
(string, default:"Robot_Tag"
)- The type of tracked objects. This type is looked for as game property of scene objects. You must then add a new game property to the objects you want to be detected by the proximity sensor.
Data fields¶
This sensor exports these datafields at each simulation step:
timestamp
(float, initial value:0.0
)- number of seconds in simulated time
near_objects
(dict, initial value:{}
)- A list of the tracked objects located within the given radius. The keys of the dictionary are the object names, and the values are the distances (in meters) from the sensor.
near_robots
(dict, initial value:{}
)- deprecated. Points to near_objects for compatibility reasons.
Interface support:
ros
as std_msgs/String (morse.middleware.ros.StringPublisher
)socket
as straight JSON serialization (morse.middleware.socket_datastream.SocketPublisher
)yarp
as YarpPublisher (morse.middleware.yarp_datastream.YarpPublisher
)yarp_json
as YarpJsonPublisher (morse.middleware.yarp.yarp_json.YarpJsonPublisher
)moos
as StringPublisher (morse.middleware.moos.abstract_moos.StringPublisher
)text
as key = value format with timestamp and index value (morse.middleware.text_datastream.Publisher
)
Services for Proximity Sensor¶
get_configurations()
(blocking)Returns the configurations of a component (parsed from the properties).
Return value
a dictionary of the current component’s configurations
get_local_data()
(blocking)Returns the current data stored in the sensor.
Return value
a dictionary of the current sensor’s data
get_properties()
(blocking)Returns the properties of a component.
Return value
a dictionary of the current component’s properties
set_property(prop_name, prop_val)
(blocking)Modify one property on a component
Parameters
prop_name
: the name of the property to modify (as shown the documentation)prop_val
: the new value of the property. Note that there is no checking about the type of the value so be careful
Return value
nothing
set_range(range)
(blocking)The service expects a float range (in meter), and modify the range used to detect objects around the proximity sensor.
- Parameters
range
: detection range, in meters
set_tracked_tag(tag)
(blocking)The service allows to modify the kind of objects detected by the proximity sensor.
- Parameters
tag
: value of the Track property used to select detected objects.
Examples¶
The following examples show how to use this component in a Builder script:
from morse.builder import *
# adds a default robot (the MORSE mascott!)
robot = Morsy()
# creates a new instance of the sensor
proximity = Proximity()
# place your component at the correct location
proximity.translate(<x>, <y>, <z>)
proximity.rotate(<rx>, <ry>, <rz>)
robot.append(proximity)
# define one or several communication interface, like 'socket'
proximity.add_interface(<interface>)
env = Environment('empty')
Other sources of examples¶
(This page has been auto-generated from MORSE module morse.sensors.proximity.)