Class: Sensor_msgs::JointState
- Inherits:
-
ROS::Message
- Object
- ROS::Message
- Sensor_msgs::JointState
- Defined in:
- lib/sensor_msgs/JointState.rb
Constant Summary collapse
- @@struct_L3 =
::ROS::Struct.new("L3")
- @@struct_L =
::ROS::Struct.new("L")
- @@slot_types =
['Header','string[]','float64[]','float64[]','float64[]']
Instance Attribute Summary collapse
-
#effort ⇒ Object
Returns the value of attribute effort.
-
#header ⇒ Object
Returns the value of attribute header.
-
#name ⇒ Object
Returns the value of attribute name.
-
#position ⇒ Object
Returns the value of attribute position.
-
#velocity ⇒ Object
Returns the value of attribute velocity.
Class Method Summary collapse
Instance Method Summary collapse
-
#_get_types ⇒ String
internal API method.
-
#deserialize(str) ⇒ Object
unpack serialized message in str into this message instance @param [String] str: byte array of serialized message.
- #has_header? ⇒ Boolean
-
#initialize(args = {}) ⇒ JointState
constructor
Constructor.
- #message_definition ⇒ Object
-
#serialize(buff) ⇒ Object
serialize message into buffer.
Constructor Details
#initialize(args = {}) ⇒ JointState
Constructor. You can set the default values using keyword operators.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/sensor_msgs/JointState.rb', line 84 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[:name] @name = args[:name] else @name = [] end if args[:position] @position = args[:position] else @position = [] end if args[:velocity] @velocity = args[:velocity] else @velocity = [] end if args[:effort] @effort = args[:effort] else @effort = [] end end |
Instance Attribute Details
#effort ⇒ Object
Returns the value of attribute effort.
69 70 71 |
# File 'lib/sensor_msgs/JointState.rb', line 69 def effort @effort end |
#header ⇒ Object
Returns the value of attribute header.
69 70 71 |
# File 'lib/sensor_msgs/JointState.rb', line 69 def header @header end |
#name ⇒ Object
Returns the value of attribute name.
69 70 71 |
# File 'lib/sensor_msgs/JointState.rb', line 69 def name @name end |
#position ⇒ Object
Returns the value of attribute position.
69 70 71 |
# File 'lib/sensor_msgs/JointState.rb', line 69 def position @position end |
#velocity ⇒ Object
Returns the value of attribute velocity.
69 70 71 |
# File 'lib/sensor_msgs/JointState.rb', line 69 def velocity @velocity end |
Class Method Details
.md5sum ⇒ Object
9 10 11 |
# File 'lib/sensor_msgs/JointState.rb', line 9 def self.md5sum "3066dcd76a6cfaef579bd0f34173e9fd" end |
.type ⇒ Object
13 14 15 |
# File 'lib/sensor_msgs/JointState.rb', line 13 def self.type "sensor_msgs/JointState" end |
Instance Method Details
#_get_types ⇒ String
internal API method
115 116 117 |
# File 'lib/sensor_msgs/JointState.rb', line 115 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
153 154 155 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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/sensor_msgs/JointState.rb', line 153 def deserialize(str) begin if @header == nil @header = Std_msgs::Header.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 += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) @name = [] length.times do start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) start = end_point end_point += length val1 = str[start..(end_point-1)] @name.push(val1) end start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) pattern = "d#{length}" start = end_point end_point += ROS::Struct::calc_size("#{pattern}") @position = str[start..(end_point-1)].unpack(pattern) start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) pattern = "d#{length}" start = end_point end_point += ROS::Struct::calc_size("#{pattern}") @velocity = str[start..(end_point-1)].unpack(pattern) start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) pattern = "d#{length}" start = end_point end_point += ROS::Struct::calc_size("#{pattern}") @effort = str[start..(end_point-1)].unpack(pattern) return self rescue => exception raise "message DeserializationError: #{exception}" #most likely buffer underfill end end |
#has_header? ⇒ Boolean
17 18 19 |
# File 'lib/sensor_msgs/JointState.rb', line 17 def has_header? true end |
#message_definition ⇒ Object
21 22 23 24 25 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 |
# File 'lib/sensor_msgs/JointState.rb', line 21 def "# This is a message that holds data to describe the state of a set of torque controlled joints. # # The state of each joint (revolute or prismatic) is defined by: # * the position of the joint (rad or m), # * the velocity of the joint (rad/s or m/s) and # * the effort that is applied in the joint (Nm or N). # # Each joint is uniquely identified by its name # The header specifies the time at which the joint states were recorded. All the joint states # in one message have to be recorded at the same time. # # This message consists of a multiple arrays, one for each part of the joint state. # The goal is to make each of the fields optional. When e.g. your joints have no # effort associated with them, you can leave the effort array empty. # # All arrays in this message should have the same size, or be empty. # This is the only way to uniquely associate the joint name with the correct # states. Header header string[] name float64[] position float64[] velocity float64[] effort ================================================================================ 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 " end |
#serialize(buff) ⇒ Object
serialize message into buffer
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/sensor_msgs/JointState.rb', line 121 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}")) length = @name.length buff.write(@@struct_L.pack(length)) for val1 in @name length = val1.length buff.write([length, val1].pack("La#{length}")) end length = @position.length buff.write(@@struct_L.pack(length)) pattern = "d#{length}" buff.write(*@position.pack(pattern)) length = @velocity.length buff.write(@@struct_L.pack(length)) pattern = "d#{length}" buff.write(*@velocity.pack(pattern)) length = @effort.length buff.write(@@struct_L.pack(length)) pattern = "d#{length}" buff.write(*@effort.pack(pattern)) rescue => exception raise "some erro in serialize: #{exception}" end end |