Class: Nav_msgs::OccupancyGrid

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/nav_msgs/OccupancyGrid.rb

Constant Summary collapse

@@struct_L3 =
::ROS::Struct.new("L3")
@@struct_L2fL2d7 =
::ROS::Struct.new("L2fL2d7")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['Header','nav_msgs/MapMetaData','int8[]']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ OccupancyGrid

Constructor. You can set the default values using keyword operators.

Parameters:

  • args (Hash) (defaults to: {})

    keyword for initializing values

Options Hash (args):

  • :header (Header)

    initialize value

  • :info (nav_msgs/MapMetaData)

    initialize value

  • :data (int8[])

    initialize value



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/nav_msgs/OccupancyGrid.rb', line 110

def initialize(args={})
  # message fields cannot be None, assign default values for those that are
  if args[:header]
    @header = args[:header]
  else
    @header = Std_msgs::Header.new
  end
  if args[:info]
    @info = args[:info]
  else
    @info = Nav_msgs::MapMetaData.new
  end
  if args[:data]
    @data = args[:data]
  else
    @data = []
  end
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



96
97
98
# File 'lib/nav_msgs/OccupancyGrid.rb', line 96

def data
  @data
end

#headerObject

Returns the value of attribute header.



96
97
98
# File 'lib/nav_msgs/OccupancyGrid.rb', line 96

def header
  @header
end

#infoObject

Returns the value of attribute info.



96
97
98
# File 'lib/nav_msgs/OccupancyGrid.rb', line 96

def info
  @info
end

Class Method Details

.md5sumObject



14
15
16
# File 'lib/nav_msgs/OccupancyGrid.rb', line 14

def self.md5sum
  "3381f2d731d4076ec5c71b0759edbe4e"
end

.typeObject



18
19
20
# File 'lib/nav_msgs/OccupancyGrid.rb', line 18

def self.type
  "nav_msgs/OccupancyGrid"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



131
132
133
# File 'lib/nav_msgs/OccupancyGrid.rb', line 131

def _get_types
  @slot_types
end

#deserialize(str) ⇒ Object

unpack serialized message in str into this message instance

@param [String] str: byte array of serialized message


156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/nav_msgs/OccupancyGrid.rb', line 156

def deserialize(str)

  begin
    if @header == nil
      @header = Std_msgs::Header.new
    end
    if @info == nil
      @info = Nav_msgs::MapMetaData.new
    end
    end_point = 0
    start = end_point
    end_point += ROS::Struct::calc_size('L3')
    (@header.seq, @header.stamp.secs, @header.stamp.nsecs,) = @@struct_L3.unpack(str[start..(end_point-1)])
    start = end_point
    end_point += 4
    (length,) = @@struct_L.unpack(str[start..(end_point-1)])
    start = end_point
    end_point += length
    @header.frame_id = str[start..(end_point-1)]
    start = end_point
    end_point += ROS::Struct::calc_size('L2fL2d7')
    (@info.map_load_time.secs, @info.map_load_time.nsecs, @info.resolution, @info.width, @info.height, @info.origin.position.x, @info.origin.position.y, @info.origin.position.z, @info.origin.orientation.x, @info.origin.orientation.y, @info.origin.orientation.z, @info.origin.orientation.w,) = @@struct_L2fL2d7.unpack(str[start..(end_point-1)])
    start = end_point
    end_point += 4
    (length,) = @@struct_L.unpack(str[start..(end_point-1)])
    pattern = "c#{length}"
    start = end_point
    end_point += ROS::Struct::calc_size("#{pattern}")
    @data = str[start..(end_point-1)].unpack(pattern)
    return self
  rescue => exception
    raise "message DeserializationError: #{exception}" #most likely buffer underfill
  end
end

#has_header?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/nav_msgs/OccupancyGrid.rb', line 22

def has_header?
  true
end

#message_definitionObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/nav_msgs/OccupancyGrid.rb', line 26

def message_definition
  "# This represents a 2-D grid map, in which each cell represents the probability of
# occupancy.

Header header 

#MetaData for the map
MapMetaData info

# The map data, in row-major order, starting with (0,0).  Occupancy
# probabilities are in the range [0,100].  Unknown is -1.
int8[] data

================================================================================
MSG: std_msgs/Header
# Standard metadata for higher-level stamped data types.
# This is generally used to communicate timestamped data 
# in a particular coordinate frame.
# 
# sequence ID: consecutively increasing ID 
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.secs: seconds (stamp_secs) since epoch
# * stamp.nsecs: nanoseconds since stamp_secs
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
# 0: no frame
# 1: global frame
string frame_id

================================================================================
MSG: nav_msgs/MapMetaData
# This hold basic information about the characterists of the OccupancyGrid

# The time at which the map was loaded
time map_load_time
# The map resolution [m/cell]
float32 resolution
# Map width [cells]
uint32 width
# Map height [cells]
uint32 height
# The origin of the map [m, m, rad].  This is the real-world pose of the
# cell (0,0) in the map.
geometry_msgs/Pose origin
================================================================================
MSG: geometry_msgs/Pose
# A representation of pose in free space, composed of postion and orientation. 
Point position
Quaternion orientation

================================================================================
MSG: geometry_msgs/Point
# This contains the position of a point in free space
float64 x
float64 y
float64 z

================================================================================
MSG: geometry_msgs/Quaternion
# This represents an orientation in free space in quaternion form.

float64 x
float64 y
float64 z
float64 w

"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/nav_msgs/OccupancyGrid.rb', line 137

def serialize(buff)
  begin
    buff.write(@@struct_L3.pack(@header.seq, @header.stamp.secs, @header.stamp.nsecs))
    _x = @header.frame_id
    length = _x.length
    buff.write([length, _x].pack("La#{length}"))
    buff.write(@@struct_L2fL2d7.pack(@info.map_load_time.secs, @info.map_load_time.nsecs, @info.resolution, @info.width, @info.height, @info.origin.position.x, @info.origin.position.y, @info.origin.position.z, @info.origin.orientation.x, @info.origin.orientation.y, @info.origin.orientation.z, @info.origin.orientation.w))
    length = @data.length
    buff.write(@@struct_L.pack(length))
    pattern = "c#{length}"
    buff.write(*@data.pack(pattern))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end