Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed X_NUCLEO_PLC01A1 ros_lib_melodic
Diff: wheel.cpp
- Revision:
- 0:43eb9ccc1583
- Child:
- 3:ea5cfd721b53
diff -r 000000000000 -r 43eb9ccc1583 wheel.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wheel.cpp Sat Aug 08 23:54:01 2020 +0000
@@ -0,0 +1,70 @@
+#include "wheel.h"
+
+/**
+ * @brief Constractor of Wheel class
+ * @param pCanController: Address of CAN controller
+ * @param pPlcController: Address of PLC controller
+*/
+Wheel::Wheel(CANController *pCanController, PLCController *pPlcController )
+:_leftWheel( lWheelID, pCanController ), _rightWheel( rWheelID, pCanController ),
+_brake(brakePin, pPlcController),
+_brakeState(0)
+{}
+
+/**
+ * @brief Initialize wheels
+ * @param None
+ * @retval None
+*/
+void Wheel::init(){
+ _leftWheel.motorInit();
+ _rightWheel.motorInit();
+}
+
+/**
+ * @brief Drive wheels
+ * @param None
+ * @retval None
+*/
+void Wheel::drive(){
+ if( _brakeState == 1 ){
+ _brake = 0;
+ _brakeState = 0;
+ wait(0.5);
+ }
+ _leftWheel.drive();
+ _rightWheel.drive();
+}
+
+/**
+ * @brief Stop wheels
+ * @param None
+ * @retval None
+*/
+void Wheel::stop(){
+ _leftWheel.stop();
+ _rightWheel.stop();
+}
+
+/**
+ * @brief Sets angular velocities of wheels
+ * @param lVelocity: Anguglar velocity of the left wheel [rpm]
+ * @param rVelocity: Anguglar velocity of the right wheel [rpm]
+ * @retval None
+*/
+void Wheel::setVelocity( float lVelocity, float rVelocity ){
+ _leftWheel.setAngularVelocity( lVelocity );
+ _rightWheel.setAngularVelocity( rVelocity );
+}
+
+/**
+ * @brief Stop wheels and Turn on the wheels' brake
+ * @param None
+ * @retval None
+*/
+void Wheel::brake(){
+ Wheel::stop();
+ wait(0.1);
+ _brake = 1;
+ _brakeState = 1;
+}
\ No newline at end of file