Auto mode with simple avoidance not working with mavlink sensor(Ardurover - boat - Skidsteering)

Hello community,

I am feeding Obstacle Distance message from my companion computer(Jetson Nano) via the Obstacle Distance message(330). My ArduPilot is receiving the obstacle message, at the specified rate(10-11Hz). Currently I am just feeding dummy values, (all 72 elements are set to 300). When I enable the proximity avoidance, and setup a mission(via QGC), the boat barely moves. However, when I disable to proximity avoidance, the boat starts moving, accelerates to cruise speed and is able to carry out the mission and complete it. The moment I enable proximity avoidance, the boat stops. Avoid margin is set to 1m, hence sending a value of 3m(300) should allow the boat to move.

Has anyone else faced this issue before? I have attached the latest log file(cloud upload), and also the c++ function, which I use to create the message and send it over to ArduPilot.

int Rover::setDistance(uint16_t (&distance)[72])
{
	// OBSTACLE_DISTANCE (330)
	// Format Data:
	mavlink_obstacle_distance_t obstacleDistance = {0}; // set all fields to zero
	obstacleDistance.time_usec = (uint32_t)(getCurrentTimeUsec());
	obstacleDistance.sensor_type = 0; //was 1
	memcpy(obstacleDistance.distances, distance, sizeof(distance));
	obstacleDistance.increment = 5;
	obstacleDistance.min_distance = 10;
	obstacleDistance.max_distance = 1500;
	obstacleDistance.frame = MAV_FRAME_BODY_FRD;
	obstacleDistance.increment_f = 0;
	obstacleDistance.angle_offset = 0;

	// Encode
	mavlink_message_t msg;
	mavlink_msg_obstacle_distance_encode(1, 158, &msg, &obstacleDistance);
	
	// Write in the serial
	int len = serial_port.write_message(msg);
	if (len <= 0)
	{
		printf("Failed to Send");
	}
	//request_GPS_message();
	//mavlink_global_position_int_t msg = recv_data_gps();
	// printf("Distances Published");
	return (len);
}

uint64_t Rover::getCurrentTimeUsec()
{
	auto now = std::chrono::high_resolution_clock::now();
	auto duration = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch());
	return duration.count();
}

The function setDistance(uint16_t (&distance)[72]) is called from the main loop at 10Hz and currently all values are forced to be 300. My other parameters are as follows

Jetson connected to Ardupilot over Serial 2(Telemetery 2)
PRX1_Type = 2(mavlink)
Avoid_Enable = 7
Avoid_Margin = 1
Avoid_Behave = Stop
Backup_Spd = 0

Log File: Box

With some testing, I realized that the firmware has some kind of an algorithm that limits the speed based on how far the obstacle is. However, this does not work very for Boats, as the water surface may be 3 meters deep(good enough for the boat to move ahead confidently), however due to the algorithm, it only moves at 0.6 m/sec. Is there a parameter that allows me to adjust values that limit speed?

I was able to find a way to get around this, which is set the sensor max range to a small value, say(1m), hence a value of 3 meter is registered as a no obstacle, and the boat is able to accelerate to its max speed. This isn’t ideal, and I was wondering if someone has another way of solving this problem?

1 Like

Hi @Dinesh_Kumar,

Great that you’ve mostly figured out the issue on your own.

AP uses the configured maximum acceleration to calculate how far away from obstacles it must start to slow down

1 Like

@rmackay9 I wouldn’t say the problem is solved, I was away on another testing couldn’t get to it. Right now, the problem persists in terms of setting a low max value for the mavlink sensor. There are times, the boat sees the obstacle but doesn’t stop.

Like I said this requires a lot more testing, and I will keep you updated, but any help from the community would help. I am assuming changing some parameter could solve the problem. I am considering changing the adjust_velocity() function under AC_AVOIDANCE.