diff --git a/doc/logBuch.md b/doc/logBuch.md index cb5eceb714553d1baff7c7bfa04f9c5ee05a8c2f..de677e13f601871c26ef0dfbe566fddd96fecf0f 100644 --- a/doc/logBuch.md +++ b/doc/logBuch.md @@ -56,7 +56,7 @@ Mo. 18.12. (Schlingloff) - Nodeletsvorstellung GruppeC - Architekturvorstellung GruppeB -Mo. 05.01. +Mo. 05.01. (Franz) ---------------------------------------------------------------- - Architekturbesprechung - Aufbau ODROID (Booting) @@ -64,7 +64,7 @@ Mo. 05.01. Mo. 08.01. (Schlingloff) ---------------------------------------------------------------- -Di. 09.01. +Di. 09.01. (Franz) ---------------------------------------------------------------- - Einrichtung WLAN ODROID @@ -117,6 +117,15 @@ Mo. 12.02. (Schlingloff) - 18.05. 13.00 Generalprobe - 22.05. Endtermin +Mo. 13.03. (Franz) +---------------------------------------------------------------- +- Erste nodelets + +Mo. 22.03. (Franz) +---------------------------------------------------------------- +- Verbindung eduroam, Ad-Hoc +- Dummy-Module, Log + XX. XX.XX. (Schlingloff) ---------------------------------------------------------------- - \ No newline at end of file diff --git a/doc/softwareSetup/adhocSetup.txt b/doc/softwareSetup/adhocSetup.txt new file mode 100644 index 0000000000000000000000000000000000000000..1ef7a799e39f6a938dceff75b1aadd0d0a5c0a14 --- /dev/null +++ b/doc/softwareSetup/adhocSetup.txt @@ -0,0 +1,30 @@ +Siehe: https://gitlab.informatik.hu-berlin.de/adapt/ws17-HF/Gruppe-B/wikis/Einrichten-Ad-Hoc-Netzwerke +Auf dem ODROID: + +$ ifconfig wlan0 down +$ iw wlan0 set type ibss +$ ifconfig wlan0 up +$ iw wlan0 ibss join test 2432 +$ ifconfig wlan0 10.42.43.1 + +Oder die Befehle in ein Skript adhoc.sh schreiben und ausführen. +Man muss das Adhoc Netzwerk ja jedes Mal neu erstellen. + +Damit ist das Adhoc Netzwerk test erstellt. +Mit einem anderem Computer kann man sich nun verbinden. + +MacOS: +WLAN bzw Wifi ID herausfinden: +$ networksetup -listallhardwareports +Als nächstes IP Adresse setzen: +$ sudo ifconfig en0 10.42.43.2 +Test: +$ ping 10.42.43.1 +Nun kann man versuchen, sich per ssh mit dem ODROID zu verbinden: +$ ssh root@10.42.43.1 +Das Passwort lautet: autonom1718a + +Copy the file "foobar.txt" from a remote host to the local host +$ scp root@10.42.43.1:foobar.txt /some/local/directory +Copy the file "foobar.txt" from the local host to a remote host +$ scp foobar.txt root@10.42.43.1:/some/remote/directory diff --git a/doc/softwareSetup/eduroamSetup.txt b/doc/softwareSetup/eduroamSetup.txt new file mode 100644 index 0000000000000000000000000000000000000000..2e70e05bd0c17567dcf52db2d3c19d101b5775ce --- /dev/null +++ b/doc/softwareSetup/eduroamSetup.txt @@ -0,0 +1,41 @@ +Einrichtung der Verbindung mit Eduroam unter Linux Ubuntu (command line): + +Der allgemeine Prozess wird hier ausführlich beschrieben: +https://www.cms.hu-berlin.de/de/dl/netze/wlan/config/eduroam/linux/eduroam-linux-wpa_supp.pdf + +0. Vorbereitung +Herausfinden der WLAN-Karten ID +z.B. nmcli d (im Fall von ODROID: wlan0) + +1. +Es werden folgende Dateinen benötigt: +http://www.cms.hu-berlin.de/dl/netze/wlan/config/eduroam/deutsche-telekom-root-ca-2.crt +http://www.cms.hu-berlin.de/dl/netze/wlan/config/eduroam/linux/wpa_supplicant.conf + +Kopieren nach /etc/wpa_supplicant + +2. Editieren von wpa_supplicant.conf +Ersetzen von YourNameHere durch z.B. foobar@informatik.hu-berlin.de +Ersetzen von YourPasswordHere durch das entsprechende Password, alternativ Zeile löschen + +3. +root@odroid: sudo service network-manager stop +root@odroid: sudo wpa_supplicant -i wlan0 -D wext -c /etc/wpa_supplicant/wpa_supplicant.conf -d + +Falls die Passwortzeile gelöscht wurde: in neuer Konsole +root@odroid: sudo wpa_cli + +4. +Um die Änderungen permanent zu machen: +sudo vim /etc/network/interfaces + +auto wlan0 +root@odroid: iface wlan0 inet dhcp +root@odroid: wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf + +------------------------- +Auf dem ODROID wurde bereits die Verbindung mit Eduroam eingerichtet (truongph) +root@odroid: wpa_cli +> password 0 <YourPassword> + +Falls das Passwort unbekannt ist, ändern des Namens in der wpa_supplicant.conf diff --git a/modules/catkin_ws/src/CMakeLists.txt b/modules/catkin_ws/src/CMakeLists.txt index 581e61db89fce59006b1ceb2d208d9f3e5fbcb5e..3421623bd042f7eb4d2675c8c9ca624feb01cd4f 120000 --- a/modules/catkin_ws/src/CMakeLists.txt +++ b/modules/catkin_ws/src/CMakeLists.txt @@ -1 +1 @@ -/opt/ros/kinetic/share/catkin/cmake/toplevel.cmake \ No newline at end of file +/opt/ros/lunar/share/catkin/cmake/toplevel.cmake \ No newline at end of file diff --git a/modules/catkin_ws/src/car/CMakeLists.txt b/modules/catkin_ws/src/car/CMakeLists.txt index 93bbf7d685aecb9ea26238cd4d9065ba36828e81..26947910a159c1e9663baba339c243ad0efb48b5 100644 --- a/modules/catkin_ws/src/car/CMakeLists.txt +++ b/modules/catkin_ws/src/car/CMakeLists.txt @@ -52,11 +52,15 @@ include_directories( set(MAIN_NODE_SOURCE_FILES include/mainNode/MainNode.h + include/mainNode/EgoMotion.h include/mainNode/NotifiableThread.h include/mainNode/PlatoonController.h + include/mainNode/CruiseController.h src/mainNode/MainNode.cpp + src/mainNode/EgoMotion.cpp src/mainNode/NotifiableThread.cpp - src/mainNode/PlatoonController.cpp) + src/mainNode/PlatoonController.cpp + src/mainNode/CruiseController.cpp) set(LOCAL_INSTALL_DIR ${CMAKE_CURRENT_LIST_DIR}/../../install) diff --git a/modules/catkin_ws/src/car/include/mainNode/CruiseController.h b/modules/catkin_ws/src/car/include/mainNode/CruiseController.h new file mode 100644 index 0000000000000000000000000000000000000000..fd8977e215e26a22c4c449e07f58ecdff1964e08 --- /dev/null +++ b/modules/catkin_ws/src/car/include/mainNode/CruiseController.h @@ -0,0 +1,22 @@ +#ifndef CRUISECONTROLLER_H +#define CRUISECONTROLLER_H + +#include "PlatoonController.h" +#include "EgoMotion.h" + +namespace car +{ +class CruiseController +{ + public: + CruiseController(EgoMotion& egoMotion, PlatoonController& platoonController); + ~CruiseController(){}; + + void run(); + + private: + EgoMotion& egoMotion; + PlatoonController& platoonController; +}; +} +#endif diff --git a/modules/catkin_ws/src/car/include/mainNode/EgoMotion.h b/modules/catkin_ws/src/car/include/mainNode/EgoMotion.h new file mode 100644 index 0000000000000000000000000000000000000000..d398bd90b53bfcad75df7b82ec7396bfa0b6b7e6 --- /dev/null +++ b/modules/catkin_ws/src/car/include/mainNode/EgoMotion.h @@ -0,0 +1,31 @@ +#ifndef EGOMOTION_H +#define EGOMOTION_H + +#include <nodelet/nodelet.h> +#include <ros/ros.h> + +#include <functional> + +#include "car/environmentDataMsg.h" + +namespace car +{ +class EgoMotion +{ + public: + using Callback = std::function<void()>; + + EgoMotion(ros::NodeHandle nh); + ~EgoMotion(){}; + + Callback platoonControllerNotify; + Callback cruiseControllerNotify; + + private: + ros::Subscriber environmentData; + void environmentDataCallback(const environmentDataMsg::ConstPtr & inMsg); + +}; +} + +#endif diff --git a/modules/catkin_ws/src/car/include/mainNode/MainNode.h b/modules/catkin_ws/src/car/include/mainNode/MainNode.h index ab237efe45d005c27a81fcc82745de828ddd9b7d..60a4c812b5b27fc6d0745b8fab39b9e4141020ee 100644 --- a/modules/catkin_ws/src/car/include/mainNode/MainNode.h +++ b/modules/catkin_ws/src/car/include/mainNode/MainNode.h @@ -4,13 +4,16 @@ #include <nodelet/nodelet.h> #include <ros/ros.h> #include "boost/thread.hpp" -#include "car/environmentDataMsg.h" + #include "NotifiableThread.h" #include "NetworkingLib/Networking.h" -#include "PlatoonController.h" #include "PlatoonProtocolLib/Vehicle.h" #include "PC2CarLib/CommandReceiver.h" +#include "PlatoonController.h" +#include "EgoMotion.h" +#include "CruiseController.h" + namespace car { class MainNode : public nodelet::Nodelet @@ -25,28 +28,29 @@ public: ~MainNode(); private: - PlatoonController platoonController; - NotifiableThread platoonControllerThread; - - std::function<void()> platoonControllerNotify = - [this] { platoonControllerThread.notify(); }; - - // dont touch! - // networking::Networking c2cNet; - // networking::Networking pcNet; - // - // platoonProtocol::Vehicle::Ptr c2c; - // pc2car::CommandReceiver::Ptr commandReceiver; - // ros::NodeHandle nh; std::string name; - ros::Publisher logEnabled; + networking::Networking c2cNet; // thread + event queue + networking::Networking pcNet; // thread + event queue + + platoonProtocol::Vehicle::Ptr c2c; + pc2car::CommandReceiver::Ptr pc; - networking::Networking net; + EgoMotion egoMotion; + + PlatoonController platoonController; + NotifiableThread platoonControllerThread; + + CruiseController cruiseController; + NotifiableThread cruiseControllerThread; + + std::function<void()> platoonControllerNotify = + [this] { platoonControllerThread.notify(); }; + + std::function<void()> cruiseControllerNotify = + [this] { cruiseControllerThread.notify(); }; - ros::Subscriber environmentData; - void environmentDataCallback(const environmentDataMsg::ConstPtr & inMsg); }; } #endif diff --git a/modules/catkin_ws/src/car/include/mainNode/PlatoonController.h b/modules/catkin_ws/src/car/include/mainNode/PlatoonController.h index f14238758d086b12f93f5febeb3f0285e83dda73..982f099bcb8a42cc57c08fb1fe50332869aaf2f4 100644 --- a/modules/catkin_ws/src/car/include/mainNode/PlatoonController.h +++ b/modules/catkin_ws/src/car/include/mainNode/PlatoonController.h @@ -7,6 +7,10 @@ #include <functional> +#include "PlatoonProtocolLib/Vehicle.h" +#include "PC2CarLib/CommandReceiver.h" +#include "EgoMotion.h" + namespace car { @@ -15,12 +19,19 @@ class PlatoonController public: using Callback = std::function<void()>; - PlatoonController(); + PlatoonController(platoonProtocol::Vehicle::Ptr c2c, + pc2car::CommandReceiver::Ptr pc, + EgoMotion& egoMotion); void run(); + Callback cruiseControllerNotify; private: - Callback ccNotify; + + platoonProtocol::Vehicle::Ptr c2c; + pc2car::CommandReceiver::Ptr pc; + EgoMotion& egoMotion; + }; } diff --git a/modules/catkin_ws/src/car/src/environment/Environment.cpp b/modules/catkin_ws/src/car/src/environment/Environment.cpp index ed418339494868d9963afe2d01a5116ec54b23c0..df596bbc27333d315c357fcc3da38b717fa91562 100644 --- a/modules/catkin_ws/src/car/src/environment/Environment.cpp +++ b/modules/catkin_ws/src/car/src/environment/Environment.cpp @@ -32,7 +32,7 @@ namespace car void Environment::ussDataCallback(const ussDataMsg::ConstPtr& inMsg) { - std::cout << "Environment recived new uss data (" << inMsg->distance << ").\n"; + // std::cout << "Environment recived new uss data (" << inMsg->distance << ").\n"; distance = inMsg->distance; prevSpeed = 1.0; @@ -45,7 +45,7 @@ namespace car void Environment::camDataCallback(const camDataMsg::ConstPtr& inMsg) { - std::cout << "Environment recived new cam data ( ).\n"; + // std::cout << "Environment recived new cam data ( ).\n"; } diff --git a/modules/catkin_ws/src/car/src/lanekeeping/Lanekeeping.cpp b/modules/catkin_ws/src/car/src/lanekeeping/Lanekeeping.cpp index b072e46ec8589c13071dc095b922f7f65e3707f4..6ef021265d0ae9b2cc6b7593d348cfcbc64fc5fa 100644 --- a/modules/catkin_ws/src/car/src/lanekeeping/Lanekeeping.cpp +++ b/modules/catkin_ws/src/car/src/lanekeeping/Lanekeeping.cpp @@ -29,7 +29,7 @@ namespace car void Lanekeeping::camDataCallback(const camDataMsg::ConstPtr& inMsg) { - std::cout << "Lanekeeping recived new cam data ( ).\n"; + // std::cout << "Lanekeeping recived new cam data ( ).\n"; } diff --git a/modules/catkin_ws/src/car/src/logging/Logging.cpp b/modules/catkin_ws/src/car/src/logging/Logging.cpp index cef2c2ff100fd77a05520196532293d74307ec4c..8e91b25f750227c3e5959e6c2fa021fad68d7815 100644 --- a/modules/catkin_ws/src/car/src/logging/Logging.cpp +++ b/modules/catkin_ws/src/car/src/logging/Logging.cpp @@ -62,12 +62,12 @@ void Logging::logMessage(const std::string & msg) void Logging::ccDataCallback(const ccDataMsg::ConstPtr & inMsg) { - std::cout << "Logging received new cc data ( ).\n"; + // std::cout << "Logging received new cc data ( ).\n"; } void Logging::camDataCallback(const camDataMsg::ConstPtr & inMsg) { - std::cout << "Logging received new cam data ( ).\n"; + // std::cout << "Logging received new cam data ( ).\n"; } void Logging::environmentDataCallback(const environmentDataMsg::ConstPtr & inMsg) @@ -78,32 +78,32 @@ void Logging::environmentDataCallback(const environmentDataMsg::ConstPtr & inMsg void Logging::laneDataCallback(const laneDataMsg::ConstPtr & inMsg) { - std::cout << "Logging received new lane data ( ).\n"; + // std::cout << "Logging received new lane data ( ).\n"; } void Logging::logEnabledCallback(const logEnabledMsg::ConstPtr & inMsg) { - std::cout << "Logging received new log enabled ( ).\n"; + // std::cout << "Logging received new log enabled ( ).\n"; } void Logging::logStringCallback(const logStringMsg::ConstPtr & inMsg) { - std::cout << "Logging received new log string ( ).\n"; + // std::cout << "Logging received new log string ( ).\n"; } void Logging::rcEnabledCallback(const rcEnabledMsg::ConstPtr & inMsg) { - std::cout << "Logging received new rc enabled ( ).\n"; + // std::cout << "Logging received new rc enabled ( ).\n"; } void Logging::stmDataCallback(const stmDataMsg::ConstPtr & inMsg) { - std::cout << "Logging received new stm data ( ).\n"; + // std::cout << "Logging received new stm data ( ).\n"; } void Logging::ussDataCallback(const ussDataMsg::ConstPtr & inMsg) { - std::cout << "Logging received new uss data ( ).\n"; + // std::cout << "Logging received new uss data ( ).\n"; } -} \ No newline at end of file +} diff --git a/modules/catkin_ws/src/car/src/mainNode/CruiseController.cpp b/modules/catkin_ws/src/car/src/mainNode/CruiseController.cpp new file mode 100644 index 0000000000000000000000000000000000000000..231b7973c5de412ae5b538aafa59394f363b34c6 --- /dev/null +++ b/modules/catkin_ws/src/car/src/mainNode/CruiseController.cpp @@ -0,0 +1,18 @@ +#include "../../include/mainNode/CruiseController.h" + +#include <iostream> + +namespace car { + +CruiseController::CruiseController(EgoMotion& egoMotion, PlatoonController& platoonController) + : egoMotion(egoMotion) + , platoonController(platoonController) +{ + std::cout << "WEEEEEEEEEEEEEEEELT" << std::endl; +} + +void CruiseController::run() { + std::cout << "CruiseController was run." << std::endl; +} + +} diff --git a/modules/catkin_ws/src/car/src/mainNode/EgoMotion.cpp b/modules/catkin_ws/src/car/src/mainNode/EgoMotion.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8ad351c01ab99c10c55a71646027a406b5bf3b9c --- /dev/null +++ b/modules/catkin_ws/src/car/src/mainNode/EgoMotion.cpp @@ -0,0 +1,19 @@ +#include "mainNode/EgoMotion.h" + + +namespace car { + +EgoMotion::EgoMotion(ros::NodeHandle nh) + : platoonControllerNotify() + , cruiseControllerNotify() +{ + environmentData = nh.subscribe("environmentData", 1, &EgoMotion::environmentDataCallback, this); +} + +void EgoMotion::environmentDataCallback(const environmentDataMsg::ConstPtr & inMsg) +{ + std::cout << "EgoMotion recived new environmentData data (" << inMsg->distance << ", " << inMsg->prevSpeed << ").\n"; + cruiseControllerNotify(); +} + +} diff --git a/modules/catkin_ws/src/car/src/mainNode/MainNode.cpp b/modules/catkin_ws/src/car/src/mainNode/MainNode.cpp index b489b9c9756a459efdc57e1e8056a1cd497b6c83..1cad6c10170a097e7fe9c03228a5dffce0871901 100644 --- a/modules/catkin_ws/src/car/src/mainNode/MainNode.cpp +++ b/modules/catkin_ws/src/car/src/mainNode/MainNode.cpp @@ -1,43 +1,47 @@ -#include <pluginlib/class_list_macros.h> -#include <ros/ros.h> - #include "mainNode/MainNode.h" -#include "car/camDataMsg.h" -#include "car/ccDataMsg.h" -#include "car/environmentDataMsg.h" -#include "car/logEnabledMsg.h" -#include "car/logStringMsg.h" -#include "car/rcEnabledMsg.h" -#include "car/stmDataMsg.h" -#include "car/ussDataMsg.h" +#include <pluginlib/class_list_macros.h> PLUGINLIB_EXPORT_CLASS(car::MainNode, nodelet::Nodelet); namespace car { MainNode::MainNode(ros::NodeHandle & nh, std::string & name) : - platoonController() - , platoonControllerThread([this] { platoonController.run(); }) - // , c2cNet() - // , pcNet() - // , c2c() - // , commandReceiver(pc2car::CommandReceiver::create(pcNet)) - , nh(nh) + nh(nh) , name(name) + , c2cNet() + , pcNet() + , c2c() + , pc(pc2car::CommandReceiver::create(pcNet)) + , egoMotion(nh) + , platoonController(c2c, pc, egoMotion) + , platoonControllerThread([this] { platoonController.run(); }) + , cruiseController(egoMotion, platoonController) + , cruiseControllerThread([this] { cruiseController.run(); }) { - std::cout << "Called MainNode(ros::NodeHandle & nh, std::string & name)." << std::endl; + egoMotion.cruiseControllerNotify = cruiseControllerNotify; + egoMotion.platoonControllerNotify = platoonControllerNotify; + platoonController.cruiseControllerNotify = cruiseControllerNotify; + // std::cout << "Called MainNode(ros::NodeHandle & nh, std::string & name)." << std::endl; } MainNode::MainNode() : - platoonController() + nh() + , name() + , c2cNet() + , pcNet() + , c2c() + , pc(pc2car::CommandReceiver::create(pcNet)) + , egoMotion(nh) + , platoonController(c2c, pc, egoMotion) , platoonControllerThread([this] { platoonController.run(); }) - // , c2cNet() - // , pcNet() - // , c2c() - // , commandReceiver(pc2car::CommandReceiver::create(pcNet)) + , cruiseController(egoMotion, platoonController) + , cruiseControllerThread([this] { cruiseController.run(); }) { - std::cout << "Called MainNode()." << std::endl; + egoMotion.cruiseControllerNotify = cruiseControllerNotify; + egoMotion.platoonControllerNotify = platoonControllerNotify; + platoonController.cruiseControllerNotify = cruiseControllerNotify; + // std::cout << "Called MainNode()." << std::endl; } MainNode::~MainNode() @@ -46,16 +50,7 @@ MainNode::~MainNode() void MainNode::onInit() { NODELET_INFO("MainNode::onInit -- START"); - logEnabled = nh.advertise<logEnabledMsg>("logEnabled", 5); - environmentData = nh.subscribe("environmentData", 1, &MainNode::environmentDataCallback, this); - - // CODE GOES HERE - NODELET_INFO("MainNode::onInit -- END"); } -void MainNode::environmentDataCallback(const environmentDataMsg::ConstPtr & inMsg) -{ - std::cout << "MainNode recived new environmentData data (" << inMsg->distance << ", " << inMsg->prevSpeed << ").\n"; -} } diff --git a/modules/catkin_ws/src/car/src/mainNode/PlatoonController.cpp b/modules/catkin_ws/src/car/src/mainNode/PlatoonController.cpp index fd1aff2bf90581994202b196d226b904e09331a0..3231cc5bcd7f53d331dbd7ef1d513100ce1de90a 100644 --- a/modules/catkin_ws/src/car/src/mainNode/PlatoonController.cpp +++ b/modules/catkin_ws/src/car/src/mainNode/PlatoonController.cpp @@ -8,9 +8,12 @@ namespace car { -PlatoonController::PlatoonController() - : ccNotify() -{} +PlatoonController::PlatoonController(platoonProtocol::Vehicle::Ptr c2c, + pc2car::CommandReceiver::Ptr pc, EgoMotion& egoMotion) + : c2c(c2c) + , pc(pc) + , egoMotion(egoMotion) + , cruiseControllerNotify() {} void car::PlatoonController::run()