Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
quadruped-reactive-walking
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
Gepetto
quadruped-reactive-walking
Commits
cd34adc2
Commit
cd34adc2
authored
3 years ago
by
odri
Browse files
Options
Downloads
Patches
Plain Diff
Continue to test things
parent
492906d0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/qrw/MpcWrapper.hpp
+2
-2
2 additions, 2 deletions
include/qrw/MpcWrapper.hpp
src/Controller.cpp
+3
-3
3 additions, 3 deletions
src/Controller.cpp
src/MpcWrapper.cpp
+34
-30
34 additions, 30 deletions
src/MpcWrapper.cpp
with
39 additions
and
35 deletions
include/qrw/MpcWrapper.hpp
+
2
−
2
View file @
cd34adc2
...
...
@@ -66,14 +66,14 @@ class MpcWrapper {
void
run_MPC_asynchronous
(
int
k
,
MatrixN
const
&
xref
,
MatrixN
const
&
fsteps
);
void
create_MPC_asynchronous
();
//
static
int check_memory();
// int check_memory();
private
:
Params
*
params_
;
MPC
mpc_
;
// shared_memory_object shm (boost::interprocess::create_only, "
My
SharedMemory", boost::interprocess::read_write);
// shared_memory_object shm (boost::interprocess::create_only, "SharedMemory", boost::interprocess::read_write);
// mapped_region region;
bi
::
managed_shared_memory
segment
;
...
...
This diff is collapsed.
Click to expand it.
src/Controller.cpp
+
3
−
3
View file @
cd34adc2
...
...
@@ -21,13 +21,13 @@ Controller::Controller()
xgoals
(
Vector12
::
Zero
())
{
namespace
bi
=
boost
::
interprocess
;
bi
::
shared_memory_object
::
remove
(
"
My
SharedMemory"
);
bi
::
shared_memory_object
::
remove
(
"SharedMemory"
);
/*//Remove shared memory on construction and destruction
struct shm_remove
{
shm_remove() { bi::shared_memory_object::remove("
My
SharedMemory"); }
~shm_remove(){ bi::shared_memory_object::remove("
My
SharedMemory"); }
shm_remove() { bi::shared_memory_object::remove("SharedMemory"); }
~shm_remove(){ bi::shared_memory_object::remove("SharedMemory"); }
} remover;*/
}
...
...
This diff is collapsed.
Click to expand it.
src/MpcWrapper.cpp
+
34
−
30
View file @
cd34adc2
#include
"qrw/MpcWrapper.hpp"
// bi::managed_shared_memory MpcWrapper::segment = bi::managed_shared_memory(bi::open_or_create, "
My
SharedMemory", 5000);
// bi::managed_shared_memory MpcWrapper::segment = bi::managed_shared_memory(bi::open_or_create, "SharedMemory", 5000);
MpcWrapper
::
MpcWrapper
()
:
test
(
0
),
last_available_result
(
Eigen
::
Matrix
<
double
,
24
,
2
>::
Zero
()),
gait_past
(
Matrix14
::
Zero
()),
gait_next
(
Matrix14
::
Zero
()),
segment
(
bi
::
open_or_create
,
"
My
SharedMemory"
,
1000
)
{}
segment
(
bi
::
open_or_create
,
"SharedMemory"
,
1000
)
{}
/*
int check_memory(
bi::managed_shared_memory &segment
)
int
check_memory
()
{
/
/
*
//Open already created shared memory object.
shared_memory_object shm_parallel(open_only, "
My
SharedMemory", read_only);
shared_memory_object shm_parallel(open_only, "SharedMemory", read_only);
//Map the whole shared memory in this process
mapped_region region_parallel(shm_parallel, read_only);
...
...
@@ -28,29 +28,30 @@ MpcWrapper::MpcWrapper()
printf("NO ERROR DETECTED\n");
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
return 0;/
return 0;
*/
printf
(
"PASS
\n
"
);
std::pair<int*, std::size_t> test0 = segment.find<int>("shared_k");
std::pair<MatrixN*, std::size_t> test1 = segment.find<MatrixN>("shared_xref");
std::pair<MatrixN*, std::size_t> test2 = segment->find<MatrixN>("shared_fsteps");
while (true)
{
std::cout << "shared_k: " << std::endl << *(test0.first) << std::endl;
std::cout << "shared_xref: " << std::endl << *(test1.first) << std::endl;
std::cout << "shared_fsteps: " << std::endl << *(test2.first) << std::endl;
/int* test0 = segment.find_or_construct<int>("shared_k");
bi
::
managed_shared_memory
segment_parallel
(
bi
::
open_only
,
"SharedMemory"
);
std
::
pair
<
int
*
,
std
::
size_t
>
test0
=
segment_parallel
.
find
<
int
>
(
"shared_k"
);
//std::pair<MatrixN*, std::size_t> test1 = segment_parallel.find<MatrixN>("shared_xref");
//std::pair<MatrixN*, std::size_t> test2 = segment_parallel.find<MatrixN>("shared_fsteps");
//while (true)
//{
// std::this_thread::sleep_for(std::chrono::milliseconds(500));
// std::cout << "shared_k: " << std::endl << *(test0.first) << std::endl;
//std::cout << "shared_xref: " << std::endl << *(test1.first) << std::endl;
//std::cout << "shared_fsteps: " << std::endl << *(test2.first) << std::endl;
/*int* test0 = segment.find_or_construct<int>("shared_k");
MatrixN* test1 = segment.find_or_construct<MatrixN>("shared_xref");
MatrixN* test2 = segment.find_or_construct<MatrixN>("shared_fsteps");
std::cout << "shared_k: " << std::endl << test0 << std::endl;
std::cout << "shared_xref: " << std::endl << test1 << std::endl;
std::cout << "shared_fsteps: " << std::endl << test2 << std::endl;/
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::cout << "shared_fsteps: " << std::endl << test2 << std::endl;*/
//}
return
0
;
}*/
}
void
MpcWrapper
::
initialize
(
Params
&
params
)
{
...
...
@@ -62,20 +63,20 @@ void MpcWrapper::initialize(Params& params) {
last_available_result
.
col
(
0
).
tail
(
12
)
=
(
Vector3
(
0.0
,
0.0
,
8.0
)).
replicate
<
4
,
1
>
();
// Initialization of the shared memory
//
shared_k = segment.construct<int>("shared_k") ();
/
/
shared_xref = segment.construct<MatrixN>("shared_xref") (12, params.gait.rows() + 1);
//
shared_fsteps = segment.construct<MatrixN>("shared_fsteps") (params.gait.rows(), 12);
shared_k
=
segment
.
construct
<
int
>
(
"shared_k"
)
(
42
);
/
*
shared_xref = segment.construct<MatrixN>("shared_xref") (12, params.gait.rows() + 1);
shared_fsteps = segment.construct<MatrixN>("shared_fsteps") (params.gait.rows(), 12);
*/
// Initialization of shared memory
// Remove shared memory on construction and destruction
/*struct shm_remove
{
shm_remove() { shared_memory_object::remove("
My
SharedMemory"); }
~shm_remove(){ shared_memory_object::remove("
My
SharedMemory"); }
shm_remove() { shared_memory_object::remove("SharedMemory"); }
~shm_remove(){ shared_memory_object::remove("SharedMemory"); }
} remover;*/
// Create a shared memory object.
/*bi::shared_memory_object shm (bi::create_only, "
My
SharedMemory", bi::read_write);
/*bi::shared_memory_object shm (bi::create_only, "SharedMemory", bi::read_write);
// Set size
shm.truncate(500);
...
...
@@ -86,9 +87,12 @@ void MpcWrapper::initialize(Params& params) {
// Write all the memory to 1
std::memset(region.get_address(), 1, region.get_size());*/
//
std::thread checking_thread(check_memory
, segment
); // spawn new thread that calls check_memory()
std
::
thread
checking_thread
(
check_memory
);
// spawn new thread that calls check_memory()
// checking_thread.join();
//std::pair<int*, std::size_t> test0 = segment.find<int>("shared_k");
// std::cout << "shared_k: " << std::endl << *(test0.first) << std::endl;
}
void
MpcWrapper
::
solve
(
int
k
,
MatrixN
const
&
xref
,
MatrixN
const
&
fsteps
,
...
...
@@ -96,11 +100,11 @@ void MpcWrapper::solve(int k, MatrixN const& xref, MatrixN const& fsteps,
std
::
cout
<<
"Pass mpcWrapper"
<<
std
::
endl
;
std
::
cout
<<
"SIZES"
<<
std
::
endl
;
/*
std::cout << "SIZES" << std::endl;
std::cout << sizeof((int)5) << std::endl;
std::cout << sizeof(MatrixN::Zero(12, params_->gait.rows() + 1)) << std::endl;
std::cout << sizeof(MatrixN::Zero(params_->gait.rows(), 12)) << std::endl;
std
::
cout
<<
params_
->
gait
<<
std
::
endl
;
std::cout << params_->gait << std::endl;
*/
// std::thread checking_thread(check_memory); // spawn new thread that calls check_memory()
// checking_thread.join();
...
...
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