Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
asclinic-system
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
Container registry
Model registry
Operate
Environments
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
Jiaao Liu
asclinic-system
Commits
d11d65ff
Commit
d11d65ff
authored
11 months ago
by
Jiaao Liu
Browse files
Options
Downloads
Patches
Plain Diff
kalman only after rotating
parent
41703e64
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
catkin_ws/src/asclinic_pkg/src/Kalman.cpp
+27
-7
27 additions, 7 deletions
catkin_ws/src/asclinic_pkg/src/Kalman.cpp
catkin_ws/src/asclinic_pkg/src/fcontroller1.cpp
+1
-2
1 addition, 2 deletions
catkin_ws/src/asclinic_pkg/src/fcontroller1.cpp
with
28 additions
and
9 deletions
catkin_ws/src/asclinic_pkg/src/Kalman.cpp
+
27
−
7
View file @
d11d65ff
...
...
@@ -9,6 +9,7 @@
#include
<eigen3/Eigen/Dense>
#include
"asclinic_pkg/vw.h"
#include
<std_msgs/UInt32.h>
#include
<thread>
using
Eigen
::
MatrixXd
;
...
...
@@ -18,7 +19,7 @@ float x = -1, y = -3, phi = M_PI/2;
int
left_p
=
1
,
right_p
=
1
;
ros
::
Time
time_previous
,
time_now
;
// Timing variables
ros
::
Duration
elapsed_time
;
// Duration to calculate elapsed time
ros
::
Time
last_time
;
double
time_float
;
// Floating-point representation of elapsed time
...
...
@@ -140,13 +141,13 @@ void ImageAnswer(const asclinic_pkg::position& msg) {
y
,
phi
;
ROS_INFO_STREAM
(
"odo_position: "
<<
odo_position
);
ROS_INFO_STREAM
(
"z_position: "
<<
z_position
);
ROS_INFO_STREAM
(
"K: "
<<
K
);
//
ROS_INFO_STREAM("odo_position: " << odo_position);
//
ROS_INFO_STREAM("z_position: " << z_position);
//
ROS_INFO_STREAM("K: " << K);
MatrixXd
new_pose
=
odo_position
+
K
*
(
z_position
-
odo_position
);
ROS_INFO_STREAM
(
"new_pose: "
<<
new_pose
);
//
ROS_INFO_STREAM("new_pose: " << new_pose);
if
(
std
::
isnan
(
new_pose
(
0
))
||
std
::
isnan
(
new_pose
(
1
))
||
std
::
isnan
(
new_pose
(
2
)))
{
x
=
odo_position
(
0
);
...
...
@@ -162,7 +163,7 @@ void ImageAnswer(const asclinic_pkg::position& msg) {
}
phi
=
normalize_angle
(
phi
);
ROS_INFO_STREAM
(
"Normalized Phi: "
<<
phi
);
//
ROS_INFO_STREAM("Normalized Phi: " << phi);
ROS_INFO
(
"Image updated"
);
authority
=
0
;
...
...
@@ -190,7 +191,26 @@ void pwmAnswer(const asclinic_pkg::LeftRightFloat32& msg){
void
update_authority
(
const
std_msgs
::
UInt32
&
msg
)
{
authority
=
1
;
ros
::
Time
last_time
=
ros
::
Time
::
now
();
ros
::
Time
current_time
=
ros
::
Time
::
now
();
ros
::
Duration
lastest_duration
;
float
duration_authority
;
ROS_INFO_STREAM
(
"Authority updated to: "
<<
authority
);
while
(
authority
){
current_time
=
ros
::
Time
::
now
();
lastest_duration
=
current_time
-
last_time
;
duration_authority
=
lastest_duration
.
toSec
();
if
(
duration_authority
>
2
){
authority
=
0
;
std_msgs
::
UInt32
Umsg
;
Umsg
.
data
=
1
;
kalman_output
.
publish
(
Umsg
);
ROS_INFO_STREAM
(
"go with no update"
);
}
last_time
=
current_time
;
ros
::
spinOnce
();
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
100
));
}
}
...
...
@@ -201,7 +221,7 @@ int main(int argc, char **argv) {
// Initialize time_now to current time
time_now
=
ros
::
Time
::
now
();
last_time
=
ros
::
Time
::
now
();
pose_covariance
<<
0.5
,
0.5
,
0.5
,
0.5
,
0.5
,
0.5
,
...
...
This diff is collapsed.
Click to expand it.
catkin_ws/src/asclinic_pkg/src/fcontroller1.cpp
+
1
−
2
View file @
d11d65ff
...
...
@@ -32,7 +32,6 @@ public:
}
};
void
rotation_thread_function
();
PIDController
pid
(
2
,
0
,
5
);
PIDController
pid1
(
40
,
0
,
0
);
...
...
@@ -151,7 +150,7 @@ void purerotation(const asclinic_pkg::rotation& rotation_msg) {
}
void
kalman_change
(
const
std_msgs
::
UInt32
&
Umsg
){
// Publish state message
std_msgs
::
UInt32
state_msg
;
state_msg
.
data
=
1
;
...
...
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