odriverobotics / ros_odrive

MIT License
55 stars 33 forks source link

TypeError: the 'package' argument is required to perform a relative import for '.odrive_can.srv' #6

Closed semyonkozlov closed 8 months ago

semyonkozlov commented 8 months ago
ros2 service call /odrive_axis0/request_axis_state /odrive_can/srv/AxisState "{axis_requested_state: 1}"
Traceback (most recent call last):
  File "/opt/ros/iron/bin/ros2", line 33, in <module>
    sys.exit(load_entry_point('ros2cli==0.25.4', 'console_scripts', 'ros2')())
  File "/opt/ros/iron/lib/python3.10/site-packages/ros2cli/cli.py", line 91, in main
    rc = extension.main(parser=parser, args=args)
  File "/opt/ros/iron/lib/python3.10/site-packages/ros2service/command/service.py", line 41, in main
    return extension.main(args=args)
  File "/opt/ros/iron/lib/python3.10/site-packages/ros2service/verb/call.py", line 58, in main
    return requester(
  File "/opt/ros/iron/lib/python3.10/site-packages/ros2service/verb/call.py", line 69, in requester
    module = importlib.import_module('.'.join(parts[:-1]))
  File "/usr/lib/python3.10/importlib/__init__.py", line 121, in import_module
    raise TypeError(msg.format(name))
TypeError: the 'package' argument is required to perform a relative import for '.odrive_can.srv'

I was able to launch node, so package is built and setup.bash is sourced. ros2 topic echo and other command are also working correctly.

semyonkozlov commented 8 months ago
# ros2 service list -t
/odrive_axis0/can_node/describe_parameters [rcl_interfaces/srv/DescribeParameters]
/odrive_axis0/can_node/get_parameter_types [rcl_interfaces/srv/GetParameterTypes]
/odrive_axis0/can_node/get_parameters [rcl_interfaces/srv/GetParameters]
/odrive_axis0/can_node/get_type_description [type_description_interfaces/srv/GetTypeDescription]
/odrive_axis0/can_node/list_parameters [rcl_interfaces/srv/ListParameters]
/odrive_axis0/can_node/set_parameters [rcl_interfaces/srv/SetParameters]
/odrive_axis0/can_node/set_parameters_atomically [rcl_interfaces/srv/SetParametersAtomically]
/odrive_axis0/request_axis_state [odrive_can/srv/AxisState]

mb will be useful

harborhoffer commented 8 months ago

Seeing the same error when trying to make a service call.

anthonywebb commented 8 months ago

same here, hoping that @samuelsadok can shed some light

JesseDarr commented 8 months ago

Hey guys, I think I can help. I checked the command you used against my notes:

ros2 service call /odrive_axis0/request_axis_state /odrive_can/srv/AxisState "{axis_requested_state: 1}" <-- yours

ros2 service call /odrive_axis0/request_axis_state odrive_can/srv/AxisState "{axis_requested_state: 1}" <-- my notes

The only difference is the leading "/" on the odrive_can/srv/AxisState. I confirmed that you're command produces the same error on my setup, but it works without the "/"

harborhoffer commented 8 months ago

Nice find @JesseDarr! The docs need be updated to remove the forward slash.

samuelsadok commented 8 months ago

Whoops don't know how that slash got in there but I could confirm that the proposed fix works. Thanks for the pointer! I just updated the docs.