Problem calling ROS service for arducopter - ROS/SITL Tutorial

Hi Everyone,

I’m following the tutorials in this page, to try and use ros with ardupilot.

http://ardupilot.org/dev/docs/ros-sitl.html

However when I get to the last part where it says

go to plugins / services/ services caller set service to /mavros/set_mode set custom_mode to ‘GUIDED’ and click the call button The response should be true,

But the response is always false… Moreover, on hte terminal window where I launch mavros I get the following message:

MODE: Unsupported FCU

and naturaly in the mavproxy window nothing changes, and it is still in STABILIZE mode. I should note that if I try to change the mode in mavproxy window by doing mode GUIDED it works. not only am I able to change mode and take off and all that.

in my launch file I set

<arg name="fcu_url" value="tcp://127.0.0.1:5760" />

Hope someone can help.

Cheers,
Hugo

Hello,

The port 5760 is already taken by mavproxy, use 5761 or 5762 in TCP. But there is a bug in mavproxy currently, that why I recommand to use UDP with <arg name="fcu_url" default="udp://127.0.0.1:14551@14555" />

Hi @khancyr
but when I change that in my roslaunch file I get

[ INFO] [1499796481.431985401]: FCU URL: tcp://127.0.0.1:5761
[ INFO] [1499796481.432272479]: tcp0: Server address: 127.0.0.1:5761
[FATAL] [1499796481.432514231]: FCU: DeviceError:tcp:connect: Connection refused

Btw, this is what the node looks like

<include file="$(find mavros)/launch/apm_sitl.launch" >
	<arg name="fcu_url" value="tcp://127.0.0.1:5761" />
	<arg name="gcs_url" value="udp://:14550@" /> 
	<arg name="tgt_system" value="1" />
	<arg name="tgt_component" value="1" /> 
</include>

As @khancyr wrote you should try;
arg name=“fcu_url” value=“udp://127.0.0.1:5762”

thanks @ppoirier

doing what you suggested made it possible to run the roslaunch… but I still get the same issue as in my first post

Looking at the wiki, MAVROS should be launch as a remote GCS… so you could try this instead:
arg name=“fcu_url” default=“udp://127.0.0.1:14551@14555”

Is SITL launch in another terminal ?

Hi @ppoirier

That’s really strange… when I change the values to that the launch doesn’t happen…instead I get

[ERROR] [1499799869.786768019, 1.000000000]: udp0: sendto: Invalid argument
terminate called after throwing an instance of 'std::system_error'
  what():  Resource deadlock avoided

@khancyr… I’m not sure if I understand your question… but waht I’m doing is in one terminal run

sim_vehicle.py -v ArduCopter -f gazebo-iris --use-dir copter0 -I 0

and in another my launch like

<include file="$(find mavros)/launch/apm_sitl.launch" >
	<arg name="fcu_url" value="tcp://127.0.0.1:5760" />
	<arg name="gcs_url" value="udp://:14550@" /> 
	<arg name="tgt_system" value="1" />
	<arg name="tgt_component" value="1" /> 
</include>
1 Like

I cannot relate this:
sim_vehicle.py -v ArduCopter -f gazebo-iris --use-dir copter0 -I 0
to any instruction within the wiki

is gazebo launched with an Iris model ?

@ppoirier, gazebo instruction will come ! But the command line seems good

1 Like

Hi @khancyr

Actually it isnt… I’m launching it with the erlecopter model. That is the physical one the lab acquired so I have to work with it. Is there something that will need changing in the source code then? But then again, even using their model I’m using the ardupilot original branch. And from the mavproxy window I’m able to change mode etc…
Thanks

Perhaps I should add that when do

rostopic info /mavros/state

I get

header: 
  seq: 0
  stamp: 
    secs: 0
    nsecs:         0
  frame_id: ''
connected: False
armed: False
guided: False
mode: ''

Shouldn’t the connected field be true?

SOLVED IT!!!

Notice that when you bring ardupilot in this manner

sim_vehicle.py -v ArduCopter -f gazebo-iris --use-dir copter0 -I 0

some of the output is

SIM_VEHICLE: "mavproxy.py" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551"

In my launch file now it reads

	<include file="$(find mavros)/launch/apm_sitl.launch" >
		<arg name="fcu_url" value="udp://127.0.0.1:14551@" /> 
		<arg name="gcs_url" value="" /> 
		<arg name="tgt_system" value="1" />
		<arg name="tgt_component" value="1" /> 
	</include> 

where the fcu_url corresponds to the second “–out” of mavproxy!

5 Likes

Nice that you solve it ! I was writing an answer and making a small video : https://youtu.be/LRo2G3z6s5w

3 Likes

Pierre, this video is GREAT !! , please add to wiki :slight_smile: