Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PTCE Double Integrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Silas Baumann
PTCE Double Integrator
Commits
feaa1b5a
Commit
feaa1b5a
authored
3 months ago
by
Lukas Krauß
Browse files
Options
Downloads
Patches
Plain Diff
Add double integrator
parent
b84ee3e2
No related branches found
No related tags found
2 merge requests
!3
Version 0.0.1
,
!1
Adding the position generator, controller and double integrator
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
my_double_integrator/double_integrator.py
+39
-0
39 additions, 0 deletions
my_double_integrator/double_integrator.py
with
39 additions
and
0 deletions
my_double_integrator/double_integrator.py
+
39
−
0
View file @
feaa1b5a
import
rclpy
from
rclpy.node
import
Node
from
std_msgs.msg
import
Float64
from
geometry_msgs.msg
import
Vector3
class
DoubleIntegratorSim
(
Node
):
def
__init__
(
self
):
super
().
__init__
(
'
double_integrator_sim
'
)
self
.
declare_parameter
(
'
update_rate
'
,
50.0
)
self
.
update_rate
=
self
.
get_parameter
(
'
update_rate
'
).
value
self
.
state
=
Vector3
(
x
=
0.0
,
y
=
0.0
,
z
=
0.0
)
# x=position, y=velocity, z=unused
self
.
control_sub
=
self
.
create_subscription
(
Float64
,
'
control_input
'
,
self
.
control_callback
,
10
)
self
.
state_pub
=
self
.
create_publisher
(
Vector3
,
'
state
'
,
10
)
self
.
control_input
=
0.0
# Initialize control input
self
.
timer
=
self
.
create_timer
(
1.0
/
self
.
update_rate
,
self
.
update_state
)
def
control_callback
(
self
,
msg
):
self
.
control_input
=
msg
.
data
def
update_state
(
self
):
dt
=
1.0
/
self
.
update_rate
self
.
state
.
y
+=
self
.
control_input
*
dt
# Update velocity
self
.
state
.
x
+=
self
.
state
.
y
*
dt
# Update position
self
.
state_pub
.
publish
(
self
.
state
)
def
main
(
args
=
None
):
rclpy
.
init
(
args
=
args
)
node
=
DoubleIntegratorSim
()
rclpy
.
spin
(
node
)
node
.
destroy_node
()
rclpy
.
shutdown
()
if
__name__
==
'
__main__
'
:
main
()
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