Skip to content

cogniteam/cognitao_ros2_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CogniTao ROS2 Examples

alt text

WorldModel Monitor

  • cognitao_wmm is a program installed by default along cognitao_server
  • Using cognitao_wmm it is possible to create a local synchronized world model through a ros2 datasource
$ export COGNITAO_DATASOURCE="ros2"
$ cognitao_wmm
  • This will make available a topic /wme/in
  • Through this topic it is possible to listen and publish world model key/value events
  • These events will be synchronized among wolrd models

Wait example

void RosActionWaitServer::execute(RosActionContext action) {

    // get parameters
    for(auto param : action.getParameters())
    {
        cout << param.first <<  << endl;
    }
    
    while( /* check condition*/)
    {
        // do some work
        std::this_thread::sleep_for(std::chrono::milliseconds(1000));

        // check if should stop
        // cancel goal
        if (ros2ActionContext.isPreemptRequested() ) {             
            ros2ActionContext.cancelGoal();            
            return;
        }      
 
    }

    // return when done
    action.setResult(true);
}
  • In the execute method
    • we can use action.getParameters() to get the actions parameters from the XML
    • we can use action.isPreemptRequested() to query if this remote goal needs to be stopped
    • we can use action.setResult(true/false) to set the return value
  • Now we will define an XML that will invoke this action on the server XML
<machine name="testBT" type="bt">
	<task name="wait" runner="ros2" action="wait" param_time="10.0"/>
</machine>
  • Now you can compile this project using catkin and should be able to run
$ rosrun cognitao_ros action_wait_server 
  • This server will connet to your ros_master and wait for a goal
  • From another terminal run
export COGNITAO_DATASOURCE="ros2"
$ cognitao_server assets/wait_example.xml
  • This will load a plan that will invoke an action in the wait server
  • Actions can run in parrallel, are remotely monitored and preempted if needed

Build status

pipeline status master

pipeline status develop

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published