Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServiceClientオブジェクトのmethodが上手く定義されない #704

Open
Kanazawanaoaki opened this issue Feb 3, 2022 · 2 comments

Comments

@Kanazawanaoaki
Copy link

Kanazawanaoaki commented Feb 3, 2022

$ rossrv show pr2_mechanism_msgs/SwitchController 
int32 BEST_EFFORT=1
int32 STRICT=2
string[] start_controllers
string[] stop_controllers
int32 strictness
---
bool ok


pr2_mechanism_msgs/SwitchControllerサービスのServiceClientオブジェクトを生成してもstart_controllers等のmethodが定義されない.

$ roseus
1.irteusgl$ (ros::load-ros-manifest "pr2_mechanism_msgs")
t
2.irteusgl$ (setq req (instance pr2_mechanism_msgs::SwitchController :init ))
#<pr2_mechanism_msgs::switchcontroller #X563e2d19dc90>
3.irteusgl$ (send req :start_controllers "r_arm_controller_loose")
Call Stack (max depth: 20):
  0: at (send req :start_controllers "r_arm_controller_loose")
  1: at #<compiled-code #X563e2c217e18>
/opt/ros/melodic/share/euslisp/jskeus/eus/Linux64/bin/irteusgl 0 error: cannot find method :start_controllers in (send req :start_controllers "r_arm_controller_loose")
4.E1-irteusgl$ (send req :methods)
(:init :md5sum- :datatype- :connection-header :plist :get :put :name :remprop :prin1 :prin1 :warning :error :slots :methods :super :get-val :set-val)

例えば他のサービスを試してみると,

1.irteusgl$ (ros::load-ros-manifest "dynamic_tf_publisher")
t
2.irteusgl$  (setq req (instance dynamic_tf_publisher::SetDynamicTFRequest :init))
#<dynamic_tf_publisher::setdynamictfrequest #X562123876c30>
3.irteusgl$ (send req :methods)
(:init :freq :cur_tf :serialization-length :serialize :deserialize :response :init :md5sum- :datatype- :connection-header :plist :get :put :name :remprop :prin1 :prin1 :warning :error :slots :methods :super :get-val :set-val)

のようにmethodが定義されています.

pythonだと,

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import rospy
from pr2_mechanism_msgs.srv import SwitchController

sp = rospy.ServiceProxy('/pr2_controller_manager/switch_controller', SwitchController)
resp = sp(start_controllers=["r_arm_controller_loose"], stop_controllers=["r_arm_controller"])

のように書くことで実行できることは確認しました.

何が問題なのでしょうか?

@Kanazawanaoaki
Copy link
Author

Kanazawanaoaki commented Feb 3, 2022

(setq req (instance pr2_mechanism_msgs::SwitchController :init ))

(setq req (instance pr2_mechanism_msgs::SwitchControllerRequest :init ))

のように,クラス名にRequestを追加したら上手く定義されました.

1.irteusgl$ (ros::load-ros-manifest "pr2_mechanism_msgs")
t
2.irteusgl$ (setq req (instance pr2_mechanism_msgs::SwitchControllerRequest :init ))
#<pr2_mechanism_msgs::switchcontrollerrequest #X55a56f9bc410>
3.irteusgl$ (send req :methods)
(:init :start_controllers :stop_controllers :strictness :serialization-length :serialize :deserialize :response :init :md5sum- :datatype- :connection-header :plist :get :put :name :remprop :prin1 :prin1 :warning :error :slots :methods :super :get-val :set-val)

タイポすると,下のようにunbound variableのエラーが出るのでRequestを付け忘れた時もRequestを付けるように案内するエラーが出ると良さそうです.

2.irteusgl$ (setq req (instance pr2_mechanism_msgs::SwitchControlle :init ))
Call Stack (max depth: 20):
  0: at (instantiate pr2_mechanism_msgs::switchcontrolle)
  1: at (let ((#:inst458 (instantiate pr2_mechanism_msgs::switchcontrolle))) (send #:inst458 :init) #:inst458)
  2: at (instance pr2_mechanism_msgs::switchcontrolle :init)
  3: at (setq req (instance pr2_mechanism_msgs::switchcontrolle :init))
  4: at #<compiled-code #X55d5c5e99e18>
/opt/ros/melodic/share/euslisp/jskeus/eus/Linux64/bin/irteusgl 0 error: unbound variable pr2_mechanism_msgs::switchcontrolle in (instantiate pr2_mechanism_msgs::switchcontrolle)

@Affonso-Gui
Copy link
Member

Looks a lot like #543 #546

Should we add a wrapper to this one too?

@Affonso-Gui Affonso-Gui reopened this Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants