mehmetkillioglu / ros2_message_converter

Ros2_message_converter is a lightweight ROS2 package and Python library to convert from Python dictionaries and JSON messages to rclpy messages, and vice versa
BSD 3-Clause "New" or "Revised" License
11 stars 7 forks source link

'Time' object has no attribute 'secs' #2

Closed Ekanshh closed 2 years ago

Ekanshh commented 3 years ago
File "/colcon_ws/build/job_manager/job_handler.py", line 109, in main
    rclpy.spin(job_server)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/__init__.py", line 191, in spin
    executor.spin_once()
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 711, in spin_once
    raise handler.exception()
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/task.py", line 239, in __call__
    self._handler.send(None)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 426, in handler
    await call_coroutine(entity, arg)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 380, in _execute_service
    response = await await_or_execute(srv.callback, request, srv.srv_type.Response())
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 118, in await_or_execute
    return callback(*args)
  File "/colcon_ws/build/job_manager/job_handler.py", line 82, in create_job_callback
    msg.job_parameters = json_message_converter.convert_ros_message_to_json(retrieve_msg)
  File "/colcon_ws/build/ros2_message_converter/ros2_message_converter/json_message_converter.py", line 27, in convert_ros_message_to_json
    dictionary = message_converter.convert_ros_message_to_dictionary(message)
  File "/colcon_ws/build/ros2_message_converter/ros2_message_converter/message_converter.py", line 243, in convert_ros_message_to_dictionary
    dictionary[field_name] = _convert_from_ros_type(field_type, field_value)
  File "/colcon_ws/build/ros2_message_converter/ros2_message_converter/message_converter.py", line 259, in _convert_from_ros_type
    field_value = convert_ros_message_to_dictionary(field_value)
  File "/colcon_ws/build/ros2_message_converter/ros2_message_converter/message_converter.py", line 243, in convert_ros_message_to_dictionary
    dictionary[field_name] = _convert_from_ros_type(field_type, field_value)
  File "/colcon_ws/build/ros2_message_converter/ros2_message_converter/message_converter.py", line 259, in _convert_from_ros_type
    field_value = convert_ros_message_to_dictionary(field_value)
  File "/colcon_ws/build/ros2_message_converter/ros2_message_converter/message_converter.py", line 243, in convert_ros_message_to_dictionary
    dictionary[field_name] = _convert_from_ros_type(field_type, field_value)
  File "/colcon_ws/build/ros2_message_converter/ros2_message_converter/message_converter.py", line 251, in _convert_from_ros_type
    field_value = _convert_from_ros_time(field_type, field_value)
  File "/colcon_ws/build/ros2_message_converter/ros2_message_converter/message_converter.py", line 290, in _convert_from_ros_time
    'secs'  : field_value.secs,
AttributeError: 'Time' object has no attribute 'secs'
dustingooding commented 2 years ago

I suspect the resolution for this is:

def _convert_from_ros_time(field_type, field_value):
    field_value = {
        'secs': field_value.sec,
        'nsecs': field_value.nanosec
    }
    return field_value
dustingooding commented 2 years ago

i think this can be closed

mehmetkillioglu commented 2 years ago

Thanks for the info.