@@ -6,29 +6,6 @@ This library helps communicate with the **`Easy PID Motor Controller Module`** (
66A simple way to get started is simply to try out and follow the example code in the example folder
77
88
9- ## How to Use the .deb Package
10-
11- #### Prequisite
12- - ensure you've already set up your microcomputer or PC system with ROS2
13-
14- - download and install the epmc-serial-dev pkg. you can also check the [ release] ( https://github.com/robocre8/epmc_serial_cpp/releases/ )
15-
16- [ PC (AMD64)] ( https://github.com/robocre8/epmc_serial_cpp/tree/amd64-build )
17- ``` shell
18- wget https://github.com/robocre8/epmc_serial_cpp/releases/download/v1.1.1/epmc-serial-dev_1.1.1_amd64.deb
19- ```
20- ``` shell
21- sudo apt install ./epmc-serial-dev_1.1.1_amd64.deb
22- ```
23- [ Raspberry Pi (ARM64)] ( https://github.com/robocre8/epmc_serial_cpp/tree/arm64-build )
24- ``` shell
25- wget https://github.com/robocre8/epmc_serial_cpp/releases/download/v1.1.1/epmc-serial-dev_1.1.1_arm64.deb
26- ```
27- ``` shell
28- sudo apt install ./epmc-serial-dev_1.1.1_arm64.deb
29- ```
30-
31-
329## How to Use the Library (build from source)
3310- install the libserial-dev package
3411 > sudo apt-get update
@@ -57,29 +34,35 @@ sudo apt install ./epmc-serial-dev_1.1.1_arm64.deb
5734 > mkdir build (i.e create a folder named build)
5835 >
5936 > enter the following command in the terminal in the root folder:
60- ````
37+ ```` shell
6138 cmake -B ./build/
6239 ````
63- ````
40+ ` ` ` ` shell
6441 cmake --build ./build/
6542 ````
43+ ` ` ` ` shell
44+ ./build/two_motor_control
6645 ````
67- ./build/motor_control
46+ ` ` ` ` shell
47+ ./build/four_motor_control
6848 ````
6949
70- - You can follow the pattern used in the example `motor_control.cpp` in your own code.
71-
50+ - You can follow the pattern used in the example ` two_motor_control.cpp` and ` four_motor_control.cpp` in your own code.
7251
7352
74-
75- ## Basic Library functions and usage
53+ # # Basic Library functions and usage (Two Motor Support Control)
7654
7755- connect to epmc_driver shield module
7856 > epmc_serial::EPMCSerialClient controller
7957 >
80- > controller.connect("port_name or port_path")
58+ > _//ensure you set/call **supportedNumOfMotors () ** before **connect () ** as below:_
8159 >
82- > controller.clearDataBuffer() # returns bool -> success
60+ > controller.supportedNumOfMotors(epmc_serial::SupportedNumOfMotors::TWO);
61+ >
62+ > controller.connect(" port_name or port_path" )
63+
64+ - clear speed, position, e.t.c data buffer on the EPMC module
65+ > controller.clearDataBuffer () // returns bool -> success
8366
8467- send target angular velocity command
8568 > controller.writeSpeed(motor0_TargetVel, motor1_TargetVel)
@@ -91,14 +74,62 @@ sudo apt install ./epmc-serial-dev_1.1.1_arm64.deb
9174 > controller.setCmdTimeout(timeout_ms)
9275
9376- get motor command timeout
94- > controller.getCmdTimeout() # returns std::tuple -> (success, motor_command_timeout_ms): bool, float
77+ > controller.getCmdTimeout () // returns std::tuple -> bool, float
78+
79+ - read motors angular position and angular velocity
80+ > controller.readMotorData () // returns std::tuple -> bool, std::vector< float> (pos0, pos1, vel0, vel1)
9581
9682- read motors angular position
97- > controller.readPos() # returns std::tuple -> (success, angPos0, angPos1): bool, float, float
83+ > controller.readPos () // returns std::tuple -> bool, std::vector < float > (pos0, pos1)
9884
9985- read motors angular velocity
100- > controller.readVel() # returns std::tuple -> (success, angVel0, angVel1): bool, float, float
86+ > controller.readVel () // returns std::tuple -> bool, std::vector < float > (vel0, vel1)
10187
102- - read motorA maximum commandable angular velocity
103- > controller.getMaxVel(motor_no) # returns std::tuple -> (success, max_vel): bool, float , float
88+ - read motor maximum commandable angular velocity
89+ > controller.getMaxVel(motor_no) // returns std::tuple -> bool, float
10490 > maxVel0 or maxVel1 based on the specified motor number
91+
92+ - while these function above help communicate with the already configure EPMC module, more examples of advanced funtions usage for parameter tuning can be found in the [epmc_setup_application](https://github.com/robocre8/epmc_setup_application) source code
93+
94+ #
95+
96+ # # Basic Library functions and usage (Four Motor Support Control)
97+
98+ - connect to epmc_driver shield module
99+ > epmc_serial::EPMCSerialClient controller
100+ >
101+ > _//ensure you set/call **supportedNumOfMotors ()** before **connect ()** as below:_
102+ >
103+ > controller.supportedNumOfMotors(epmc_serial::SupportedNumOfMotors::FOUR)
104+ >
105+ > controller.connect(" port_name or port_path" )
106+
107+ - clear speed, position, e.t.c data buffer on the EPMC module
108+ > controller.clearDataBuffer () // returns bool -> success
109+
110+ - send target angular velocity command
111+ > controller.writeSpeed(motor0_TargetVel, motor1_TargetVel, motor2_TargetVel, motor3_TargetVel)
112+
113+ - send PWM command
114+ > controller.writePWM(motor0_PWM, motor1_PWM, motor2_PWM, motor3_PWM)
115+
116+ - set motor command timeout
117+ > controller.setCmdTimeout(timeout_ms)
118+
119+ - get motor command timeout
120+ > controller.getCmdTimeout () // returns std::tuple -> bool, float
121+
122+ - read motors angular position and angular velocity
123+ > controller.readMotorData () // returns std::tuple -> bool, std::vector< float> (pos0, pos1, pos2, pos3, vel0, vel1, vel2, vel3)
124+
125+ - read motors angular position
126+ > controller.readPos () // returns std::tuple -> bool, std::vector< float> (pos0, pos1, pos2, pos3)
127+
128+ - read motors angular velocity
129+ > controller.readVel () // returns std::tuple -> bool, std::vector< float> (vel0, vel1, vel2, vel3)
130+
131+ - read motor maximum commandable angular velocity
132+ > controller.getMaxVel(motor_no) // returns std::tuple -> bool, float
133+ > maxVel0 or maxVel1 based on the specified motor number
134+
135+ - while these function above help communicate with the already configure EPMC module, more examples of advanced funtions usage for parameter tuning can be found in the [epmc_setup_application](https://github.com/robocre8/epmc_setup_application) source code
0 commit comments