Help with object avoidance

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

okay, thank you! :slight_smile: but where is the heartbeat sending the distance measurement?
do you have any idea how to permanently change the i2c address of the lidar lite v3? I want to use 2 of them via i2c.
thank you :slight_smile:

Fabianpedd,

Did you ever end up getting this to work for you?

which sonar or LIDAR are I using?
in the USA, where can I buy sonar or LIDAR for pixhawk 2.4.6?
Iā€™ll use it on a quad

@ppoirier how can I install and use MAVLink Inspector on windows? May you help me?

thanks

Just install QgroundControl , its part of the widgets

thanks!
I will install QGroundControl

@ppoirier

Which message pack should I use to send the distance messages?
Iā€™m guessing I need something that looks like the pack function for the heartbeat (mavlink_msg_heartbeat_pack(sysid,compid, &msg, system_type, autopilot_type, system_mode, custom_mode, system_state))

But Iā€™m not sure which pack to use. Also, if you know where to find a list of the pack functions, that would be great.

Thanks!

Take a look at my Arduino code:
https://github.com/patrickpoirier51/POC/blob/master/MAVLINK-POC.ino#L194

Hello Patrick

Thanks for the reply and link to your code! I really appreciate it.

Iā€™m using SharpIR sensors, which are sampled at a baud rate of 9600. Do I have to feed the Pixhawk serial port (using Telem1) at 115200 like what your code is doing? or can I simply adjust the serial baud rate in pixhawk parameters to 9600? As you know, switching baud rate on a non-mega arduino is a bit tricky.

@MCITYFC you can use SoftwareSerial, and the Sharp Library for arduino.

Never been really successfull with the SharpIR , I prefer the VL53L0x for the same range.

Patrick, I have a LIDARLite v3 working as a horizontal proximity sensor (Mission Planner 1.3.52.0; Copter 3.5.4). The copter slides (annoyingly) to port side when the AVOID_MARGIN 2m is reached. From the info in your post I gather that I can set PROXIMITY_SENSOR 2 to cause a STOP. You mention that this can be configured using advanced options within Mission Planner. Iā€™ve scoured MP Full Parameter List but canā€™t find any reference to this setting. Can you please advise further how to define AC_AVOID_USE_PROXIMITY_SENSOR value?
Thanks for your time.

@Alan_Winlaw depends on the mode and on sensors setup.
As an example , if you have single sensor (looking forward) and fly in Alt-Hold mode , chances are that it will slip one side or the other.
You can adjust this parameter http://ardupilot.org/copter/docs/parameters.html#avoid-angle-max-avoidance-max-lean-angle-in-non-gps-flight-mode , but bear in mind that in my setup (The POC), I have 6 sensors covering 180 degree forward , making the avoidance system ā€˜ā€˜boxedā€™ā€™ within the walls, with no chances of slipping.

Cheers, mate. Iā€™ll check that out.

Hello Patrick

The obstacle stop system is a go on my drone! I switched to VL53L0X as well, itā€™s tiny, lightweight and effective! Thanks for the suggestion and the help!

Just one point to note for the others who want to try this: When objects are out of range, your sensor should be giving you a constant reading equal to your max value set in the arduino code. If itā€™s jumping around between max and min, check if the protective film is still on the sensor! I didnā€™t realize that until a few hours into it! A jumping reading will cause the drone to jerk around or fly in one direction.

1 Like