Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distance Sensor Capabilities #88

Closed
wants to merge 11 commits into from
Closed

Distance Sensor Capabilities #88

wants to merge 11 commits into from

Conversation

xabierolaz
Copy link

@xabierolaz xabierolaz commented Sep 14, 2020

Description of the Change

Before we implement a new distance sensor into the aircraft we first have to work on GymFC in order to have those capabilities.

-Distance Sensor Message included in State.proto
-Distance Sensor added in FlightControllerPlugin.cpp

Distance Sensor included in State.proto
Used IMU as an example in FlightControllerPlugin.cpp to add distance sensor
DistanceSensor.proto added

Verification Process

Running build_plugin.sh error

[ 87%] Building CXX object CMakeFiles/FlightControllerPlugin.dir/FlightControllerPlugin.cpp.o
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp: In member function ‘virtual void gazebo::FlightControllerPlugin::Load(gazebo::physics::WorldPtr, sdf::ElementPtr)’:
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:195:98: error: ‘class gazebo::FlightControllerPlugin’ has no member named ‘distanceSubTopic’; did you mean ‘distanceSub’?
         this->distanceSub = this->nodeHandle->Subscribe<sensor_msgs::msgs::DistanceSensor>(this->distanceSubTopic, &FlightControllerPlugin::DistanceSensorCallback, this);
                                                                                                  ^~~~~~~~~~~~~~~~
                                                                                                  distanceSub
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:195:141: error: ‘DistanceSensorCallback’ is not a member of ‘gazebo::FlightControllerPlugin’
         this->distanceSub = this->nodeHandle->Subscribe<sensor_msgs::msgs::DistanceSensor>(this->distanceSubTopic, &FlightControllerPlugin::DistanceSensorCallback, this);
                                                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp: In member function ‘void gazebo::FlightControllerPlugin::InitState()’:
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:290:17: error: ‘class gymfc::msgs::State’ has no member named ‘add_distance’; did you mean ‘add_force’?
     this->state.add_distance(0);
                 ^~~~~~~~~~~~
                 add_force
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp: At global scope:
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:311:87: error: no ‘void gazebo::FlightControllerPlugin::DistanceSensorCallback(gazebo::DistanceSensorPtr&)’ member function declared in class ‘gazebo::FlightControllerPlugin’
 void FlightControllerPlugin::DistanceSensorCallback(DistanceSensorPtr &_distanceSensor)
                                                                                       ^
CMakeFiles/FlightControllerPlugin.dir/build.make:62: recipe for target 'CMakeFiles/FlightControllerPlugin.dir/FlightControllerPlugin.cpp.o' failed
make[2]: *** [CMakeFiles/FlightControllerPlugin.dir/FlightControllerPlugin.cpp.o] Error 1
CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/FlightControllerPlugin.dir/all' failed
make[1]: *** [CMakeFiles/FlightControllerPlugin.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
(env) xabi@xabi-VirtualBox:~/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins$ 

State.proto and FlightControllerPlugin.cpp
@wil3
Copy link
Owner

wil3 commented Sep 14, 2020

This PR, and your commit needs a meaningful title, please review CONTRIBUTING.md.

Your build is also failing, you can click the details to find out why.

Also before opening a PR its important to first be able to verify the code otherwise there's no way for me or another reviewer to verify your code. This may include unit tests, functional tests and/or additional python scripts, that is essentially what the scripts in the /tests directory are used for. Under the PR's Verification Process should include the steps to be able to reproduce the changes to the PR. A test for this would probably look like a stub distance sensor plugin / model (these can be external to GymFC).

I guess a more meaningful questions is, how are you verifying what you posted as a PR works?

@xabierolaz xabierolaz changed the title First Commit Distance Sensor Capabilities Sep 15, 2020
Code related to distance sensor  added, using as reference the IMU and ESC parts
@xabierolaz
Copy link
Author

This PR, and your commit needs a meaningful title, please review CONTRIBUTING.md.

Your build is also failing, you can click the details to find out why.

Also before opening a PR its important to first be able to verify the code otherwise there's no way for me or another reviewer to verify your code. This may include unit tests, functional tests and/or additional python scripts, that is essentially what the scripts in the /tests directory are used for. Under the PR's Verification Process should include the steps to be able to reproduce the changes to the PR. A test for this would probably look like a stub distance sensor plugin / model (these can be external to GymFC).

I guess a more meaningful questions is, how are you verifying what you posted as a PR works?

Noted, fixing and completing everything now

Copy link
Author

@xabierolaz xabierolaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wil3 while running build_plugin.sh, the #include DistanceSensor.pb.h (as it is with IMU) says that file or directory missing file, output error in first message

@wil3
Copy link
Owner

wil3 commented Sep 21, 2020

doesn't look like you ever modified cmakelists.txt

Included DistanceSensor in sensor_msgs
@xabierolaz
Copy link
Author

doesn't look like you ever modified cmakelists.txt

sorry, I hadn't pull that one, still throwing same error message though

Changed  distance value from 0 to 13, its current value in State.proto
@xabierolaz
Copy link
Author

xabierolaz commented Sep 22, 2020

As cmakelist and distancesensor.proto are fixed now, new errors are thrown, most of them being the sensor not well declared in the flightcontrollerplugin.cpp working on them right now

[ 87%] Building CXX object CMakeFiles/FlightControllerPlugin.dir/FlightControllerPlugin.cpp.o
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp: In member function ‘virtual void gazebo::FlightControllerPlugin::Load(gazebo::physics::WorldPtr, sdf::ElementPtr)’:
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:193:12: error: ‘DISTANCE’ was not declared in this scope
       case DISTANCE:  //distance sensor
            ^~~~~~~~
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:193:12: note: suggested alternative: ‘ESTALE’
       case DISTANCE:  //distance sensor
            ^~~~~~~~
            ESTALE
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:195:15: error: ‘class gazebo::FlightControllerPlugin’ has no member named ‘distanceSub’
         this->distanceSub = this->nodeHandle->Subscribe<sensor_msgs::msgs::DistanceSensor>(this->distanceSubTopic, &FlightControllerPlugin::ImuCallback, this);
               ^~~~~~~~~~~
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:195:98: error: ‘class gazebo::FlightControllerPlugin’ has no member named ‘distanceSubTopic’; did you mean ‘escSubTopic’?
 his->nodeHandle->Subscribe<sensor_msgs::msgs::DistanceSensor>(this->distanceSubTopic, &FlightControllerPlugin::ImuCallback, this);
                                                                     ^~~~~~~~~~~~~~~~
                                                                                                  escSubTopic
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp: In member function ‘void gazebo::FlightControllerPlugin::InitState()’:
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:290:17: error: ‘class gymfc::msgs::State’ has no member named ‘add_distance’; did you mean ‘add_force’?
     this->state.add_distance(0);
                 ^~~~~~~~~~~~
                 add_force
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp: At global scope:
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:311:53: error: variable or field ‘DistanceSensorCallback’ declared void
 void FlightControllerPlugin::DistanceSensorCallback(DistanceSensorPtr &_distanceSensor)
                                                     ^~~~~~~~~~~~~~~~~
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:311:53: error: ‘DistanceSensorPtr’ was not declared in this scope
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:311:53: note: suggested alternative: ‘ConstSensorPtr’
 void FlightControllerPlugin::DistanceSensorCallback(DistanceSensorPtr &_distanceSensor)
                                                     ^~~~~~~~~~~~~~~~~
                                                     ConstSensorPtr
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:311:72: error: ‘_distanceSensor’ was not declared in this scope
 d FlightControllerPlugin::DistanceSensorCallback(DistanceSensorPtr &_distanceSensor)
                                                                     ^~~~~~~~~~~~~~~
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp: In member function ‘void gazebo::FlightControllerPlugin::ParseDigitalTwinSDF()’:
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:462:40: error: ‘DISTANCE’ was not declared in this scope
       this->supportedSensors.push_back(DISTANCE);
                                        ^~~~~~~~
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:462:40: note: suggested alternative: ‘ESTALE’
       this->supportedSensors.push_back(DISTANCE);
                                        ^~~~~~~~
                                        ESTALE
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp: In member function ‘void gazebo::FlightControllerPlugin::CalculateCallbackCount()’:
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:704:12: error: ‘DISTANCE’ was not declared in this scope
       case DISTANCE:
            ^~~~~~~~
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:704:12: note: suggested alternative: ‘ESTALE’
       case DISTANCE:
            ^~~~~~~~
            ESTALE
CMakeFiles/FlightControllerPlugin.dir/build.make:62: recipe for target 'CMakeFiles/FlightControllerPlugin.dir/FlightControllerPlugin.cpp.o' failed
make[2]: *** [CMakeFiles/FlightControllerPlugin.dir/FlightControllerPlugin.cpp.o] Error 1
CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/FlightControllerPlugin.dir/all' failed
make[1]: *** [CMakeFiles/FlightControllerPlugin.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
(env) xabi@xabi-VirtualBox:~/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins$ 

Added distance in enum Sensors
In cluded DistanceSensor.pb.h
callback to receive distance sensor values
@xabierolaz
Copy link
Author

xabierolaz commented Oct 8, 2020

Still getting some building errors with the new distance sensor implementation files published in the PR, any guess @wil3 ?

Thanks

[ 87%] Building CXX object CMakeFiles/FlightControllerPlugin.dir/FlightControllerPlugin.cpp.o
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp: In member function ‘void gazebo::FlightControllerPlugin::InitState()’:
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:290:17: error: ‘class gymfc::msgs::State’ has no member named ‘add_distance’; did you mean ‘add_force’?
     this->state.add_distance(0);
                 ^~~~~~~~~~~~
                 add_force
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp: In member function ‘void gazebo::FlightControllerPlugin::DistanceSensorCallback(gazebo::DistanceSensorPtr&)’:
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:313:34: error: ‘const class sensor_msgs::msgs::DistanceSensor’ has no member named ‘id’
   uint32_t id = _distanceSensor->id();
                                  ^~
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:317:15: error: ‘class gymfc::msgs::State’ has no member named ‘set_distance’; did you mean ‘set_sim_time’?
   this->state.set_distance(id, _distanceSensor->distance_meters());
               ^~~~~~~~~~~~
               set_sim_time
/home/xabi/projects/gymfc-xabi/gymfc/envs/assets/gazebo/plugins/FlightControllerPlugin.cpp:317:49: error: ‘const class sensor_msgs::msgs::DistanceSensor’ has no member named ‘distance_meters’; did you mean ‘distance_’?
   this->state.set_distance(id, _distanceSensor->distance_meters());
                                                 ^~~~~~~~~~~~~~~
                                                 distance_
CMakeFiles/FlightControllerPlugin.dir/build.make:62: recipe for target 'CMakeFiles/FlightControllerPlugin.dir/FlightControllerPlugin.cpp.o' failed
make[2]: *** [CMakeFiles/FlightControllerPlugin.dir/FlightControllerPlugin.cpp.o] Error 1
CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/FlightControllerPlugin.dir/all' failed
make[1]: *** [CMakeFiles/FlightControllerPlugin.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

@wil3 wil3 added the WIP work in progress label Oct 8, 2020
@wil3
Copy link
Owner

wil3 commented Oct 8, 2020

All of those errors are in reference to the new entry you added to the State.proto message. The compiler is saying they don't exist so it doesn't appear the source files for the proto are getting compiled with it. Inspect the generated build files in the build directory and confirm its being generated as expected.

@xabierolaz
Copy link
Author

xabierolaz commented Feb 2, 2021

Closed as its outdated, newest in #95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants