1
$\begingroup$

I am using a raspberry pi to practice low level development with a differential drive robot; bare metal without an OS underneath.

I've gotten to the point where I have a very small, single purpose kernel that drives a couple of DC motors, and reads an IR sensor over I2C with an Analog Digital Converter.

I have also started writing code for a PID controller: so far so good.

I use a bootloader over USB to UART to update the Pi with new versions of the kernel, and I also started looking at the Check unit test framework, so I can avoid too much trial and error

However, many of the online material about robotics use simulators (which makes great sense).

I am familiar with Gazeebo, and the one from GA Tech as well, and this lists a great number also

However I am having trouble understanding how I can use my C code for bare metal on one of these simulators?

$\endgroup$
  • $\begingroup$ Are you trying to test the code only (Software in the Loop) or the hardware together with the software (Hardware in the Loop)? $\endgroup$ – 50k4 Dec 28 '17 at 22:07
  • $\begingroup$ Software in the loop $\endgroup$ – Sam Hammamy Dec 29 '17 at 0:34
1
$\begingroup$

You can alter the C code structure in the Controller, so that the code you want to test is indepencent from platfrom specific code. (You can only test the platform independent code using Software in the Loop anyways.) I am not sure what ways are available in C in order to achive this, but all inversion of control methods, e.g. Dependency injection, have this goal.

The platform independen code then can be compiled not only for the bare metal implementation, but also for Linux (assuming Gazeebo only runs on Linux), you will need different build settings (e.g. make file or project, depending on what you use to build the project).

The code which is platform independent can be included in a Gazeebo simulation. Since I have never used Gazeboo, I cannot help with this, but here are my assumptions:

  • Gazeebo is aimed for developing high level algorithms, so testing code for a PID controller or similar, will probably need a different simulation software (e.g. Matlab Simulink).

  • You will have to re-implement all platform dependent code, this time, instead of bare metal platform dependent code it will be Gazeboo dependent. If you use dependeny injection, for one build your logic is injected with the bare metal platform specific code, for the test build it will be injected with Gazeebo specific code E.g. instead of reading a lidar, you will need to find a way to emulate that lidar read using the Gazeebo environment and feed the sam data to your logic, as it would come from the lidar.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.