0
$\begingroup$

Rosanswers logo

I an running ros on 2 raspberry pi's. one pi runs master, mapserver, gmapping or amcl and my motor control and sensor node. on the other I an running Rviz. I am in my motor control and sensor node I and turning sonar readings into lasersans by adapting a sonartolaserscan package. I added the laserscan layer in rviz and I see the scan dots but they are not oriented correctly. I can see the values change as I put an obstacle in different positions. I have the obstacles in such a way that I tell where the laserscan dots should be but they are not. Hopefully the image will attach. What should be direction in front of the robot is out the back and not directly opposite from where it should be (1) The one that should be on the robot's left (2) should be 90 degrees left but it is more like 120 degrees left and the one on the right should be 90 degrees right but it is move like 160 degrees right.

Sorry I am not able to add and image

I do not know if the problem is my urdf or my code or I am missing a transform.

Here is the code where I set up the message for the laserscan with all values as no value


scan.header.frame_id = "/base_link";

scan.angle_min = 1.81514242;//DEG_TO_RAD(MIN_ANGLE);

scan.angle_max = -1.81514242;//DEG_TO_RAD(MAX_ANGLE);

scan.angle_increment = 0.034906585;//DEG_TO_RAD(DEG_INCREMENT);

scan.time_increment = (1.0 / 100) / (NUM_READINGS);

scan.range_min = 0.0;

scan.range_max = MAX_SONAR_CM;

scan.ranges.resize(NUM_READINGS);

scan.intensities.resize(NUM_READINGS);

for(unsigned int i = 0; i < NUM_READINGS; ++i) {

scan.ranges[i] = (double)(MAX_SONAR_CM + .15)/100.0;

scan.intensities[i] = 0;

}

Then here is code where I set the appropriate laserdots that correspond to the sonar readings during each sensor update.

ROS_INFO("begin scan conversion");

scan.header.stamp = ros::Time::now();

// overwrite the no signal with our sonar for the 14 readings within our beam

for(unsigned int i = 0; i < 8; ++i){

scan.ranges[i] = (float)(LeftF/100.0) + SIDE_OFFSET;

scan.intensities[i] = 0.5;

}

for(unsigned int i = 26-3; i < 26+3; ++i){

scan.ranges[i] = (float)Front/100.0 + FRONT_OFFSET;

scan.intensities[i] = 0.5;

}

for(unsigned int i = 53-9; i < 53; ++i){

scan.ranges[i] = (float)Right/100.0 + SIDE_OFFSET;

scan.intensities[i] = 0.5;

}

ptr_scan_pub->publish(scan);

ROS_INFO("end scan conversion");

I tried to add a transform for base_link to laser but got an error message saying the transform is already published in my motor control and sensor node Here is the urdf


Originally posted by ed on ROS Answers with karma: 91 on 2017-07-08

Post score: 0


Original comments

Comment by gvdhoorn on 2017-07-08:
Please format your question text properly. Use the Preformatted Text button (the one with 101010 on it) to format console copy-pastes, code, and urdfs.

I've also given you enough karma to so please attach an image that shows what is going on.

Thanks.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I abandoned this robot and reused some of the components to build another robots that uses a ydliar F4 instead. However I think the issue that I was experiencing in this question was there were issues with the URDF that caused the TF for the sonars. I think that was introducing a rotation.


Originally posted by ed with karma: 91 on 2018-12-15

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.