Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
omniwheels_controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stevedan Ogochukwu Omodolor
omniwheels_controller
Commits
0e52b48d
Commit
0e52b48d
authored
3 years ago
by
Stevedan Ogochukwu Omodolor
Browse files
Options
Downloads
Patches
Plain Diff
Controller finished
parent
7260078b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/omniwheels_config.yaml
+6
-2
6 additions, 2 deletions
config/omniwheels_config.yaml
scripts/omni_wheel_controller_node.py
+19
-15
19 additions, 15 deletions
scripts/omni_wheel_controller_node.py
with
25 additions
and
17 deletions
config/omniwheels_config.yaml
+
6
−
2
View file @
0e52b48d
...
@@ -6,8 +6,12 @@ type: default
...
@@ -6,8 +6,12 @@ type: default
position_offset
:
0.11
# ofsset from crazyflie module to the cenyter of the omniwheels
position_offset
:
0.11
# ofsset from crazyflie module to the cenyter of the omniwheels
R
:
0.0165
R
:
0.0165
r
:
0.00065
#this does not match the real wheelradius
r
:
0.00065
#this does not match the real wheelradius
kp
:
0.1
kp_x
:
0.095
ki
:
0.0
ki_x
:
0.01
kp_y
:
0.095
ki_y
:
0.0
kp_z
:
1.75
ki_z
:
0.0
rate_hz
:
50
# rate of the control loop
rate_hz
:
50
# rate of the control loop
This diff is collapsed.
Click to expand it.
scripts/omni_wheel_controller_node.py
+
19
−
15
View file @
0e52b48d
...
@@ -57,10 +57,12 @@ class omniWheelvelocityController:
...
@@ -57,10 +57,12 @@ class omniWheelvelocityController:
self
.
a1
=
2
*
np
.
pi
/
3
# Angle between x axis and first wheel
self
.
a1
=
2
*
np
.
pi
/
3
# Angle between x axis and first wheel
self
.
a2
=
4
*
np
.
pi
/
3
# Angle between x axis and second wheel
self
.
a2
=
4
*
np
.
pi
/
3
# Angle between x axis and second wheel
self
.
r
=
rospy
.
get_param
(
"
/r
"
)
# Wheel radius. Has been fudge-factored because the actual velocity of the wheels did not align with the set-points.
self
.
r
=
rospy
.
get_param
(
"
/r
"
)
# Wheel radius. Has been fudge-factored because the actual velocity of the wheels did not align with the set-points.
kp
=
rospy
.
get_param
(
"
/kp
"
)
kp_x
=
rospy
.
get_param
(
"
/kp_x
"
)
ki
=
rospy
.
get_param
(
"
/ki
"
)
ki_x
=
rospy
.
get_param
(
"
/ki_x
"
)
kp_y
=
rospy
.
get_param
(
"
/kp_y
"
)
ki_y
=
rospy
.
get_param
(
"
/ki_y
"
)
kp_z
=
rospy
.
get_param
(
"
/kp_z
"
)
ki_z
=
rospy
.
get_param
(
"
/ki_z
"
)
# get ros param value
# get ros param value
robot_name
=
rospy
.
get_param
(
"
/name
"
);
robot_name
=
rospy
.
get_param
(
"
/name
"
);
...
@@ -92,9 +94,9 @@ class omniWheelvelocityController:
...
@@ -92,9 +94,9 @@ class omniWheelvelocityController:
rate_hz
=
rospy
.
get_param
(
"
/rate_hz
"
)
rate_hz
=
rospy
.
get_param
(
"
/rate_hz
"
)
rate
=
rospy
.
Rate
(
rate_hz
)
# 10hz
rate
=
rospy
.
Rate
(
rate_hz
)
# 10hz
dt
=
1.0
/
float
(
rate_hz
);
dt
=
1.0
/
float
(
rate_hz
);
self
.
pi
=
SimplePI
(
kp
,
ki
,
dt
)
# Create a PI-controller
self
.
pi
_x
=
SimplePI
(
kp
_x
,
ki
_x
,
dt
)
# Create a PI-controller
self
.
pi_y
=
SimplePI
(
kp_y
,
ki_y
,
dt
)
# Create a PI-controller
self
.
pi_z
=
SimplePI
(
kp_y
,
ki_y
,
dt
)
# Create a PI-controller
# main loop
# main loop
while
not
rospy
.
is_shutdown
():
while
not
rospy
.
is_shutdown
():
...
@@ -105,14 +107,18 @@ class omniWheelvelocityController:
...
@@ -105,14 +107,18 @@ class omniWheelvelocityController:
roll
,
pitch
,
yaw
=
euler_from_quaternion
(
self
.
_current_pose
.
orientation
.
x
,
self
.
_current_pose
.
orientation
.
y
,
self
.
_current_pose
.
orientation
.
z
,
self
.
_current_pose
.
orientation
.
w
)
roll
,
pitch
,
yaw
=
euler_from_quaternion
(
self
.
_current_pose
.
orientation
.
x
,
self
.
_current_pose
.
orientation
.
y
,
self
.
_current_pose
.
orientation
.
z
,
self
.
_current_pose
.
orientation
.
w
)
vel_ref
=
np
.
array
([
self
.
vel_cmd
.
linear
.
x
,
self
.
vel_cmd
.
linear
.
y
,
self
.
vel_cmd
.
angular
.
z
])
vel_ref
=
np
.
array
([
self
.
vel_cmd
.
linear
.
x
,
self
.
vel_cmd
.
linear
.
y
,
self
.
vel_cmd
.
angular
.
z
])
error
=
vel_ref
-
np
.
array
([
self
.
_current_vel
.
linear
.
x
,
self
.
_current_vel
.
linear
.
y
,
self
.
_current_vel
.
angular
.
z
]);
error
=
vel_ref
-
np
.
array
([
self
.
_current_vel
.
linear
.
x
,
self
.
_current_vel
.
linear
.
y
,
self
.
_current_vel
.
angular
.
z
]);
xdot
=
vel_ref
+
self
.
pi
.
update_control
(
error
)
vel_x
=
vel_ref
[
0
]
+
self
.
pi_x
.
update_control
(
error
[
0
])
ph
=
self
.
vel2motor
(
vel_ref
,
np
.
deg2rad
(
-
180
));
vel_y
=
vel_ref
[
1
]
+
self
.
pi_y
.
update_control
(
error
[
1
])
vel_z
=
vel_ref
[
2
]
+
self
.
pi_z
.
update_control
(
error
[
2
])
xdot
=
np
.
array
([
vel_x
[
0
],
vel_y
[
0
],
vel_z
[
0
]])
ph
=
self
.
vel2motor
(
xdot
,
yaw
);
#print(np.rad2deg(yaw))
#print(np.rad2deg(yaw))
#print(ph)
self
.
motor_command
[
0
]
=
ph
[
0
]
self
.
motor_command
[
0
]
=
ph
[
0
]
self
.
motor_command
[
1
]
=
ph
[
1
]
self
.
motor_command
[
1
]
=
ph
[
1
]
self
.
motor_command
[
2
]
=
ph
[
2
]
self
.
motor_command
[
2
]
=
ph
[
2
]
print
(
error
)
#
print(error
_x
)
self
.
vel_cmd_arrived
=
False
self
.
vel_cmd_arrived
=
False
else
:
else
:
...
@@ -172,7 +178,5 @@ if __name__ == '__main__':
...
@@ -172,7 +178,5 @@ if __name__ == '__main__':
rospy
.
init_node
(
"
omni_wheel_controller_node
"
)
rospy
.
init_node
(
"
omni_wheel_controller_node
"
)
try
:
try
:
omniwheel1
=
omniWheelvelocityController
()
omniwheel1
=
omniWheelvelocityController
()
except
rospy
.
ROSInterruptException
:
except
(
rospy
.
ServiceException
,
rospy
.
ROSException
)
as
e
:
pass
print
(
"
ERROR :
"
+
str
(
e
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment