ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Calling /ardrone/togglecam from python code rather than from terminal

asked 2015-08-10 08:25:53 -0500

AmitShukla_IITK gravatar image

I have difficulty that I am able to use ($rosservice call /ardrone/togglecam) command from terminal to toggle between front and bottom camera of AR Drone but same I am not able to do from my python code.

I am using:

to generate publishing command

Self.Pubtogglec = rospy.Publisher(‘/ardrone/togglecam’, Empty)

#Then I have defined a function to finally publish this command to ardrone Def ToggleBCam(self) Self.Pubtgglec.publish(Empty())

My code is reaching to this ToggleBCam method (as I am printing some massage there to see if it reaches to this publish line or not) but this is not changing video feed. I am not sure what exactly wrong I am doing. I have search extensively but I have not found any help either. Can you please help me, how I can toggle camera from my python code? I habve seen some of the old tutorial methods have used above mentioned method for toggling cam but why I am not able to do that.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2015-08-10 09:43:38 -0500

mgruhler gravatar image

updated 2015-08-10 09:44:53 -0500

You cannot call a service using a publisher. This is simply the wrong way to do this.

You need to use a ServiceClient. Have a look at the python tutorial on creating a ServiceClient (or ServiceProxy) for how to do this. Then, use the respective service type in your script.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2015-08-10 08:25:53 -0500

Seen: 493 times

Last updated: Aug 10 '15