Help with object avoidance

hi Patrick,

I am having trouble reading the command.

As you already know, I use rplidar to generate sensor message and then send it through the mavros plugin upstream as MavLink message, type distance_sensor.

After setting the proximity sensor type and enable avoidance to 3, I still dont see QGroundControl Mavlink Inspector publishes DISTANCE_SENSOR type.

What do you see on your MavLink inspector? I am sure my topic is being published.

I cant really use mission planner because i need to manually run somethings first over linux.

Thanks,

Its Avoid 2 and Proximity 2
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AC_Avoidance/AC_Avoid.h#L18
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_Proximity/AP_Proximity.h#L43

I changed that now and I am tempted to test it. Could you share what you are able to read on QGC?

I’ll get the POC back to work later on today and upload pics

1 Like

The Analyse tool makes no sense .
Using Mavlink Inspector gets more intelligible update

1 Like

Too Bad You cannot Use Mission Planner, it gives such a great radar screen:

1 Like

interesting. So there is only one DISTANCE_SENSOR showing up? The radar looks so professional

Mavlink Inspector is scanning (quite randomly) through the different id & associated orientations

1 Like

I couldn’t find where to enable this radar screen to be displayed on Mission Planner (1.3.48). How can I do it?

There is no setting , this radar pops automatically on a window if you have valid proximity sensor(s) configured and sending signal

I’m having a hard time to get DISTANCE_SENSOR messages to be used, despite spending hours on this. I simply cannot validate that ArduCopter is using it.

I’ll describe my scenario below, in the hope that someone spots the missing piece or my fault.

I configured ArduCopter (3.4.6) with: AVOID_ENABLE=2 and PRX_TYPE=2.

I’m running a companion computer (RPi). There, I run cmavnode as as mavlink hub. cmavnode has 4 endpoints:

EP1: ArduCopter on Pixhawk, connected via serial (ttyAMA0, baud=921600).
EP2: Mission Planner (1.3.48) connected via UDP.
EP3: Custom built software (I call it LOGGER) that listens to messages and prints them, connected via UDP.
EP4: Custom built software (I call it SENDER) that generates DISTANCE_SENSOR messages, connected via UDP.

At first, I start cmavnode. It promptly reports that EP1 (ArduCopter) is connected with sysId 1.
Then, I connect EP2 (MP). cmavnode reports that EP2 is connected with sysId 255.
Then, I connect EP3 (LOGGER). cmavnode stays quiet, possibly because LOGGER does not send messages. LOGGER starts reporing various messages with sysId 1, presumably from Ardupilot and some debug messages with sysId 255 (from MP).
Then, I connect EP4 (SENDER). cmavnode reports that EP4 is connected with sysId 1. SENDER starts sending DISTANCE_SENSOR messages at 10Hz with sysId=1, compId=154, min_distance=4, max_distance=400, current_distance=120 and orientation=0. LOGGER starts reporing DISTANCE_SENSOR messages with correct values.

I don’t know how to validade that ArduCopter is receiving the messages and that it is using (accepting) them. Is there a way to do this? I expected that ArduCopter would send new DISTANCE_SENSOR messages to everybody else, but it doesn’t.

I don’t know how to validade that Mission Planner is receiving the messages and that it is using (accepting) them. @ppoirier said that the “radar” window should appear, but nothing happened. Mission Planner “Tuning” feature does not have"distance variables", so I could graph them. Is there a way to do this?

LOGGER and SENDER are written in Java, using MAVLinkJava library. They don’t send heartbeat messages.

What am I missing?

Hello

Take note that the POC sends a Heartbeat

command_heartbeat();
command_distance_1();
command_distance_2();
command_distance_3();
command_distance_4();
command_distance_5();
command_distance_6();

I dont use cmavnode, so I cannot comment on this part.
My preferred tool for debugging are QGroundControl Widgets : Analyse & Mavlink Inspector as showned on the picture above, you will be able to confirm the operation and values of Distance Sensor.

Which values does POC send in heatbeat message parameters?
Which values does POC send in DISTANCE_SENSOR message parameters?

Where can I find POC code? Is it opensource?

The POC is ARDUINO based, so if that can help, here is the heartbeat code:
}

void command_heartbeat() {

//< ID 1 for this system
int sysid = 100;
//< The component sending the message.
int compid = MAV_COMP_ID_PATHPLANNER;

// Define the system type, in this case ground control station
uint8_t system_type =MAV_TYPE_GCS;
uint8_t autopilot_type = MAV_AUTOPILOT_INVALID;

uint8_t system_mode = 0;
uint32_t custom_mode = 0;
uint8_t system_state = 0;

// Initialize the required buffers
mavlink_message_t msg;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];

// Pack the message
mavlink_msg_heartbeat_pack(sysid,compid, &msg, system_type, autopilot_type, system_mode, custom_mode, system_state);

// Copy the message to the send buffer
uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);

// Send the message
//delay(1);
Serial.write(buf, len);
}

Thank you! I’ll keep trying.

As I mentioned on “Radar”/DISTANCE_SENSOR screen, I managed to get the “radar screen” displayed.

The problem was ArduCopter 3.4.6. When I switched to 3.5-rc11, a window simply poped-up.

I don’t recall now why I thought 3.4 was enough. Maybe a mistake.

Despite this, I recommend adding a note to http://ardupilot.org/dev/docs/code-overview-object-avoidance.html, stating that minimum version is 3.5.

@ppoirier, heartbeat messages were not necessary. I noticed that POC is using system_mode parameter with value zero. It seems that this value is invalid, since it is not in MAV_MODE_FLAG ENUM.

I’m sending distance_sensor messages for orientations 0-7, 24, and 25.

Now I’ll test if ArduCopter really uses these messages to avoid obstacles.

@FabricioSilva

Godd, nice to know you are making progress.

Updating the wiki is something you could certainly do, it is quite easy, and its helping everyone :slight_smile:
Concerning the heartbeat, you are right, I used the feature as a standalone when working directly with the widget. The value “0” returns a Uninitialized system, state is unknown, that has no real incidence for this component, but thanks for pointing it.

@ppoirier

nice, thats really cool. Could you share your arduino code? Most importantly the part where it sends the mavlink message. Are there any resources / libraries involved? Could you give me a hint, where to look for those?

thank you :slight_smile:
Fabi

Hello,

The code is just exactly with is shown on my last replyabove